public LithpOpChain Finalize() { LithpOpChain chain = new LithpOpChain(); foreach (dynamic x in ops) { ILithpOpChainMember c = convert(chain, x); chain.Add(c); } return(chain); }
public LithpPrimitive Run(LithpOpChain chain) { ILithpPrimitive value = LithpAtom.Atom("nil"); while (chain.AtEnd() == false) { ILithpOpChainMember current = chain.Next(); switch (current.LithpType()) { case LithpType.OPCHAIN: value = this.Run(new LithpOpChain(chain, (LithpOpChain)current)); break; case LithpType.FUNCTIONCALL: LithpFunctionCall call = (LithpFunctionCall)current; LithpList resolved = ResolveParameters(call, chain); value = InvokeResolved(call, resolved, chain); if (value.LithpType() == LithpType.OPCHAIN) { LithpOpChain subchain = (LithpOpChain)value; value = this.Run(new LithpOpChain(chain, subchain)); } break; case LithpType.LITERAL: value = ((LithpLiteral)current).Value; break; case LithpType.FN: case LithpType.FN_NATIVE: value = current; break; default: throw new NotImplementedException(); } } return((LithpPrimitive)value); }