List of usage examples for org.eclipse.jdt.internal.compiler.ast AND_AND_Expression AND_AND_Expression
public AND_AND_Expression(Expression left, Expression right, int operator)
From source file:lombok.eclipse.handlers.ast.EclipseASTMaker.java
License:Open Source License
@Override public ASTNode visitBinary(final lombok.ast.Binary node, final Void p) { final String operator = node.getOperator(); final int opCode; if (BINARY_OPERATORS.containsKey(operator)) { opCode = BINARY_OPERATORS.get(operator); } else {/* w w w. j a v a 2 s.com*/ throw new IllegalStateException(String.format("Unknown binary operator '%s'", operator)); } final BinaryExpression binaryExpression; if ("||".equals(operator)) { binaryExpression = new OR_OR_Expression(build(node.getLeft(), Expression.class), build(node.getRight(), Expression.class), opCode); } else if ("&&".equals(operator)) { binaryExpression = new AND_AND_Expression(build(node.getLeft(), Expression.class), build(node.getRight(), Expression.class), opCode); } else if (Is.oneOf(operator, "==", "!=")) { binaryExpression = new EqualExpression(build(node.getLeft(), Expression.class), build(node.getRight(), Expression.class), opCode); } else { binaryExpression = new BinaryExpression(build(node.getLeft(), Expression.class), build(node.getRight(), Expression.class), opCode); } setGeneratedByAndCopyPos(binaryExpression, source, posHintOf(node)); return binaryExpression; }
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected void consumeBinaryExpression(int op) { // MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression // MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression // MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression // AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression // AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression // ShiftExpression ::= ShiftExpression '<<' AdditiveExpression // ShiftExpression ::= ShiftExpression '>>' AdditiveExpression // ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression // RelationalExpression ::= RelationalExpression '<' ShiftExpression // RelationalExpression ::= RelationalExpression '>' ShiftExpression // RelationalExpression ::= RelationalExpression '<=' ShiftExpression // RelationalExpression ::= RelationalExpression '>=' ShiftExpression // AndExpression ::= AndExpression '&' EqualityExpression // ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression // InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression // ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression // ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression //optimize the push/pop this.expressionPtr--; this.expressionLengthPtr--; Expression expr1 = this.expressionStack[this.expressionPtr]; Expression expr2 = this.expressionStack[this.expressionPtr + 1]; switch (op) { case OR_OR://from w w w. j a va 2s .co m this.expressionStack[this.expressionPtr] = new OR_OR_Expression(expr1, expr2, op); break; case AND_AND: this.expressionStack[this.expressionPtr] = new AND_AND_Expression(expr1, expr2, op); break; case PLUS: // look for "string1" + "string2" if (this.optimizeStringLiterals) { if (expr1 instanceof StringLiteral) { if (((expr1.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0) { if (expr2 instanceof CharLiteral) { // string+char this.expressionStack[this.expressionPtr] = ((StringLiteral) expr1) .extendWith((CharLiteral) expr2); } else if (expr2 instanceof StringLiteral) { //string+string this.expressionStack[this.expressionPtr] = ((StringLiteral) expr1) .extendWith((StringLiteral) expr2); } else { this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); } } else { this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); } } else if (expr1 instanceof CombinedBinaryExpression) { CombinedBinaryExpression cursor; // left branch is comprised of PLUS BEs // cursor is shifted upwards, while needed BEs are added // on demand; past the arityMax-th // consecutive BE, a CBE is inserted that holds a // full-fledged references table if ((cursor = (CombinedBinaryExpression) expr1).arity < cursor.arityMax) { cursor.left = new BinaryExpression(cursor); cursor.arity++; } else { cursor.left = new CombinedBinaryExpression(cursor); cursor.arity = 0; cursor.tuneArityMax(); } cursor.right = expr2; cursor.sourceEnd = expr2.sourceEnd; this.expressionStack[this.expressionPtr] = cursor; // BE_INSTRUMENTATION: neutralized in the released code // cursor.depthTracker = ((BinaryExpression)cursor.left). // depthTracker + 1; } else if (expr1 instanceof BinaryExpression && // single out the a + b case, which is a BE // instead of a CBE (slightly more than a half of // strings concatenation are one-deep binary // expressions) ((expr1.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT) == OperatorIds.PLUS) { this.expressionStack[this.expressionPtr] = new CombinedBinaryExpression(expr1, expr2, PLUS, 1); } else { this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); } } else if (expr1 instanceof StringLiteral) { if (expr2 instanceof StringLiteral && ((expr1.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0) { // string + string this.expressionStack[this.expressionPtr] = ((StringLiteral) expr1) .extendsWith((StringLiteral) expr2); } else { // single out the a + b case this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); } } else if (expr1 instanceof CombinedBinaryExpression) { CombinedBinaryExpression cursor; // shift cursor; create BE/CBE as needed if ((cursor = (CombinedBinaryExpression) expr1).arity < cursor.arityMax) { cursor.left = new BinaryExpression(cursor); // clear the bits on cursor cursor.bits &= ~ASTNode.ParenthesizedMASK; cursor.arity++; } else { cursor.left = new CombinedBinaryExpression(cursor); // clear the bits on cursor cursor.bits &= ~ASTNode.ParenthesizedMASK; cursor.arity = 0; cursor.tuneArityMax(); } cursor.right = expr2; cursor.sourceEnd = expr2.sourceEnd; // BE_INSTRUMENTATION: neutralized in the released code // cursor.depthTracker = ((BinaryExpression)cursor.left). // depthTracker + 1; this.expressionStack[this.expressionPtr] = cursor; } else if (expr1 instanceof BinaryExpression && ((expr1.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT) == OperatorIds.PLUS) { // single out the a + b case this.expressionStack[this.expressionPtr] = new CombinedBinaryExpression(expr1, expr2, PLUS, 1); } else { this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); } break; case LESS: case MULTIPLY: this.intPtr--; // star end position or starting position of angle bracket this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, op); break; default: this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, op); } }
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
/** * @param op binary operator//from ww w . j a v a2 s . c o m */ protected void consumeBinaryExpressionWithName(int op) { pushOnExpressionStack(getUnspecifiedReferenceOptimized()); this.expressionPtr--; this.expressionLengthPtr--; /* if (op == OR_OR) { this.expressionStack[this.expressionPtr] = new OR_OR_Expression( this.expressionStack[this.expressionPtr + 1], this.expressionStack[this.expressionPtr], op); } else { if (op == AND_AND) { this.expressionStack[this.expressionPtr] = new AND_AND_Expression( this.expressionStack[this.expressionPtr + 1], this.expressionStack[this.expressionPtr], op); } else { // look for "string1" + "string2" if ((op == PLUS) && this.optimizeStringLiterals) { Expression expr1, expr2; expr1 = this.expressionStack[this.expressionPtr + 1]; expr2 = this.expressionStack[this.expressionPtr]; if (expr1 instanceof StringLiteral) { if (expr2 instanceof CharLiteral) { // string+char this.expressionStack[this.expressionPtr] = ((StringLiteral) expr1).extendWith((CharLiteral) expr2); } else if (expr2 instanceof StringLiteral) { //string+string this.expressionStack[this.expressionPtr] = ((StringLiteral) expr1).extendWith((StringLiteral) expr2); } else { this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); } } else { this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); } } else { this.expressionStack[this.expressionPtr] = new BinaryExpression( this.expressionStack[this.expressionPtr + 1], this.expressionStack[this.expressionPtr], op); } } } */ Expression expr1 = this.expressionStack[this.expressionPtr + 1]; Expression expr2 = this.expressionStack[this.expressionPtr]; // Note: we do not attempt to promote BinaryExpression-s to // IndexedBinaryExpression-s here since expr1 always holds a name switch (op) { case OR_OR: this.expressionStack[this.expressionPtr] = new OR_OR_Expression(expr1, expr2, op); break; case AND_AND: this.expressionStack[this.expressionPtr] = new AND_AND_Expression(expr1, expr2, op); break; case PLUS: // look for "string1" + "string2" if (this.optimizeStringLiterals) { if (expr1 instanceof StringLiteral && ((expr1.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0) { if (expr2 instanceof CharLiteral) { // string+char this.expressionStack[this.expressionPtr] = ((StringLiteral) expr1) .extendWith((CharLiteral) expr2); } else if (expr2 instanceof StringLiteral) { //string+string this.expressionStack[this.expressionPtr] = ((StringLiteral) expr1) .extendWith((StringLiteral) expr2); } else { this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); } } else { this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); } } else if (expr1 instanceof StringLiteral) { if (expr2 instanceof StringLiteral && ((expr1.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0) { // string + string this.expressionStack[this.expressionPtr] = ((StringLiteral) expr1) .extendsWith((StringLiteral) expr2); } else { this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, op); } } else { this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, op); } break; case LESS: case MULTIPLY: this.intPtr--; // star end position or starting position of angle bracket this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, op); break; default: this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, op); } }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.PredicateGenerator.java
License:Open Source License
/** * Before resolving statements we might need to insert evaluations of * additional predicates (outer, tsuper, super). * * @param predDecl the predicate method//w w w . j a v a2 s. c o m */ public static void linkPredicates(GuardPredicateDeclaration predDecl) { if (predDecl.ignoreFurtherInvestigation) return; if (predDecl.isCopied) return; if (predDecl.statements == null) { if (Config.getStrictDiet() || predDecl.scope.classScope().referenceContext.isConverted) return; // we know why there are no statements throw new InternalCompilerError("predicate should have statements in this mode"); //$NON-NLS-1$ } ArrayList<Expression> otherPreds = new ArrayList<Expression>(); AstGenerator gen = new AstGenerator(predDecl.bodyStart, predDecl.bodyEnd); // outer: Expression callOuterPredicate = getOuterPredicateCheck(predDecl, gen); if (callOuterPredicate != null) otherPreds.add(callOuterPredicate); // tsuper Expression evalTSuperPredicate = getTSuperPredicateChecks(predDecl, gen); if (evalTSuperPredicate != null) otherPreds.add(evalTSuperPredicate); // super: Expression callSuperPredicate = getSuperPredicateCheck(predDecl, gen); if (callSuperPredicate != null) otherPreds.add(callSuperPredicate); // combine all predicates with "&&": if (otherPreds.size() > 0) { ReturnStatement returnStat = predDecl.returnStatement; Expression expression = returnStat.expression; for (Iterator<Expression> predIter = otherPreds.iterator(); predIter.hasNext();) { Expression pred = predIter.next(); expression = new AND_AND_Expression(expression, pred, OperatorIds.AND_AND); } returnStat.expression = expression; } }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.PredicateGenerator.java
License:Open Source License
/** * Find relevant predicates in all tsuper-roles, create check expressions and join them with AND. */// w w w .j a v a2 s . c o m private static Expression getTSuperPredicateChecks(MethodDeclaration pred, AstGenerator gen) { ReferenceBinding thisType = pred.binding.declaringClass; Expression accumulatedResult = null; if (thisType.isRole()) { ReferenceBinding[] tsuperRoles = thisType.roleModel.getTSuperRoleBindings(); for (int i = tsuperRoles.length - 1; i >= 0; i--) { // check highest prio first (which comes last in the array) MethodBinding tsuperMethod = TypeAnalyzer.findMethod(pred.scope, tsuperRoles[i], pred.selector, pred.binding.parameters); if (!tsuperMethod.isValidBinding()) continue; char[] markerIfcName = TSuperHelper.getTSuperMarkName(tsuperRoles[i].enclosingType()); Expression current = gen.messageSend( // 'implicit' prevents role type wrapping (tsuper pred is not in the ifc-part) ThisReference.implicitThis(), pred.selector, makeArgExpressions(pred, tsuperMethod.parameters.length, gen.castExpression(gen.nullLiteral(), gen.singleTypeReference(markerIfcName), CastExpression.RAW), gen)); if (accumulatedResult == null) accumulatedResult = current; else accumulatedResult = new AND_AND_Expression(accumulatedResult, current, OperatorIds.AND_AND); } } return accumulatedResult; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.ReflectionGenerator.java
License:Open Source License
private static Statement createRemoveIfFound(AstGenerator gen, WeavingScheme weavingScheme) { /*/*from ww w.j av a 2s . co m*/ * For the end of unregisterRole(Object) create: * if (first_cache != null && found_base != null) { // ensure no null problems against either variable * first_cache.remove(_OT$base_arg); * ((IBoundBase)found_base)._OT$removeRole(_OT$role_arg); * } */ return gen.ifStatement(new AND_AND_Expression( new EqualExpression(gen.singleNameReference(FIRST_CACHE), gen.nullLiteral(), OperatorIds.NOT_EQUAL), new EqualExpression(gen.singleNameReference(FOUND_BASE), gen.nullLiteral(), OperatorIds.NOT_EQUAL), OperatorIds.AND_AND), gen.block(new Statement[] { gen.messageSend(gen.singleNameReference(FIRST_CACHE), REMOVE, new Expression[] { gen.singleNameReference(FOUND_BASE) }), // OTDYN: Slightly different methods depending on the weaving strategy: weavingScheme == WeavingScheme.OTDRE ? gen.messageSend( gen.castExpression( gen.singleNameReference(FOUND_BASE), gen.qualifiedTypeReference( ORG_OBJECTTEAMS_IBOUNDBASE2), CastExpression.RAW), ADD_REMOVE_ROLE, new Expression[] { gen.singleNameReference(_OT_ROLE_ARG), gen.booleanLiteral(false) }) // isAdding=false : gen.messageSend(gen.castExpression(gen.singleNameReference(FOUND_BASE), gen.qualifiedTypeReference(ORG_OBJECTTEAMS_IBOUNDBASE), CastExpression.RAW), REMOVE_ROLE, new Expression[] { gen.singleNameReference(_OT_ROLE_ARG) }) })); }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.StandardElementGenerator.java
License:Open Source License
/** * Retreive (or create) a team level method used for casting an expression to a role. * After casting also check the containingInstance against the current team. * @param teamModel//from w w w. j a va 2s .c o m * @param roleType * @param scope (used only for lookup of j.l.Object) * @param searchSuper should super classes of teamClass be search, too? * @param sourceStart * @param sourceEnd * @return the method */ public static MethodBinding getCastMethod(TeamModel teamModel, ReferenceBinding roleType, Scope scope, int dimensions, boolean searchSuper, int sourceStart, int sourceEnd) { /* * protected <role> _OT$castTo$<role> (Object _OT$arg1) { * if (_OT$arg1 == null) return null; * __OT__<role> role = (__OT__<role>) _OT$arg1; * if (role._OT$getTeam() != this) * throw new RuntimeException(); * return role; * } *OR FOR ARRAY: * protected <role>[].. _OT$castTo$<role>$<dims> (Object[].. _OT$arg1) { * if (_OT$arg1 == null) return null; * <role>[].. role = (<role>[]..) _OT$arg1; * if (role.length > 0 && ((__OT__<role>)role[0])._OT$getTeam() != this) // TODO(SH): extract through several dims * throw new RuntimeException(); * return role; * } * NOTE(SH): it suffices to check team equivalence for one element, since at this point it * must already be a role-array, which cannot mix roles from different teams ;-) */ boolean shouldWeaken = (teamModel.getState() >= ITranslationStates.STATE_TYPES_ADJUSTED); // weakening for other methods already done? MethodBinding superMethod = null; roleType = roleType.getRealType(); char[] methodName = CharOperation.concat(CAST_PREFIX, roleType.sourceName()); if (dimensions > 0) methodName = CharOperation.concat(methodName, String.valueOf(dimensions).toCharArray(), '$'); ReferenceBinding teamBinding = teamModel.getBinding(); while (teamBinding != null) { MethodBinding[] methods = teamBinding.getMethods(methodName); if (methods != null && methods.length == 1) { if (TypeBinding.equalsEquals(methods[0].declaringClass, teamModel.getBinding()) || searchSuper) return methods[0]; // go ahead and generate a new method, but use superMethod for weakening after generating: superMethod = methods[0]; break; } if (!searchSuper && !shouldWeaken) break; teamBinding = teamBinding.superclass(); } TypeDeclaration teamClass = teamModel.getAst(); if (teamClass == null) { if (true) {// FIXME(SH): team has error? MethodBinding castMethod = new MethodBinding(AccPublic, methodName, roleType, new TypeBinding[] { scope.getJavaLangObject() }, null, teamModel.getBinding()); teamModel.getBinding().addMethod(castMethod); return castMethod; } throw new InternalCompilerError("Required cast method not found."); //$NON-NLS-1$ } AstGenerator gen = new AstGenerator(sourceStart, sourceEnd); // --- method header --- int modifiers = 0; boolean clearPrivateModifier = false; if (roleType.isPublic()) { modifiers = AccPublic; } else { // this weird combination allows to return a non-public role and will // grant access across packages in the byte code. modifiers = AccProtected; clearPrivateModifier = true; // See also BinaryTypeBinding.resolveTypesFor(MethodBinding) where the Protected flag is restored. } // args char[] argName = OT_DOLLAR_ARG.toCharArray(); // find the appropriate top-level-super-type: ReferenceBinding exprType = teamClass.scope.getJavaLangObject(); // if (!roleType.isStrictlyCompatibleWith(exprType)) { // exprType = (ReferenceBinding)teamClass.scope.getType(ORG_OBJECTTEAMS_ICONFINED, 3); // if (!roleType.isCompatibleWith(exprType)) // exprType = (ReferenceBinding)teamClass.scope.getType( // ORG_OBJECTTEAMS_TEAM_DOT_CONFINED, // 4); // } TypeReference exprTypeRef = gen.typeReference(exprType); MethodDeclaration castMethod = gen.method(teamClass.compilationResult(), modifiers, gen.createArrayTypeReference(roleType, dimensions), methodName, new Argument[] { gen.argument(argName, exprTypeRef) }); // see org.eclipse.objectteams.otdt.tests.otjld.regression.ReportedBugs.testB11_sh15(): // pre-set return type to prevent problems with resolving lateron TypeBinding returnType = dimensions == 0 ? roleType : scope.environment().createArrayType(roleType, dimensions); castMethod.returnType.resolvedType = RoleTypeCreator.maybeWrapUnqualifiedRoleType(returnType, teamBinding); // <role> role = (<role>)_OT$arg; TypeReference arrayCastType = gen.createArrayTypeReference(roleType, dimensions); LocalDeclaration castedLocalVar = gen.localVariable(ROLE, arrayCastType, gen.castExpression(gen.singleNameReference(argName), arrayCastType, CastExpression.RAW)); //STATEMENTS: // if (_OT$arg1 == null) return null; //AND // if (role._OT$getTeam() != this) // throw new RuntimeException(); // OR // if (role.length > 0 && ((<roleClass>)role[0])._OT$getTeam() != this) // throw new RuntimeException(); Statement nullCheck = gen.ifStatement(gen.nullCheck(gen.singleNameReference(argName)), gen.returnStatement(gen.nullLiteral())); Expression teamCheckCondition; teamCheckCondition = genTeamCheck(gen, OperatorIds.NOT_EQUAL, gen.singleNameReference(ROLE), gen.thisReference(), dimensions); if (dimensions > 0) teamCheckCondition = gen .setPos(new AND_AND_Expression( gen.equalExpression(gen.qualifiedNameReference(new char[][] { ROLE, LENGTH }), gen.intLiteral(0), OperatorIds.GREATER), teamCheckCondition, OperatorIds.AND_AND)); // here we go: castMethod.setStatements(new Statement[] { nullCheck, castedLocalVar, gen.ifStatement(teamCheckCondition, gen.throwStatement( gen.allocation(gen.qualifiedTypeReference(ROLE_CAST_EXCEPTION), new Expression[0]))), // return role; gen.returnStatement(gen.singleNameReference(ROLE)) }); castMethod.isGenerated = true; AstEdit.addGeneratedMethod(teamClass, castMethod); if (clearPrivateModifier) castMethod.binding.tagBits = TagBits.ClearPrivateModifier; if (superMethod != null) CopyInheritance.weakenSignature(castMethod, superMethod); return castMethod.binding; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.StandardElementGenerator.java
License:Open Source License
/** * Create the code that combines team anchor comparison and a regulare instanceof. * @param exprType/* w w w. j a va 2 s . c om*/ * @param castType */ public static Expression createRoleInstanceOfCheck(BlockScope scope, InstanceOfExpression expr, ReferenceBinding exprType, DependentTypeBinding castType) { AstGenerator gen = new AstGenerator(expr.sourceStart, expr.sourceEnd); Expression teamInstanceComparison; if (RoleTypeBinding.isRoleWithExplicitAnchor(exprType)) { teamInstanceComparison = createAnchorEqualCheck(scope, (RoleTypeBinding) exprType, castType, expr.sourceStart, expr.sourceEnd); } else { BinaryExpression teamCheck = genTeamCheck(gen, OperatorIds.EQUAL_EQUAL, gen.resolvedCastExpression(expr.expression, // FIXME(SH): avoid double evaluation of expression! // but how can we store a value without a statement? // use a byte-code hack (cf. Lowering.{Pushing,Pop}Expression!) castType.getRealType(), CastExpression.RAW), createTeamAnchorReference(scope, castType, gen), expr.type.dimensions()); // manually resolve: MessageSend msg = (MessageSend) teamCheck.left; msg.binding = castType.getMethod(scope, IOTConstants._OT_GETTEAM); if (msg.binding == null) { // add a fake method, assuming it was not created due to errors: msg.binding = new MethodBinding(AccPublic, IOTConstants._OT_GETTEAM, scope.getOrgObjectteamsITeam(), Binding.NO_PARAMETERS, Binding.NO_EXCEPTIONS, castType); assert castType.roleModel.isIgnoreFurtherInvestigation(); } msg.actualReceiverType = castType.getRealType(); // msg.resolvedType = msg.binding.returnType; msg.constant = Constant.NotAConstant; teamCheck.right.constant = Constant.NotAConstant; teamCheck.constant = Constant.NotAConstant; teamCheck.resolvedType = TypeBinding.BOOLEAN; teamInstanceComparison = teamCheck; } TypeReference castTypeRef = gen.typeReference(castType.getRealType()); castTypeRef.resolvedType = castType.getRealType(); castTypeRef.constant = Constant.NotAConstant; expr.expression.resolvedType = exprType.getRealClass(); expr.expression.constant = Constant.NotAConstant; InstanceOfExpression origCheckClone = gen.setPos(new InstanceOfExpression(expr.expression, castTypeRef)); origCheckClone.bits = expr.bits; // includes operator origCheckClone.resolvedType = TypeBinding.BOOLEAN; origCheckClone.constant = Constant.NotAConstant; AND_AND_Expression andAnd = gen .setPos(new AND_AND_Expression(origCheckClone, teamInstanceComparison, OperatorIds.AND_AND)); andAnd.resolvedType = TypeBinding.BOOLEAN; andAnd.constant = Constant.NotAConstant; return andAnd; }
From source file:org.nabucco.framework.mda.model.java.ast.produce.JavaAstModelProducer.java
License:Open Source License
public BinaryExpression createBinaryExpression(BinaryExpressionType type, Expression left, Expression right, Integer operator) {//from w ww . j a v a2 s .co m switch (type) { case AND_AND_EXPRESSION: return new AND_AND_Expression(left, right, operator); case OR_OR_EXPRESSION: return new OR_OR_Expression(left, right, operator); case BINARY_EXPRESSION: return new BinaryExpression(left, right, operator); case EQUAL_EXPRESSION: return new EqualExpression(left, right, operator); } return null; }
From source file:org.nabucco.framework.mda.template.java.extract.statement.JavaAstStatementExtractorVisitor.java
License:Open Source License
@Override public boolean visit(AND_AND_Expression andAndExpression, BlockScope scope) { Expression left = copy(andAndExpression.left, scope); Expression right = copy(andAndExpression.right, scope); AND_AND_Expression andCopy = new AND_AND_Expression(left, right, 0); andCopy.bits = andAndExpression.bits; this.statement = andCopy; return false; }