diff options
| author | Marc Vertes <mvertes@free.fr> | 2024-03-08 19:29:34 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2024-03-08 19:29:34 +0100 |
| commit | 8c4fa9d85cd274439dbd7d0a5c699fe1cea557dc (patch) | |
| tree | a8c910cf13aa06e61ee2db40b5dd2f1f63a25b9d /vm/vm_test.go | |
| parent | 828cfd1c8da5e243fd0f34530fb1a7faab49784e (diff) | |
feat: add type representation in vm package
Type and Value types in vm package are now used in place of reflect.Type
and reflect.Value. It allows to remove the dependency on reflect for
parser and compiler packages.
The main purpose of Type is to provide a solution to implement recursive
structs, named types, interfaces and methods, despite the limitations of
Go reflect. The goal is to provide the thinnest layer around reflect.
Diffstat (limited to 'vm/vm_test.go')
| -rw-r--r-- | vm/vm_test.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/vm/vm_test.go b/vm/vm_test.go index 07c063e..fb71176 100644 --- a/vm/vm_test.go +++ b/vm/vm_test.go @@ -3,7 +3,6 @@ package vm import ( "fmt" "log" - "reflect" "testing" ) @@ -50,11 +49,10 @@ func BenchmarkVM(b *testing.B) { } var tests = []struct { - //sym []any // initial memory values - sym []reflect.Value // initial memory values - code [][]int64 // bytecode to execute - start, end int // - mem string // expected memory content + sym []Value // initial memory values + code [][]int64 // bytecode to execute + start, end int // + mem string // expected memory content }{{ // #00 -- A simple addition. code: [][]int64{ {0, Push, 1}, @@ -64,7 +62,7 @@ var tests = []struct { }, start: 0, end: 1, mem: "[3]", }, { // #01 -- Calling a function defined outside the VM. - sym: []reflect.Value{reflect.ValueOf(fmt.Println), reflect.ValueOf("Hello")}, + sym: []Value{ValueOf(fmt.Println), ValueOf("Hello")}, code: [][]int64{ {0, Dup, 0}, {0, CallX, 1}, |
