Search in sources :

Example 26 with MethodCode

use of com.github.anba.es6draft.compiler.assembler.Code.MethodCode in project es6draft by anba.

the class FunctionDeclarationInstantiationGenerator method generate.

void generate(FunctionNode function) {
    MethodCode method = codegen.newMethod(function, FunctionName.Init);
    CodeVisitor mv = new FunctionDeclInitMethodGenerator(method, function, targetType(function));
    mv.lineInfo(function);
    mv.begin();
    mv.enterScope(function);
    generate(function, mv);
    mv.exitScope();
    mv.end();
}
Also used : MethodCode(com.github.anba.es6draft.compiler.assembler.Code.MethodCode)

Example 27 with MethodCode

use of com.github.anba.es6draft.compiler.assembler.Code.MethodCode in project es6draft by anba.

the class ModuleDeclarationInstantiationGenerator method generate.

void generate(Module module, SourceTextModuleRecord moduleRecord) {
    MethodCode method = codegen.newMethod(module, ModuleName.Init);
    InstructionVisitor mv = new ModuleDeclInitMethodGenerator(method);
    mv.lineInfo(module);
    mv.begin();
    generate(module, moduleRecord, mv);
    mv.end();
}
Also used : MethodCode(com.github.anba.es6draft.compiler.assembler.Code.MethodCode)

Example 28 with MethodCode

use of com.github.anba.es6draft.compiler.assembler.Code.MethodCode in project es6draft by anba.

the class EvalDeclarationInstantiationGenerator method generate.

void generate(Script evalScript) {
    MethodCode method = codegen.newMethod(evalScript, ScriptName.Init);
    InstructionVisitor mv = new EvalDeclInitMethodGenerator(method);
    mv.lineInfo(evalScript);
    mv.begin();
    if (VarDeclaredNames(evalScript).isEmpty() && LexicallyDeclaredNames(evalScript).isEmpty() && !hasBlockFunctions(evalScript)) {
        mv._return();
    } else if (evalScript.isScripting()) {
        generateScripting(evalScript, mv);
    } else if (evalScript.isStrict()) {
        generateStrict(evalScript, mv);
    } else if (evalScript.isGlobalCode()) {
        generateGlobal(evalScript, mv);
    } else {
        generateFunction(evalScript, mv);
    }
    mv.end();
}
Also used : MethodCode(com.github.anba.es6draft.compiler.assembler.Code.MethodCode)

Example 29 with MethodCode

use of com.github.anba.es6draft.compiler.assembler.Code.MethodCode in project es6draft by anba.

the class FunctionCodeGenerator method generateConstruct.

private void generateConstruct(FunctionNode node, boolean tailCall) {
    MethodCode method = codegen.newMethod(node, tailCall ? FunctionName.ConstructTailCall : FunctionName.Construct);
    InstructionVisitor mv = new ConstructMethodGenerator(method, targetName(node), targetType(node));
    mv.lineInfo(node);
    mv.begin();
    if (node.isGenerator()) {
        generateGeneratorConstruct(node, mv);
    } else if (isDerivedClassConstructor(node)) {
        generateDerivedClassConstructorConstruct(node, tailCall, mv);
    } else if (isLegacy(node)) {
        generateLegacyFunctionConstruct(node, mv);
    } else {
        generateFunctionConstruct(node, tailCall, mv);
    }
    mv.end();
}
Also used : MethodCode(com.github.anba.es6draft.compiler.assembler.Code.MethodCode)

Example 30 with MethodCode

use of com.github.anba.es6draft.compiler.assembler.Code.MethodCode in project es6draft by anba.

the class FunctionCodeGenerator method generateCall.

private void generateCall(FunctionNode node) {
    MethodCode method = codegen.newMethod(node, FunctionName.Call);
    InstructionVisitor mv = new CallMethodGenerator(method, targetName(node), targetType(node));
    mv.lineInfo(node);
    mv.begin();
    if (node.isAsync() && node.isGenerator()) {
        generateAsyncGeneratorCall(node, mv);
    } else if (node.isAsync()) {
        generateAsyncFunctionCall(node, mv);
    } else if (node.isGenerator()) {
        if (node.isConstructor()) {
            generateConstructorGeneratorCall(node, mv);
        } else {
            generateGeneratorCall(node, mv);
        }
    } else if (isClassConstructor(node)) {
        generateClassConstructorCall(mv);
    } else if (isLegacy(node)) {
        generateLegacyFunctionCall(node, mv);
    } else if (node.isConstructor()) {
        generateFunctionCall(node, OrdinaryConstructorFunction.class, mv);
    } else {
        generateFunctionCall(node, OrdinaryFunction.class, mv);
    }
    mv.end();
}
Also used : OrdinaryConstructorFunction(com.github.anba.es6draft.runtime.types.builtins.OrdinaryConstructorFunction) OrdinaryFunction(com.github.anba.es6draft.runtime.types.builtins.OrdinaryFunction) MethodCode(com.github.anba.es6draft.compiler.assembler.Code.MethodCode)

Aggregations

MethodCode (com.github.anba.es6draft.compiler.assembler.Code.MethodCode)46 MethodTypeDescriptor (com.github.anba.es6draft.compiler.assembler.MethodTypeDescriptor)12 Completion (com.github.anba.es6draft.compiler.StatementGenerator.Completion)8 ExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext)6 OrdinaryObject (com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)6 GeneratorState (com.github.anba.es6draft.compiler.CodeVisitor.GeneratorState)5 MethodName (com.github.anba.es6draft.compiler.assembler.MethodName)4 LexicalEnvironment (com.github.anba.es6draft.runtime.LexicalEnvironment)4 OrdinaryConstructorFunction (com.github.anba.es6draft.runtime.types.builtins.OrdinaryConstructorFunction)4 SwitchClause (com.github.anba.es6draft.ast.SwitchClause)3 Jump (com.github.anba.es6draft.compiler.assembler.Jump)3 LabelState (com.github.anba.es6draft.compiler.CodeVisitor.LabelState)2 ResumptionPoint (com.github.anba.es6draft.runtime.internal.ResumptionPoint)2 ArrayObject (com.github.anba.es6draft.runtime.types.builtins.ArrayObject)2 SimpleImmutableEntry (java.util.AbstractMap.SimpleImmutableEntry)2 ArrayList (java.util.ArrayList)2 MethodDefinition (com.github.anba.es6draft.ast.MethodDefinition)1 ValType (com.github.anba.es6draft.compiler.DefaultCodeGenerator.ValType)1 InstanceMethod (com.github.anba.es6draft.runtime.language.ClassOperations.InstanceMethod)1 ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)1