private Class writeLiteralOrSubexpression(Object stmt, Class desiredTarget, Class knownIngressType) { if (stmt instanceof ExecutableLiteral) { Class type = ((ExecutableLiteral) stmt).getLiteral().getClass(); intPush(((ExecutableLiteral) stmt).getInteger32()); type = int.class; throw new CompileException("was expecting type: " + desiredTarget.getName() + "; but found type: " + type.getName()); writeOutLiteralWrapped(convert(((ExecutableLiteral) stmt).getLiteral(), desiredTarget)); writeOutLiteralWrapped(((ExecutableLiteral) stmt).getLiteral());
public static Accessor extractAccessor(ASTNode n) { if (n instanceof LiteralNode) return new ExecutableLiteral(n.getLiteralValue()); else return new ExecutableAccessor(n, n.getEgressType()); }
public static String decompile(Serializable expr) { if (expr instanceof CompiledExpression) return decompile((CompiledExpression) expr); else if (expr instanceof ExecutableAccessor) return "CANNOT DECOMPILE OPTIMIZED STATEMENT (Run with -Dmvel.optimizer=false)"; else if (expr instanceof ExecutableLiteral) { return "LITERAL: " + ((ExecutableLiteral) expr).getValue(null, null); } else return "NOT A KNOWN PAYLOAD: " + expr.getClass().getName(); }
System.arraycopy(es,0,executableStatements,0,es.length); executableStatements[executableStatements.length -1 ]= new ExecutableLiteral(Array.newInstance(aClass,0)); es = executableStatements; ExecutableLiteral literal = (ExecutableLiteral) es[i]; if (literal.getLiteral() == null) { assert debug("ICONST_NULL"); mv.visitInsn(ACONST_NULL); continue; else if (parameterTypes[i] == int.class && literal.intOptimized()) { intPush(literal.getInteger32()); continue; boolean bool = DataConversion.convert(literal.getLiteral(), Boolean.class); assert debug(bool ? "ICONST_1" : "ICONST_0"); mv.visitInsn(bool ? ICONST_1 : ICONST_0); Object lit = literal.getLiteral();
ExecutableLiteral literal = (ExecutableLiteral) es[i]; if (literal.getLiteral() == null) { assert debug("ICONST_NULL"); mv.visitInsn(ACONST_NULL); continue; else if (parameterTypes[i] == int.class && literal.intOptimized()) { intPush(literal.getInteger32()); continue; boolean bool = DataConversion.convert(literal.getLiteral(), Boolean.class); assert debug(bool ? "ICONST_1" : "ICONST_0"); mv.visitInsn(bool ? ICONST_1 : ICONST_0); Object lit = literal.getLiteral();
private Expression statementToExpression(ExecutableStatement param, Class paramType) { if (param instanceof ExecutableLiteral) { return new FixedExpression(paramType, ((ExecutableLiteral)param).getLiteral()); } else if (param instanceof ExecutableAccessor) { return analyzeNode(((ExecutableAccessor)param).getNode()); } else { throw new RuntimeException("Unknown ExecutableStatement type: " + param); } }
System.arraycopy(es,0,executableStatements,0,es.length); executableStatements[executableStatements.length -1 ]= new ExecutableLiteral(Array.newInstance(aClass,0)); es = executableStatements; ExecutableLiteral literal = (ExecutableLiteral) es[i]; if (literal.getLiteral() == null) { assert debug("ICONST_NULL"); mv.visitInsn(ACONST_NULL); continue; else if (parameterTypes[i] == int.class && literal.intOptimized()) { intPush(literal.getInteger32()); continue; boolean bool = DataConversion.convert(literal.getLiteral(), Boolean.class); assert debug(bool ? "ICONST_1" : "ICONST_0"); mv.visitInsn(bool ? ICONST_1 : ICONST_0); Object lit = literal.getLiteral();
public Condition analyzeCondition() { if (executableLiteral != null) { return new FixedValueCondition((Boolean)executableLiteral.getLiteral()); } while (node.nextASTNode != null) node = node.nextASTNode; return analyzeCondition(node); }
private Class writeLiteralOrSubexpression(Object stmt, Class desiredTarget, Class knownIngressType) { if (stmt instanceof ExecutableLiteral) { Object literalValue = ((ExecutableLiteral) stmt).getLiteral(); intPush(((ExecutableLiteral) stmt).getInteger32()); type = int.class;
for (int i = 0; i < args.length; i++) { argTypes[i] = es[i].getKnownEgressType(); if (es[i] instanceof ExecutableLiteral && ((ExecutableLiteral)es[i]).getLiteral() == null) { argTypes[i] = NullType.class;
public static Accessor extractAccessor(ASTNode n) { if (n instanceof LiteralNode) return new ExecutableLiteral(n.getLiteralValue()); else return new ExecutableAccessor(n, n.getEgressType()); }
public static String decompile(Serializable expr) { if (expr instanceof CompiledExpression) return decompile((CompiledExpression) expr); else if (expr instanceof ExecutableAccessor) return "CANNOT DECOMPILE OPTIMIZED STATEMENT (Run with -Dmvel.optimizer=false)"; else if (expr instanceof ExecutableLiteral) { return "LITERAL: " + ((ExecutableLiteral) expr).getValue(null, null); } else return "NOT A KNOWN PAYLOAD: " + expr.getClass().getName(); }
private Class writeLiteralOrSubexpression(Object stmt, Class desiredTarget, Class knownIngressType) { if (stmt instanceof ExecutableLiteral) { Object literalValue = ((ExecutableLiteral) stmt).getLiteral(); intPush(((ExecutableLiteral) stmt).getInteger32()); type = int.class;
for (int i = 0; i < args.length; i++) { argTypes[i] = es[i].getKnownEgressType(); if (es[i] instanceof ExecutableLiteral && ((ExecutableLiteral)es[i]).getLiteral() == null) { argTypes[i] = NullType.class;
public static Accessor extractAccessor(ASTNode n) { if (n instanceof LiteralNode) return new ExecutableLiteral(n.getLiteralValue()); else return new ExecutableAccessor(n, n.getEgressType()); }
public static String decompile(Serializable expr) { if (expr instanceof CompiledExpression) return decompile((CompiledExpression) expr); else if (expr instanceof ExecutableAccessor) return "CANNOT DECOMPILE OPTIMIZED STATEMENT (Run with -Dmvel.optimizer=false)"; else if (expr instanceof ExecutableLiteral) { return "LITERAL: " + ((ExecutableLiteral) expr).getValue(null, null); } else return "NOT A KNOWN PAYLOAD: " + expr.getClass().getName(); }
private Condition analyzeCondition(ASTNode node) { boolean isNegated = false; if (node instanceof Negation) { isNegated = true; ExecutableStatement statement = ((Negation)node).getStatement(); if (statement instanceof ExecutableLiteral) { return new FixedValueCondition(!(Boolean)((ExecutableLiteral)statement).getLiteral()); } node = ((ExecutableAccessor)statement).getNode(); } node = analyzeSubstatement(node); if (node instanceof LiteralNode && node.getEgressType() == Boolean.class) { boolean literalValue = (Boolean)node.getLiteralValue(); return new FixedValueCondition(isNegated ? !literalValue : literalValue); } if (node instanceof Negation) { isNegated = !isNegated; node = ((ExecutableAccessor)((Negation)node).getStatement()).getNode(); node = analyzeSubstatement(node); } if (node instanceof And || node instanceof Or) { return analyzeCombinedCondition((BooleanNode)node, isNegated); } return analyzeSingleCondition(node, isNegated); }
public ExprValueAccessor(String ex, Class expectedType, Object ctx, VariableResolverFactory factory, ParserContext pCtx) { stmt = (ExecutableStatement) ParseTools.subCompileExpression(ex.toCharArray(), pCtx); //if (expectedType.isArray()) { Class tt = getSubComponentType(expectedType); Class et = stmt.getKnownEgressType(); if (stmt.getKnownEgressType() != null && !tt.isAssignableFrom(et)) { if ((stmt instanceof ExecutableLiteral) && canConvert(et, tt)) { try { stmt = new ExecutableLiteral(convert(stmt.getValue(ctx, factory), tt)); return; } catch (IllegalArgumentException e) { // fall through; } } if (pCtx != null && pCtx.isStrongTyping()) throw new CompileException("was expecting type: " + tt + "; but found type: " + (et == null ? "null" : et.getName())); } }
} else { ExecutableLiteral literal = (ExecutableLiteral) statement; return new CastExpression(node.getEgressType(), new FixedExpression(literal.getLiteral())); } else { ExecutableLiteral literal = (ExecutableLiteral) statement; return new AritmeticExpression(new FixedExpression(0), AritmeticOperator.SUB, new FixedExpression(literal.getLiteral()));
public ExprValueAccessor(String ex, Class expectedType, Object ctx, VariableResolverFactory factory, ParserContext pCtx) { stmt = (ExecutableStatement) ParseTools.subCompileExpression(ex.toCharArray(), pCtx); //if (expectedType.isArray()) { Class tt = getSubComponentType(expectedType); Class et = stmt.getKnownEgressType(); if (stmt.getKnownEgressType() != null && !isAssignableFrom(tt, et)) { if ((stmt instanceof ExecutableLiteral) && canConvert(et, tt)) { try { stmt = new ExecutableLiteral(convert(stmt.getValue(ctx, factory), tt)); return; } catch (IllegalArgumentException e) { // fall through; } } if (pCtx != null && pCtx.isStrongTyping()) throw new RuntimeException("was expecting type: " + tt + "; but found type: " + (et == null ? "null" : et.getName())); } }