@@ -5,16 +5,10 @@ import (
55 "reflect"
66)
77
8- var (
9- anyType = reflect .TypeOf (new (interface {})).Elem ()
10- integerType = reflect .TypeOf (0 )
11- floatType = reflect .TypeOf (float64 (0 ))
12- )
13-
148type Function struct {
159 Name string
10+ Id int
1611 Func func (args ... interface {}) (interface {}, error )
17- Opcode int
1812 Types []reflect.Type
1913 Validate func (args []reflect.Type ) (reflect.Type , error )
2014}
@@ -28,8 +22,8 @@ const (
2822
2923var Builtins = map [int ]* Function {
3024 Len : {
31- Name : "len" ,
32- Opcode : Len ,
25+ Name : "len" ,
26+ Id : Len ,
3327 Validate : func (args []reflect.Type ) (reflect.Type , error ) {
3428 if len (args ) != 1 {
3529 return anyType , fmt .Errorf ("invalid number of arguments for len (expected 1, got %d)" , len (args ))
@@ -42,8 +36,8 @@ var Builtins = map[int]*Function{
4236 },
4337 },
4438 Abs : {
45- Name : "abs" ,
46- Opcode : Abs ,
39+ Name : "abs" ,
40+ Id : Abs ,
4741 Validate : func (args []reflect.Type ) (reflect.Type , error ) {
4842 if len (args ) != 1 {
4943 return anyType , fmt .Errorf ("invalid number of arguments for abs (expected 1, got %d)" , len (args ))
@@ -56,8 +50,8 @@ var Builtins = map[int]*Function{
5650 },
5751 },
5852 Int : {
59- Name : "int" ,
60- Opcode : Int ,
53+ Name : "int" ,
54+ Id : Int ,
6155 Validate : func (args []reflect.Type ) (reflect.Type , error ) {
6256 if len (args ) != 1 {
6357 return anyType , fmt .Errorf ("invalid number of arguments for int (expected 1, got %d)" , len (args ))
@@ -74,8 +68,8 @@ var Builtins = map[int]*Function{
7468 },
7569 },
7670 Float : {
77- Name : "float" ,
78- Opcode : Float ,
71+ Name : "float" ,
72+ Id : Float ,
7973 Validate : func (args []reflect.Type ) (reflect.Type , error ) {
8074 if len (args ) != 1 {
8175 return anyType , fmt .Errorf ("invalid number of arguments for float (expected 1, got %d)" , len (args ))
@@ -92,10 +86,3 @@ var Builtins = map[int]*Function{
9286 },
9387 },
9488}
95-
96- func kind (t reflect.Type ) reflect.Kind {
97- if t == nil {
98- return reflect .Invalid
99- }
100- return t .Kind ()
101- }
0 commit comments