aboutsummaryrefslogtreecommitdiffstats
path: root/qv4isel_p.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2012-12-13 12:09:04 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2012-12-13 12:38:11 +0100
commit9edd6967753c16512c8c589f3dedcae02687070a (patch)
treea8c4460d5c556fa9b087c229ba88dd68980ce9ef /qv4isel_p.cpp
parentd6fcbdbf5182dcd549ef685cfeb2e3e90d3e81c7 (diff)
Correctly set up nested functions
Make sure we have the correct set of nested functions in both IR::Function and VM::Function. This is required so that closures can work correctly. Change-Id: I42493d5ee503090653b71650c8d19e06c4bcfdda Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'qv4isel_p.cpp')
-rw-r--r--qv4isel_p.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/qv4isel_p.cpp b/qv4isel_p.cpp
index 5a668fa246..b49d4d3adc 100644
--- a/qv4isel_p.cpp
+++ b/qv4isel_p.cpp
@@ -16,8 +16,10 @@ EvalInstructionSelection::EvalInstructionSelection(VM::ExecutionEngine *engine,
assert(engine);
assert(module);
- foreach (IR::Function *f, module->functions)
- _irToVM.insert(f, createFunctionMapping(engine, f));
+ createFunctionMapping(engine, module->rootFunction);
+ foreach (IR::Function *f, module->functions) {
+ assert(_irToVM.contains(f));
+ }
}
EvalInstructionSelection::~EvalInstructionSelection()
@@ -29,6 +31,8 @@ EvalISelFactory::~EvalISelFactory()
VM::Function *EvalInstructionSelection::createFunctionMapping(VM::ExecutionEngine *engine, IR::Function *irFunction)
{
VM::Function *vmFunction = engine->newFunction(irFunction->name ? *irFunction->name : QString());
+ _irToVM.insert(irFunction, vmFunction);
+
vmFunction->hasDirectEval = irFunction->hasDirectEval;
vmFunction->isStrict = irFunction->isStrict;
@@ -39,8 +43,18 @@ VM::Function *EvalInstructionSelection::createFunctionMapping(VM::ExecutionEngin
if (local)
vmFunction->locals.append(*local);
+ foreach (IR::Function *function, irFunction->nestedFunctions)
+ vmFunction->nestedFunctions.append(createFunctionMapping(engine, function));
+
if (engine->debugger)
engine->debugger->mapFunction(vmFunction, irFunction);
return vmFunction;
}
+
+VM::Function *EvalInstructionSelection::vmFunction(IR::Function *f) {
+ VM::Function *function = _irToVM[f];
+ if (!function->code)
+ run(function, f);
+ return function;
+}