@@ -5,16 +5,10 @@ import (
5
5
"reflect"
6
6
)
7
7
8
- var (
9
- anyType = reflect .TypeOf (new (interface {})).Elem ()
10
- integerType = reflect .TypeOf (0 )
11
- floatType = reflect .TypeOf (float64 (0 ))
12
- )
13
-
14
8
type Function struct {
15
9
Name string
10
+ Id int
16
11
Func func (args ... interface {}) (interface {}, error )
17
- Opcode int
18
12
Types []reflect.Type
19
13
Validate func (args []reflect.Type ) (reflect.Type , error )
20
14
}
@@ -28,8 +22,8 @@ const (
28
22
29
23
var Builtins = map [int ]* Function {
30
24
Len : {
31
- Name : "len" ,
32
- Opcode : Len ,
25
+ Name : "len" ,
26
+ Id : Len ,
33
27
Validate : func (args []reflect.Type ) (reflect.Type , error ) {
34
28
if len (args ) != 1 {
35
29
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{
42
36
},
43
37
},
44
38
Abs : {
45
- Name : "abs" ,
46
- Opcode : Abs ,
39
+ Name : "abs" ,
40
+ Id : Abs ,
47
41
Validate : func (args []reflect.Type ) (reflect.Type , error ) {
48
42
if len (args ) != 1 {
49
43
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{
56
50
},
57
51
},
58
52
Int : {
59
- Name : "int" ,
60
- Opcode : Int ,
53
+ Name : "int" ,
54
+ Id : Int ,
61
55
Validate : func (args []reflect.Type ) (reflect.Type , error ) {
62
56
if len (args ) != 1 {
63
57
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{
74
68
},
75
69
},
76
70
Float : {
77
- Name : "float" ,
78
- Opcode : Float ,
71
+ Name : "float" ,
72
+ Id : Float ,
79
73
Validate : func (args []reflect.Type ) (reflect.Type , error ) {
80
74
if len (args ) != 1 {
81
75
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{
92
86
},
93
87
},
94
88
}
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