diff options
| author | Mel <einebeere@gmail.com> | 2022-05-18 19:37:47 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-05-18 19:37:47 +0200 |
| commit | e4d68d39ce7f990895686139cd5cba20d2b2ef89 (patch) | |
| tree | 8862118abb2181f3bb244daaec5ced0497bc07fd /pkg/lang/vm/value | |
| parent | 089fa82b8f83695cb17b8f41d0376c03303e7663 (diff) | |
| download | jinx-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.go | 23 |
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") +} |
