예제 #1
0
        static void CompileSingleForm(Cons form, Environment e, Function p)
        {
            var car = form.car;

            if (car is Symbol s)
            {
                if (SO.IsSO(s))
                {
                    SO.Dispatch(form, e, p);
                    return;
                }
                else if (Macro.IsMacro(s))
                {
                    CompileSingleExpr(Macro.Expand(form), e, p);
                    return;
                }
                else
                {
                    CompileAtom(s, e, p);
                }
            }
            else if (car is Cons c)
            {
                CompileSingleForm(c, e, p);
            }
            else
            {
                throw new SyntaxError(string.Format("Object is not a function, macro or special operator: {0}", car));
            }
            LocalVariable v = e.AddUnnamedVariable();

            p.Load(v);
            CompileFunctionCall(v, form.cdr, e, p);
        }
 public static void Init()
 {
     if (!inited)
     {
         inited = true;
         Core.Init();
         SO.Init();
         nil      = env.FindOrExtern(Symbol.FindOrCreate("NIL"));
         env.Name = "global";
         Macro.Init();
     }
 }