use of org.codehaus.groovy.ast.expr.BinaryExpression in project groovy by apache.
the class BinaryExpressionMultiTypeDispatcher method isAssignmentToArray.
private static boolean isAssignmentToArray(BinaryExpression binExp) {
Expression leftExpression = binExp.getLeftExpression();
if (!(leftExpression instanceof BinaryExpression))
return false;
BinaryExpression leftBinExpr = (BinaryExpression) leftExpression;
if (leftBinExpr.getOperation().getType() != LEFT_SQUARE_BRACKET)
return false;
return true;
}
use of org.codehaus.groovy.ast.expr.BinaryExpression in project groovy by apache.
the class BinaryExpressionMultiTypeDispatcher method doAssignmentToLocalVariable.
private boolean doAssignmentToLocalVariable(String method, BinaryExpression binExp) {
Expression left = binExp.getLeftExpression();
if (left instanceof VariableExpression) {
VariableExpression ve = (VariableExpression) left;
Variable v = ve.getAccessedVariable();
if (v instanceof DynamicVariable)
return false;
if (v instanceof PropertyExpression)
return false;
/* field and declaration we don't return false */
} else {
return false;
}
evaluateBinaryExpression(method, binExp);
getController().getOperandStack().dup();
getController().getCompileStack().pushLHS(true);
binExp.getLeftExpression().visit(getController().getAcg());
getController().getCompileStack().popLHS();
return true;
}
use of org.codehaus.groovy.ast.expr.BinaryExpression in project groovy by apache.
the class BinaryExpressionMultiTypeDispatcher method doPrimitiveCompare.
protected boolean doPrimitiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp) {
Expression leftExp = binExp.getLeftExpression();
Expression rightExp = binExp.getRightExpression();
int operation = binExp.getOperation().getType();
int operationType = getOperandConversionType(leftType, rightType);
BinaryExpressionWriter bew = binExpWriter[operationType];
if (!bew.write(operation, true))
return false;
AsmClassGenerator acg = getController().getAcg();
OperandStack os = getController().getOperandStack();
leftExp.visit(acg);
os.doGroovyCast(bew.getNormalOpResultType());
rightExp.visit(acg);
os.doGroovyCast(bew.getNormalOpResultType());
bew.write(operation, false);
return true;
}
use of org.codehaus.groovy.ast.expr.BinaryExpression in project groovy by apache.
the class EqualsAndHashCodeASTTransformation method bothSelfRecursivePropertyX.
private static BinaryExpression bothSelfRecursivePropertyX(PropertyNode pNode, Expression other) {
String getterName = getGetterName(pNode);
Expression selfGetter = callThisX(getterName);
Expression otherGetter = callX(other, getterName);
return andX(sameX(selfGetter, varX("this")), sameX(otherGetter, other));
}
use of org.codehaus.groovy.ast.expr.BinaryExpression in project groovy by apache.
the class EqualsAndHashCodeASTTransformation method differentSelfRecursivePropertyX.
private static BinaryExpression differentSelfRecursivePropertyX(PropertyNode pNode, Expression other) {
String getterName = getGetterName(pNode);
Expression selfGetter = callThisX(getterName);
Expression otherGetter = callX(other, getterName);
return orX(andX(sameX(selfGetter, varX("this")), notX(sameX(otherGetter, other))), andX(notX(sameX(selfGetter, varX("this"))), sameX(otherGetter, other)));
}
Aggregations