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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/CharLiteral.java (-2 / +7 lines)
Lines 17-39 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 CharLiteral extends NumberLiteral {
19
public class CharLiteral extends NumberLiteral {
20
	
20
	char value;
21
	char value;
22
	
21
public CharLiteral(char[] token, int s, int e) {
23
public CharLiteral(char[] token, int s, int e) {
22
	super(token, s, e);
24
	super(token, s, e);
23
	computeValue();
25
	computeValue();
24
}
26
}
27
25
public void computeConstant() {
28
public void computeConstant() {
26
	//The source is a  char[3] first and last char are '
29
	//The source is a  char[3] first and last char are '
27
	//This is true for both regular char AND unicode char
30
	//This is true for both regular char AND unicode char
28
	//BUT not for escape char like '\b' which are char[4]....
31
	//BUT not for escape char like '\b' which are char[4]....
29
30
	this.constant = CharConstant.fromValue(this.value);
32
	this.constant = CharConstant.fromValue(this.value);
31
}
33
}
34
32
private void computeValue() {
35
private void computeValue() {
33
	//The source is a  char[3] first and last char are '
36
	//The source is a  char[3] first and last char are '
34
	//This is true for both regular char AND unicode char
37
	//This is true for both regular char AND unicode char
35
	//BUT not for escape char like '\b' which are char[4]....
38
	//BUT not for escape char like '\b' which are char[4]....
36
37
	if ((this.value = this.source[1]) != '\\')
39
	if ((this.value = this.source[1]) != '\\')
38
		return;
40
		return;
39
	char digit;
41
	char digit;
Lines 76-81 Link Here
76
			break;
78
			break;
77
	}
79
	}
78
}
80
}
81
79
/**
82
/**
80
 * CharLiteral code generation
83
 * CharLiteral code generation
81
 *
84
 *
Lines 90-98 Link Here
90
	}
93
	}
91
	codeStream.recordPositionsFrom(pc, this.sourceStart);
94
	codeStream.recordPositionsFrom(pc, this.sourceStart);
92
}
95
}
96
93
public TypeBinding literalType(BlockScope scope) {
97
public TypeBinding literalType(BlockScope scope) {
94
	return TypeBinding.CHAR;
98
	return TypeBinding.CHAR;
95
}
99
}
100
96
public void traverse(ASTVisitor visitor, BlockScope blockScope) {
101
public void traverse(ASTVisitor visitor, BlockScope blockScope) {
97
	visitor.visit(this, blockScope);
102
	visitor.visit(this, blockScope);
98
	visitor.endVisit(this, blockScope);
103
	visitor.endVisit(this, blockScope);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java (+2 lines)
Lines 18-24 Link Here
18
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
18
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
19
19
20
public class TrueLiteral extends MagicLiteral {
20
public class TrueLiteral extends MagicLiteral {
21
	
21
	static final char[] source = {'t' , 'r' , 'u' , 'e'};
22
	static final char[] source = {'t' , 'r' , 'u' , 'e'};
23
	
22
public TrueLiteral(int s , int e) {
24
public TrueLiteral(int s , int e) {
23
	super(s,e);
25
	super(s,e);
24
}
26
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java (+2 lines)
Lines 18-24 Link Here
18
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
18
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
19
19
20
public class FalseLiteral extends MagicLiteral {
20
public class FalseLiteral extends MagicLiteral {
21
	
21
	static final char[] source = {'f', 'a', 'l', 's', 'e'};
22
	static final char[] source = {'f', 'a', 'l', 's', 'e'};
23
	
22
public FalseLiteral(int s , int e) {
24
public FalseLiteral(int s , int e) {
23
	super(s,e);
25
	super(s,e);
24
}
26
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FloatLiteral.java (-85 / +89 lines)
Lines 18-115 Link Here
18
import org.eclipse.jdt.internal.compiler.util.FloatUtil;
18
import org.eclipse.jdt.internal.compiler.util.FloatUtil;
19
19
20
public class FloatLiteral extends NumberLiteral {
20
public class FloatLiteral extends NumberLiteral {
21
	
21
	float value;
22
	float value;
22
	final static float Float_MIN_VALUE = Float.intBitsToFloat(1); // work-around VAJ problem 1F6IGUU
23
	
23
	public FloatLiteral(char[] token, int s, int e) {
24
public FloatLiteral(char[] token, int s, int e) {
24
		super(token, s, e);
25
	super(token, s, e);
25
	}
26
}
26
	public void computeConstant() {
27
27
		Float computedValue;
28
public void computeConstant() {
29
	Float computedValue;
30
	try {
31
		computedValue = Float.valueOf(String.valueOf(this.source));
32
	} catch (NumberFormatException e) {
33
		// hex floating point literal
34
		// being rejected by 1.4 libraries where Float.valueOf(...) doesn't handle hex decimal floats
28
		try {
35
		try {
29
			computedValue = Float.valueOf(String.valueOf(this.source));
36
			float v = FloatUtil.valueOfHexFloatLiteral(this.source);
30
		} catch (NumberFormatException e) {
37
			if (v == Float.POSITIVE_INFINITY) {
31
			// hex floating point literal
38
				// error: the number is too large to represent
32
			// being rejected by 1.4 libraries where Float.valueOf(...) doesn't handle hex decimal floats
39
				return;
33
			try {
34
				float v = FloatUtil.valueOfHexFloatLiteral(this.source);
35
				if (v == Float.POSITIVE_INFINITY) {
36
					// error: the number is too large to represent
37
					return;
38
				}
39
				if (Float.isNaN(v)) {
40
					// error: the number is too small to represent
41
					return;
42
				}
43
				this.value = v;
44
				this.constant = FloatConstant.fromValue(v);
45
			} catch (NumberFormatException e1) {
46
				// if the computation of the constant fails
47
			}
40
			}
48
			return;
41
			if (Float.isNaN(v)) {
49
		}
42
				// error: the number is too small to represent
50
43
				return;
51
		final float floatValue = computedValue.floatValue();
52
		if (floatValue > Float.MAX_VALUE) {
53
			// error: the number is too large to represent
54
			return;
55
		}
56
		if (floatValue < Float.MIN_VALUE) {
57
			// see 1F6IGUU
58
			// a true 0 only has '0' and '.' in mantissa
59
			// 1.0e-5000d is non-zero, but underflows to 0
60
			boolean isHexaDecimal = false;
61
			label : for (int i = 0; i < this.source.length; i++) { //it is welled formated so just test against '0' and potential . D d
62
				switch (this.source[i]) {
63
					case '0' :
64
					case '.' :
65
						break;
66
					case 'x' :
67
					case 'X' :
68
						isHexaDecimal = true;
69
						break;
70
					case 'e' :
71
					case 'E' :
72
					case 'f' :
73
					case 'F' :
74
					case 'd' :
75
					case 'D' :
76
						if (isHexaDecimal) {
77
							return;
78
						}
79
						// starting the exponent - mantissa is all zero
80
						// no exponent - mantissa is all zero
81
						break label;
82
					case 'p' :
83
					case 'P' :
84
						break label;
85
					default :
86
						// error: the number is too small to represent
87
						return;
88
				}
89
			}
44
			}
45
			this.value = v;
46
			this.constant = FloatConstant.fromValue(v);
47
		} catch (NumberFormatException e1) {
48
			// if the computation of the constant fails
90
		}
49
		}
91
		this.value = floatValue;
50
		return;
92
		this.constant = FloatConstant.fromValue(this.value);
93
	}
51
	}
94
	/**
52
	final float floatValue = computedValue.floatValue();
95
	 * Code generation for float literal
53
	if (floatValue > Float.MAX_VALUE) {
96
	 *
54
		// error: the number is too large to represent
97
	 * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
55
		return;
98
	 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
99
	 * @param valueRequired boolean
100
	 */
101
	public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
102
		int pc = codeStream.position;
103
		if (valueRequired) {
104
			codeStream.generateConstant(this.constant, this.implicitConversion);
105
		}
106
		codeStream.recordPositionsFrom(pc, this.sourceStart);
107
	}
56
	}
108
	public TypeBinding literalType(BlockScope scope) {
57
	if (floatValue < Float.MIN_VALUE) {
109
		return TypeBinding.FLOAT;
58
		// see 1F6IGUU
59
		// a true 0 only has '0' and '.' in mantissa
60
		// 1.0e-5000d is non-zero, but underflows to 0
61
		boolean isHexaDecimal = false;
62
		label : for (int i = 0; i < this.source.length; i++) { //it is welled formated so just test against '0' and potential . D d
63
			switch (this.source[i]) {
64
				case '0' :
65
				case '.' :
66
					break;
67
				case 'x' :
68
				case 'X' :
69
					isHexaDecimal = true;
70
					break;
71
				case 'e' :
72
				case 'E' :
73
				case 'f' :
74
				case 'F' :
75
				case 'd' :
76
				case 'D' :
77
					if (isHexaDecimal) {
78
						return;
79
					}
80
					// starting the exponent - mantissa is all zero
81
					// no exponent - mantissa is all zero
82
					break label;
83
				case 'p' :
84
				case 'P' :
85
					break label;
86
				default :
87
					// error: the number is too small to represent
88
					return;
89
			}
90
		}
110
	}
91
	}
111
	public void traverse(ASTVisitor visitor, BlockScope scope) {
92
	this.value = floatValue;
112
		visitor.visit(this, scope);
93
	this.constant = FloatConstant.fromValue(this.value);
113
		visitor.endVisit(this, scope);
94
}
95
96
/**
97
 * Code generation for float literal
98
 *
99
 * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
100
 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
101
 * @param valueRequired boolean
102
 */
103
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
104
	int pc = codeStream.position;
105
	if (valueRequired) {
106
		codeStream.generateConstant(this.constant, this.implicitConversion);
114
	}
107
	}
108
	codeStream.recordPositionsFrom(pc, this.sourceStart);
109
}
110
111
public TypeBinding literalType(BlockScope scope) {
112
	return TypeBinding.FLOAT;
113
}
114
115
public void traverse(ASTVisitor visitor, BlockScope scope) {
116
	visitor.visit(this, scope);
117
	visitor.endVisit(this, scope);
118
}
115
}
119
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java (-23 / +12 lines)
Lines 17-32 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);
24
}
23
}
24
25
public void computeConstant() {
25
public void computeConstant() {
26
	//the overflow (when radix=10) is tested using the fact that
26
	//the overflow (when radix=10) is tested using the fact that
27
	//the value should always grow during its computation
27
	//the value should always grow during its computation
28
	int length = this.source.length - 1; //minus one because the last char is 'l' or 'L'
28
	int length = this.source.length - 1; //minus one because the last char is 'l' or 'L'
29
30
	long computedValue ;
29
	long computedValue ;
31
	if (this.source[0] == '0') {
30
	if (this.source[0] == '0') {
32
		if (length == 1) {
31
		if (length == 1) {
Lines 46-58 Link Here
46
			if ( j == length) {
45
			if ( j == length) {
47
				//watch for 0000000000000L
46
				//watch for 0000000000000L
48
				this.constant = LongConstant.fromValue(0L);
47
				this.constant = LongConstant.fromValue(0L);
49
				return ;
48
				return;
50
			}
49
			}
51
		}
50
		}
52
51
53
		int digitValue ;
52
		int digitValue ;
54
		if ((digitValue = ScannerHelper.digit(this.source[j++],radix)) < 0 ) {
53
		if ((digitValue = ScannerHelper.digit(this.source[j++],radix)) < 0 ) {
55
			this.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-74 Link Here
65
		computedValue = digitValue ;
64
		computedValue = digitValue ;
66
		while (j<length) {
65
		while (j<length) {
67
			if ((digitValue = ScannerHelper.digit(this.source[j++],radix)) < 0) {
66
			if ((digitValue = ScannerHelper.digit(this.source[j++],radix)) < 0) {
68
				this.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*/
72
			computedValue = (computedValue<<shift) | digitValue ;
71
			computedValue = (computedValue<<shift) | digitValue ;
73
		}
72
		}
74
	} else {
73
	} else {
Lines 81-97 Link Here
81
			if ((digitValue = ScannerHelper.digit(this.source[i], 10)) < 0 ) return /*constant stays null*/;
80
			if ((digitValue = ScannerHelper.digit(this.source[i], 10)) < 0 ) return /*constant stays null*/;
82
			previous = computedValue;
81
			previous = computedValue;
83
			if (computedValue > limit)
82
			if (computedValue > limit)
84
				return /*constant stays null*/;
83
				return; /*constant stays null*/
85
			computedValue *= 10;
84
			computedValue *= 10;
86
			if ((computedValue + digitValue) > Long.MAX_VALUE)
85
			if ((computedValue + digitValue) > Long.MAX_VALUE)
87
				return /*constant stays null*/;
86
				return; /*constant stays null*/
88
			computedValue += digitValue;
87
			computedValue += digitValue;
89
			if (previous > computedValue)
88
			if (previous > computedValue)
90
				return /*constant stays null*/;
89
				return; /*constant stays null*/
91
		}
90
		}
92
	}
91
	}
93
	this.constant = LongConstant.fromValue(computedValue);
92
	this.constant = LongConstant.fromValue(computedValue);
94
}
93
}
94
95
/**
95
/**
96
 * Code generation for long literal
96
 * Code generation for long literal
97
 *
97
 *
Lines 106-120 Link Here
106
	}
106
	}
107
	codeStream.recordPositionsFrom(pc, this.sourceStart);
107
	codeStream.recordPositionsFrom(pc, this.sourceStart);
108
}
108
}
109
109
public TypeBinding literalType(BlockScope scope) {
110
public TypeBinding literalType(BlockScope scope) {
110
	return TypeBinding.LONG;
111
	return TypeBinding.LONG;
111
}
112
}
113
112
public final boolean mayRepresentMIN_VALUE(){
114
public final boolean mayRepresentMIN_VALUE(){
113
	//a special autorized int literral is 9223372036854775808L
115
	//a special autorized int literral is 9223372036854775808L
114
	//which is ONE over the limit. This special case
116
	//which is ONE over the limit. This special case
115
	//only is used in combinaison with - to denote
117
	//only is used in combinaison with - to denote
116
	//the minimal value of int -9223372036854775808L
118
	//the minimal value of int -9223372036854775808L
117
118
	return ((this.source.length == 20) &&
119
	return ((this.source.length == 20) &&
119
			(this.source[0] == '9') &&
120
			(this.source[0] == '9') &&
120
			(this.source[1] == '2') &&
121
			(this.source[1] == '2') &&
Lines 137-155 Link Here
137
			(this.source[18] == '8') &&
138
			(this.source[18] == '8') &&
138
			(((this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0));
139
			(((this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0));
139
}
140
}
140
public TypeBinding resolveType(BlockScope scope) {
141
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 (this.constant == FORMAT_ERROR) {
146
		this.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) {
142
public void traverse(ASTVisitor visitor, BlockScope scope) {
154
	visitor.visit(this, scope);
143
	visitor.visit(this, scope);
155
	visitor.endVisit(this, scope);
144
	visitor.endVisit(this, scope);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java (-1 lines)
Lines 206-212 Link Here
206
	}
206
	}
207
207
208
	public TypeBinding resolveType(BlockScope scope) {
208
	public TypeBinding resolveType(BlockScope scope) {
209
210
		boolean expressionIsCast;
209
		boolean expressionIsCast;
211
		if ((expressionIsCast = this.expression instanceof CastExpression) == true) this.expression.bits |= DisableUnnecessaryCastCheck; // will check later on
210
		if ((expressionIsCast = this.expression instanceof CastExpression) == true) this.expression.bits |= DisableUnnecessaryCastCheck; // will check later on
212
		TypeBinding expressionType = this.expression.resolveType(scope);
211
		TypeBinding expressionType = this.expression.resolveType(scope);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteralMinValue.java (-3 / +1 lines)
Lines 15-27 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
	this.constant = MIN_VALUE;
21
	this.constant = LongConstant.fromValue(Long.MIN_VALUE);
23
}
22
}
24
public void computeConstant() {
23
public void computeConstant() {
25
26
	/*precomputed at creation time*/}
24
	/*precomputed at creation time*/}
27
}
25
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteral.java (-50 / +48 lines)
Lines 17-38 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 IntLiteral extends NumberLiteral {
19
public class IntLiteral extends NumberLiteral {
20
	
20
	public int value;
21
	public int value;
21
22
22
	public static final IntLiteral
23
	public static final IntLiteral 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
}
28
29
public IntLiteral(char[] token, int s,int e, int value) {
29
public IntLiteral(char[] token, int s,int e, int value) {
30
	this(token, s,e);
30
	this(token, s,e);
31
	this.value = value;
31
	this.value = value;
32
}
32
}
33
33
public IntLiteral(int intValue) {
34
public IntLiteral(int intValue) {
34
	//special optimized constructor : the cst is the argument
35
	//special optimized constructor : the cst is the argument
35
36
	//value that should not be used
36
	//value that should not be used
37
	//	tokens = null ;
37
	//	tokens = null ;
38
	//	sourceStart = 0;
38
	//	sourceStart = 0;
Lines 40-91 Link Here
40
	super(null,0,0);
40
	super(null,0,0);
41
	this.constant = IntConstant.fromValue(intValue);
41
	this.constant = IntConstant.fromValue(intValue);
42
	this.value = intValue;
42
	this.value = intValue;
43
44
}
43
}
44
45
public void computeConstant() {
45
public void computeConstant() {
46
	//a special constant is use for the potential Integer.MAX_VALUE+1
46
	//a special constant is use for the potential Integer.MAX_VALUE+1
47
	//which is legal if used with a - as prefix....cool....
47
	//which is legal if used with a - as prefix....cool....
48
	//notice that Integer.MIN_VALUE  == -2147483648
48
	//notice that Integer.MIN_VALUE  == -2147483648
49
50
	long MAX = Integer.MAX_VALUE;
49
	long MAX = Integer.MAX_VALUE;
51
	if (this == One) {	this.constant = IntConstant.fromValue(1); return ;}
50
	if (this == One) {	
52
51
		this.constant = IntConstant.fromValue(1); 
52
		return ;
53
	}
53
	int length = this.source.length;
54
	int length = this.source.length;
54
	long computedValue = 0L;
55
	long computedValue = 0L;
55
	if (this.source[0] == '0')
56
	if (this.source[0] == '0') {	
56
	{	MAX = 0xFFFFFFFFL ; //a long in order to be positive !
57
		MAX = 0xFFFFFFFFL ; //a long in order to be positive !
57
		if (length == 1) {	this.constant = IntConstant.fromValue(0); return ;}
58
		if (length == 1) {
59
			this.constant = IntConstant.fromValue(0); return ;
60
		}
58
		final int shift,radix;
61
		final int shift,radix;
59
		int j ;
62
		int j ;
60
		if ( (this.source[1] == 'x') || (this.source[1] == 'X') )
63
		if ((this.source[1] == 'x') || (this.source[1] == 'X')) {	
61
		{	shift = 4 ; j = 2; radix = 16;}
64
			shift = 4 ; j = 2; radix = 16;
62
		else
65
		} else {	
63
		{	shift = 3 ; j = 1; radix = 8;}
66
			shift = 3 ; j = 1; radix = 8;
64
		while (this.source[j]=='0')
67
		}
65
		{	j++; //jump over redondant zero
68
		while (this.source[j]=='0')	 {	
66
			if (j == length)
69
			j++; //jump over redondant zero
67
			{	//watch for 000000000000000000
70
			if (j == length) {
71
				//watch for 000000000000000000
68
				this.constant = IntConstant.fromValue(this.value = (int)computedValue);
72
				this.constant = IntConstant.fromValue(this.value = (int)computedValue);
69
				return ;}}
73
				return;
70
74
			}
71
		while (j<length)
75
		}
72
		{	int digitValue ;
76
		while (j<length) {	
73
			if ((digitValue = ScannerHelper.digit(this.source[j++],radix))	< 0 )
77
			int digitValue ;
74
			{	this.constant = FORMAT_ERROR; return ;}
78
			if ((digitValue = ScannerHelper.digit(this.source[j++],radix))	< 0 ) {
79
				return; /*constant stays null*/
80
			}
75
			computedValue = (computedValue<<shift) | digitValue ;
81
			computedValue = (computedValue<<shift) | digitValue ;
76
			if (computedValue > MAX) return /*constant stays null*/ ;}}
82
			if (computedValue > MAX) return; /*constant stays null*/
77
	else
83
		}
78
	{	//-----------regular case : radix = 10-----------
84
	} else {	
79
		for (int i = 0 ; i < length;i++)
85
		//-----------regular case : radix = 10-----------
80
		{	int digitValue ;
86
		for (int i = 0 ; i < length;i++) {	
81
			if ((digitValue = ScannerHelper.digit(this.source[i],10))	< 0 )
87
			int digitValue ;
82
			{	this.constant = FORMAT_ERROR; return ;}
88
			if ((digitValue = ScannerHelper.digit(this.source[i],10))	< 0 ) {
89
				return; /*constant stays null*/
90
			}
83
			computedValue = 10*computedValue + digitValue;
91
			computedValue = 10*computedValue + digitValue;
84
			if (computedValue > MAX) return /*constant stays null*/ ; }}
92
			if (computedValue > MAX) return /*constant stays null*/ ;
85
93
		}
94
	}
86
	this.constant = IntConstant.fromValue(this.value = (int)computedValue);
95
	this.constant = IntConstant.fromValue(this.value = (int)computedValue);
87
96
88
}
97
}
98
89
/**
99
/**
90
 * Code generation for int literal
100
 * Code generation for int literal
91
 *
101
 *
Lines 100-114 Link Here
100
	}
110
	}
101
	codeStream.recordPositionsFrom(pc, this.sourceStart);
111
	codeStream.recordPositionsFrom(pc, this.sourceStart);
102
}
112
}
113
103
public TypeBinding literalType(BlockScope scope) {
114
public TypeBinding literalType(BlockScope scope) {
104
	return TypeBinding.INT;
115
	return TypeBinding.INT;
105
}
116
}
117
106
public final boolean mayRepresentMIN_VALUE(){
118
public final boolean mayRepresentMIN_VALUE(){
107
	//a special autorized int literral is 2147483648
119
	//a special autorized int literral is 2147483648
108
	//which is ONE over the limit. This special case
120
	//which is ONE over the limit. This special case
109
	//only is used in combinaison with - to denote
121
	//only is used in combinaison with - to denote
110
	//the minimal value of int -2147483648
122
	//the minimal value of int -2147483648
111
112
	return ((this.source.length == 10) &&
123
	return ((this.source.length == 10) &&
113
			(this.source[0] == '2') &&
124
			(this.source[0] == '2') &&
114
			(this.source[1] == '1') &&
125
			(this.source[1] == '1') &&
Lines 122-142 Link Here
122
			(this.source[9] == '8') &&
133
			(this.source[9] == '8') &&
123
			(((this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0));
134
			(((this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0));
124
}
135
}
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 (this.constant == FORMAT_ERROR) {
131
		this.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){
139
136
137
public StringBuffer printExpression(int indent, StringBuffer output){
140
	if (this.source == null) {
138
	if (this.source == null) {
141
	/* special optimized IntLiteral that are created by the compiler */
139
	/* special optimized IntLiteral that are created by the compiler */
142
		return output.append(String.valueOf(this.value));
140
		return output.append(String.valueOf(this.value));
(-)compiler/org/eclipse/jdt/internal/compiler/ast/DoubleLiteral.java (-84 / +89 lines)
Lines 17-113 Link Here
17
import org.eclipse.jdt.internal.compiler.util.FloatUtil;
17
import org.eclipse.jdt.internal.compiler.util.FloatUtil;
18
18
19
public class DoubleLiteral extends NumberLiteral {
19
public class DoubleLiteral extends NumberLiteral {
20
	
20
	double value;
21
	double value;
21
	public DoubleLiteral(char[] token, int s, int e) {
22
	
22
		super(token, s, e);
23
public DoubleLiteral(char[] token, int s, int e) {
23
	}
24
	super(token, s, e);
24
	public void computeConstant() {
25
}
25
		Double computedValue;
26
27
public void computeConstant() {
28
	Double computedValue;
29
	try {
30
		computedValue = Double.valueOf(String.valueOf(this.source));
31
	} catch (NumberFormatException e) {
32
		// hex floating point literal
33
		// being rejected by 1.4 libraries where Double.valueOf(...) doesn't handle hex decimal floats
26
		try {
34
		try {
27
			computedValue = Double.valueOf(String.valueOf(this.source));
35
			double v = FloatUtil.valueOfHexDoubleLiteral(this.source);
28
		} catch (NumberFormatException e) {
36
			if (v == Double.POSITIVE_INFINITY) {
29
			// hex floating point literal
37
				// error: the number is too large to represent
30
			// being rejected by 1.4 libraries where Double.valueOf(...) doesn't handle hex decimal floats
38
				return;
31
			try {
32
				double v = FloatUtil.valueOfHexDoubleLiteral(this.source);
33
				if (v == Double.POSITIVE_INFINITY) {
34
					// error: the number is too large to represent
35
					return;
36
				}
37
				if (Double.isNaN(v)) {
38
					// error: the number is too small to represent
39
					return;
40
				}
41
				this.value = v;
42
				this.constant = DoubleConstant.fromValue(v);
43
			} catch (NumberFormatException e1) {
44
				// if the computation of the constant fails
45
			}
39
			}
46
			return;
40
			if (Double.isNaN(v)) {
47
		}
41
				// error: the number is too small to represent
48
42
				return;
49
		final double doubleValue = computedValue.doubleValue();
50
		if (doubleValue > Double.MAX_VALUE) {
51
			// error: the number is too large to represent
52
			return;
53
		}
54
		if (doubleValue < Double.MIN_VALUE) {
55
			// see 1F6IGUU
56
			// a true 0 only has '0' and '.' in mantissa
57
			// 1.0e-5000d is non-zero, but underflows to 0
58
			boolean isHexaDecimal = false;
59
			label : for (int i = 0; i < this.source.length; i++) { //it is welled formated so just test against '0' and potential . D d
60
				switch (this.source[i]) {
61
					case '0' :
62
					case '.' :
63
						break;
64
					case 'x' :
65
					case 'X' :
66
						isHexaDecimal = true;
67
						break;
68
					case 'e' :
69
					case 'E' :
70
					case 'f' :
71
					case 'F' :
72
					case 'd' :
73
					case 'D' :
74
						if (isHexaDecimal) {
75
							return;
76
						}
77
						// starting the exponent - mantissa is all zero
78
						// no exponent - mantissa is all zero
79
						break label;
80
					case 'p' :
81
					case 'P' :
82
						break label;
83
					default :
84
						// error: the number is too small to represent
85
						return;
86
				}
87
			}
43
			}
44
			this.value = v;
45
			this.constant = DoubleConstant.fromValue(v);
46
		} catch (NumberFormatException e1) {
47
			// if the computation of the constant fails
88
		}
48
		}
89
		this.value = doubleValue;
49
		return;
90
		this.constant = DoubleConstant.fromValue(this.value);
91
	}
50
	}
92
	/**
51
	final double doubleValue = computedValue.doubleValue();
93
	 * Code generation for the double literak
52
	if (doubleValue > Double.MAX_VALUE) {
94
	 *
53
		// error: the number is too large to represent
95
	 * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
54
		return;
96
	 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
97
	 * @param valueRequired boolean
98
	 */
99
	public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
100
		int pc = codeStream.position;
101
		if (valueRequired) {
102
			codeStream.generateConstant(this.constant, this.implicitConversion);
103
		}
104
		codeStream.recordPositionsFrom(pc, this.sourceStart);
105
	}
55
	}
106
	public TypeBinding literalType(BlockScope scope) {
56
	if (doubleValue < Double.MIN_VALUE) {
107
		return TypeBinding.DOUBLE;
57
		// see 1F6IGUU
58
		// a true 0 only has '0' and '.' in mantissa
59
		// 1.0e-5000d is non-zero, but underflows to 0
60
		boolean isHexaDecimal = false;
61
		label : for (int i = 0; i < this.source.length; i++) { //it is welled formated so just test against '0' and potential . D d
62
			switch (this.source[i]) {
63
				case '0' :
64
				case '.' :
65
					break;
66
				case 'x' :
67
				case 'X' :
68
					isHexaDecimal = true;
69
					break;
70
				case 'e' :
71
				case 'E' :
72
				case 'f' :
73
				case 'F' :
74
				case 'd' :
75
				case 'D' :
76
					if (isHexaDecimal) {
77
						return;
78
					}
79
					// starting the exponent - mantissa is all zero
80
					// no exponent - mantissa is all zero
81
					break label;
82
				case 'p' :
83
				case 'P' :
84
					break label;
85
				default :
86
					// error: the number is too small to represent
87
					return;
88
			}
89
		}
108
	}
90
	}
109
	public void traverse(ASTVisitor visitor, BlockScope scope) {
91
	this.value = doubleValue;
110
		visitor.visit(this, scope);
92
	this.constant = DoubleConstant.fromValue(this.value);
111
		visitor.endVisit(this, scope);
93
}
94
95
/**
96
 * Code generation for the double literak
97
 *
98
 * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
99
 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
100
 * @param valueRequired boolean
101
 */
102
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
103
	int pc = codeStream.position;
104
	if (valueRequired) {
105
		codeStream.generateConstant(this.constant, this.implicitConversion);
112
	}
106
	}
107
	codeStream.recordPositionsFrom(pc, this.sourceStart);
108
}
109
110
public TypeBinding literalType(BlockScope scope) {
111
	return TypeBinding.DOUBLE;
112
}
113
114
public void traverse(ASTVisitor visitor, BlockScope scope) {
115
	visitor.visit(this, scope);
116
	visitor.endVisit(this, scope);
117
}
113
}
118
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteralMinValue.java (-3 / +2 lines)
Lines 15-27 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
	this.constant = MIN_VALUE;
21
	this.constant = IntConstant.fromValue(Integer.MIN_VALUE);
23
}
22
}
24
public void computeConstant(){
25
23
24
public void computeConstant(){
26
	/*precomputed at creation time*/ }
25
	/*precomputed at creation time*/ }
27
}
26
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/NumberLiteral.java (-3 lines)
Lines 15-21 Link Here
15
	char[] source;
15
	char[] source;
16
16
17
	public NumberLiteral(char[] token, int s, int e) {
17
	public NumberLiteral(char[] token, int s, int e) {
18
19
		this(s,e) ;
18
		this(s,e) ;
20
		this.source = token ;
19
		this.source = token ;
21
	}
20
	}
Lines 25-36 Link Here
25
	}
24
	}
26
25
27
	public boolean isValidJavaStatement(){
26
	public boolean isValidJavaStatement(){
28
29
		return false ;
27
		return false ;
30
	}
28
	}
31
29
32
	public char[] source(){
30
	public char[] source(){
33
34
		return this.source;
31
		return this.source;
35
	}
32
	}
36
}
33
}
(-)compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java (+5 lines)
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.impl;
11
package org.eclipse.jdt.internal.compiler.impl;
12
12
/*
13
/*
13
 * Implementors are valid compilation contexts from which we can
14
 * Implementors are valid compilation contexts from which we can
14
 * escape in case of error:
15
 * escape in case of error:
Lines 19-26 Link Here
19
import org.eclipse.jdt.internal.compiler.CompilationResult;
20
import org.eclipse.jdt.internal.compiler.CompilationResult;
20
21
21
public interface ReferenceContext {
22
public interface ReferenceContext {
23
22
	void abort(int abortLevel, CategorizedProblem problem);
24
	void abort(int abortLevel, CategorizedProblem problem);
25
23
	CompilationResult compilationResult();
26
	CompilationResult compilationResult();
27
24
	boolean hasErrors();
28
	boolean hasErrors();
29
25
	void tagAsHavingErrors();
30
	void tagAsHavingErrors();
26
}
31
}
(-)compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java (-37 / +50 lines)
Lines 11-53 Link Here
11
package org.eclipse.jdt.internal.compiler.impl;
11
package org.eclipse.jdt.internal.compiler.impl;
12
12
13
public class ShortConstant extends Constant {
13
public class ShortConstant extends Constant {
14
private short value;
14
	
15
	private short value;
15
16
16
public static Constant fromValue(short value) {
17
	public static Constant fromValue(short value) {
17
	return new ShortConstant(value);
18
		return new ShortConstant(value);
18
}
19
	}
19
private ShortConstant(short value) {
20
	this.value = value;
21
}
22
public byte byteValue() {
23
	return (byte) this.value;
24
}
25
public char charValue() {
26
	return (char) this.value;
27
}
28
public double doubleValue() {
29
	return this.value; // implicit cast to return type
30
}
31
public float floatValue() {
32
	return this.value; // implicit cast to return type
33
}
34
public int intValue() {
35
	return this.value; // implicit cast to return type
36
}
37
public long longValue() {
38
	return this.value; // implicit cast to return type
39
}
40
public short shortValue() {
41
	return this.value;
42
}
43
public String stringValue() {
44
	//spec 15.17.11
45
	return String.valueOf(this.value);
46
}
47
public String toString(){
48
20
49
	return "(short)" + this.value ; } //$NON-NLS-1$
21
	private ShortConstant(short value) {
50
public int typeID() {
22
		this.value = value;
51
	return T_short;
23
	}
52
}
24
25
	public byte byteValue() {
26
		return (byte) this.value;
27
	}
28
29
	public char charValue() {
30
		return (char) this.value;
31
	}
32
33
	public double doubleValue() {
34
		return this.value; // implicit cast to return type
35
	}
36
37
	public float floatValue() {
38
		return this.value; // implicit cast to return type
39
	}
40
41
	public int intValue() {
42
		return this.value; // implicit cast to return type
43
	}
44
45
	public long longValue() {
46
		return this.value; // implicit cast to return type
47
	}
48
49
	public short shortValue() {
50
		return this.value;
51
	}
52
53
	public String stringValue() {
54
		// spec 15.17.11
55
		return String.valueOf(this.value);
56
	}
57
58
	public String toString() {
59
60
		return "(short)" + this.value; //$NON-NLS-1$
61
	}
62
63
	public int typeID() {
64
		return T_short;
65
	}
53
}
66
}
(-)compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java (-3 / +19 lines)
Lines 11-57 Link Here
11
package org.eclipse.jdt.internal.compiler.impl;
11
package org.eclipse.jdt.internal.compiler.impl;
12
12
13
public class LongConstant extends Constant {
13
public class LongConstant extends Constant {
14
private static final LongConstant ZERO = new LongConstant(0L);
15
14
16
private long value;
15
		private static final LongConstant ZERO = new LongConstant(0L);
16
		private static final LongConstant MIN_VALUE = new LongConstant(Long.MIN_VALUE);
17
		
18
		private long value;
17
19
18
public static Constant fromValue(long value) {
20
public static Constant fromValue(long value) {
19
	if (value == 0L) {
21
	if (value == 0L) {
20
		return ZERO;
22
		return ZERO;
23
	} else if (value == Long.MIN_VALUE) {
24
		return MIN_VALUE;
21
	}
25
	}
22
	return new LongConstant(value);
26
	return new LongConstant(value);
23
}
27
}
28
24
private LongConstant(long value) {
29
private LongConstant(long value) {
25
	this.value = value;
30
	this.value = value;
26
}
31
}
32
27
public byte byteValue() {
33
public byte byteValue() {
28
	return (byte) this.value;
34
	return (byte) this.value;
29
}
35
}
36
30
public char charValue() {
37
public char charValue() {
31
	return (char) this.value;
38
	return (char) this.value;
32
}
39
}
40
33
public double doubleValue() {
41
public double doubleValue() {
34
	return this.value; // implicit cast to return type
42
	return this.value; // implicit cast to return type
35
}
43
}
44
36
public float floatValue() {
45
public float floatValue() {
37
	return this.value; // implicit cast to return type
46
	return this.value; // implicit cast to return type
38
}
47
}
48
39
public int intValue() {
49
public int intValue() {
40
	return (int) this.value;
50
	return (int) this.value;
41
}
51
}
52
42
public long longValue() {
53
public long longValue() {
43
	return this.value;
54
	return this.value;
44
}
55
}
56
45
public short shortValue() {
57
public short shortValue() {
46
	return (short) this.value;
58
	return (short) this.value;
47
}
59
}
60
48
public String stringValue() {
61
public String stringValue() {
49
	//spec 15.17.11
62
	//spec 15.17.11
50
	return String.valueOf(this.value);
63
	return String.valueOf(this.value);
51
}
64
}
65
52
public String toString(){
66
public String toString(){
53
67
54
	return "(long)" + this.value ; } //$NON-NLS-1$
68
	return "(long)" + this.value ; //$NON-NLS-1$
69
}
70
55
public int typeID() {
71
public int typeID() {
56
	return T_long;
72
	return T_long;
57
}
73
}
(-)compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java (-26 / +27 lines)
Lines 12-43 Link Here
12
12
13
public class BooleanConstant extends Constant {
13
public class BooleanConstant extends Constant {
14
14
15
private boolean value;
15
	private boolean value;
16
16
17
private static final BooleanConstant TRUE = new BooleanConstant(true);
17
	private static final BooleanConstant TRUE = new BooleanConstant(true);
18
private static final BooleanConstant FALSE = new BooleanConstant(false);
18
	private static final BooleanConstant FALSE = new BooleanConstant(false);
19
19
20
public static BooleanConstant fromValue(boolean value) {
20
	public static BooleanConstant fromValue(boolean value) {
21
	return value ? BooleanConstant.TRUE : BooleanConstant.FALSE;
21
		return value ? BooleanConstant.TRUE : BooleanConstant.FALSE;
22
}
22
	}
23
private BooleanConstant(boolean value) {
23
24
	this.value = value;
24
	private BooleanConstant(boolean value) {
25
}
25
		this.value = value;
26
26
	}
27
public boolean booleanValue() {
27
28
	return this.value;
28
	public boolean booleanValue() {
29
}
29
		return this.value;
30
30
	}
31
public String stringValue() {
31
32
	//spec 15.17.11
32
	public String stringValue() {
33
	return String.valueOf(this.value);
33
		// spec 15.17.11
34
}
34
		return String.valueOf(this.value);
35
35
	}
36
public String toString(){
36
37
	return "(boolean)" + this.value ;  //$NON-NLS-1$
37
	public String toString() {
38
}
38
		return "(boolean)" + this.value; //$NON-NLS-1$
39
39
	}
40
public int typeID() {
40
41
	return T_boolean;
41
	public int typeID() {
42
}
42
		return T_boolean;
43
	}
43
}
44
}
(-)compiler/org/eclipse/jdt/internal/compiler/impl/StringConstant.java (-30 / +26 lines)
Lines 11-46 Link Here
11
package org.eclipse.jdt.internal.compiler.impl;
11
package org.eclipse.jdt.internal.compiler.impl;
12
12
13
public class StringConstant extends Constant {
13
public class StringConstant extends Constant {
14
private String value;
15
14
15
	private String value;
16
16
17
public static Constant fromValue(String value) {
17
	public static Constant fromValue(String value) {
18
	return new StringConstant(value);
18
		return new StringConstant(value);
19
}
19
	}
20
20
21
private StringConstant(String value) {
21
	private StringConstant(String value) {
22
	this.value = value ;
22
		this.value = value;
23
}
23
	}
24
24
25
public String stringValue() {
25
	public String stringValue() {
26
	//spec 15.17.11
26
		// spec 15.17.11
27
27
28
	//the next line do not go into the toString() send....!
28
		// the next line do not go into the toString() send....!
29
	return this.value ;
29
		return this.value;
30
30
		/*
31
	/*
31
		 * String s = value.toString() ; if (s == null) return "null"; else return s;
32
	String s = value.toString() ;
32
		 */
33
	if (s == null)
33
	}
34
		return "null";
34
35
	else
35
	public String toString() {
36
		return s;
36
		return "(String)\"" + this.value + "\""; //$NON-NLS-2$ //$NON-NLS-1$
37
	*/
37
	}
38
38
39
}
39
	public int typeID() {
40
public String toString(){
40
		return T_JavaLangString;
41
41
	}
42
	return "(String)\"" + this.value +"\""; } //$NON-NLS-2$ //$NON-NLS-1$
43
public int typeID() {
44
	return T_JavaLangString;
45
}
46
}
42
}
(-)compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java (-154 / +98 lines)
Lines 18-31 Link Here
18
public abstract class Constant implements TypeIds, OperatorIds {
18
public abstract class Constant implements TypeIds, OperatorIds {
19
19
20
	public static final Constant NotAConstant = DoubleConstant.fromValue(Double.NaN);
20
	public static final Constant NotAConstant = DoubleConstant.fromValue(Double.NaN);
21
21
	
22
	public boolean booleanValue() {
22
	public boolean booleanValue() {
23
24
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "boolean" })); //$NON-NLS-1$
23
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "boolean" })); //$NON-NLS-1$
25
	}
24
	}
26
25
27
	public byte byteValue() {
26
	public byte byteValue() {
28
29
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "byte" })); //$NON-NLS-1$
27
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "byte" })); //$NON-NLS-1$
30
	}
28
	}
31
29
Lines 195-211 Link Here
195
		    case (T_int<<4)+T_int  		 	 : return this;
193
		    case (T_int<<4)+T_int  		 	 : return this;
196
194
197
		}
195
		}
198
199
		return NotAConstant;
196
		return NotAConstant;
200
	}
197
	}
201
198
202
	public char charValue() {
199
	public char charValue() {
203
204
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "char" })); //$NON-NLS-1$
200
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "char" })); //$NON-NLS-1$
205
	}
201
	}
206
202
207
	public static final Constant computeConstantOperation(Constant cst, int id, int operator) {
203
	public static final Constant computeConstantOperation(Constant cst, int id, int operator) {
208
209
		switch (operator) {
204
		switch (operator) {
210
			case NOT	:
205
			case NOT	:
211
							return BooleanConstant.fromValue(!cst.booleanValue());
206
							return BooleanConstant.fromValue(!cst.booleanValue());
Lines 245-251 Link Here
245
	}
240
	}
246
241
247
	public static final Constant computeConstantOperation(Constant left, int leftId, int operator, Constant right, int rightId) {
242
	public static final Constant computeConstantOperation(Constant left, int leftId, int operator, Constant right, int rightId) {
248
249
		switch (operator) {
243
		switch (operator) {
250
			case AND		: return computeConstantOperationAND		(left,leftId,right,rightId);
244
			case AND		: return computeConstantOperationAND		(left,leftId,right,rightId);
251
			case AND_AND	: return computeConstantOperationAND_AND	(left,leftId,right,rightId);
245
			case AND_AND	: return computeConstantOperationAND_AND	(left,leftId,right,rightId);
Lines 264-276 Link Here
264
			case RIGHT_SHIFT: return computeConstantOperationRIGHT_SHIFT(left,leftId,right,rightId);
258
			case RIGHT_SHIFT: return computeConstantOperationRIGHT_SHIFT(left,leftId,right,rightId);
265
			case UNSIGNED_RIGHT_SHIFT: return computeConstantOperationUNSIGNED_RIGHT_SHIFT(left,leftId,right,rightId);
259
			case UNSIGNED_RIGHT_SHIFT: return computeConstantOperationUNSIGNED_RIGHT_SHIFT(left,leftId,right,rightId);
266
			case XOR		: return computeConstantOperationXOR		(left,leftId,right,rightId);
260
			case XOR		: return computeConstantOperationXOR		(left,leftId,right,rightId);
267
268
			default : return NotAConstant;
261
			default : return NotAConstant;
269
		}
262
		}
270
	}
263
	}
271
264
272
	public static final Constant computeConstantOperationAND(Constant left, int leftId, Constant right, int rightId) {
265
	public static final Constant computeConstantOperationAND(Constant left, int leftId, Constant right, int rightId) {
273
274
		switch (leftId){
266
		switch (leftId){
275
			case T_boolean :		return BooleanConstant.fromValue(left.booleanValue() & right.booleanValue());
267
			case T_boolean :		return BooleanConstant.fromValue(left.booleanValue() & right.booleanValue());
276
			case T_char :
268
			case T_char :
Lines 281-287 Link Here
281
					case T_int:		return IntConstant.fromValue(left.charValue() & right.intValue());
273
					case T_int:		return IntConstant.fromValue(left.charValue() & right.intValue());
282
					case T_long:	return LongConstant.fromValue(left.charValue() & right.longValue());
274
					case T_long:	return LongConstant.fromValue(left.charValue() & right.longValue());
283
				}
275
				}
284
			break;
276
				break;
285
			case T_byte :
277
			case T_byte :
286
				switch (rightId){
278
				switch (rightId){
287
					case T_char :	return IntConstant.fromValue(left.byteValue() & right.charValue());
279
					case T_char :	return IntConstant.fromValue(left.byteValue() & right.charValue());
Lines 290-296 Link Here
290
					case T_int:		return IntConstant.fromValue(left.byteValue() & right.intValue());
282
					case T_int:		return IntConstant.fromValue(left.byteValue() & right.intValue());
291
					case T_long:	return LongConstant.fromValue(left.byteValue() & right.longValue());
283
					case T_long:	return LongConstant.fromValue(left.byteValue() & right.longValue());
292
				}
284
				}
293
			break;
285
				break;
294
			case T_short :
286
			case T_short :
295
				switch (rightId){
287
				switch (rightId){
296
					case T_char :	return IntConstant.fromValue(left.shortValue() & right.charValue());
288
					case T_char :	return IntConstant.fromValue(left.shortValue() & right.charValue());
Lines 299-305 Link Here
299
					case T_int:		return IntConstant.fromValue(left.shortValue() & right.intValue());
291
					case T_int:		return IntConstant.fromValue(left.shortValue() & right.intValue());
300
					case T_long:	return LongConstant.fromValue(left.shortValue() & right.longValue());
292
					case T_long:	return LongConstant.fromValue(left.shortValue() & right.longValue());
301
				}
293
				}
302
			break;
294
				break;
303
			case T_int :
295
			case T_int :
304
				switch (rightId){
296
				switch (rightId){
305
					case T_char :	return IntConstant.fromValue(left.intValue() & right.charValue());
297
					case T_char :	return IntConstant.fromValue(left.intValue() & right.charValue());
Lines 308-314 Link Here
308
					case T_int:		return IntConstant.fromValue(left.intValue() & right.intValue());
300
					case T_int:		return IntConstant.fromValue(left.intValue() & right.intValue());
309
					case T_long:	return LongConstant.fromValue(left.intValue() & right.longValue());
301
					case T_long:	return LongConstant.fromValue(left.intValue() & right.longValue());
310
				}
302
				}
311
			break;
303
				break;
312
			case T_long :
304
			case T_long :
313
				switch (rightId){
305
				switch (rightId){
314
					case T_char :	return LongConstant.fromValue(left.longValue() & right.charValue());
306
					case T_char :	return LongConstant.fromValue(left.longValue() & right.charValue());
Lines 317-335 Link Here
317
					case T_int:		return LongConstant.fromValue(left.longValue() & right.intValue());
309
					case T_int:		return LongConstant.fromValue(left.longValue() & right.intValue());
318
					case T_long:	return LongConstant.fromValue(left.longValue() & right.longValue());
310
					case T_long:	return LongConstant.fromValue(left.longValue() & right.longValue());
319
				}
311
				}
320
			}
312
		}
321
322
		return NotAConstant;
313
		return NotAConstant;
323
	}
314
	}
324
315
325
	public static final Constant computeConstantOperationAND_AND(Constant left, int leftId, Constant right, int rightId) {
316
	public static final Constant computeConstantOperationAND_AND(Constant left, int leftId, Constant right, int rightId) {
326
327
		return BooleanConstant.fromValue(left.booleanValue() && right.booleanValue());
317
		return BooleanConstant.fromValue(left.booleanValue() && right.booleanValue());
328
	}
318
	}
329
319
330
	public static final Constant computeConstantOperationDIVIDE(Constant left, int leftId, Constant right, int rightId) {
320
	public static final Constant computeConstantOperationDIVIDE(Constant left, int leftId, Constant right, int rightId) {
331
		// division by zero must be handled outside this method (error reporting)
321
		// division by zero must be handled outside this method (error reporting)
332
333
		switch (leftId){
322
		switch (leftId){
334
			case T_char :
323
			case T_char :
335
				switch (rightId){
324
				switch (rightId){
Lines 341-347 Link Here
341
					case T_int:		return IntConstant.fromValue(left.charValue() / right.intValue());
330
					case T_int:		return IntConstant.fromValue(left.charValue() / right.intValue());
342
					case T_long:	return LongConstant.fromValue(left.charValue() / right.longValue());
331
					case T_long:	return LongConstant.fromValue(left.charValue() / right.longValue());
343
				}
332
				}
344
			break;
333
				break;
345
			case T_float :
334
			case T_float :
346
				switch (rightId){
335
				switch (rightId){
347
					case T_char :	return FloatConstant.fromValue(left.floatValue() / right.charValue());
336
					case T_char :	return FloatConstant.fromValue(left.floatValue() / right.charValue());
Lines 352-358 Link Here
352
					case T_int:		return FloatConstant.fromValue(left.floatValue() / right.intValue());
341
					case T_int:		return FloatConstant.fromValue(left.floatValue() / right.intValue());
353
					case T_long:	return FloatConstant.fromValue(left.floatValue() / right.longValue());
342
					case T_long:	return FloatConstant.fromValue(left.floatValue() / right.longValue());
354
				}
343
				}
355
			break;
344
				break;
356
			case T_double :
345
			case T_double :
357
				switch (rightId){
346
				switch (rightId){
358
					case T_char :	return DoubleConstant.fromValue(left.doubleValue() / right.charValue());
347
					case T_char :	return DoubleConstant.fromValue(left.doubleValue() / right.charValue());
Lines 363-369 Link Here
363
					case T_int:		return DoubleConstant.fromValue(left.doubleValue() / right.intValue());
352
					case T_int:		return DoubleConstant.fromValue(left.doubleValue() / right.intValue());
364
					case T_long:	return DoubleConstant.fromValue(left.doubleValue() / right.longValue());
353
					case T_long:	return DoubleConstant.fromValue(left.doubleValue() / right.longValue());
365
				}
354
				}
366
			break;
355
				break;
367
			case T_byte :
356
			case T_byte :
368
				switch (rightId){
357
				switch (rightId){
369
					case T_char :	return IntConstant.fromValue(left.byteValue() / right.charValue());
358
					case T_char :	return IntConstant.fromValue(left.byteValue() / right.charValue());
Lines 374-380 Link Here
374
					case T_int:		return IntConstant.fromValue(left.byteValue() / right.intValue());
363
					case T_int:		return IntConstant.fromValue(left.byteValue() / right.intValue());
375
					case T_long:	return LongConstant.fromValue(left.byteValue() / right.longValue());
364
					case T_long:	return LongConstant.fromValue(left.byteValue() / right.longValue());
376
				}
365
				}
377
			break;
366
				break;
378
			case T_short :
367
			case T_short :
379
				switch (rightId){
368
				switch (rightId){
380
					case T_char :	return IntConstant.fromValue(left.shortValue() / right.charValue());
369
					case T_char :	return IntConstant.fromValue(left.shortValue() / right.charValue());
Lines 385-391 Link Here
385
					case T_int:		return IntConstant.fromValue(left.shortValue() / right.intValue());
374
					case T_int:		return IntConstant.fromValue(left.shortValue() / right.intValue());
386
					case T_long:	return LongConstant.fromValue(left.shortValue() / right.longValue());
375
					case T_long:	return LongConstant.fromValue(left.shortValue() / right.longValue());
387
				}
376
				}
388
			break;
377
				break;
389
			case T_int :
378
			case T_int :
390
				switch (rightId){
379
				switch (rightId){
391
					case T_char :	return IntConstant.fromValue(left.intValue() / right.charValue());
380
					case T_char :	return IntConstant.fromValue(left.intValue() / right.charValue());
Lines 396-402 Link Here
396
					case T_int:		return IntConstant.fromValue(left.intValue() / right.intValue());
385
					case T_int:		return IntConstant.fromValue(left.intValue() / right.intValue());
397
					case T_long:	return LongConstant.fromValue(left.intValue() / right.longValue());
386
					case T_long:	return LongConstant.fromValue(left.intValue() / right.longValue());
398
				}
387
				}
399
			break;
388
				break;
400
			case T_long :
389
			case T_long :
401
				switch (rightId){
390
				switch (rightId){
402
					case T_char :	return LongConstant.fromValue(left.longValue() / right.charValue());
391
					case T_char :	return LongConstant.fromValue(left.longValue() / right.charValue());
Lines 407-426 Link Here
407
					case T_int:		return LongConstant.fromValue(left.longValue() / right.intValue());
396
					case T_int:		return LongConstant.fromValue(left.longValue() / right.intValue());
408
					case T_long:	return LongConstant.fromValue(left.longValue() / right.longValue());
397
					case T_long:	return LongConstant.fromValue(left.longValue() / right.longValue());
409
				}
398
				}
410
399
		}
411
			}
412
413
		return NotAConstant;
400
		return NotAConstant;
414
	}
401
	}
415
402
416
	public static final Constant computeConstantOperationEQUAL_EQUAL(Constant left, int leftId, Constant right, int rightId) {
403
	public static final Constant computeConstantOperationEQUAL_EQUAL(Constant left, int leftId, Constant right, int rightId) {
417
418
		switch (leftId){
404
		switch (leftId){
419
			case T_boolean :
405
			case T_boolean :
420
				if (rightId == T_boolean) {
406
				if (rightId == T_boolean) {
421
					return BooleanConstant.fromValue(left.booleanValue() == right.booleanValue());
407
					return BooleanConstant.fromValue(left.booleanValue() == right.booleanValue());
422
				}
408
				}
423
			break;
409
				break;
424
			case T_char :
410
			case T_char :
425
				switch (rightId){
411
				switch (rightId){
426
					case T_char :	return BooleanConstant.fromValue(left.charValue() == right.charValue());
412
					case T_char :	return BooleanConstant.fromValue(left.charValue() == right.charValue());
Lines 430-436 Link Here
430
					case T_short:	return BooleanConstant.fromValue(left.charValue() == right.shortValue());
416
					case T_short:	return BooleanConstant.fromValue(left.charValue() == right.shortValue());
431
					case T_int:		return BooleanConstant.fromValue(left.charValue() == right.intValue());
417
					case T_int:		return BooleanConstant.fromValue(left.charValue() == right.intValue());
432
					case T_long:	return BooleanConstant.fromValue(left.charValue() == right.longValue());}
418
					case T_long:	return BooleanConstant.fromValue(left.charValue() == right.longValue());}
433
			break;
419
				break;
434
			case T_float :
420
			case T_float :
435
				switch (rightId){
421
				switch (rightId){
436
					case T_char :	return BooleanConstant.fromValue(left.floatValue() == right.charValue());
422
					case T_char :	return BooleanConstant.fromValue(left.floatValue() == right.charValue());
Lines 441-447 Link Here
441
					case T_int:		return BooleanConstant.fromValue(left.floatValue() == right.intValue());
427
					case T_int:		return BooleanConstant.fromValue(left.floatValue() == right.intValue());
442
					case T_long:	return BooleanConstant.fromValue(left.floatValue() == right.longValue());
428
					case T_long:	return BooleanConstant.fromValue(left.floatValue() == right.longValue());
443
				}
429
				}
444
			break;
430
				break;
445
			case T_double :
431
			case T_double :
446
				switch (rightId){
432
				switch (rightId){
447
					case T_char :	return BooleanConstant.fromValue(left.doubleValue() == right.charValue());
433
					case T_char :	return BooleanConstant.fromValue(left.doubleValue() == right.charValue());
Lines 452-458 Link Here
452
					case T_int:		return BooleanConstant.fromValue(left.doubleValue() == right.intValue());
438
					case T_int:		return BooleanConstant.fromValue(left.doubleValue() == right.intValue());
453
					case T_long:	return BooleanConstant.fromValue(left.doubleValue() == right.longValue());
439
					case T_long:	return BooleanConstant.fromValue(left.doubleValue() == right.longValue());
454
				}
440
				}
455
			break;
441
				break;
456
			case T_byte :
442
			case T_byte :
457
				switch (rightId){
443
				switch (rightId){
458
					case T_char :	return BooleanConstant.fromValue(left.byteValue() == right.charValue());
444
					case T_char :	return BooleanConstant.fromValue(left.byteValue() == right.charValue());
Lines 463-469 Link Here
463
					case T_int:		return BooleanConstant.fromValue(left.byteValue() == right.intValue());
449
					case T_int:		return BooleanConstant.fromValue(left.byteValue() == right.intValue());
464
					case T_long:	return BooleanConstant.fromValue(left.byteValue() == right.longValue());
450
					case T_long:	return BooleanConstant.fromValue(left.byteValue() == right.longValue());
465
				}
451
				}
466
			break;
452
				break;
467
			case T_short :
453
			case T_short :
468
				switch (rightId){
454
				switch (rightId){
469
					case T_char :	return BooleanConstant.fromValue(left.shortValue() == right.charValue());
455
					case T_char :	return BooleanConstant.fromValue(left.shortValue() == right.charValue());
Lines 474-480 Link Here
474
					case T_int:		return BooleanConstant.fromValue(left.shortValue() == right.intValue());
460
					case T_int:		return BooleanConstant.fromValue(left.shortValue() == right.intValue());
475
					case T_long:	return BooleanConstant.fromValue(left.shortValue() == right.longValue());
461
					case T_long:	return BooleanConstant.fromValue(left.shortValue() == right.longValue());
476
				}
462
				}
477
			break;
463
				break;
478
			case T_int :
464
			case T_int :
479
				switch (rightId){
465
				switch (rightId){
480
					case T_char :	return BooleanConstant.fromValue(left.intValue() == right.charValue());
466
					case T_char :	return BooleanConstant.fromValue(left.intValue() == right.charValue());
Lines 485-491 Link Here
485
					case T_int:		return BooleanConstant.fromValue(left.intValue() == right.intValue());
471
					case T_int:		return BooleanConstant.fromValue(left.intValue() == right.intValue());
486
					case T_long:	return BooleanConstant.fromValue(left.intValue() == right.longValue());
472
					case T_long:	return BooleanConstant.fromValue(left.intValue() == right.longValue());
487
				}
473
				}
488
			break;
474
				break;
489
			case T_long :
475
			case T_long :
490
				switch (rightId){
476
				switch (rightId){
491
					case T_char :	return BooleanConstant.fromValue(left.longValue() == right.charValue());
477
					case T_char :	return BooleanConstant.fromValue(left.longValue() == right.charValue());
Lines 496-509 Link Here
496
					case T_int:		return BooleanConstant.fromValue(left.longValue() == right.intValue());
482
					case T_int:		return BooleanConstant.fromValue(left.longValue() == right.intValue());
497
					case T_long:	return BooleanConstant.fromValue(left.longValue() == right.longValue());
483
					case T_long:	return BooleanConstant.fromValue(left.longValue() == right.longValue());
498
				}
484
				}
499
			break;
485
				break;
500
			case T_JavaLangString :
486
			case T_JavaLangString :
501
				if (rightId == T_JavaLangString) {
487
				if (rightId == T_JavaLangString) {
502
					//String are interned in th compiler==>thus if two string constant
488
					//String are interned in th compiler==>thus if two string constant
503
					//get to be compared, it is an equal on the vale which is done
489
					//get to be compared, it is an equal on the vale which is done
504
					return BooleanConstant.fromValue(((StringConstant)left).hasSameValue(right));
490
					return BooleanConstant.fromValue(((StringConstant)left).hasSameValue(right));
505
				}
491
				}
506
			break;
492
				break;
507
			case T_null :
493
			case T_null :
508
				if (rightId == T_JavaLangString) {
494
				if (rightId == T_JavaLangString) {
509
					return BooleanConstant.fromValue(false);
495
					return BooleanConstant.fromValue(false);
Lines 512-524 Link Here
512
						return BooleanConstant.fromValue(true);
498
						return BooleanConstant.fromValue(true);
513
					}
499
					}
514
				}
500
				}
515
			}
501
		}
516
517
		return BooleanConstant.fromValue(false);
502
		return BooleanConstant.fromValue(false);
518
	}
503
	}
519
504
520
	public static final Constant computeConstantOperationGREATER(Constant left, int leftId, Constant right, int rightId) {
505
	public static final Constant computeConstantOperationGREATER(Constant left, int leftId, Constant right, int rightId) {
521
522
		switch (leftId){
506
		switch (leftId){
523
			case T_char :
507
			case T_char :
524
				switch (rightId){
508
				switch (rightId){
Lines 530-536 Link Here
530
					case T_int:		return BooleanConstant.fromValue(left.charValue() > right.intValue());
514
					case T_int:		return BooleanConstant.fromValue(left.charValue() > right.intValue());
531
					case T_long:	return BooleanConstant.fromValue(left.charValue() > right.longValue());
515
					case T_long:	return BooleanConstant.fromValue(left.charValue() > right.longValue());
532
				}
516
				}
533
			break;
517
				break;
534
			case T_float :
518
			case T_float :
535
				switch (rightId){
519
				switch (rightId){
536
					case T_char :	return BooleanConstant.fromValue(left.floatValue() > right.charValue());
520
					case T_char :	return BooleanConstant.fromValue(left.floatValue() > right.charValue());
Lines 541-547 Link Here
541
					case T_int:		return BooleanConstant.fromValue(left.floatValue() > right.intValue());
525
					case T_int:		return BooleanConstant.fromValue(left.floatValue() > right.intValue());
542
					case T_long:	return BooleanConstant.fromValue(left.floatValue() > right.longValue());
526
					case T_long:	return BooleanConstant.fromValue(left.floatValue() > right.longValue());
543
				}
527
				}
544
			break;
528
				break;
545
			case T_double :
529
			case T_double :
546
				switch (rightId){
530
				switch (rightId){
547
					case T_char :	return BooleanConstant.fromValue(left.doubleValue() > right.charValue());
531
					case T_char :	return BooleanConstant.fromValue(left.doubleValue() > right.charValue());
Lines 552-558 Link Here
552
					case T_int:		return BooleanConstant.fromValue(left.doubleValue() > right.intValue());
536
					case T_int:		return BooleanConstant.fromValue(left.doubleValue() > right.intValue());
553
					case T_long:	return BooleanConstant.fromValue(left.doubleValue() > right.longValue());
537
					case T_long:	return BooleanConstant.fromValue(left.doubleValue() > right.longValue());
554
				}
538
				}
555
			break;
539
				break;
556
			case T_byte :
540
			case T_byte :
557
				switch (rightId){
541
				switch (rightId){
558
					case T_char :	return BooleanConstant.fromValue(left.byteValue() > right.charValue());
542
					case T_char :	return BooleanConstant.fromValue(left.byteValue() > right.charValue());
Lines 563-569 Link Here
563
					case T_int:		return BooleanConstant.fromValue(left.byteValue() > right.intValue());
547
					case T_int:		return BooleanConstant.fromValue(left.byteValue() > right.intValue());
564
					case T_long:	return BooleanConstant.fromValue(left.byteValue() > right.longValue());
548
					case T_long:	return BooleanConstant.fromValue(left.byteValue() > right.longValue());
565
				}
549
				}
566
			break;
550
				break;
567
			case T_short :
551
			case T_short :
568
				switch (rightId){
552
				switch (rightId){
569
					case T_char :	return BooleanConstant.fromValue(left.shortValue() > right.charValue());
553
					case T_char :	return BooleanConstant.fromValue(left.shortValue() > right.charValue());
Lines 574-580 Link Here
574
					case T_int:		return BooleanConstant.fromValue(left.shortValue() > right.intValue());
558
					case T_int:		return BooleanConstant.fromValue(left.shortValue() > right.intValue());
575
					case T_long:	return BooleanConstant.fromValue(left.shortValue() > right.longValue());
559
					case T_long:	return BooleanConstant.fromValue(left.shortValue() > right.longValue());
576
				}
560
				}
577
			break;
561
				break;
578
			case T_int :
562
			case T_int :
579
				switch (rightId){
563
				switch (rightId){
580
					case T_char :	return BooleanConstant.fromValue(left.intValue() > right.charValue());
564
					case T_char :	return BooleanConstant.fromValue(left.intValue() > right.charValue());
Lines 585-591 Link Here
585
					case T_int:		return BooleanConstant.fromValue(left.intValue() > right.intValue());
569
					case T_int:		return BooleanConstant.fromValue(left.intValue() > right.intValue());
586
					case T_long:	return BooleanConstant.fromValue(left.intValue() > right.longValue());
570
					case T_long:	return BooleanConstant.fromValue(left.intValue() > right.longValue());
587
				}
571
				}
588
			break;
572
				break;
589
			case T_long :
573
			case T_long :
590
				switch (rightId){
574
				switch (rightId){
591
					case T_char :	return BooleanConstant.fromValue(left.longValue() > right.charValue());
575
					case T_char :	return BooleanConstant.fromValue(left.longValue() > right.charValue());
Lines 597-609 Link Here
597
					case T_long:	return BooleanConstant.fromValue(left.longValue() > right.longValue());
581
					case T_long:	return BooleanConstant.fromValue(left.longValue() > right.longValue());
598
				}
582
				}
599
583
600
			}
584
		}
601
602
		return NotAConstant;
585
		return NotAConstant;
603
	}
586
	}
604
587
605
	public static final Constant computeConstantOperationGREATER_EQUAL(Constant left, int leftId, Constant right, int rightId) {
588
	public static final Constant computeConstantOperationGREATER_EQUAL(Constant left, int leftId, Constant right, int rightId) {
606
607
		switch (leftId){
589
		switch (leftId){
608
			case T_char :
590
			case T_char :
609
				switch (rightId){
591
				switch (rightId){
Lines 615-621 Link Here
615
					case T_int:		return BooleanConstant.fromValue(left.charValue() >= right.intValue());
597
					case T_int:		return BooleanConstant.fromValue(left.charValue() >= right.intValue());
616
					case T_long:	return BooleanConstant.fromValue(left.charValue() >= right.longValue());
598
					case T_long:	return BooleanConstant.fromValue(left.charValue() >= right.longValue());
617
				}
599
				}
618
			break;
600
				break;
619
			case T_float :
601
			case T_float :
620
				switch (rightId){
602
				switch (rightId){
621
					case T_char :	return BooleanConstant.fromValue(left.floatValue() >= right.charValue());
603
					case T_char :	return BooleanConstant.fromValue(left.floatValue() >= right.charValue());
Lines 626-632 Link Here
626
					case T_int:		return BooleanConstant.fromValue(left.floatValue() >= right.intValue());
608
					case T_int:		return BooleanConstant.fromValue(left.floatValue() >= right.intValue());
627
					case T_long:	return BooleanConstant.fromValue(left.floatValue() >= right.longValue());
609
					case T_long:	return BooleanConstant.fromValue(left.floatValue() >= right.longValue());
628
				}
610
				}
629
			break;
611
				break;
630
			case T_double :
612
			case T_double :
631
				switch (rightId){
613
				switch (rightId){
632
					case T_char :	return BooleanConstant.fromValue(left.doubleValue() >= right.charValue());
614
					case T_char :	return BooleanConstant.fromValue(left.doubleValue() >= right.charValue());
Lines 637-643 Link Here
637
					case T_int:		return BooleanConstant.fromValue(left.doubleValue() >= right.intValue());
619
					case T_int:		return BooleanConstant.fromValue(left.doubleValue() >= right.intValue());
638
					case T_long:	return BooleanConstant.fromValue(left.doubleValue() >= right.longValue());
620
					case T_long:	return BooleanConstant.fromValue(left.doubleValue() >= right.longValue());
639
				}
621
				}
640
			break;
622
				break;
641
			case T_byte :
623
			case T_byte :
642
				switch (rightId){
624
				switch (rightId){
643
					case T_char :	return BooleanConstant.fromValue(left.byteValue() >= right.charValue());
625
					case T_char :	return BooleanConstant.fromValue(left.byteValue() >= right.charValue());
Lines 648-654 Link Here
648
					case T_int:		return BooleanConstant.fromValue(left.byteValue() >= right.intValue());
630
					case T_int:		return BooleanConstant.fromValue(left.byteValue() >= right.intValue());
649
					case T_long:	return BooleanConstant.fromValue(left.byteValue() >= right.longValue());
631
					case T_long:	return BooleanConstant.fromValue(left.byteValue() >= right.longValue());
650
				}
632
				}
651
			break;
633
				break;
652
			case T_short :
634
			case T_short :
653
				switch (rightId){
635
				switch (rightId){
654
					case T_char :	return BooleanConstant.fromValue(left.shortValue() >= right.charValue());
636
					case T_char :	return BooleanConstant.fromValue(left.shortValue() >= right.charValue());
Lines 659-665 Link Here
659
					case T_int:		return BooleanConstant.fromValue(left.shortValue() >= right.intValue());
641
					case T_int:		return BooleanConstant.fromValue(left.shortValue() >= right.intValue());
660
					case T_long:	return BooleanConstant.fromValue(left.shortValue() >= right.longValue());
642
					case T_long:	return BooleanConstant.fromValue(left.shortValue() >= right.longValue());
661
				}
643
				}
662
			break;
644
				break;
663
			case T_int :
645
			case T_int :
664
				switch (rightId){
646
				switch (rightId){
665
					case T_char :	return BooleanConstant.fromValue(left.intValue() >= right.charValue());
647
					case T_char :	return BooleanConstant.fromValue(left.intValue() >= right.charValue());
Lines 670-676 Link Here
670
					case T_int:		return BooleanConstant.fromValue(left.intValue() >= right.intValue());
652
					case T_int:		return BooleanConstant.fromValue(left.intValue() >= right.intValue());
671
					case T_long:	return BooleanConstant.fromValue(left.intValue() >= right.longValue());
653
					case T_long:	return BooleanConstant.fromValue(left.intValue() >= right.longValue());
672
				}
654
				}
673
			break;
655
				break;
674
			case T_long :
656
			case T_long :
675
				switch (rightId){
657
				switch (rightId){
676
					case T_char :	return BooleanConstant.fromValue(left.longValue() >= right.charValue());
658
					case T_char :	return BooleanConstant.fromValue(left.longValue() >= right.charValue());
Lines 681-694 Link Here
681
					case T_int:		return BooleanConstant.fromValue(left.longValue() >= right.intValue());
663
					case T_int:		return BooleanConstant.fromValue(left.longValue() >= right.intValue());
682
					case T_long:	return BooleanConstant.fromValue(left.longValue() >= right.longValue());
664
					case T_long:	return BooleanConstant.fromValue(left.longValue() >= right.longValue());
683
				}
665
				}
684
666
		}
685
			}
686
687
		return NotAConstant;
667
		return NotAConstant;
688
	}
668
	}
689
669
690
	public static final Constant computeConstantOperationLEFT_SHIFT(Constant left, int leftId, Constant right, int rightId) {
670
	public static final Constant computeConstantOperationLEFT_SHIFT(Constant left, int leftId, Constant right, int rightId) {
691
692
		switch (leftId){
671
		switch (leftId){
693
			case T_char :
672
			case T_char :
694
				switch (rightId){
673
				switch (rightId){
Lines 698-704 Link Here
698
					case T_int:		return IntConstant.fromValue(left.charValue() << right.intValue());
677
					case T_int:		return IntConstant.fromValue(left.charValue() << right.intValue());
699
					case T_long:	return IntConstant.fromValue(left.charValue() << right.longValue());
678
					case T_long:	return IntConstant.fromValue(left.charValue() << right.longValue());
700
				}
679
				}
701
			break;
680
				break;
702
			case T_byte :
681
			case T_byte :
703
				switch (rightId){
682
				switch (rightId){
704
					case T_char :	return IntConstant.fromValue(left.byteValue() << right.charValue());
683
					case T_char :	return IntConstant.fromValue(left.byteValue() << right.charValue());
Lines 707-713 Link Here
707
					case T_int:		return IntConstant.fromValue(left.byteValue() << right.intValue());
686
					case T_int:		return IntConstant.fromValue(left.byteValue() << right.intValue());
708
					case T_long:	return IntConstant.fromValue(left.byteValue() << right.longValue());
687
					case T_long:	return IntConstant.fromValue(left.byteValue() << right.longValue());
709
				}
688
				}
710
			break;
689
				break;
711
			case T_short :
690
			case T_short :
712
				switch (rightId){
691
				switch (rightId){
713
					case T_char :	return IntConstant.fromValue(left.shortValue() << right.charValue());
692
					case T_char :	return IntConstant.fromValue(left.shortValue() << right.charValue());
Lines 716-722 Link Here
716
					case T_int:		return IntConstant.fromValue(left.shortValue() << right.intValue());
695
					case T_int:		return IntConstant.fromValue(left.shortValue() << right.intValue());
717
					case T_long:	return IntConstant.fromValue(left.shortValue() << right.longValue());
696
					case T_long:	return IntConstant.fromValue(left.shortValue() << right.longValue());
718
				}
697
				}
719
			break;
698
				break;
720
			case T_int :
699
			case T_int :
721
				switch (rightId){
700
				switch (rightId){
722
					case T_char :	return IntConstant.fromValue(left.intValue() << right.charValue());
701
					case T_char :	return IntConstant.fromValue(left.intValue() << right.charValue());
Lines 725-731 Link Here
725
					case T_int:		return IntConstant.fromValue(left.intValue() << right.intValue());
704
					case T_int:		return IntConstant.fromValue(left.intValue() << right.intValue());
726
					case T_long:	return IntConstant.fromValue(left.intValue() << right.longValue());
705
					case T_long:	return IntConstant.fromValue(left.intValue() << right.longValue());
727
				}
706
				}
728
			break;
707
				break;
729
			case T_long :
708
			case T_long :
730
				switch (rightId){
709
				switch (rightId){
731
					case T_char :	return LongConstant.fromValue(left.longValue() << right.charValue());
710
					case T_char :	return LongConstant.fromValue(left.longValue() << right.charValue());
Lines 734-747 Link Here
734
					case T_int:		return LongConstant.fromValue(left.longValue() << right.intValue());
713
					case T_int:		return LongConstant.fromValue(left.longValue() << right.intValue());
735
					case T_long:	return LongConstant.fromValue(left.longValue() << right.longValue());
714
					case T_long:	return LongConstant.fromValue(left.longValue() << right.longValue());
736
				}
715
				}
737
716
		}
738
			}
739
740
		return NotAConstant;
717
		return NotAConstant;
741
	}
718
	}
742
719
743
	public static final Constant computeConstantOperationLESS(Constant left, int leftId, Constant right, int rightId) {
720
	public static final Constant computeConstantOperationLESS(Constant left, int leftId, Constant right, int rightId) {
744
745
		switch (leftId){
721
		switch (leftId){
746
			case T_char :
722
			case T_char :
747
				switch (rightId){
723
				switch (rightId){
Lines 753-759 Link Here
753
					case T_int:		return BooleanConstant.fromValue(left.charValue() < right.intValue());
729
					case T_int:		return BooleanConstant.fromValue(left.charValue() < right.intValue());
754
					case T_long:	return BooleanConstant.fromValue(left.charValue() < right.longValue());
730
					case T_long:	return BooleanConstant.fromValue(left.charValue() < right.longValue());
755
				}
731
				}
756
			break;
732
				break;
757
			case T_float :
733
			case T_float :
758
				switch (rightId){
734
				switch (rightId){
759
					case T_char :	return BooleanConstant.fromValue(left.floatValue() < right.charValue());
735
					case T_char :	return BooleanConstant.fromValue(left.floatValue() < right.charValue());
Lines 764-770 Link Here
764
					case T_int:		return BooleanConstant.fromValue(left.floatValue() < right.intValue());
740
					case T_int:		return BooleanConstant.fromValue(left.floatValue() < right.intValue());
765
					case T_long:	return BooleanConstant.fromValue(left.floatValue() < right.longValue());
741
					case T_long:	return BooleanConstant.fromValue(left.floatValue() < right.longValue());
766
				}
742
				}
767
			break;
743
				break;
768
			case T_double :
744
			case T_double :
769
				switch (rightId){
745
				switch (rightId){
770
					case T_char :	return BooleanConstant.fromValue(left.doubleValue() < right.charValue());
746
					case T_char :	return BooleanConstant.fromValue(left.doubleValue() < right.charValue());
Lines 775-781 Link Here
775
					case T_int:		return BooleanConstant.fromValue(left.doubleValue() < right.intValue());
751
					case T_int:		return BooleanConstant.fromValue(left.doubleValue() < right.intValue());
776
					case T_long:	return BooleanConstant.fromValue(left.doubleValue() < right.longValue());
752
					case T_long:	return BooleanConstant.fromValue(left.doubleValue() < right.longValue());
777
				}
753
				}
778
			break;
754
				break;
779
			case T_byte :
755
			case T_byte :
780
				switch (rightId){
756
				switch (rightId){
781
					case T_char :	return BooleanConstant.fromValue(left.byteValue() < right.charValue());
757
					case T_char :	return BooleanConstant.fromValue(left.byteValue() < right.charValue());
Lines 786-792 Link Here
786
					case T_int:		return BooleanConstant.fromValue(left.byteValue() < right.intValue());
762
					case T_int:		return BooleanConstant.fromValue(left.byteValue() < right.intValue());
787
					case T_long:	return BooleanConstant.fromValue(left.byteValue() < right.longValue());
763
					case T_long:	return BooleanConstant.fromValue(left.byteValue() < right.longValue());
788
				}
764
				}
789
			break;
765
				break;
790
			case T_short :
766
			case T_short :
791
				switch (rightId){
767
				switch (rightId){
792
					case T_char :	return BooleanConstant.fromValue(left.shortValue() < right.charValue());
768
					case T_char :	return BooleanConstant.fromValue(left.shortValue() < right.charValue());
Lines 797-803 Link Here
797
					case T_int:		return BooleanConstant.fromValue(left.shortValue() < right.intValue());
773
					case T_int:		return BooleanConstant.fromValue(left.shortValue() < right.intValue());
798
					case T_long:	return BooleanConstant.fromValue(left.shortValue() < right.longValue());
774
					case T_long:	return BooleanConstant.fromValue(left.shortValue() < right.longValue());
799
				}
775
				}
800
			break;
776
				break;
801
			case T_int :
777
			case T_int :
802
				switch (rightId){
778
				switch (rightId){
803
					case T_char :	return BooleanConstant.fromValue(left.intValue() < right.charValue());
779
					case T_char :	return BooleanConstant.fromValue(left.intValue() < right.charValue());
Lines 808-814 Link Here
808
					case T_int:		return BooleanConstant.fromValue(left.intValue() < right.intValue());
784
					case T_int:		return BooleanConstant.fromValue(left.intValue() < right.intValue());
809
					case T_long:	return BooleanConstant.fromValue(left.intValue() < right.longValue());
785
					case T_long:	return BooleanConstant.fromValue(left.intValue() < right.longValue());
810
				}
786
				}
811
			break;
787
				break;
812
			case T_long :
788
			case T_long :
813
				switch (rightId){
789
				switch (rightId){
814
					case T_char :	return BooleanConstant.fromValue(left.longValue() < right.charValue());
790
					case T_char :	return BooleanConstant.fromValue(left.longValue() < right.charValue());
Lines 819-832 Link Here
819
					case T_int:		return BooleanConstant.fromValue(left.longValue() < right.intValue());
795
					case T_int:		return BooleanConstant.fromValue(left.longValue() < right.intValue());
820
					case T_long:	return BooleanConstant.fromValue(left.longValue() < right.longValue());
796
					case T_long:	return BooleanConstant.fromValue(left.longValue() < right.longValue());
821
				}
797
				}
822
798
		}
823
			}
824
825
		return NotAConstant;
799
		return NotAConstant;
826
	}
800
	}
827
801
828
	public static final Constant computeConstantOperationLESS_EQUAL(Constant left, int leftId, Constant right, int rightId) {
802
	public static final Constant computeConstantOperationLESS_EQUAL(Constant left, int leftId, Constant right, int rightId) {
829
830
		switch (leftId){
803
		switch (leftId){
831
			case T_char :
804
			case T_char :
832
				switch (rightId){
805
				switch (rightId){
Lines 838-844 Link Here
838
					case T_int:		return BooleanConstant.fromValue(left.charValue() <= right.intValue());
811
					case T_int:		return BooleanConstant.fromValue(left.charValue() <= right.intValue());
839
					case T_long:	return BooleanConstant.fromValue(left.charValue() <= right.longValue());
812
					case T_long:	return BooleanConstant.fromValue(left.charValue() <= right.longValue());
840
				}
813
				}
841
			break;
814
				break;
842
			case T_float :
815
			case T_float :
843
				switch (rightId){
816
				switch (rightId){
844
					case T_char :	return BooleanConstant.fromValue(left.floatValue() <= right.charValue());
817
					case T_char :	return BooleanConstant.fromValue(left.floatValue() <= right.charValue());
Lines 849-855 Link Here
849
					case T_int:		return BooleanConstant.fromValue(left.floatValue() <= right.intValue());
822
					case T_int:		return BooleanConstant.fromValue(left.floatValue() <= right.intValue());
850
					case T_long:	return BooleanConstant.fromValue(left.floatValue() <= right.longValue());
823
					case T_long:	return BooleanConstant.fromValue(left.floatValue() <= right.longValue());
851
				}
824
				}
852
			break;
825
				break;
853
			case T_double :
826
			case T_double :
854
				switch (rightId){
827
				switch (rightId){
855
					case T_char :	return BooleanConstant.fromValue(left.doubleValue() <= right.charValue());
828
					case T_char :	return BooleanConstant.fromValue(left.doubleValue() <= right.charValue());
Lines 860-866 Link Here
860
					case T_int:		return BooleanConstant.fromValue(left.doubleValue() <= right.intValue());
833
					case T_int:		return BooleanConstant.fromValue(left.doubleValue() <= right.intValue());
861
					case T_long:	return BooleanConstant.fromValue(left.doubleValue() <= right.longValue());
834
					case T_long:	return BooleanConstant.fromValue(left.doubleValue() <= right.longValue());
862
				}
835
				}
863
			break;
836
				break;
864
			case T_byte :
837
			case T_byte :
865
				switch (rightId){
838
				switch (rightId){
866
					case T_char :	return BooleanConstant.fromValue(left.byteValue() <= right.charValue());
839
					case T_char :	return BooleanConstant.fromValue(left.byteValue() <= right.charValue());
Lines 871-877 Link Here
871
					case T_int:		return BooleanConstant.fromValue(left.byteValue() <= right.intValue());
844
					case T_int:		return BooleanConstant.fromValue(left.byteValue() <= right.intValue());
872
					case T_long:	return BooleanConstant.fromValue(left.byteValue() <= right.longValue());
845
					case T_long:	return BooleanConstant.fromValue(left.byteValue() <= right.longValue());
873
				}
846
				}
874
			break;
847
				break;
875
			case T_short :
848
			case T_short :
876
				switch (rightId){
849
				switch (rightId){
877
					case T_char :	return BooleanConstant.fromValue(left.shortValue() <= right.charValue());
850
					case T_char :	return BooleanConstant.fromValue(left.shortValue() <= right.charValue());
Lines 893-899 Link Here
893
					case T_int:		return BooleanConstant.fromValue(left.intValue() <= right.intValue());
866
					case T_int:		return BooleanConstant.fromValue(left.intValue() <= right.intValue());
894
					case T_long:	return BooleanConstant.fromValue(left.intValue() <= right.longValue());
867
					case T_long:	return BooleanConstant.fromValue(left.intValue() <= right.longValue());
895
				}
868
				}
896
			break;
869
				break;
897
			case T_long :
870
			case T_long :
898
				switch (rightId){
871
				switch (rightId){
899
					case T_char :	return BooleanConstant.fromValue(left.longValue() <= right.charValue());
872
					case T_char :	return BooleanConstant.fromValue(left.longValue() <= right.charValue());
Lines 904-916 Link Here
904
					case T_int:		return BooleanConstant.fromValue(left.longValue() <= right.intValue());
877
					case T_int:		return BooleanConstant.fromValue(left.longValue() <= right.intValue());
905
					case T_long:	return BooleanConstant.fromValue(left.longValue() <= right.longValue());
878
					case T_long:	return BooleanConstant.fromValue(left.longValue() <= right.longValue());
906
				}
879
				}
907
			}
880
		}
908
909
		return NotAConstant;
881
		return NotAConstant;
910
	}
882
	}
911
883
912
	public static final Constant computeConstantOperationMINUS(Constant left, int leftId, Constant right, int rightId) {
884
	public static final Constant computeConstantOperationMINUS(Constant left, int leftId, Constant right, int rightId) {
913
914
		switch (leftId){
885
		switch (leftId){
915
			case T_char :
886
			case T_char :
916
				switch (rightId){
887
				switch (rightId){
Lines 922-928 Link Here
922
					case T_int:		return IntConstant.fromValue(left.charValue() - right.intValue());
893
					case T_int:		return IntConstant.fromValue(left.charValue() - right.intValue());
923
					case T_long:	return LongConstant.fromValue(left.charValue() - right.longValue());
894
					case T_long:	return LongConstant.fromValue(left.charValue() - right.longValue());
924
				}
895
				}
925
			break;
896
				break;
926
			case T_float :
897
			case T_float :
927
				switch (rightId){
898
				switch (rightId){
928
					case T_char :	return FloatConstant.fromValue(left.floatValue() - right.charValue());
899
					case T_char :	return FloatConstant.fromValue(left.floatValue() - right.charValue());
Lines 933-939 Link Here
933
					case T_int:		return FloatConstant.fromValue(left.floatValue() - right.intValue());
904
					case T_int:		return FloatConstant.fromValue(left.floatValue() - right.intValue());
934
					case T_long:	return FloatConstant.fromValue(left.floatValue() - right.longValue());
905
					case T_long:	return FloatConstant.fromValue(left.floatValue() - right.longValue());
935
				}
906
				}
936
			break;
907
				break;
937
			case T_double :
908
			case T_double :
938
				switch (rightId){
909
				switch (rightId){
939
					case T_char :	return DoubleConstant.fromValue(left.doubleValue() - right.charValue());
910
					case T_char :	return DoubleConstant.fromValue(left.doubleValue() - right.charValue());
Lines 944-950 Link Here
944
					case T_int:		return DoubleConstant.fromValue(left.doubleValue() - right.intValue());
915
					case T_int:		return DoubleConstant.fromValue(left.doubleValue() - right.intValue());
945
					case T_long:	return DoubleConstant.fromValue(left.doubleValue() - right.longValue());
916
					case T_long:	return DoubleConstant.fromValue(left.doubleValue() - right.longValue());
946
				}
917
				}
947
			break;
918
				break;
948
			case T_byte :
919
			case T_byte :
949
				switch (rightId){
920
				switch (rightId){
950
					case T_char :	return IntConstant.fromValue(left.byteValue() - right.charValue());
921
					case T_char :	return IntConstant.fromValue(left.byteValue() - right.charValue());
Lines 955-961 Link Here
955
					case T_int:		return IntConstant.fromValue(left.byteValue() - right.intValue());
926
					case T_int:		return IntConstant.fromValue(left.byteValue() - right.intValue());
956
					case T_long:	return LongConstant.fromValue(left.byteValue() - right.longValue());
927
					case T_long:	return LongConstant.fromValue(left.byteValue() - right.longValue());
957
				}
928
				}
958
			break;
929
				break;
959
			case T_short :
930
			case T_short :
960
				switch (rightId){
931
				switch (rightId){
961
					case T_char :	return IntConstant.fromValue(left.shortValue() - right.charValue());
932
					case T_char :	return IntConstant.fromValue(left.shortValue() - right.charValue());
Lines 966-972 Link Here
966
					case T_int:		return IntConstant.fromValue(left.shortValue() - right.intValue());
937
					case T_int:		return IntConstant.fromValue(left.shortValue() - right.intValue());
967
					case T_long:	return LongConstant.fromValue(left.shortValue() - right.longValue());
938
					case T_long:	return LongConstant.fromValue(left.shortValue() - right.longValue());
968
				}
939
				}
969
			break;
940
				break;
970
			case T_int :
941
			case T_int :
971
				switch (rightId){
942
				switch (rightId){
972
					case T_char :	return IntConstant.fromValue(left.intValue() - right.charValue());
943
					case T_char :	return IntConstant.fromValue(left.intValue() - right.charValue());
Lines 977-983 Link Here
977
					case T_int:		return IntConstant.fromValue(left.intValue() - right.intValue());
948
					case T_int:		return IntConstant.fromValue(left.intValue() - right.intValue());
978
					case T_long:	return LongConstant.fromValue(left.intValue() - right.longValue());
949
					case T_long:	return LongConstant.fromValue(left.intValue() - right.longValue());
979
				}
950
				}
980
			break;
951
				break;
981
			case T_long :
952
			case T_long :
982
				switch (rightId){
953
				switch (rightId){
983
					case T_char :	return LongConstant.fromValue(left.longValue() - right.charValue());
954
					case T_char :	return LongConstant.fromValue(left.longValue() - right.charValue());
Lines 988-1001 Link Here
988
					case T_int:		return LongConstant.fromValue(left.longValue() - right.intValue());
959
					case T_int:		return LongConstant.fromValue(left.longValue() - right.intValue());
989
					case T_long:	return LongConstant.fromValue(left.longValue() - right.longValue());
960
					case T_long:	return LongConstant.fromValue(left.longValue() - right.longValue());
990
				}
961
				}
991
962
		}
992
			}
993
994
		return NotAConstant;
963
		return NotAConstant;
995
	}
964
	}
996
965
997
	public static final Constant computeConstantOperationMULTIPLY(Constant left, int leftId, Constant right, int rightId) {
966
	public static final Constant computeConstantOperationMULTIPLY(Constant left, int leftId, Constant right, int rightId) {
998
999
		switch (leftId){
967
		switch (leftId){
1000
			case T_char :
968
			case T_char :
1001
				switch (rightId){
969
				switch (rightId){
Lines 1007-1013 Link Here
1007
					case T_int:		return IntConstant.fromValue(left.charValue() * right.intValue());
975
					case T_int:		return IntConstant.fromValue(left.charValue() * right.intValue());
1008
					case T_long:	return LongConstant.fromValue(left.charValue() * right.longValue());
976
					case T_long:	return LongConstant.fromValue(left.charValue() * right.longValue());
1009
				}
977
				}
1010
			break;
978
				break;
1011
			case T_float :
979
			case T_float :
1012
				switch (rightId){
980
				switch (rightId){
1013
					case T_char :	return FloatConstant.fromValue(left.floatValue() * right.charValue());
981
					case T_char :	return FloatConstant.fromValue(left.floatValue() * right.charValue());
Lines 1018-1024 Link Here
1018
					case T_int:		return FloatConstant.fromValue(left.floatValue() * right.intValue());
986
					case T_int:		return FloatConstant.fromValue(left.floatValue() * right.intValue());
1019
					case T_long:	return FloatConstant.fromValue(left.floatValue() * right.longValue());
987
					case T_long:	return FloatConstant.fromValue(left.floatValue() * right.longValue());
1020
				}
988
				}
1021
			break;
989
				break;
1022
			case T_double :
990
			case T_double :
1023
				switch (rightId){
991
				switch (rightId){
1024
					case T_char :	return DoubleConstant.fromValue(left.doubleValue() * right.charValue());
992
					case T_char :	return DoubleConstant.fromValue(left.doubleValue() * right.charValue());
Lines 1029-1035 Link Here
1029
					case T_int:		return DoubleConstant.fromValue(left.doubleValue() * right.intValue());
997
					case T_int:		return DoubleConstant.fromValue(left.doubleValue() * right.intValue());
1030
					case T_long:	return DoubleConstant.fromValue(left.doubleValue() * right.longValue());
998
					case T_long:	return DoubleConstant.fromValue(left.doubleValue() * right.longValue());
1031
				}
999
				}
1032
			break;
1000
				break;
1033
			case T_byte :
1001
			case T_byte :
1034
				switch (rightId){
1002
				switch (rightId){
1035
					case T_char :	return IntConstant.fromValue(left.byteValue() * right.charValue());
1003
					case T_char :	return IntConstant.fromValue(left.byteValue() * right.charValue());
Lines 1040-1046 Link Here
1040
					case T_int:		return IntConstant.fromValue(left.byteValue() * right.intValue());
1008
					case T_int:		return IntConstant.fromValue(left.byteValue() * right.intValue());
1041
					case T_long:	return LongConstant.fromValue(left.byteValue() * right.longValue());
1009
					case T_long:	return LongConstant.fromValue(left.byteValue() * right.longValue());
1042
				}
1010
				}
1043
			break;
1011
				break;
1044
			case T_short :
1012
			case T_short :
1045
				switch (rightId){
1013
				switch (rightId){
1046
					case T_char :	return IntConstant.fromValue(left.shortValue() * right.charValue());
1014
					case T_char :	return IntConstant.fromValue(left.shortValue() * right.charValue());
Lines 1051-1057 Link Here
1051
					case T_int:		return IntConstant.fromValue(left.shortValue() * right.intValue());
1019
					case T_int:		return IntConstant.fromValue(left.shortValue() * right.intValue());
1052
					case T_long:	return LongConstant.fromValue(left.shortValue() * right.longValue());
1020
					case T_long:	return LongConstant.fromValue(left.shortValue() * right.longValue());
1053
				}
1021
				}
1054
			break;
1022
				break;
1055
			case T_int :
1023
			case T_int :
1056
				switch (rightId){
1024
				switch (rightId){
1057
					case T_char :	return IntConstant.fromValue(left.intValue() * right.charValue());
1025
					case T_char :	return IntConstant.fromValue(left.intValue() * right.charValue());
Lines 1062-1068 Link Here
1062
					case T_int:		return IntConstant.fromValue(left.intValue() * right.intValue());
1030
					case T_int:		return IntConstant.fromValue(left.intValue() * right.intValue());
1063
					case T_long:	return LongConstant.fromValue(left.intValue() * right.longValue());
1031
					case T_long:	return LongConstant.fromValue(left.intValue() * right.longValue());
1064
				}
1032
				}
1065
			break;
1033
				break;
1066
			case T_long :
1034
			case T_long :
1067
				switch (rightId){
1035
				switch (rightId){
1068
					case T_char :	return LongConstant.fromValue(left.longValue() * right.charValue());
1036
					case T_char :	return LongConstant.fromValue(left.longValue() * right.charValue());
Lines 1073-1085 Link Here
1073
					case T_int:		return LongConstant.fromValue(left.longValue() * right.intValue());
1041
					case T_int:		return LongConstant.fromValue(left.longValue() * right.intValue());
1074
					case T_long:	return LongConstant.fromValue(left.longValue() * right.longValue());
1042
					case T_long:	return LongConstant.fromValue(left.longValue() * right.longValue());
1075
				}
1043
				}
1076
			}
1044
		}
1077
1078
		return NotAConstant;
1045
		return NotAConstant;
1079
	}
1046
	}
1080
1047
1081
	public static final Constant computeConstantOperationOR(Constant left, int leftId, Constant right, int rightId) {
1048
	public static final Constant computeConstantOperationOR(Constant left, int leftId, Constant right, int rightId) {
1082
1083
		switch (leftId){
1049
		switch (leftId){
1084
			case T_boolean :		return BooleanConstant.fromValue(left.booleanValue() | right.booleanValue());
1050
			case T_boolean :		return BooleanConstant.fromValue(left.booleanValue() | right.booleanValue());
1085
			case T_char :
1051
			case T_char :
Lines 1090-1096 Link Here
1090
					case T_int:		return IntConstant.fromValue(left.charValue() | right.intValue());
1056
					case T_int:		return IntConstant.fromValue(left.charValue() | right.intValue());
1091
					case T_long:	return LongConstant.fromValue(left.charValue() | right.longValue());
1057
					case T_long:	return LongConstant.fromValue(left.charValue() | right.longValue());
1092
				}
1058
				}
1093
			break;
1059
				break;
1094
			case T_byte :
1060
			case T_byte :
1095
				switch (rightId){
1061
				switch (rightId){
1096
					case T_char :	return IntConstant.fromValue(left.byteValue() | right.charValue());
1062
					case T_char :	return IntConstant.fromValue(left.byteValue() | right.charValue());
Lines 1099-1105 Link Here
1099
					case T_int:		return IntConstant.fromValue(left.byteValue() | right.intValue());
1065
					case T_int:		return IntConstant.fromValue(left.byteValue() | right.intValue());
1100
					case T_long:	return LongConstant.fromValue(left.byteValue() | right.longValue());
1066
					case T_long:	return LongConstant.fromValue(left.byteValue() | right.longValue());
1101
				}
1067
				}
1102
			break;
1068
				break;
1103
			case T_short :
1069
			case T_short :
1104
				switch (rightId){
1070
				switch (rightId){
1105
					case T_char :	return IntConstant.fromValue(left.shortValue() | right.charValue());
1071
					case T_char :	return IntConstant.fromValue(left.shortValue() | right.charValue());
Lines 1108-1114 Link Here
1108
					case T_int:		return IntConstant.fromValue(left.shortValue() | right.intValue());
1074
					case T_int:		return IntConstant.fromValue(left.shortValue() | right.intValue());
1109
					case T_long:	return LongConstant.fromValue(left.shortValue() | right.longValue());
1075
					case T_long:	return LongConstant.fromValue(left.shortValue() | right.longValue());
1110
				}
1076
				}
1111
			break;
1077
				break;
1112
			case T_int :
1078
			case T_int :
1113
				switch (rightId){
1079
				switch (rightId){
1114
					case T_char :	return IntConstant.fromValue(left.intValue() | right.charValue());
1080
					case T_char :	return IntConstant.fromValue(left.intValue() | right.charValue());
Lines 1117-1123 Link Here
1117
					case T_int:		return IntConstant.fromValue(left.intValue() | right.intValue());
1083
					case T_int:		return IntConstant.fromValue(left.intValue() | right.intValue());
1118
					case T_long:	return LongConstant.fromValue(left.intValue() | right.longValue());
1084
					case T_long:	return LongConstant.fromValue(left.intValue() | right.longValue());
1119
				}
1085
				}
1120
			break;
1086
				break;
1121
			case T_long :
1087
			case T_long :
1122
				switch (rightId){
1088
				switch (rightId){
1123
					case T_char :	return LongConstant.fromValue(left.longValue() | right.charValue());
1089
					case T_char :	return LongConstant.fromValue(left.longValue() | right.charValue());
Lines 1126-1144 Link Here
1126
					case T_int:		return LongConstant.fromValue(left.longValue() | right.intValue());
1092
					case T_int:		return LongConstant.fromValue(left.longValue() | right.intValue());
1127
					case T_long:	return LongConstant.fromValue(left.longValue() | right.longValue());
1093
					case T_long:	return LongConstant.fromValue(left.longValue() | right.longValue());
1128
				}
1094
				}
1129
1095
		}
1130
			}
1131
1132
		return NotAConstant;
1096
		return NotAConstant;
1133
	}
1097
	}
1134
1098
1135
	public static final Constant computeConstantOperationOR_OR(Constant left, int leftId, Constant right, int rightId) {
1099
	public static final Constant computeConstantOperationOR_OR(Constant left, int leftId, Constant right, int rightId) {
1136
1137
		return BooleanConstant.fromValue(left.booleanValue() || right.booleanValue());
1100
		return BooleanConstant.fromValue(left.booleanValue() || right.booleanValue());
1138
	}
1101
	}
1139
1102
1140
	public static final Constant computeConstantOperationPLUS(Constant left, int leftId, Constant right, int rightId) {
1103
	public static final Constant computeConstantOperationPLUS(Constant left, int leftId, Constant right, int rightId) {
1141
1142
		switch (leftId){
1104
		switch (leftId){
1143
			case T_JavaLangObject :
1105
			case T_JavaLangObject :
1144
				if (rightId == T_JavaLangString) {
1106
				if (rightId == T_JavaLangString) {
Lines 1259-1271 Link Here
1259
//					case T_JavaLangString:	return Constant.fromValue(left.stringValue() + right.stringValue());
1221
//					case T_JavaLangString:	return Constant.fromValue(left.stringValue() + right.stringValue());
1260
//					case T_boolean:	return Constant.fromValue(left.stringValue() + right.booleanValue());
1222
//					case T_boolean:	return Constant.fromValue(left.stringValue() + right.booleanValue());
1261
//				}
1223
//				}
1262
			}
1224
		}
1263
1264
		return NotAConstant;
1225
		return NotAConstant;
1265
	}
1226
	}
1266
1227
1267
	public static final Constant computeConstantOperationREMAINDER(Constant left, int leftId, Constant right, int rightId) {
1228
	public static final Constant computeConstantOperationREMAINDER(Constant left, int leftId, Constant right, int rightId) {
1268
1269
		switch (leftId){
1229
		switch (leftId){
1270
			case T_char :
1230
			case T_char :
1271
				switch (rightId){
1231
				switch (rightId){
Lines 1277-1283 Link Here
1277
					case T_int:		return IntConstant.fromValue(left.charValue() % right.intValue());
1237
					case T_int:		return IntConstant.fromValue(left.charValue() % right.intValue());
1278
					case T_long:	return LongConstant.fromValue(left.charValue() % right.longValue());
1238
					case T_long:	return LongConstant.fromValue(left.charValue() % right.longValue());
1279
				}
1239
				}
1280
			break;
1240
				break;
1281
			case T_float :
1241
			case T_float :
1282
				switch (rightId){
1242
				switch (rightId){
1283
					case T_char :	return FloatConstant.fromValue(left.floatValue() % right.charValue());
1243
					case T_char :	return FloatConstant.fromValue(left.floatValue() % right.charValue());
Lines 1288-1294 Link Here
1288
					case T_int:		return FloatConstant.fromValue(left.floatValue() % right.intValue());
1248
					case T_int:		return FloatConstant.fromValue(left.floatValue() % right.intValue());
1289
					case T_long:	return FloatConstant.fromValue(left.floatValue() % right.longValue());
1249
					case T_long:	return FloatConstant.fromValue(left.floatValue() % right.longValue());
1290
				}
1250
				}
1291
			break;
1251
				break;
1292
			case T_double :
1252
			case T_double :
1293
				switch (rightId){
1253
				switch (rightId){
1294
					case T_char :	return DoubleConstant.fromValue(left.doubleValue() % right.charValue());
1254
					case T_char :	return DoubleConstant.fromValue(left.doubleValue() % right.charValue());
Lines 1299-1305 Link Here
1299
					case T_int:		return DoubleConstant.fromValue(left.doubleValue() % right.intValue());
1259
					case T_int:		return DoubleConstant.fromValue(left.doubleValue() % right.intValue());
1300
					case T_long:	return DoubleConstant.fromValue(left.doubleValue() % right.longValue());
1260
					case T_long:	return DoubleConstant.fromValue(left.doubleValue() % right.longValue());
1301
				}
1261
				}
1302
			break;
1262
				break;
1303
			case T_byte :
1263
			case T_byte :
1304
				switch (rightId){
1264
				switch (rightId){
1305
					case T_char :	return IntConstant.fromValue(left.byteValue() % right.charValue());
1265
					case T_char :	return IntConstant.fromValue(left.byteValue() % right.charValue());
Lines 1310-1316 Link Here
1310
					case T_int:		return IntConstant.fromValue(left.byteValue() % right.intValue());
1270
					case T_int:		return IntConstant.fromValue(left.byteValue() % right.intValue());
1311
					case T_long:	return LongConstant.fromValue(left.byteValue() % right.longValue());
1271
					case T_long:	return LongConstant.fromValue(left.byteValue() % right.longValue());
1312
				}
1272
				}
1313
			break;
1273
				break;
1314
			case T_short :
1274
			case T_short :
1315
				switch (rightId){
1275
				switch (rightId){
1316
					case T_char :	return IntConstant.fromValue(left.shortValue() % right.charValue());
1276
					case T_char :	return IntConstant.fromValue(left.shortValue() % right.charValue());
Lines 1321-1327 Link Here
1321
					case T_int:		return IntConstant.fromValue(left.shortValue() % right.intValue());
1281
					case T_int:		return IntConstant.fromValue(left.shortValue() % right.intValue());
1322
					case T_long:	return LongConstant.fromValue(left.shortValue() % right.longValue());
1282
					case T_long:	return LongConstant.fromValue(left.shortValue() % right.longValue());
1323
				}
1283
				}
1324
			break;
1284
				break;
1325
			case T_int :
1285
			case T_int :
1326
				switch (rightId){
1286
				switch (rightId){
1327
					case T_char :	return IntConstant.fromValue(left.intValue() % right.charValue());
1287
					case T_char :	return IntConstant.fromValue(left.intValue() % right.charValue());
Lines 1332-1338 Link Here
1332
					case T_int:		return IntConstant.fromValue(left.intValue() % right.intValue());
1292
					case T_int:		return IntConstant.fromValue(left.intValue() % right.intValue());
1333
					case T_long:	return LongConstant.fromValue(left.intValue() % right.longValue());
1293
					case T_long:	return LongConstant.fromValue(left.intValue() % right.longValue());
1334
				}
1294
				}
1335
			break;
1295
				break;
1336
			case T_long :
1296
			case T_long :
1337
				switch (rightId){
1297
				switch (rightId){
1338
					case T_char :	return LongConstant.fromValue(left.longValue() % right.charValue());
1298
					case T_char :	return LongConstant.fromValue(left.longValue() % right.charValue());
Lines 1343-1356 Link Here
1343
					case T_int:		return LongConstant.fromValue(left.longValue() % right.intValue());
1303
					case T_int:		return LongConstant.fromValue(left.longValue() % right.intValue());
1344
					case T_long:	return LongConstant.fromValue(left.longValue() % right.longValue());
1304
					case T_long:	return LongConstant.fromValue(left.longValue() % right.longValue());
1345
				}
1305
				}
1346
1306
		}
1347
			}
1348
1349
		return NotAConstant;
1307
		return NotAConstant;
1350
	}
1308
	}
1351
1309
1352
	public static final Constant computeConstantOperationRIGHT_SHIFT(Constant left, int leftId, Constant right, int rightId) {
1310
	public static final Constant computeConstantOperationRIGHT_SHIFT(Constant left, int leftId, Constant right, int rightId) {
1353
1354
		switch (leftId){
1311
		switch (leftId){
1355
			case T_char :
1312
			case T_char :
1356
				switch (rightId){
1313
				switch (rightId){
Lines 1360-1366 Link Here
1360
					case T_int:		return IntConstant.fromValue(left.charValue() >> right.intValue());
1317
					case T_int:		return IntConstant.fromValue(left.charValue() >> right.intValue());
1361
					case T_long:	return IntConstant.fromValue(left.charValue() >> right.longValue());
1318
					case T_long:	return IntConstant.fromValue(left.charValue() >> right.longValue());
1362
				}
1319
				}
1363
			break;
1320
				break;
1364
			case T_byte :
1321
			case T_byte :
1365
				switch (rightId){
1322
				switch (rightId){
1366
					case T_char :	return IntConstant.fromValue(left.byteValue() >> right.charValue());
1323
					case T_char :	return IntConstant.fromValue(left.byteValue() >> right.charValue());
Lines 1369-1375 Link Here
1369
					case T_int:		return IntConstant.fromValue(left.byteValue() >> right.intValue());
1326
					case T_int:		return IntConstant.fromValue(left.byteValue() >> right.intValue());
1370
					case T_long:	return IntConstant.fromValue(left.byteValue() >> right.longValue());
1327
					case T_long:	return IntConstant.fromValue(left.byteValue() >> right.longValue());
1371
				}
1328
				}
1372
			break;
1329
				break;
1373
			case T_short :
1330
			case T_short :
1374
				switch (rightId){
1331
				switch (rightId){
1375
					case T_char :	return IntConstant.fromValue(left.shortValue() >> right.charValue());
1332
					case T_char :	return IntConstant.fromValue(left.shortValue() >> right.charValue());
Lines 1378-1384 Link Here
1378
					case T_int:		return IntConstant.fromValue(left.shortValue() >> right.intValue());
1335
					case T_int:		return IntConstant.fromValue(left.shortValue() >> right.intValue());
1379
					case T_long:	return IntConstant.fromValue(left.shortValue() >> right.longValue());
1336
					case T_long:	return IntConstant.fromValue(left.shortValue() >> right.longValue());
1380
				}
1337
				}
1381
			break;
1338
				break;
1382
			case T_int :
1339
			case T_int :
1383
				switch (rightId){
1340
				switch (rightId){
1384
					case T_char :	return IntConstant.fromValue(left.intValue() >> right.charValue());
1341
					case T_char :	return IntConstant.fromValue(left.intValue() >> right.charValue());
Lines 1387-1393 Link Here
1387
					case T_int:		return IntConstant.fromValue(left.intValue() >> right.intValue());
1344
					case T_int:		return IntConstant.fromValue(left.intValue() >> right.intValue());
1388
					case T_long:	return IntConstant.fromValue(left.intValue() >> right.longValue());
1345
					case T_long:	return IntConstant.fromValue(left.intValue() >> right.longValue());
1389
				}
1346
				}
1390
			break;
1347
				break;
1391
			case T_long :
1348
			case T_long :
1392
				switch (rightId){
1349
				switch (rightId){
1393
					case T_char :	return LongConstant.fromValue(left.longValue() >> right.charValue());
1350
					case T_char :	return LongConstant.fromValue(left.longValue() >> right.charValue());
Lines 1396-1409 Link Here
1396
					case T_int:		return LongConstant.fromValue(left.longValue() >> right.intValue());
1353
					case T_int:		return LongConstant.fromValue(left.longValue() >> right.intValue());
1397
					case T_long:	return LongConstant.fromValue(left.longValue() >> right.longValue());
1354
					case T_long:	return LongConstant.fromValue(left.longValue() >> right.longValue());
1398
				}
1355
				}
1399
1356
		}
1400
			}
1401
1402
		return NotAConstant;
1357
		return NotAConstant;
1403
	}
1358
	}
1404
1359
1405
	public static final Constant computeConstantOperationUNSIGNED_RIGHT_SHIFT(Constant left, int leftId, Constant right, int rightId) {
1360
	public static final Constant computeConstantOperationUNSIGNED_RIGHT_SHIFT(Constant left, int leftId, Constant right, int rightId) {
1406
1407
		switch (leftId){
1361
		switch (leftId){
1408
			case T_char :
1362
			case T_char :
1409
				switch (rightId){
1363
				switch (rightId){
Lines 1413-1419 Link Here
1413
					case T_int:		return IntConstant.fromValue(left.charValue() >>> right.intValue());
1367
					case T_int:		return IntConstant.fromValue(left.charValue() >>> right.intValue());
1414
					case T_long:	return IntConstant.fromValue(left.charValue() >>> right.longValue());
1368
					case T_long:	return IntConstant.fromValue(left.charValue() >>> right.longValue());
1415
				}
1369
				}
1416
			break;
1370
				break;
1417
			case T_byte :
1371
			case T_byte :
1418
				switch (rightId){
1372
				switch (rightId){
1419
					case T_char :	return IntConstant.fromValue(left.byteValue() >>> right.charValue());
1373
					case T_char :	return IntConstant.fromValue(left.byteValue() >>> right.charValue());
Lines 1422-1428 Link Here
1422
					case T_int:		return IntConstant.fromValue(left.byteValue() >>> right.intValue());
1376
					case T_int:		return IntConstant.fromValue(left.byteValue() >>> right.intValue());
1423
					case T_long:	return IntConstant.fromValue(left.byteValue() >>> right.longValue());
1377
					case T_long:	return IntConstant.fromValue(left.byteValue() >>> right.longValue());
1424
				}
1378
				}
1425
			break;
1379
				break;
1426
			case T_short :
1380
			case T_short :
1427
				switch (rightId){
1381
				switch (rightId){
1428
					case T_char :	return IntConstant.fromValue(left.shortValue() >>> right.charValue());
1382
					case T_char :	return IntConstant.fromValue(left.shortValue() >>> right.charValue());
Lines 1431-1437 Link Here
1431
					case T_int:		return IntConstant.fromValue(left.shortValue() >>> right.intValue());
1385
					case T_int:		return IntConstant.fromValue(left.shortValue() >>> right.intValue());
1432
					case T_long:	return IntConstant.fromValue(left.shortValue() >>> right.longValue());
1386
					case T_long:	return IntConstant.fromValue(left.shortValue() >>> right.longValue());
1433
				}
1387
				}
1434
			break;
1388
				break;
1435
			case T_int :
1389
			case T_int :
1436
				switch (rightId){
1390
				switch (rightId){
1437
					case T_char :	return IntConstant.fromValue(left.intValue() >>> right.charValue());
1391
					case T_char :	return IntConstant.fromValue(left.intValue() >>> right.charValue());
Lines 1440-1446 Link Here
1440
					case T_int:		return IntConstant.fromValue(left.intValue() >>> right.intValue());
1394
					case T_int:		return IntConstant.fromValue(left.intValue() >>> right.intValue());
1441
					case T_long:	return IntConstant.fromValue(left.intValue() >>> right.longValue());
1395
					case T_long:	return IntConstant.fromValue(left.intValue() >>> right.longValue());
1442
				}
1396
				}
1443
			break;
1397
				break;
1444
			case T_long :
1398
			case T_long :
1445
				switch (rightId){
1399
				switch (rightId){
1446
					case T_char :	return LongConstant.fromValue(left.longValue() >>> right.charValue());
1400
					case T_char :	return LongConstant.fromValue(left.longValue() >>> right.charValue());
Lines 1449-1462 Link Here
1449
					case T_int:		return LongConstant.fromValue(left.longValue() >>> right.intValue());
1403
					case T_int:		return LongConstant.fromValue(left.longValue() >>> right.intValue());
1450
					case T_long:	return LongConstant.fromValue(left.longValue() >>> right.longValue());
1404
					case T_long:	return LongConstant.fromValue(left.longValue() >>> right.longValue());
1451
				}
1405
				}
1452
1406
		}
1453
			}
1454
1455
		return NotAConstant;
1407
		return NotAConstant;
1456
	}
1408
	}
1457
1409
1458
	public static final Constant computeConstantOperationXOR(Constant left, int leftId, Constant right, int rightId) {
1410
	public static final Constant computeConstantOperationXOR(Constant left, int leftId, Constant right, int rightId) {
1459
1460
		switch (leftId){
1411
		switch (leftId){
1461
			case T_boolean :		return BooleanConstant.fromValue(left.booleanValue() ^ right.booleanValue());
1412
			case T_boolean :		return BooleanConstant.fromValue(left.booleanValue() ^ right.booleanValue());
1462
			case T_char :
1413
			case T_char :
Lines 1467-1473 Link Here
1467
					case T_int:		return IntConstant.fromValue(left.charValue() ^ right.intValue());
1418
					case T_int:		return IntConstant.fromValue(left.charValue() ^ right.intValue());
1468
					case T_long:	return LongConstant.fromValue(left.charValue() ^ right.longValue());
1419
					case T_long:	return LongConstant.fromValue(left.charValue() ^ right.longValue());
1469
				}
1420
				}
1470
			break;
1421
				break;
1471
			case T_byte :
1422
			case T_byte :
1472
				switch (rightId){
1423
				switch (rightId){
1473
					case T_char :	return IntConstant.fromValue(left.byteValue() ^ right.charValue());
1424
					case T_char :	return IntConstant.fromValue(left.byteValue() ^ right.charValue());
Lines 1476-1482 Link Here
1476
					case T_int:		return IntConstant.fromValue(left.byteValue() ^ right.intValue());
1427
					case T_int:		return IntConstant.fromValue(left.byteValue() ^ right.intValue());
1477
					case T_long:	return LongConstant.fromValue(left.byteValue() ^ right.longValue());
1428
					case T_long:	return LongConstant.fromValue(left.byteValue() ^ right.longValue());
1478
				}
1429
				}
1479
			break;
1430
				break;
1480
			case T_short :
1431
			case T_short :
1481
				switch (rightId){
1432
				switch (rightId){
1482
					case T_char :	return IntConstant.fromValue(left.shortValue() ^ right.charValue());
1433
					case T_char :	return IntConstant.fromValue(left.shortValue() ^ right.charValue());
Lines 1485-1491 Link Here
1485
					case T_int:		return IntConstant.fromValue(left.shortValue() ^ right.intValue());
1436
					case T_int:		return IntConstant.fromValue(left.shortValue() ^ right.intValue());
1486
					case T_long:	return LongConstant.fromValue(left.shortValue() ^ right.longValue());
1437
					case T_long:	return LongConstant.fromValue(left.shortValue() ^ right.longValue());
1487
				}
1438
				}
1488
			break;
1439
				break;
1489
			case T_int :
1440
			case T_int :
1490
				switch (rightId){
1441
				switch (rightId){
1491
					case T_char :	return IntConstant.fromValue(left.intValue() ^ right.charValue());
1442
					case T_char :	return IntConstant.fromValue(left.intValue() ^ right.charValue());
Lines 1494-1500 Link Here
1494
					case T_int:		return IntConstant.fromValue(left.intValue() ^ right.intValue());
1445
					case T_int:		return IntConstant.fromValue(left.intValue() ^ right.intValue());
1495
					case T_long:	return LongConstant.fromValue(left.intValue() ^ right.longValue());
1446
					case T_long:	return LongConstant.fromValue(left.intValue() ^ right.longValue());
1496
				}
1447
				}
1497
			break;
1448
				break;
1498
			case T_long :
1449
			case T_long :
1499
				switch (rightId){
1450
				switch (rightId){
1500
					case T_char :	return LongConstant.fromValue(left.longValue() ^ right.charValue());
1451
					case T_char :	return LongConstant.fromValue(left.longValue() ^ right.charValue());
Lines 1503-1522 Link Here
1503
					case T_int:		return LongConstant.fromValue(left.longValue() ^ right.intValue());
1454
					case T_int:		return LongConstant.fromValue(left.longValue() ^ right.intValue());
1504
					case T_long:	return LongConstant.fromValue(left.longValue() ^ right.longValue());
1455
					case T_long:	return LongConstant.fromValue(left.longValue() ^ right.longValue());
1505
				}
1456
				}
1506
			}
1457
		}
1507
1508
		return NotAConstant;
1458
		return NotAConstant;
1509
	}
1459
	}
1510
1460
1511
	public double doubleValue() {
1461
	public double doubleValue() {
1512
1513
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "double" })); //$NON-NLS-1$
1462
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "double" })); //$NON-NLS-1$
1514
	}
1463
	}
1515
1464
1516
	public float floatValue() {
1465
	public float floatValue() {
1517
1518
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "float" })); //$NON-NLS-1$
1466
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "float" })); //$NON-NLS-1$
1519
	}
1467
	}
1468
	
1520
	/**
1469
	/**
1521
	 * Returns true if both constants have the same type and the same actual value
1470
	 * Returns true if both constants have the same type and the same actual value
1522
	 * @param otherConstant
1471
	 * @param otherConstant
Lines 1554-1580 Link Here
1554
	}
1503
	}
1555
1504
1556
	public int intValue() {
1505
	public int intValue() {
1557
1558
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "int" })); //$NON-NLS-1$
1506
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "int" })); //$NON-NLS-1$
1559
	}
1507
	}
1560
1508
1561
	public long longValue() {
1509
	public long longValue() {
1562
1563
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "long" })); //$NON-NLS-1$
1510
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "long" })); //$NON-NLS-1$
1564
	}
1511
	}
1565
1512
1566
	public short shortValue() {
1513
	public short shortValue() {
1567
1568
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotConvertedTo, new String[] { typeName(), "short" })); //$NON-NLS-1$
1514
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotConvertedTo, new String[] { typeName(), "short" })); //$NON-NLS-1$
1569
	}
1515
	}
1570
1516
1571
	public String stringValue() {
1517
	public String stringValue() {
1572
1573
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotConvertedTo, new String[] { typeName(), "String" })); //$NON-NLS-1$
1518
		throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotConvertedTo, new String[] { typeName(), "String" })); //$NON-NLS-1$
1574
	}
1519
	}
1575
1520
1576
	public String toString(){
1521
	public String toString(){
1577
1578
		if (this == NotAConstant) return "(Constant) NotAConstant"; //$NON-NLS-1$
1522
		if (this == NotAConstant) return "(Constant) NotAConstant"; //$NON-NLS-1$
1579
		return super.toString(); }
1523
		return super.toString(); }
1580
1524
(-)compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java (-36 / +48 lines)
Lines 11-53 Link Here
11
package org.eclipse.jdt.internal.compiler.impl;
11
package org.eclipse.jdt.internal.compiler.impl;
12
12
13
public class ByteConstant extends Constant {
13
public class ByteConstant extends Constant {
14
14
	private byte value;
15
	private byte value;
15
16
16
public static Constant fromValue(byte value) {
17
	public static Constant fromValue(byte value) {
17
	return new ByteConstant(value);
18
		return new ByteConstant(value);
18
}
19
	}
19
private ByteConstant(byte value) {
20
	this.value = value;
21
}
22
public byte byteValue() {
23
	return this.value;
24
}
25
public char charValue() {
26
	return (char) this.value;
27
}
28
public double doubleValue() {
29
	return this.value; // implicit cast to return type
30
}
31
public float floatValue() {
32
	return this.value; // implicit cast to return type
33
}
34
public int intValue() {
35
	return this.value; // implicit cast to return type
36
}
37
public long longValue() {
38
	return this.value; // implicit cast to return type
39
}
40
public short shortValue() {
41
	return this.value; // implicit cast to return type
42
}
43
public String stringValue() {
44
	//spec 15.17.11
45
	return String.valueOf(this.value) ;
46
}
47
public String toString(){
48
20
49
	return "(byte)" + this.value ; } //$NON-NLS-1$
21
	private ByteConstant(byte value) {
50
public int typeID() {
22
		this.value = value;
51
	return T_byte;
23
	}
52
}
24
25
	public byte byteValue() {
26
		return this.value;
27
	}
28
29
	public char charValue() {
30
		return (char) this.value;
31
	}
32
33
	public double doubleValue() {
34
		return this.value; // implicit cast to return type
35
	}
36
37
	public float floatValue() {
38
		return this.value; // implicit cast to return type
39
	}
40
41
	public int intValue() {
42
		return this.value; // implicit cast to return type
43
	}
44
45
	public long longValue() {
46
		return this.value; // implicit cast to return type
47
	}
48
49
	public short shortValue() {
50
		return this.value; // implicit cast to return type
51
	}
52
53
	public String stringValue() {
54
		// spec 15.17.11
55
		return String.valueOf(this.value);
56
	}
57
58
	public String toString() {
59
		return "(byte)" + this.value; //$NON-NLS-1$
60
	}
61
62
	public int typeID() {
63
		return T_byte;
64
	}
53
}
65
}
(-)compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java (-1 / +2 lines)
Lines 14-19 Link Here
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 31-38 Link Here
31
	private static final IntConstant TEN = new IntConstant(10);
32
	private static final IntConstant TEN = new IntConstant(10);
32
33
33
	public static Constant fromValue(int value) {
34
	public static Constant fromValue(int value) {
34
35
		switch (value) {
35
		switch (value) {
36
			case Integer.MIN_VALUE : return IntConstant.MIN_VALUE;
36
			case -4 : return IntConstant.MINUS_FOUR;
37
			case -4 : return IntConstant.MINUS_FOUR;
37
			case -3 : return IntConstant.MINUS_THREE;
38
			case -3 : return IntConstant.MINUS_THREE;
38
			case -2 : return IntConstant.MINUS_TWO;
39
			case -2 : return IntConstant.MINUS_TWO;
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java (-2 / +11 lines)
Lines 21-55 Link Here
21
	private CharConstant(char value) {
21
	private CharConstant(char value) {
22
		this.value = value;
22
		this.value = value;
23
	}
23
	}
24
24
	public byte byteValue() {
25
	public byte byteValue() {
25
		return (byte) this.value;
26
		return (byte) this.value;
26
	}
27
	}
28
27
	public char charValue() {
29
	public char charValue() {
28
		return this.value;
30
		return this.value;
29
	}
31
	}
32
30
	public double doubleValue() {
33
	public double doubleValue() {
31
		return this.value; // implicit cast to return type
34
		return this.value; // implicit cast to return type
32
	}
35
	}
36
33
	public float floatValue() {
37
	public float floatValue() {
34
		return this.value; // implicit cast to return type
38
		return this.value; // implicit cast to return type
35
	}
39
	}
40
36
	public int intValue() {
41
	public int intValue() {
37
		return this.value; // implicit cast to return type
42
		return this.value; // implicit cast to return type
38
	}
43
	}
44
39
	public long longValue() {
45
	public long longValue() {
40
		return this.value; // implicit cast to return type
46
		return this.value; // implicit cast to return type
41
	}
47
	}
48
42
	public short shortValue() {
49
	public short shortValue() {
43
		return (short) this.value;
50
		return (short) this.value;
44
	}
51
	}
52
45
	public String stringValue() {
53
	public String stringValue() {
46
		//spec 15.17.11
54
		// spec 15.17.11
47
		return String.valueOf(this.value);
55
		return String.valueOf(this.value);
48
	}
56
	}
49
	public String toString(){
50
57
58
	public String toString() {
51
		return "(char)" + this.value; //$NON-NLS-1$
59
		return "(char)" + this.value; //$NON-NLS-1$
52
	}
60
	}
61
53
	public int typeID() {
62
	public int typeID() {
54
		return T_char;
63
		return T_char;
55
	}
64
	}

Return to bug 261510