aboutsummaryrefslogtreecommitdiffstats
path: root/qv4isel_p.cpp
blob: 5a668fa246f7122cd6f1794ece4bb91fd6e7c3eb (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
#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);

    foreach (IR::Function *f, module->functions)
        _irToVM.insert(f, createFunctionMapping(engine, 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());
    vmFunction->hasDirectEval = irFunction->hasDirectEval;
    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);

    if (engine->debugger)
        engine->debugger->mapFunction(vmFunction, irFunction);

    return vmFunction;
}