From 26890bcd5b910603f1955ba125b1602fbc2bfa9d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 15 Mar 2009 17:40:52 +0000 Subject: Fix REPL variable addressing. git-svn-id: http://svn.drobilla.net/resp/tuplr@107 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- llvm.cpp | 8 +++++--- tuplr.hpp | 2 +- typing.cpp | 2 -- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/llvm.cpp b/llvm.cpp index a081c0a..ef52b88 100644 --- a/llvm.cpp +++ b/llvm.cpp @@ -325,7 +325,7 @@ ACall::compile(CEnv& cenv) void ADefinition::lift(CEnv& cenv) { - // Define first for recursion + // Define stub first for recursion cenv.def(at(1)->as(), at(2), cenv.type(at(2)), NULL); AClosure* c = at(2)->to(); if (c) @@ -336,9 +336,11 @@ ADefinition::lift(CEnv& cenv) CValue ADefinition::compile(CEnv& cenv) { - // Define first for recursion + // Define stub first for recursion cenv.def(at(1)->as(), at(2), cenv.type(at(2)), NULL); - return cenv.compile(at(2)); + CValue val = cenv.compile(at(2)); + cenv.vals.def(at(1)->as(), val); + return val; } CValue diff --git a/tuplr.hpp b/tuplr.hpp index f458fd0..aaf4497 100644 --- a/tuplr.hpp +++ b/tuplr.hpp @@ -483,7 +483,7 @@ struct TEnv : public Env< const ASymbol*, pair > { } AST* resolve(AST* ast) { ASymbol* sym = ast->to(); - return sym ? ref(sym)->first : ast; + return (sym && sym->addr) ? ref(sym)->first : ast; } static Subst unify(const Constraints& c); diff --git a/typing.cpp b/typing.cpp index 518ab00..94826e9 100644 --- a/typing.cpp +++ b/typing.cpp @@ -156,8 +156,6 @@ ADefinition::constrain(TEnv& tenv, Constraints& c) const const ASymbol* sym = at(1)->to(); if (!sym) throw Error("`def' name is not a symbol", loc); - if (tenv.lookup(sym)) - throw Error(string("`") + at(1)->str() + "' redefined", loc); AType* tvar = tenv.var(at(2)); tenv.def(sym, make_pair(at(2), tvar)); at(2)->constrain(tenv, c); -- cgit v1.2.1