From e4d68d39ce7f990895686139cd5cba20d2b2ef89 Mon Sep 17 00:00:00 2001 From: Mel Date: Wed, 18 May 2022 19:37:47 +0200 Subject: Handle errors gracefully in VM --- pkg/lang/vm/value/type.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'pkg/lang/vm/value') diff --git a/pkg/lang/vm/value/type.go b/pkg/lang/vm/value/type.go index 1aec251..cd518d9 100644 --- a/pkg/lang/vm/value/type.go +++ b/pkg/lang/vm/value/type.go @@ -17,3 +17,26 @@ const ( type Type struct { Kind TypeKind } + +func (t Type) String() string { + switch t.Kind { + case IntType: + return "int" + case FloatType: + return "float" + case StringType: + return "string" + case BoolType: + return "bool" + case ArrayType: + return "array" + case NullType: + return "null" + case FunctionType: + return "function" + case ObjectType: + return "object" + } + + panic("invalid type kind") +} -- cgit 1.4.1