public override void CreateVariables(Executive engine, object form, ILGen il, LocalAccess locals, object[] args) { if (args.Length == 0) throw new ArgumentException("Unproperly formated expression"); locals.DeclareScope(form); locals.EnterScope(form, _activeScope); foreach (object arg in Lisp.getIterator(args[0])) { object[] pair = Lisp.ToArray(arg); if (pair.Length != 2 || !Lisp.IsAtom(pair[0])) throw new ArgumentException("Unproperly formated expression"); locals.DeclareLocal(pair[0]); engine.CreateVariables(il, locals, pair[1]); } if (!_activeScope) locals.ActivateScope(); for (int k = 1; k < args.Length; k++) engine.CreateVariables(il, locals, args[k]); locals.LeaveScope(); }
public override void Compile(Executive engine, object form, ILGen il, LocalAccess locals, Stack<Type> st, object[] args) { locals.EnterScope(form, _activeScope); foreach (object arg in Lisp.getIterator(args[0])) { object[] pair = Lisp.ToArray(arg); engine.CompileExpr(il, locals, st, pair[1]); LocalBuilder localvar = locals.BindLocal(pair[0], st.Pop()); il.Emit(OpCodes.Stloc, localvar); } if (!_activeScope) locals.ActivateScope(); for (int k = 1; k < args.Length; k++) { engine.CompileExpr(il, locals, st, args[k]); if (k < args.Length - 1) { st.Pop(); il.Emit(OpCodes.Pop); } } locals.DestroyScope(); }