Exemplo n.º 1
0
func (bt BindingTable) IndexSet(idx, v eval.Value) {
	key := keyIndex(idx)

	var f Caller
	switch v := v.(type) {
	case eval.String:
		builtin, ok := builtinMap[string(v)]
		if !ok {
			throw(fmt.Errorf("no builtin named %s", v.Repr()))
		}
		f = builtin
	case eval.Caller:
		f = EvalCaller{v}
	default:
		throw(fmt.Errorf("bad function type %s", v.Kind()))
	}

	bt.inner[key] = f
}
Exemplo n.º 2
0
func (bt BindingTable) IndexSet(idx, v eval.Value) {
	key := keyIndex(idx)

	var f BoundFunc
	switch v := v.(type) {
	case eval.String:
		builtin, ok := builtinMap[string(v)]
		if !ok {
			throw(fmt.Errorf("no builtin named %s", v.Repr(eval.NoPretty)))
		}
		f = builtin
	case eval.FnValue:
		f = FnAsBoundFunc{v}
	default:
		throw(fmt.Errorf("bad function type %s", v.Kind()))
	}

	bt.inner[key] = f
}