List of usage examples for org.eclipse.jdt.internal.compiler.ast IntLiteral convertToMinValue
public IntLiteral convertToMinValue()
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected void consumeUnaryExpression(int op) { // UnaryExpression ::= '+' PushPosition UnaryExpression // UnaryExpression ::= '-' PushPosition UnaryExpression // UnaryExpressionNotPlusMinus ::= '~' PushPosition UnaryExpression // UnaryExpressionNotPlusMinus ::= '!' PushPosition UnaryExpression //optimize the push/pop //handle manually the -2147483648 while it is not a real //computation of an - and 2147483648 (notice that 2147483648 //is Integer.MAX_VALUE+1.....) //Same for -9223372036854775808L ............ //this.intStack have the position of the operator Expression r, exp = this.expressionStack[this.expressionPtr]; if (op == MINUS) { if (exp instanceof IntLiteral) { IntLiteral intLiteral = (IntLiteral) exp; IntLiteral convertToMinValue = intLiteral.convertToMinValue(); if (convertToMinValue == intLiteral) { // not a min value literal so we convert it to an unary expression r = new UnaryExpression(exp, op); } else { r = convertToMinValue;//from ww w . jav a2 s.co m } } else if (exp instanceof LongLiteral) { LongLiteral longLiteral = (LongLiteral) exp; LongLiteral convertToMinValue = longLiteral.convertToMinValue(); if (convertToMinValue == longLiteral) { // not a min value literal so we convert it to an unary expression r = new UnaryExpression(exp, op); } else { r = convertToMinValue; } } else { r = new UnaryExpression(exp, op); } } else { r = new UnaryExpression(exp, op); } r.sourceStart = this.intStack[this.intPtr--]; r.sourceEnd = exp.sourceEnd; this.expressionStack[this.expressionPtr] = r; }