Beispiel #1
0
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()
}
Beispiel #2
0
func txForStart(st *State) {
	array := reflect.ValueOf(st.sa)

	switch array.Kind() {
	case reflect.Array, reflect.Slice:
		// Normal case. nothing to do
	default:
		// Oh you silly goose. You didn't give me a array.
		// Use a dummy array
		array = reflect.ValueOf([]struct{}{})
	}

	cf := st.CurrentFrame()
	cf.SetLvar(0, nil) // item
	cf.SetLvar(1, NewLoopVar(-1, array))

	st.Advance()
}