@@ -75,7 +75,7 @@ abstract class ConstantFolder {
75
75
case nme.AND => Constant (x.booleanValue & y.booleanValue)
76
76
case nme.EQ => Constant (x.booleanValue == y.booleanValue)
77
77
case nme.NE => Constant (x.booleanValue != y.booleanValue)
78
- case _ => null
78
+ case _ => null
79
79
}
80
80
private def foldSubrangeOp (op : Name , x : Constant , y : Constant ): Constant = op match {
81
81
case nme.OR => Constant (x.intValue | y.intValue)
@@ -95,14 +95,20 @@ abstract class ConstantFolder {
95
95
case nme.MUL => Constant (x.intValue * y.intValue)
96
96
case nme.DIV => Constant (x.intValue / y.intValue)
97
97
case nme.MOD => Constant (x.intValue % y.intValue)
98
- case _ => null
98
+ case _ => null
99
99
}
100
100
private def foldLongOp (op : Name , x : Constant , y : Constant ): Constant = op match {
101
101
case nme.OR => Constant (x.longValue | y.longValue)
102
102
case nme.XOR => Constant (x.longValue ^ y.longValue)
103
103
case nme.AND => Constant (x.longValue & y.longValue)
104
- case nme.LSL => Constant (x.longValue << y.longValue)
104
+ case nme.LSL if x.tag <= IntTag
105
+ => Constant (x.intValue << y.longValue)
106
+ case nme.LSL => Constant (x.longValue << y.longValue)
107
+ case nme.LSR if x.tag <= IntTag
108
+ => Constant (x.intValue >>> y.longValue)
105
109
case nme.LSR => Constant (x.longValue >>> y.longValue)
110
+ case nme.ASR if x.tag <= IntTag
111
+ => Constant (x.intValue >> y.longValue)
106
112
case nme.ASR => Constant (x.longValue >> y.longValue)
107
113
case nme.EQ => Constant (x.longValue == y.longValue)
108
114
case nme.NE => Constant (x.longValue != y.longValue)
@@ -115,7 +121,7 @@ abstract class ConstantFolder {
115
121
case nme.MUL => Constant (x.longValue * y.longValue)
116
122
case nme.DIV => Constant (x.longValue / y.longValue)
117
123
case nme.MOD => Constant (x.longValue % y.longValue)
118
- case _ => null
124
+ case _ => null
119
125
}
120
126
private def foldFloatOp (op : Name , x : Constant , y : Constant ): Constant = op match {
121
127
case nme.EQ => Constant (x.floatValue == y.floatValue)
@@ -129,7 +135,7 @@ abstract class ConstantFolder {
129
135
case nme.MUL => Constant (x.floatValue * y.floatValue)
130
136
case nme.DIV => Constant (x.floatValue / y.floatValue)
131
137
case nme.MOD => Constant (x.floatValue % y.floatValue)
132
- case _ => null
138
+ case _ => null
133
139
}
134
140
private def foldDoubleOp (op : Name , x : Constant , y : Constant ): Constant = op match {
135
141
case nme.EQ => Constant (x.doubleValue == y.doubleValue)
@@ -143,7 +149,7 @@ abstract class ConstantFolder {
143
149
case nme.MUL => Constant (x.doubleValue * y.doubleValue)
144
150
case nme.DIV => Constant (x.doubleValue / y.doubleValue)
145
151
case nme.MOD => Constant (x.doubleValue % y.doubleValue)
146
- case _ => null
152
+ case _ => null
147
153
}
148
154
149
155
private def foldBinop (op : Name , x : Constant , y : Constant ): Constant = {
@@ -162,7 +168,7 @@ abstract class ConstantFolder {
162
168
case _ => null
163
169
}
164
170
catch {
165
- case ex : ArithmeticException => null
171
+ case _ : ArithmeticException => null
166
172
}
167
173
}
168
174
}
0 commit comments