diff options
Diffstat (limited to 'src/resp.hpp')
-rw-r--r-- | src/resp.hpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/resp.hpp b/src/resp.hpp index a972d48..3f73f2f 100644 --- a/src/resp.hpp +++ b/src/resp.hpp @@ -647,10 +647,6 @@ struct TEnv : public Env<const ASymbol*, const AType*> { if (!ast) return new AType(Cursor(), varID++); - const ASymbol* sym = ast->to<const ASymbol*>(); - if (sym) - return *ref(sym); - Vars::iterator v = vars.find(ast); if (v != vars.end()) return v->second; @@ -730,18 +726,20 @@ struct CEnv { void lock(const AST* ast) { Object::pool.addRoot(ast); if (type(ast)) - Object::pool.addRoot(type(ast)); + Object::pool.addRoot(type(ast)); } const AType* type(const AST* ast, const Subst& subst = Subst()) const { + const AType* ret = NULL; const ASymbol* sym = ast->to<const ASymbol*>(); if (sym) { const AType** rec = tenv.ref(sym); - return rec ? *rec : NULL; - } - const AType* var = tenv.vars[ast]; - if (var) { - return tsubst.apply(subst.apply(var))->to<const AType*>(); + if (rec) + ret = *rec; } + if (!ret) + ret = tenv.vars[ast]; + if (ret) + return tsubst.apply(subst.apply(ret))->to<const AType*>(); return NULL; } void def(const ASymbol* sym, const AST* c, const AType* t, CVal v) { @@ -814,9 +812,9 @@ private: * EVAL/REPL/MAIN * ***************************************************************************/ -void pprint(std::ostream& out, const AST* ast); +void pprint(std::ostream& out, const AST* ast, CEnv* cenv, bool types); void initLang(PEnv& penv, TEnv& tenv); -int eval(CEnv& cenv, const string& name, istream& is, bool execute); +int eval(CEnv& cenv, Cursor& cursor, istream& is, bool execute); int repl(CEnv& cenv); #endif // RESP_HPP |