public override int Eval(Stack stack) { int narg = GetNarg(stack); var local = pc.env.copy(); var code = GetList(stack); var ups = new Stack(); int ret = UserProgram.process_block(code, ups, local, false); pc.env.update(local); if (ret != Processor.ERROR && ups.Count > 0) { var y = ups.Pop(); stack.Push(y); } else { throw new JasymcaException("Error processing block."); } return(0); }
public override int Eval(Stack stack) { int narg = GetNarg(stack); var local = Session.Proc.Store.Clone(); var code = GetList(stack); var ups = new Stack(); int ret = UserProgram.process_block(code, ups, local, false); Session.Proc.Store.Update(local); if (ret != Processor.ERROR && ups.Count > 0) { var y = ups.Pop(); stack.Push(y); } else { throw new SymbolicException("Error processing block."); } return(0); }
public override int Eval(Stack st) { int narg = GetNarg(st); var code_in = GetList(st); var fname = GetSymbol(st).Substring(1); int nvar = GetNarg(st); var vars = new SimpleVariable[nvar]; for (int i = 0; i < nvar; i++) { vars[i] = new SimpleVariable(GetSymbol(st)); } Lambda func = null; var env = new Environment(); var ups = new Stack(); object y = null; if (nvar == 1) { int res = UserProgram.process_block(code_in, ups, env, false); if (res != Processor.ERROR) { y = ups.Pop(); } } if (y is Algebraic) { func = new UserFunction(fname, vars, ( Algebraic )y, null, null); } else { func = new UserProgram(fname, vars, code_in, null, env, ups); } pc.env.putValue(fname, func); st.Push(fname); return(0); }
public override int lambda(Stack st) { int narg = getNarg(st); Environment local = pc.env.copy(); List code = getList(st); Stack ups = new Stack(); int ret = UserProgram.process_block(code, ups, local, false); pc.env.update(local); if (ret != Processor.ERROR && ups.Count > 0) { object y = ups.Pop(); st.Push(y); } else { throw new JasymcaException("Error processing block."); } return(0); }