From 378683d25bdae89fa446b2b82f8dda5d6b34ea33 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 14 Mar 2024 14:37:32 +0100 Subject: feat: initial support of closures Also detection and automatic execution of main function. Make sure that all debug is output to stderr. --- vm/type.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'vm/type.go') 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()} } -- cgit v1.2.3