示例#1
0
文件: ops.go 项目: shawnps/go-xslate
func txFetchArrayElement(st *State) {
	// There should only be items pushed
	array := reflect.ValueOf(st.StackPop())
	idx := st.StackPop()

	v := array.Index(int(idx.(int64)))
	st.sa = v.Interface()
	st.Advance()
}
示例#2
0
文件: ops.go 项目: jeremiah/go-xslate
func txFetchArrayElement(st *State) {
	defer st.Advance()

	array := reflect.ValueOf(st.StackPop())
	switch array.Kind() {
	case reflect.Array, reflect.Slice:
	default:
		st.Warnf("cannot index into non-array/slice element")
		return
	}

	idx := st.StackPop()
	v := array.Index(int(idx.(int64)))
	st.sa = v.Interface()
}