blob: 6d5d2297b8a9052f4126492b11124bd3e38aaaf3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#include "debugging.h"
#include "qmljs_engine.h"
#include "qv4ir_p.h"
#include "qv4isel_p.h"
#include "qv4isel_util_p.h"
#include <QString>
#include <cassert>
using namespace QQmlJS;
EvalInstructionSelection::EvalInstructionSelection(VM::ExecutionEngine *engine, IR::Module *module)
: _engine(engine)
{
assert(engine);
assert(module);
createFunctionMapping(engine, module->rootFunction);
foreach (IR::Function *f, module->functions) {
assert(_irToVM.contains(f));
}
}
EvalInstructionSelection::~EvalInstructionSelection()
{}
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->usesArgumentsObject = irFunction->usesArgumentsObject;
vmFunction->isStrict = irFunction->isStrict;
foreach (const QString *formal, irFunction->formals)
if (formal)
vmFunction->formals.append(*formal);
foreach (const QString *local, irFunction->locals)
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;
}
|