Search in sources :

Example 1 with SourceInfo

use of com.googlecode.aviator.code.interpreter.ir.SourceInfo in project aviatorscript by killme2008.

the class InterpretCodeGenerator method onMethodInvoke.

@Override
public void onMethodInvoke(final Token<?> lookhead) {
    final MethodMetaData methodMetaData = this.methodMetaDataStack.pop();
    @SuppressWarnings("unchecked") final List<FunctionArgument> params = lookhead != null ? (List<FunctionArgument>) lookhead.getMeta(Constants.PARAMS_META, Collections.EMPTY_LIST) : Collections.<FunctionArgument>emptyList();
    if (this.instance.getOptionValue(Options.CAPTURE_FUNCTION_ARGS).bool) {
        int funcId = getNextFuncInvocationId();
        getFuncsArgs().put(funcId, Collections.unmodifiableList(params));
        methodMetaData.funcId = funcId;
    }
    emit(new SendIR(methodMetaData.methodName, methodMetaData.parameterCount, methodMetaData.token.getMeta(Constants.UNPACK_ARGS, false), methodMetaData.funcId, new SourceInfo(this.sourceFile, methodMetaData.token.getLineNo())));
}
Also used : SendIR(com.googlecode.aviator.code.interpreter.ir.SendIR) SourceInfo(com.googlecode.aviator.code.interpreter.ir.SourceInfo) MethodMetaData(com.googlecode.aviator.code.asm.ASMCodeGenerator.MethodMetaData) FunctionArgument(com.googlecode.aviator.runtime.FunctionArgument)

Example 2 with SourceInfo

use of com.googlecode.aviator.code.interpreter.ir.SourceInfo in project aviatorscript by killme2008.

the class InterpretCodeGenerator method onJoinLeft.

@Override
public void onJoinLeft(final Token<?> lookhead) {
    if (!OperationRuntime.containsOpFunction(this.compileEnv, OperatorType.AND)) {
        emit(new AssertTypeIR(AssertTypes.Bool));
        Label label = makeLabel();
        pushLabel0(label);
        this.instruments.add(new BranchIfIR(label, new SourceInfo(this.sourceFile, lookhead.getLineNo())));
        emit(PopIR.INSTANCE);
    }
}
Also used : SourceInfo(com.googlecode.aviator.code.interpreter.ir.SourceInfo) Label(com.googlecode.aviator.code.interpreter.ir.Label) AssertTypeIR(com.googlecode.aviator.code.interpreter.ir.AssertTypeIR) BranchIfIR(com.googlecode.aviator.code.interpreter.ir.BranchIfIR)

Example 3 with SourceInfo

use of com.googlecode.aviator.code.interpreter.ir.SourceInfo in project aviatorscript by killme2008.

the class InterpretCodeGenerator method onTernaryLeft.

@Override
public void onTernaryLeft(final Token<?> lookhead) {
    this.instruments.add(new GotoIR(peekLabel1(), new SourceInfo(this.sourceFile, lookhead.getLineNo())));
    // emit(PopIR.INSTANCE);
    Label label0 = popLabel0();
    visitLabel(label0);
    emit(PopIR.INSTANCE);
}
Also used : SourceInfo(com.googlecode.aviator.code.interpreter.ir.SourceInfo) GotoIR(com.googlecode.aviator.code.interpreter.ir.GotoIR) Label(com.googlecode.aviator.code.interpreter.ir.Label)

Example 4 with SourceInfo

use of com.googlecode.aviator.code.interpreter.ir.SourceInfo in project aviatorscript by killme2008.

the class InterpretCodeGenerator method onAndLeft.

@Override
public void onAndLeft(final Token<?> lookhead) {
    if (!OperationRuntime.containsOpFunction(this.compileEnv, OperatorType.AND)) {
        emit(new AssertTypeIR(AssertTypes.Bool));
        Label label = makeLabel();
        pushLabel0(label);
        this.instruments.add(new BranchUnlessIR(label, new SourceInfo(this.sourceFile, lookhead.getLineNo())));
        emit(PopIR.INSTANCE);
    }
}
Also used : SourceInfo(com.googlecode.aviator.code.interpreter.ir.SourceInfo) Label(com.googlecode.aviator.code.interpreter.ir.Label) AssertTypeIR(com.googlecode.aviator.code.interpreter.ir.AssertTypeIR) BranchUnlessIR(com.googlecode.aviator.code.interpreter.ir.BranchUnlessIR)

Example 5 with SourceInfo

use of com.googlecode.aviator.code.interpreter.ir.SourceInfo in project aviatorscript by killme2008.

the class InterpretCodeGenerator method onTernaryBoolean.

@Override
public void onTernaryBoolean(final Token<?> lookhead) {
    Label label0 = makeLabel();
    pushLabel0(label0);
    Label label1 = makeLabel();
    pushLabel1(label1);
    this.instruments.add(new BranchUnlessIR(label0, new SourceInfo(this.sourceFile, lookhead.getLineNo())));
    emit(PopIR.INSTANCE);
}
Also used : SourceInfo(com.googlecode.aviator.code.interpreter.ir.SourceInfo) Label(com.googlecode.aviator.code.interpreter.ir.Label) BranchUnlessIR(com.googlecode.aviator.code.interpreter.ir.BranchUnlessIR)

Aggregations

SourceInfo (com.googlecode.aviator.code.interpreter.ir.SourceInfo)5 Label (com.googlecode.aviator.code.interpreter.ir.Label)4 AssertTypeIR (com.googlecode.aviator.code.interpreter.ir.AssertTypeIR)2 BranchUnlessIR (com.googlecode.aviator.code.interpreter.ir.BranchUnlessIR)2 MethodMetaData (com.googlecode.aviator.code.asm.ASMCodeGenerator.MethodMetaData)1 BranchIfIR (com.googlecode.aviator.code.interpreter.ir.BranchIfIR)1 GotoIR (com.googlecode.aviator.code.interpreter.ir.GotoIR)1 SendIR (com.googlecode.aviator.code.interpreter.ir.SendIR)1 FunctionArgument (com.googlecode.aviator.runtime.FunctionArgument)1