Search in sources :

Example 1 with LambdaFunctionBootstrap

use of com.googlecode.aviator.runtime.LambdaFunctionBootstrap in project aviatorscript by killme2008.

the class InterpretCodeGenerator method onLambdaBodyEnd.

@Override
public void onLambdaBodyEnd(final Token<?> lookhead) {
    // this.lambdaGenerator.compileCallMethod();
    LambdaFunctionBootstrap bootstrap = this.lambdaGenerator.getLmabdaBootstrap();
    if (this.lambdaBootstraps == null) {
        // keep in order
        this.lambdaBootstraps = new LinkedHashMap<String, LambdaFunctionBootstrap>();
    }
    this.lambdaBootstraps.put(bootstrap.getName(), bootstrap);
    genNewLambdaCode(bootstrap);
    this.parser.restoreScope(this.lambdaGenerator.getScopeInfo());
    this.lambdaGenerator = null;
    this.parser.setCodeGenerator(this.parentCodeGenerator);
}
Also used : LambdaFunctionBootstrap(com.googlecode.aviator.runtime.LambdaFunctionBootstrap)

Example 2 with LambdaFunctionBootstrap

use of com.googlecode.aviator.runtime.LambdaFunctionBootstrap in project aviatorscript by killme2008.

the class OptimizeCodeGenerator method onLambdaBodyEnd.

@Override
public void onLambdaBodyEnd(final Token<?> lookhead) {
    // this.lambdaGenerator.compileCallMethod();
    LambdaFunctionBootstrap bootstrap = this.lambdaGenerator.getLmabdaBootstrap();
    if (this.lambdaBootstraps == null) {
        this.lambdaBootstraps = new HashMap<String, LambdaFunctionBootstrap>();
    }
    this.lambdaBootstraps.put(bootstrap.getName(), bootstrap);
    DelegateToken token = new DelegateToken(lookhead, DelegateTokenType.Lambda_New);
    token.setLambdaFunctionBootstrap(bootstrap);
    this.tokenList.add(token);
    this.parser.restoreScope(this.lambdaGenerator.getScopeInfo());
    this.lambdaGenerator = null;
    this.parser.setCodeGenerator(this.parentCodeGenerator);
}
Also used : DelegateToken(com.googlecode.aviator.lexer.token.DelegateToken) LambdaFunctionBootstrap(com.googlecode.aviator.runtime.LambdaFunctionBootstrap) AviatorString(com.googlecode.aviator.runtime.type.AviatorString)

Example 3 with LambdaFunctionBootstrap

use of com.googlecode.aviator.runtime.LambdaFunctionBootstrap in project aviatorscript by killme2008.

the class ASMCodeGenerator method onLambdaBodyEnd.

@Override
public void onLambdaBodyEnd(final Token<?> lookhead) {
    // this.lambdaGenerator.compileCallMethod();
    LambdaFunctionBootstrap bootstrap = this.lambdaGenerator.getLmabdaBootstrap();
    if (this.lambdaBootstraps == null) {
        // keep in order
        this.lambdaBootstraps = new LinkedHashMap<String, LambdaFunctionBootstrap>();
    }
    this.lambdaBootstraps.put(bootstrap.getName(), bootstrap);
    visitLineNumber(lookhead);
    genNewLambdaCode(bootstrap);
    this.parser.restoreScope(this.lambdaGenerator.getScopeInfo());
    this.lambdaGenerator = null;
    this.parser.setCodeGenerator(this.parentCodeGenerator);
}
Also used : LambdaFunctionBootstrap(com.googlecode.aviator.runtime.LambdaFunctionBootstrap)

Example 4 with LambdaFunctionBootstrap

use of com.googlecode.aviator.runtime.LambdaFunctionBootstrap in project aviatorscript by killme2008.

the class InterpretExpression method traceInstruments.

private void traceInstruments(final Map<String, Object> env, final String name, final boolean traceLambda) {
    int pc = 0;
    RuntimeUtils.printlnTrace(env, (name == null ? this.sourceFile : name) + " instruments: ");
    for (IR ir : this.instruments) {
        RuntimeUtils.printlnTrace(env, "    " + (pc++) + " " + ir.toString());
    }
    RuntimeUtils.printlnTrace(env, "    " + pc + " return");
    if (this.lambdaBootstraps != null) {
        final List<LambdaFunctionBootstrap> bootstraps = new ArrayList<>(this.lambdaBootstraps.values());
        Collections.sort(bootstraps);
        for (LambdaFunctionBootstrap bootstrap : bootstraps) {
            final Expression exp = bootstrap.getExpression();
            if (exp instanceof InterpretExpression) {
                InterpretExpression iexp = (InterpretExpression) exp;
                iexp.traceInstruments(env, bootstrap.getName(), traceLambda);
            } else {
                RuntimeUtils.printlnTrace(env, bootstrap.getName() + " instruments: " + exp);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) LoadIR(com.googlecode.aviator.code.interpreter.ir.LoadIR) IR(com.googlecode.aviator.code.interpreter.IR) LambdaFunctionBootstrap(com.googlecode.aviator.runtime.LambdaFunctionBootstrap)

Aggregations

LambdaFunctionBootstrap (com.googlecode.aviator.runtime.LambdaFunctionBootstrap)4 IR (com.googlecode.aviator.code.interpreter.IR)1 LoadIR (com.googlecode.aviator.code.interpreter.ir.LoadIR)1 DelegateToken (com.googlecode.aviator.lexer.token.DelegateToken)1 AviatorString (com.googlecode.aviator.runtime.type.AviatorString)1 ArrayList (java.util.ArrayList)1