public static LithpPrimitive Print(LithpList parameters, LithpOpChain state, LithpInterpreter interp) { LithpPrimitive result = ApplyAction((A, B, X, Y) => { return(A.ToString() + " " + B.ToString()); }, parameters, state, interp); Console.WriteLine(result.ToString()); return(LithpAtom.Nil); }
public static LithpPrimitive Call(LithpList parameters, LithpOpChain state, LithpInterpreter interp) { LithpPrimitive def = parameters[0]; LithpList defParams = (LithpList)Tail(LithpList.New(parameters), state, interp); switch (def.LithpType()) { case LithpType.FN_NATIVE: return(((LithpFunctionDefinitionNative)def).Invoke(defParams, state, interp)); case LithpType.FN: return(((LithpFunctionDefinition)def).Invoke(defParams, state, interp)); case LithpType.ATOM: case LithpType.STRING: string strName = def.ToString(); ILithpFunctionDefinition search; if ((object)state.Closure.TopMost != null && state.Closure.TopMost.IsDefined(strName)) { search = (ILithpFunctionDefinition)state.Closure.TopMost[strName]; } else if (state.Closure.IsDefined(strName)) { search = (ILithpFunctionDefinition)state.Closure[strName]; } else { string arityStar = strName + "/*"; if ((object)state.Closure.TopMost != null && state.Closure.TopMost.IsDefined(arityStar)) { search = (ILithpFunctionDefinition)state.Closure.TopMost[arityStar]; } else if (state.Closure.IsDefined(arityStar)) { search = (ILithpFunctionDefinition)state.Closure[arityStar]; } else { throw new MissingMethodException(); } } return(search.Invoke(defParams, state, interp)); default: throw new NotImplementedException(); } }
protected override LithpPrimitive operatorPlus(LithpPrimitive other) { return(Value + other.ToString()); }