Example #1
0
        public LithpPrimitive Invoke(LithpList parameters, LithpOpChain state, LithpInterpreter interp)
        {
            LithpOpChain parent;

            if (body.Scoped)
            {
                parent = body;
            }
            else
            {
                parent = state;
            }
            LithpOpChain chain = new LithpOpChain(parent, body);

            // Arity star functions pass all arguments in first parameter
            if (arity.HasValue == false)
            {
                parameters = LithpList.New(parameters);
            }
            parameters.Each((Value, Index) =>
            {
                if (Index < this.parameters.Length)
                {
                    chain.Closure.SetImmediate(this.parameters[Index], Value);
                }
            });
            chain.FunctionEntry = name;
            return(interp.Run(chain));
        }
 public LithpPrimitive Invoke(LithpList parameters, LithpOpChain state,
                              LithpInterpreter interp)
 {
     return(fn_body(parameters, state, interp));
 }