예제 #1
0
        public Object Eval(Object x)
        {
            Object ret = null;

            try
            {
                ret = eval(x, globalenv);
                THIRDLASTVAL.setGlobalValue(NEXTLASTVAL.getGlobalValue());
                NEXTLASTVAL.setGlobalValue(LASTVAL.getGlobalValue());
                LASTVAL.setGlobalValue(ret);
            }
            catch (Exception e)
            {
                EX.setGlobalValue(e);
                throw;
            }
            return(ret);
        }
예제 #2
0
        public Interpreter(Interpreter parent)
        {
            this.Parent = parent;
            globalenv   = new Env(null, null, null, this);
            reader      = new Reader(this);
            symbolTable = new SymbolTable(this);

            Assembly[] asm = AppDomain.CurrentDomain.GetAssemblies();
            foreach (Assembly a in asm)
            {
                addTypesFrom(a);
            }
            addTypesFrom(Assembly.LoadWithPartialName("System.Web"));
            internBuiltins();
            Primitives.internAll(this);
            // MEH: EX was not set to null
            EX.setGlobalValue(null);
            LASTVAL.setGlobalValue(null);
            NEXTLASTVAL.setGlobalValue(null);
            THIRDLASTVAL.setGlobalValue(null);

            //these primitives are here, rather than in Primitives, because their implementation
            //requires calls to gfs bound to symbols
            Intern("intern", new Function(internf));
            Intern("eval", new Function(evalf));
            Intern("load", new Function(loadf));
            Intern("map->list", new Function(map_to_list));
            Intern("apply", new Function(apply));
            Intern("<", new Function(lt));
            Intern("<=", new Function(lteq));
            Intern(">", new Function(gt));
            Intern(">=", new Function(gteq));
            Intern("==", new Function(eqeq));
            Intern("!=", new Function(noteq));

            strgf       = (GenericFunction)intern("str").getGlobalValue();
            get_enum_gf = (GenericFunction)intern("get-enum").getGlobalValue();
            compare_gf  = (BinOp)intern("compare").getGlobalValue();

            Intern("interpreter", this);
        }