mirror of https://github.com/exaloop/codon.git
Fix globals in JIT
parent
7655e09e83
commit
d5741a27e0
codon/parser/visitors/simplify
|
@ -144,19 +144,19 @@ StmtPtr SimplifyVisitor::transformAssignment(ExprPtr lhs, ExprPtr rhs, ExprPtr t
|
|||
// Generate new canonical variable name for this assignment and add it to the context
|
||||
auto canonical = ctx->generateCanonicalName(e->value);
|
||||
auto assign = N<AssignStmt>(N<IdExpr>(canonical), rhs, type);
|
||||
val = nullptr;
|
||||
if (rhs && rhs->isType()) {
|
||||
ctx->addType(e->value, canonical, lhs->getSrcInfo());
|
||||
val = ctx->addType(e->value, canonical, lhs->getSrcInfo());
|
||||
} else {
|
||||
auto val = ctx->addVar(e->value, canonical, lhs->getSrcInfo());
|
||||
val = ctx->addVar(e->value, canonical, lhs->getSrcInfo());
|
||||
if (auto st = getStaticGeneric(type.get()))
|
||||
val->staticType = st;
|
||||
}
|
||||
|
||||
// Register all toplevel variables as global in JIT mode
|
||||
bool isGlobal =
|
||||
(ctx->cache->isJit && ctx->isGlobal() && getStaticGeneric(type.get()) == 0) ||
|
||||
(canonical == VAR_ARGV);
|
||||
if (isGlobal && !getStaticGeneric(type.get()))
|
||||
bool isGlobal = (ctx->cache->isJit && val->isGlobal() && !val->isGeneric() == 0) ||
|
||||
(canonical == VAR_ARGV);
|
||||
if (isGlobal && !val->isGeneric())
|
||||
ctx->cache->addGlobal(canonical);
|
||||
|
||||
return assign;
|
||||
|
|
|
@ -56,8 +56,9 @@ void SimplifyVisitor::visit(WhileStmt *stmt) {
|
|||
transformConditionalScope(stmt->suite);
|
||||
ctx->leaveConditionalBlock();
|
||||
// Dominate loop variables
|
||||
for (auto &var : ctx->getBase()->getLoop()->seenVars)
|
||||
for (auto &var : ctx->getBase()->getLoop()->seenVars) {
|
||||
ctx->findDominatingBinding(var);
|
||||
}
|
||||
ctx->getBase()->loops.pop_back();
|
||||
|
||||
// Complete while-else clause
|
||||
|
|
Loading…
Reference in New Issue