コード例 #1
0
ファイル: index.go プロジェクト: callistoaz/3
func (w *World) compileIndexExpr(n *ast.IndexExpr) Expr {
	x := w.compileExpr(n.X)
	kind := x.Type().Kind()
	if !(kind == reflect.Array || kind == reflect.Slice) {
		panic(err(n.Pos(), "can not index", x.Type()))
	}
	i := typeConv(n.Index.Pos(), w.compileExpr(n.Index), int_t)
	return &index{x, i}
}