aboutsummaryrefslogtreecommitdiffstats
path: root/src/compile.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-05-14 22:41:13 +0000
committerDavid Robillard <d@drobilla.net>2011-05-14 22:41:13 +0000
commitccc0e2c718ac0562bbc2273cde5c853249f94ab2 (patch)
tree84369ee8b39099eb3e145708e2db6a236c549895 /src/compile.cpp
parent6ca900cd7409cfea90294d274bf0a6c48a13a8dc (diff)
downloadresp-ccc0e2c718ac0562bbc2273cde5c853249f94ab2.tar.gz
resp-ccc0e2c718ac0562bbc2273cde5c853249f94ab2.tar.bz2
resp-ccc0e2c718ac0562bbc2273cde5c853249f94ab2.zip
Fix global set/get (top level variable definitions in the REPL).
git-svn-id: http://svn.drobilla.net/resp/trunk@425 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/compile.cpp')
-rw-r--r--src/compile.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index 1534263..e8baed3 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -90,7 +90,13 @@ compile_def(CEnv& cenv, const ATuple* def) throw()
const ASymbol* const sym = def->list_ref(1)->as_symbol();
const AST* const body = def->list_ref(2);
CVal val = resp_compile(cenv, body);
- cenv.def(sym, body, cenv.type(body), val);
+ if (cenv.repl && cenv.vals.topLevel(sym) && !is_form(cenv.type(sym), "Fn")) {
+ CVal global = cenv.engine()->compileGlobalSet(
+ cenv, sym->sym(), val, cenv.type(body));
+ cenv.def(sym, body, cenv.type(body), global);
+ } else {
+ cenv.def(sym, body, cenv.type(body), val);
+ }
return NULL;
}