View | Details | Raw Unified | Return to bug 261510 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java (-1 / +3 lines)
Lines 13-19 Link Here
13
public class IntConstant extends Constant {
13
public class IntConstant extends Constant {
14
	
14
	
15
	int value;
15
	int value;
16
	
16
17
	private static final IntConstant MIN_VALUE = new IntConstant(Integer.MIN_VALUE);
17
	private static final IntConstant MINUS_FOUR = new IntConstant(-4);
18
	private static final IntConstant MINUS_FOUR = new IntConstant(-4);
18
	private static final IntConstant MINUS_THREE = new IntConstant(-3);
19
	private static final IntConstant MINUS_THREE = new IntConstant(-3);
19
	private static final IntConstant MINUS_TWO = new IntConstant(-2);
20
	private static final IntConstant MINUS_TWO = new IntConstant(-2);
Lines 33-38 Link Here
33
	public static Constant fromValue(int value) {
34
	public static Constant fromValue(int value) {
34
35
35
		switch (value) {
36
		switch (value) {
37
			case Integer.MIN_VALUE : return IntConstant.MIN_VALUE;
36
			case -4 : return IntConstant.MINUS_FOUR;
38
			case -4 : return IntConstant.MINUS_FOUR;
37
			case -3 : return IntConstant.MINUS_THREE;
39
			case -3 : return IntConstant.MINUS_THREE;
38
			case -2 : return IntConstant.MINUS_TWO;
40
			case -2 : return IntConstant.MINUS_TWO;
(-)compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java (+3 lines)
Lines 12-23 Link Here
12
12
13
public class LongConstant extends Constant {
13
public class LongConstant extends Constant {
14
private static final LongConstant ZERO = new LongConstant(0L);
14
private static final LongConstant ZERO = new LongConstant(0L);
15
private static final LongConstant MIN_VALUE = new LongConstant(Long.MIN_VALUE); 
15
16
16
private long value;
17
private long value;
17
18
18
public static Constant fromValue(long value) {
19
public static Constant fromValue(long value) {
19
	if (value == 0L) {
20
	if (value == 0L) {
20
		return ZERO;
21
		return ZERO;
22
	} else if (value == Long.MIN_VALUE) {
23
		return MIN_VALUE;
21
	}
24
	}
22
	return new LongConstant(value);
25
	return new LongConstant(value);
23
}
26
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java (-16 / +2 lines)
Lines 17-23 Link Here
17
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
17
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
18
18
19
public class LongLiteral extends NumberLiteral {
19
public class LongLiteral extends NumberLiteral {
20
	static final Constant FORMAT_ERROR = DoubleConstant.fromValue(1.0/0.0); // NaN;	
21
		
20
		
22
public LongLiteral(char[] token, int s,int e) {
21
public LongLiteral(char[] token, int s,int e) {
23
	super(token, s,e);
22
	super(token, s,e);
Lines 52-58 Link Here
52
				
51
				
53
		int digitValue ;
52
		int digitValue ;
54
		if ((digitValue = ScannerHelper.digit(source[j++],radix)) < 0 ) {
53
		if ((digitValue = ScannerHelper.digit(source[j++],radix)) < 0 ) {
55
			constant = FORMAT_ERROR; return ;
54
			return /*constant stays null*/ ;
56
		}
55
		}
57
		if (digitValue >= 8)
56
		if (digitValue >= 8)
58
			nbDigit = 4;
57
			nbDigit = 4;
Lines 65-71 Link Here
65
		computedValue = digitValue ;
64
		computedValue = digitValue ;
66
		while (j<length) {
65
		while (j<length) {
67
			if ((digitValue = ScannerHelper.digit(source[j++],radix)) < 0) {
66
			if ((digitValue = ScannerHelper.digit(source[j++],radix)) < 0) {
68
				constant = FORMAT_ERROR; return ;
67
				return /*constant stays null*/ ;
69
			}
68
			}
70
			if ((nbDigit += shift) > 64)
69
			if ((nbDigit += shift) > 64)
71
				return /*constant stays null*/ ;
70
				return /*constant stays null*/ ;
Lines 137-155 Link Here
137
			(source[18] == '8') &&
136
			(source[18] == '8') &&
138
			(((this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0));
137
			(((this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0));
139
}
138
}
140
public TypeBinding resolveType(BlockScope scope) {
141
	// the format may be incorrect while the scanner could detect
142
	// such error only on painfull tests...easier and faster here
143
144
	TypeBinding tb = super.resolveType(scope);
145
	if (constant == FORMAT_ERROR) {
146
		constant = Constant.NotAConstant;
147
		scope.problemReporter().constantOutOfFormat(this);
148
		this.resolvedType = null;
149
		return null;
150
	}
151
	return tb;
152
}
153
public void traverse(ASTVisitor visitor, BlockScope scope) {
139
public void traverse(ASTVisitor visitor, BlockScope scope) {
154
	visitor.visit(this, scope);
140
	visitor.visit(this, scope);
155
	visitor.endVisit(this, scope);
141
	visitor.endVisit(this, scope);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteralMinValue.java (-2 / +1 lines)
Lines 15-25 Link Here
15
public class LongLiteralMinValue extends LongLiteral {
15
public class LongLiteralMinValue extends LongLiteral {
16
16
17
	final static char[] CharValue = new char[]{'-', '9','2','2','3','3','7','2','0','3','6','8','5','4','7','7','5','8','0','8','L'};
17
	final static char[] CharValue = new char[]{'-', '9','2','2','3','3','7','2','0','3','6','8','5','4','7','7','5','8','0','8','L'};
18
	final static Constant MIN_VALUE = LongConstant.fromValue(Long.MIN_VALUE) ; 
19
18
20
public LongLiteralMinValue(){
19
public LongLiteralMinValue(){
21
	super(CharValue,0,0);
20
	super(CharValue,0,0);
22
	constant = MIN_VALUE;
21
	constant = LongConstant.fromValue(Long.MIN_VALUE);
23
}
22
}
24
public void computeConstant() {
23
public void computeConstant() {
25
24
(-)compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteralMinValue.java (-3 / +2 lines)
Lines 15-25 Link Here
15
public class IntLiteralMinValue extends IntLiteral {
15
public class IntLiteralMinValue extends IntLiteral {
16
16
17
	final static char[] CharValue = new char[]{'-','2','1','4','7','4','8','3','6','4','8'};
17
	final static char[] CharValue = new char[]{'-','2','1','4','7','4','8','3','6','4','8'};
18
	final static Constant MIN_VALUE = IntConstant.fromValue(Integer.MIN_VALUE) ; 
19
18
20
public IntLiteralMinValue() {
19
public IntLiteralMinValue() {
21
	super(CharValue,0,0,Integer.MIN_VALUE);
20
	super(CharValue, 0,0, Integer.MIN_VALUE);
22
	constant = MIN_VALUE;
21
	constant = IntConstant.fromValue(Integer.MIN_VALUE);
23
}
22
}
24
public void computeConstant(){
23
public void computeConstant(){
25
	
24
	
(-)compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteral.java (-16 / +2 lines)
Lines 22-28 Link Here
22
	public static final IntLiteral
22
	public static final IntLiteral
23
		One = new IntLiteral(new char[]{'1'},0,0,1);//used for ++ and -- 
23
		One = new IntLiteral(new char[]{'1'},0,0,1);//used for ++ and -- 
24
24
25
	static final Constant FORMAT_ERROR = DoubleConstant.fromValue(1.0/0.0); // NaN;
26
public IntLiteral(char[] token, int s, int e) {
25
public IntLiteral(char[] token, int s, int e) {
27
	super(token, s,e);
26
	super(token, s,e);
28
}
27
}
Lines 71-77 Link Here
71
		while (j<length)
70
		while (j<length)
72
		{	int digitValue ;
71
		{	int digitValue ;
73
			if ((digitValue = ScannerHelper.digit(source[j++],radix))	< 0 ) 	
72
			if ((digitValue = ScannerHelper.digit(source[j++],radix))	< 0 ) 	
74
			{	constant = FORMAT_ERROR; return ;}
73
			{	return /*constant stays null*/ ;}
75
			computedValue = (computedValue<<shift) | digitValue ;
74
			computedValue = (computedValue<<shift) | digitValue ;
76
			if (computedValue > MAX) return /*constant stays null*/ ;}}
75
			if (computedValue > MAX) return /*constant stays null*/ ;}}
77
	else
76
	else
Lines 79-85 Link Here
79
		for (int i = 0 ; i < length;i++)
78
		for (int i = 0 ; i < length;i++)
80
		{	int digitValue ;
79
		{	int digitValue ;
81
			if ((digitValue = ScannerHelper.digit(source[i],10))	< 0 ) 
80
			if ((digitValue = ScannerHelper.digit(source[i],10))	< 0 ) 
82
			{	constant = FORMAT_ERROR; return ;}
81
			{	return /*constant stays null*/ ; }
83
			computedValue = 10*computedValue + digitValue;
82
			computedValue = 10*computedValue + digitValue;
84
			if (computedValue > MAX) return /*constant stays null*/ ; }}
83
			if (computedValue > MAX) return /*constant stays null*/ ; }}
85
84
Lines 122-140 Link Here
122
			(source[9] == '8') &&
121
			(source[9] == '8') &&
123
			(((this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0));
122
			(((this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0));
124
}
123
}
125
public TypeBinding resolveType(BlockScope scope) {
126
	// the format may be incorrect while the scanner could detect
127
	// such an error only on painfull tests...easier and faster here
128
129
	TypeBinding tb = super.resolveType(scope);
130
	if (constant == FORMAT_ERROR) {
131
		constant = Constant.NotAConstant;
132
		scope.problemReporter().constantOutOfFormat(this);
133
		this.resolvedType = null;
134
		return null;
135
	}
136
	return tb;
137
}
138
public StringBuffer printExpression(int indent, StringBuffer output){
124
public StringBuffer printExpression(int indent, StringBuffer output){
139
125
140
	if (source == null) {
126
	if (source == null) {

Return to bug 261510