aboutsummaryrefslogtreecommitdiff
path: root/pkg/lang/vm/value
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-05-18 19:37:47 +0200
committerMel <einebeere@gmail.com>2022-05-18 19:37:47 +0200
commite4d68d39ce7f990895686139cd5cba20d2b2ef89 (patch)
tree8862118abb2181f3bb244daaec5ced0497bc07fd /pkg/lang/vm/value
parent089fa82b8f83695cb17b8f41d0376c03303e7663 (diff)
downloadjinx-e4d68d39ce7f990895686139cd5cba20d2b2ef89.tar.zst
jinx-e4d68d39ce7f990895686139cd5cba20d2b2ef89.zip
Handle errors gracefully in VM
Diffstat (limited to 'pkg/lang/vm/value')
-rw-r--r--pkg/lang/vm/value/type.go23
1 files changed, 23 insertions, 0 deletions
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")
+}