Get rid of reflect pkg when handling arrays

This commit is contained in:
Marc Vertes
2018-02-14 11:45:08 +01:00
parent 87edd051e2
commit 11795336f5
2 changed files with 4 additions and 5 deletions

View File

@@ -1,9 +1,9 @@
package interp
import (
"fmt"
"go/ast"
"go/token"
"reflect"
"strconv"
)
@@ -215,7 +215,7 @@ func (e *Node) Cfg(i *Interpreter) int {
case *ast.FuncType:
case *ast.File:
default:
println("unknown type:", reflect.TypeOf(*n.anode).String())
fmt.Printf("unknown type: %T\n", *n.anode)
}
})
return maxIndex + 1

View File

@@ -2,7 +2,6 @@ package interp
import (
"fmt"
"reflect"
)
// Run a Go function
@@ -97,8 +96,8 @@ func (interp *Interpreter) call(n *Node, f *Frame) {
}
func getIndex(n *Node, f *Frame) {
a := reflect.ValueOf(value(n.Child[0], f))
(*f)[n.findex] = a.Index(int(value(n.Child[1], f).(int64)))
a := value(n.Child[0], f).([]interface{})
(*f)[n.findex] = a[value(n.Child[1], f).(int64)]
}
func add(n *Node, f *Frame) {