|
Lines 175-181
Link Here
|
| 175 |
} |
175 |
} |
| 176 |
|
176 |
|
| 177 |
final boolean hasCases = this.caseCount != 0; |
177 |
final boolean hasCases = this.caseCount != 0; |
| 178 |
final boolean valueRequired = this.expression.constant == Constant.NotAConstant || hasCases; |
|
|
| 179 |
|
178 |
|
| 180 |
StringSwitchCase [] stringCases = new StringSwitchCase[this.caseCount]; // may have to shrink later if multiple strings hash to same code. |
179 |
StringSwitchCase [] stringCases = new StringSwitchCase[this.caseCount]; // may have to shrink later if multiple strings hash to same code. |
| 181 |
BranchLabel[] sourceCaseLabels = new BranchLabel[this.caseCount]; |
180 |
BranchLabel[] sourceCaseLabels = new BranchLabel[this.caseCount]; |
|
Lines 242-248
Link Here
|
| 242 |
codeStream.ifne(stringCases[i].label); |
241 |
codeStream.ifne(stringCases[i].label); |
| 243 |
} |
242 |
} |
| 244 |
codeStream.goto_(defaultBranchLabel); |
243 |
codeStream.goto_(defaultBranchLabel); |
| 245 |
} else if (valueRequired) { |
244 |
} else { |
| 246 |
codeStream.pop(); |
245 |
codeStream.pop(); |
| 247 |
} |
246 |
} |
| 248 |
|
247 |
|
|
Lines 474-479
Link Here
|
| 474 |
expressionType = null; // fault-tolerance: ignore type mismatch from constants from hereon |
473 |
expressionType = null; // fault-tolerance: ignore type mismatch from constants from hereon |
| 475 |
} |
474 |
} |
| 476 |
} |
475 |
} |
|
|
476 |
if (isStringSwitch) { |
| 477 |
// the secret variable should be created before iterating over the switch's statements that could |
| 478 |
// create more locals. This must be done to prevent overlapping of locals |
| 479 |
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=356002 |
| 480 |
this.dispatchStringCopy = new LocalVariableBinding(SecretStringVariableName, upperScope.getJavaLangString(), ClassFileConstants.AccDefault, false); |
| 481 |
upperScope.addLocalVariable(this.dispatchStringCopy); |
| 482 |
this.dispatchStringCopy.setConstant(Constant.NotAConstant); |
| 483 |
this.dispatchStringCopy.useFlag = LocalVariableBinding.USED; |
| 484 |
} |
| 477 |
if (this.statements != null) { |
485 |
if (this.statements != null) { |
| 478 |
this.scope = new BlockScope(upperScope); |
486 |
this.scope = new BlockScope(upperScope); |
| 479 |
int length; |
487 |
int length; |
|
Lines 522-533
Link Here
|
| 522 |
upperScope.problemReporter().undocumentedEmptyBlock(this.blockStart, this.sourceEnd); |
530 |
upperScope.problemReporter().undocumentedEmptyBlock(this.blockStart, this.sourceEnd); |
| 523 |
} |
531 |
} |
| 524 |
} |
532 |
} |
| 525 |
if (isStringSwitch) { |
|
|
| 526 |
this.dispatchStringCopy = new LocalVariableBinding(SecretStringVariableName, upperScope.getJavaLangString(), ClassFileConstants.AccDefault, false); |
| 527 |
upperScope.addLocalVariable(this.dispatchStringCopy); |
| 528 |
this.dispatchStringCopy.setConstant(Constant.NotAConstant); |
| 529 |
this.dispatchStringCopy.useFlag = LocalVariableBinding.USED; |
| 530 |
} |
| 531 |
// for enum switch, check if all constants are accounted for (if no default) |
533 |
// for enum switch, check if all constants are accounted for (if no default) |
| 532 |
if (isEnumSwitch && this.defaultCase == null |
534 |
if (isEnumSwitch && this.defaultCase == null |
| 533 |
&& upperScope.compilerOptions().getSeverity(CompilerOptions.IncompleteEnumSwitch) != ProblemSeverities.Ignore) { |
535 |
&& upperScope.compilerOptions().getSeverity(CompilerOptions.IncompleteEnumSwitch) != ProblemSeverities.Ignore) { |