use of com.googlecode.aviator.lexer.token.OperatorType in project aviatorscript by killme2008.
the class InterpretCodeGenerator method emit.
private void emit(IR ir) {
if (ir instanceof OperatorIR) {
// check if operator is override.
final OperatorType op = ((OperatorIR) ir).getOp();
AviatorFunction fn = this.instance.getOpFunction(op);
if (fn != null) {
// replace it with new IR
ir = new OperatorIR(op, fn);
}
}
this.instruments.add(ir);
}
use of com.googlecode.aviator.lexer.token.OperatorType in project aviatorscript by killme2008.
the class OptimizeCodeGenerator method execute.
private int execute() {
int exeCount = 0;
final int size = this.tokenList.size();
printTokenList();
for (int i = 0; i < size; i++) {
Token<?> token = this.tokenList.get(i);
if (token.getType() == TokenType.Operator) {
final OperatorToken op = (OperatorToken) token;
final OperatorType operatorType = op.getOperatorType();
final int operandCount = operatorType.getArity();
switch(operatorType) {
case FUNC:
case INDEX:
// Could not optimize function and index call
break;
default:
Map<Integer, DelegateTokenType> index2DelegateType = getIndex2DelegateTypeMap(operatorType);
final int result = executeOperator(index2DelegateType, token, operatorType, i, operandCount);
if (result < 0) {
compactTokenList();
return exeCount;
}
exeCount += result;
break;
}
}
}
compactTokenList();
return exeCount;
}
use of com.googlecode.aviator.lexer.token.OperatorType in project aviatorscript by killme2008.
the class ASMCodeGenerator method onAssignment.
@Override
public void onAssignment(final Token<?> lookhead) {
visitLineNumber(lookhead);
OperatorType opType = lookhead.getMeta(Constants.DEFINE_META, false) ? OperatorType.DEFINE : OperatorType.ASSIGNMENT;
loadEnv();
if (!OperationRuntime.hasRuntimeContext(this.compileEnv, opType)) {
String methodName = (opType == OperatorType.DEFINE) ? "defineValue" : "setValue";
this.mv.visitMethodInsn(INVOKEVIRTUAL, OBJECT_OWNER, methodName, "(Lcom/googlecode/aviator/runtime/type/AviatorObject;Ljava/util/Map;)Lcom/googlecode/aviator/runtime/type/AviatorObject;");
} else {
loadOpType(opType);
this.mv.visitMethodInsn(INVOKESTATIC, "com/googlecode/aviator/runtime/op/OperationRuntime", "eval", "(Lcom/googlecode/aviator/runtime/type/AviatorObject;Lcom/googlecode/aviator/runtime/type/AviatorObject;Ljava/util/Map;Lcom/googlecode/aviator/lexer/token/OperatorType;)Lcom/googlecode/aviator/runtime/type/AviatorObject;");
this.popOperand();
}
this.popOperand(3);
this.pushOperand();
}
Aggregations