/** * Returns the type for the specified symbol/keyword text. Returns UNKNOWN * if the text isn't found. You can filter finds on a type. */ public static int lookup( String text, int filter ) { int type = UNKNOWN; if( LOOKUP.containsKey(text) ) { type = LOOKUP.get(text); if( filter != UNKNOWN && !ofType(type, filter) ) { type = UNKNOWN; } } return type; }
/** * Returns true if the node's meaning matches the specified type. */ public boolean isA( int type ) { return Types.ofType( getMeaning(), type ); }
/** * Returns true if the node's meaning matches all of the specified types. */ public boolean isAllOf( int[] types ) { int meaning = getMeaning(); for( int i = 0; i < types.length; i++ ) { if( !Types.ofType(meaning, types[i]) ) { return false; } } return true; }
/** * Returns true if the node's meaning matches any of the specified types. */ public boolean isOneOf( int[] types ) { int meaning = getMeaning(); for( int i = 0; i < types.length; i++ ) { if( Types.ofType(meaning, types[i]) ) { return true; } } return false; }
private void checkIsValidImplicitCondition(Statement stat) { BinaryExpression binExpr = AstUtil.getExpression(stat, BinaryExpression.class); if (binExpr == null) return; if (Types.ofType(binExpr.getOperation().getType(), Types.ASSIGNMENT_OPERATOR)) { resources.getErrorReporter().error(stat, "Expected a condition, but found an assignment. Did you intend to write '==' ?"); } } }
@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); }
if (Types.ofType(type, Types.ASSIGNMENT_OPERATOR)) { if (leftExpression instanceof VariableExpression || leftExpression.getClass() == PropertyExpression.class || } else if (leftExpression instanceof BinaryExpression) { int lefttype = ((BinaryExpression) leftExpression).getOperation().getType(); if (!Types.ofType(lefttype, Types.ASSIGNMENT_OPERATOR) && lefttype != Types.LEFT_SQUARE_BRACKET) { throw new ASTRuntimeException(node, "\n" + ((BinaryExpression) leftExpression).getText() + " is a binary expression, but it should be a variable expression");
public static boolean isComparisionOperator(int type) { return Types.ofType(type,COMPARISON_OPERATOR); }
/** * Returns the type for the specified symbol/keyword text. Returns UNKNOWN * if the text isn't found. You can filter finds on a type. */ public static int lookup( String text, int filter ) { int type = UNKNOWN; if( LOOKUP.containsKey(text) ) { type = LOOKUP.get(text); if( filter != UNKNOWN && !ofType(type, filter) ) { type = UNKNOWN; } } return type; }
/** * Returns the type for the specified symbol/keyword text. Returns UNKNOWN * if the text isn't found. You can filter finds on a type. */ public static int lookup( String text, int filter ) { int type = UNKNOWN; if( LOOKUP.containsKey(text) ) { type = ((Integer)LOOKUP.get(text)).intValue(); if( filter != UNKNOWN && !ofType(type, filter) ) { type = UNKNOWN; } } return type; }
/** * Returns the type for the specified symbol/keyword text. Returns UNKNOWN * if the text isn't found. You can filter finds on a type. */ public static int lookup( String text, int filter ) { int type = UNKNOWN; if( LOOKUP.containsKey(text) ) { type = ((Integer)LOOKUP.get(text)).intValue(); if( filter != UNKNOWN && !ofType(type, filter) ) { type = UNKNOWN; } } return type; }
/** * Returns the type for the specified symbol/keyword text. Returns UNKNOWN * if the text isn't found. You can filter finds on a type. */ public static int lookup( String text, int filter ) { int type = UNKNOWN; if( LOOKUP.containsKey(text) ) { type = ((Integer)LOOKUP.get(text)).intValue(); if( filter != UNKNOWN && !ofType(type, filter) ) { type = UNKNOWN; } } return type; }
/** * Returns true if the node's meaning matches the specified type. */ public boolean isA( int type ) { return Types.ofType( getMeaning(), type ); }
/** * Returns true if the node's meaning matches the specified type. */ public boolean isA( int type ) { return Types.ofType( getMeaning(), type ); }
/** * Returns true if the node's meaning matches the specified type. */ public boolean isA( int type ) { return Types.ofType( getMeaning(), type ); }
/** * Returns true if the node's meaning matches the specified type. */ public boolean isA( int type ) { return Types.ofType( getMeaning(), type ); }
/** * Returns true if the node's meaning matches any of the specified types. */ public boolean isOneOf( int[] types ) { int meaning = getMeaning(); for( int i = 0; i < types.length; i++ ) { if( Types.ofType(meaning, types[i]) ) { return true; } } return false; }
/** * Returns true if the node's meaning matches all of the specified types. */ public boolean isAllOf( int[] types ) { int meaning = getMeaning(); for( int i = 0; i < types.length; i++ ) { if( !Types.ofType(meaning, types[i]) ) { return false; } } return true; }
private void checkOperation(Expression expression, Token operation) { if (Types.ofType(operation.getType(), Types.ASSIGNMENT_OPERATOR)) { addError("[GContracts] Assignment operators are not supported.", expression); } if (Types.ofType(operation.getType(), Types.POSTFIX_OPERATOR)) { addError("[GContracts] State changing postfix & prefix operators are not supported.", expression); } }