summaryrefslogtreecommitdiff
path: root/vm/type.go
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2024-03-14 14:37:32 +0100
committerMarc Vertes <mvertes@free.fr>2024-03-14 14:37:32 +0100
commit378683d25bdae89fa446b2b82f8dda5d6b34ea33 (patch)
treecbf624e4eb38fafe51a12a718b48f43192cfcfac /vm/type.go
parent60170bad25f912e0ba44e4c0095b54f6e26e307e (diff)
feat: initial support of closures
Also detection and automatic execution of main function. Make sure that all debug is output to stderr.
Diffstat (limited to 'vm/type.go')
-rw-r--r--vm/type.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/vm/type.go b/vm/type.go
index d29de48..16e3733 100644
--- a/vm/type.go
+++ b/vm/type.go
@@ -26,6 +26,9 @@ type Value struct {
// NewValue returns an addressable zero value for the specified type.
func NewValue(typ *Type) Value {
+ if typ.Rtype.Kind() == reflect.Func {
+ typ = TypeOf(0) // Function value is its index in the code segment.
+ }
return Value{Type: typ, Data: reflect.New(typ.Rtype).Elem()}
}