private static boolean extractImplicitThis$0StmtIfInnerClassFromExpression(final List<Statement> stmts, final Statement bstmt) { Expression expr = ((ExpressionStatement) bstmt).getExpression(); if (expr instanceof BinaryExpression) { Expression lExpr = ((BinaryExpression) expr).getLeftExpression(); if (lExpr instanceof FieldExpression) { if ("this$0".equals(((FieldExpression) lExpr).getFieldName())) { stmts.remove(bstmt); // remove from here and let the caller reposition it return true; } } } return false; }
public static Expression getVariableType(BinaryExpression assignment) { ClassNode type = assignment.getLeftExpression().getType(); return type == null || type == ClassHelper.DYNAMIC_TYPE ? ConstantExpression.NULL : new ClassExpression(type); }
public void visitBinaryExpression(BinaryExpression expression) { Expression left = expression.getLeftExpression(); Expression right = expression.getRightExpression(); boolean leaf = (right instanceof ConstantExpression || left instanceof ConstantExpression); if (!leaf) buffer.append("("); left.visit(this); buffer.append(" "); Token token = expression.getOperation(); buffer.append(tokenAsSql(token)); buffer.append(" "); right.visit(this); if (!leaf) buffer.append(")"); }
private static boolean isAssignmentToArray(BinaryExpression binExp) { Expression leftExpression = binExp.getLeftExpression(); if (!(leftExpression instanceof BinaryExpression)) return false; BinaryExpression leftBinExpr = (BinaryExpression) leftExpression; return leftBinExpr.getOperation().getType() == LEFT_SQUARE_BRACKET; }
public void visitInstanceofNot(BinaryExpression be) { final BlockStatement currentBlock = typeCheckingContext.enclosingBlocks.getFirst(); assert currentBlock != null; if (typeCheckingContext.blockStatements2Types.containsKey(currentBlock)) { // another instanceOf_not was before, no need store vars } else { // saving type of variables to restoring them after returning from block Map<VariableExpression, List<ClassNode>> oldTracker = pushAssignmentTracking(); getTypeCheckingContext().pushTemporaryTypeInfo(); typeCheckingContext.blockStatements2Types.put(currentBlock, oldTracker); } pushInstanceOfTypeInfo(be.getLeftExpression(), be.getRightExpression()); }
private void splitRow(Expression row, List<Expression> parts) { BinaryExpression orExpr = getOrExpression(row); if (orExpr == null) parts.add(row); else { splitRow(orExpr.getLeftExpression(), parts); splitRow(orExpr.getRightExpression(), parts); } }
private Expression parseResults(Expression expr) { while (expr instanceof BinaryExpression) { BinaryExpression binExpr = (BinaryExpression) expr; int type = binExpr.getOperation().getType(); if (type != Types.RIGHT_SHIFT && type != Types.RIGHT_SHIFT_UNSIGNED) break; responses.add(new InteractionResponse(binExpr.getRightExpression(), type == Types.RIGHT_SHIFT_UNSIGNED)); expr = binExpr.getLeftExpression(); } return expr; }
public void visitBinaryExpression(BinaryExpression expression) { expression.getLeftExpression().visit(this); expression.getRightExpression().visit(this); }
private Expression parseCount(Expression expr) { BinaryExpression binExpr = ObjectUtil.asInstance(expr, BinaryExpression.class); if (binExpr == null || binExpr.getOperation().getType() != Types.MULTIPLY) return expr; count = binExpr.getLeftExpression(); return binExpr.getRightExpression(); }
public static Expression getVariableName(BinaryExpression assignment) { Expression left = assignment.getLeftExpression(); if (left instanceof Variable) return new ConstantExpression(((Variable) left).getName()); if (left instanceof FieldExpression) return new ConstantExpression(((FieldExpression) left).getFieldName()); return ConstantExpression.NULL; }
@Override public void visitBinaryExpression(BinaryExpression expr) { expr.setLeftExpression(replaceExpr(expr.getLeftExpression())); expr.setRightExpression(replaceExpr(expr.getRightExpression())); }
private void rewriteDerivedParameterization(BinaryExpression parameterization, Statement enclosingStat) throws InvalidSpecCompileException { VariableExpression dataVar = createDataProcessorVariable(parameterization.getLeftExpression(), enclosingStat); ExpressionStatement exprStat = new ExpressionStatement( new DeclarationExpression( dataVar, Token.newSymbol(Types.ASSIGN, -1, -1), parameterization.getRightExpression())); exprStat.setSourcePosition(enclosingStat); dataProcessorStats.add(exprStat); }
private void addVariableNames(Expression expression, List<String> list) { if (expression instanceof BooleanExpression) { BooleanExpression boolExp = (BooleanExpression) expression; addVariableNames(boolExp.getExpression(), list); } else if (expression instanceof BinaryExpression) { BinaryExpression binExp = (BinaryExpression) expression; addVariableNames(binExp.getLeftExpression(), list); addVariableNames(binExp.getRightExpression(), list); } else if (expression instanceof VariableExpression) { VariableExpression varExp = (VariableExpression) expression; list.add(varExp.getName()); } }
protected void evaluateBinaryExpression(String message, BinaryExpression binExp) { CompileStack compileStack = controller.getCompileStack(); Expression receiver = binExp.getLeftExpression(); Expression arguments = binExp.getRightExpression(); // ensure VariableArguments are read, not stored compileStack.pushLHS(false); controller.getInvocationWriter().makeSingleArgumentCall(receiver, message, arguments); compileStack.popLHS(); }
public void visitBinaryExpression(final BinaryExpression expression) { assertExpressionAuthorized(expression); assertTokenAuthorized(expression.getOperation()); expression.getLeftExpression().visit(this); expression.getRightExpression().visit(this); }
private void rewriteSimpleParameterization(BinaryExpression binExpr, ASTNode sourcePos) throws InvalidSpecCompileException { int nextDataVariableIndex = dataProcessorVars.size(); Parameter dataProcessorParameter = createDataProcessorParameter(); VariableExpression arg = (VariableExpression) binExpr.getLeftExpression(); VariableExpression dataVar = createDataProcessorVariable(arg, sourcePos); ExpressionStatement exprStat = new ExpressionStatement( new DeclarationExpression( dataVar, Token.newSymbol(Types.ASSIGN, -1, -1), new VariableExpression(dataProcessorParameter))); exprStat.setSourcePosition(sourcePos); dataProcessorStats.add(exprStat); createDataProviderMethod(binExpr.getRightExpression(), nextDataVariableIndex); }
@Override public void visitBinaryExpression(BinaryExpression expr) { // order of convert calls is important or indexes and thus recorded values get confused Expression convertedLeftExpression = Types.ofType(expr.getOperation().getType(), Types.ASSIGNMENT_OPERATOR) ? // prevent lvalue from getting turned into record(lvalue), which can no longer be assigned to convertAndRecordNa(expr.getLeftExpression()) : convert(expr.getLeftExpression()); Expression convertedRightExpression = convert(expr.getRightExpression()); Expression conversion = Types.ofType(expr.getOperation().getType(), Types.KEYWORD_INSTANCEOF) ? // morph instanceof expression to isInstance method call to be able to record rvalue new MethodCallExpression(convertedRightExpression, "isInstance", convertedLeftExpression): new BinaryExpression(convertedLeftExpression, expr.getOperation(), convertedRightExpression); conversion.setSourcePosition(expr); result = record(conversion); }
@Override protected void evaluateCompareExpression(final MethodCaller compareMethod, BinaryExpression binExp) { ClassNode current = getController().getClassNode(); TypeChooser typeChooser = getController().getTypeChooser(); Expression leftExp = binExp.getLeftExpression(); ClassNode leftType = typeChooser.resolveType(leftExp, current); Expression rightExp = binExp.getRightExpression(); ClassNode rightType = typeChooser.resolveType(rightExp, current); if (!doPrimitiveCompare(leftType, rightType, binExp)) { super.evaluateCompareExpression(compareMethod, binExp); } }
private void evaluateCompareTo(BinaryExpression expression) { Expression leftExpression = expression.getLeftExpression(); AsmClassGenerator acg = controller.getAcg(); OperandStack operandStack = controller.getOperandStack(); leftExpression.visit(acg); operandStack.box(); // if the right hand side is a boolean expression, we need to autobox Expression rightExpression = expression.getRightExpression(); rightExpression.visit(acg); operandStack.box(); compareToMethod.call(controller.getMethodVisitor()); operandStack.replace(ClassHelper.Integer_TYPE,2); }
@Override public void visitBinaryExpression(BinaryExpression expr) { result = new ExpressionInfo( TextRegion.of(expr), expr.getOperation().getType() == Types.LEFT_SQUARE_BRACKET ? startOf("[", expr.getRightExpression()) : // workaround for the fact that Token.startLine == 0 for token [ TextPosition.startOf(expr.getOperation()), expr.getOperation().getText(), convert(expr.getLeftExpression()), convert(expr.getRightExpression()) ); }