Lines 89-137
Link Here
|
89 |
return; |
89 |
return; |
90 |
} |
90 |
} |
91 |
int pc = codeStream.position; |
91 |
int pc = codeStream.position; |
92 |
Constant inlinedValue; |
|
|
93 |
|
92 |
|
94 |
// something to initialize? |
93 |
// something to initialize? |
95 |
if (initialization != null) { |
94 |
generateInit: { |
96 |
// initialize to constant value? |
95 |
if (this.initialization == null) |
97 |
if ((inlinedValue = initialization.constant) != Constant.NotAConstant) { |
96 |
break generateInit; |
98 |
// forget initializing unused or final locals set to constant value (final ones are inlined) |
97 |
// forget initializing unused or final locals set to constant value (final ones are inlined) |
99 |
if (binding.resolvedPosition != -1) { // may need to preserve variable |
98 |
if (binding.resolvedPosition < 0) { |
100 |
int initPC = codeStream.position; |
99 |
if (initialization.constant != Constant.NotAConstant) |
101 |
codeStream.generateConstant(inlinedValue, initialization.implicitConversion); |
100 |
break generateInit; |
102 |
codeStream.recordPositionsFrom(initPC, initialization.sourceStart); |
|
|
103 |
codeStream.store(binding, false); |
104 |
binding.recordInitializationStartPC(codeStream.position); |
105 |
// codeStream.lastInitStateIndexWhenRemovingInits = -2; // reinitialize remove index |
106 |
// codeStream.lastInitStateIndexWhenAddingInits = -2; // reinitialize add index |
107 |
} |
108 |
} else { // initializing to non-constant value |
109 |
initialization.generateCode(currentScope, codeStream, true); |
110 |
// if binding unused generate then discard the value |
101 |
// if binding unused generate then discard the value |
111 |
if (binding.resolvedPosition != -1) { |
102 |
// TODO why not simply discard value ? |
112 |
// 26903, need extra cast to store null in array local var |
103 |
initialization.generateCode(currentScope, codeStream, true); |
113 |
if (binding.type.isArrayType() |
104 |
if ((binding.type == TypeBinding.LONG) || (binding.type == TypeBinding.DOUBLE)) { |
114 |
&& (initialization.resolvedType == TypeBinding.NULL // arrayLoc = null |
105 |
codeStream.pop2(); |
115 |
|| ((initialization instanceof CastExpression) // arrayLoc = (type[])null |
|
|
116 |
&& (((CastExpression)initialization).innermostCastedExpression().resolvedType == TypeBinding.NULL)))){ |
117 |
codeStream.checkcast(binding.type); |
118 |
} |
119 |
codeStream.store(binding, false); |
120 |
if (binding.initializationCount == 0) { |
121 |
/* Variable may have been initialized during the code initializing it |
122 |
e.g. int i = (i = 1); |
123 |
*/ |
124 |
binding.recordInitializationStartPC(codeStream.position); |
125 |
// codeStream.lastInitStateIndexWhenRemovingInits = -2; // reinitialize remove index |
126 |
// codeStream.lastInitStateIndexWhenAddingInits = -2; // reinitialize add index |
127 |
} |
128 |
} else { |
106 |
} else { |
129 |
if ((binding.type == TypeBinding.LONG) || (binding.type == TypeBinding.DOUBLE)) { |
107 |
codeStream.pop(); |
130 |
codeStream.pop2(); |
|
|
131 |
} else { |
132 |
codeStream.pop(); |
133 |
} |
134 |
} |
108 |
} |
|
|
109 |
break generateInit; |
110 |
} |
111 |
initialization.generateCode(currentScope, codeStream, true); |
112 |
// 26903, need extra cast to store null in array local var |
113 |
if (binding.type.isArrayType() |
114 |
&& (initialization.resolvedType == TypeBinding.NULL // arrayLoc = null |
115 |
|| ((initialization instanceof CastExpression) // arrayLoc = (type[])null |
116 |
&& (((CastExpression)initialization).innermostCastedExpression().resolvedType == TypeBinding.NULL)))){ |
117 |
codeStream.checkcast(binding.type); |
118 |
} |
119 |
codeStream.store(binding, false); |
120 |
if (binding.initializationCount == 0) { |
121 |
/* Variable may have been initialized during the code initializing it |
122 |
e.g. int i = (i = 1); |
123 |
*/ |
124 |
binding.recordInitializationStartPC(codeStream.position); |
135 |
} |
125 |
} |
136 |
} |
126 |
} |
137 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
127 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |