@@ -65,7 +65,7 @@ func (n unaryNode) Eval(env interface{}) (interface{}, error) {
65
65
66
66
switch n .operator {
67
67
case "not" , "!" :
68
- return ! toBool ( n , val ), nil
68
+ return ! val .( bool ), nil
69
69
}
70
70
71
71
v := toNumber (n , val )
@@ -87,22 +87,22 @@ func (n binaryNode) Eval(env interface{}) (interface{}, error) {
87
87
88
88
switch n .operator {
89
89
case "or" , "||" :
90
- if toBool ( n . left , left ) {
90
+ if left .( bool ) {
91
91
return true , nil
92
92
}
93
93
right , err := n .right .Eval (env )
94
94
if err != nil {
95
95
return nil , err
96
96
}
97
- return toBool ( n . right , right ), nil
97
+ return right .( bool ), nil
98
98
99
99
case "and" , "&&" :
100
- if toBool ( n . left , left ) {
100
+ if left .( bool ) {
101
101
right , err := n .right .Eval (env )
102
102
if err != nil {
103
103
return nil , err
104
104
}
105
- return toBool ( n . right , right ), nil
105
+ return right .( bool ), nil
106
106
}
107
107
return false , nil
108
108
}
@@ -134,7 +134,7 @@ func (n binaryNode) Eval(env interface{}) (interface{}, error) {
134
134
return ! ok , nil
135
135
136
136
case "~" :
137
- return toText ( n . left , left ) + toText ( n . right , right ), nil
137
+ return left .( string ) + right .( string ), nil
138
138
}
139
139
140
140
// Next goes operators on numbers
@@ -216,15 +216,15 @@ func (n matchesNode) Eval(env interface{}) (interface{}, error) {
216
216
}
217
217
218
218
if n .r != nil {
219
- return n .r .MatchString (toText ( n . left , left )), nil
219
+ return n .r .MatchString (left .( string )), nil
220
220
}
221
221
222
222
right , err := n .right .Eval (env )
223
223
if err != nil {
224
224
return nil , err
225
225
}
226
226
227
- matched , err := regexp .MatchString (toText ( n . right , right ), toText ( n . left , left ))
227
+ matched , err := regexp .MatchString (right .( string ), left .( string ))
228
228
if err != nil {
229
229
return nil , err
230
230
}
@@ -361,7 +361,7 @@ func (n conditionalNode) Eval(env interface{}) (interface{}, error) {
361
361
}
362
362
363
363
// If
364
- if toBool ( n . cond , cond ) {
364
+ if cond .( bool ) {
365
365
// Then
366
366
a , err := n .exp1 .Eval (env )
367
367
if err != nil {
0 commit comments