summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2004-09-14 13:30:58 +0000
committermihaylov <mihaylov@epfl.ch>2004-09-14 13:30:58 +0000
commit913e6bd36f0967ed5f53844a841fc00c7a2378d5 (patch)
tree9bf4fe7ac8ed87067eee2577041e287986a7e1bf /sources
parentb6cc6b0e576ccc557df9d36ddc34297c1c2d195c (diff)
downloadscala-913e6bd36f0967ed5f53844a841fc00c7a2378d5.tar.gz
scala-913e6bd36f0967ed5f53844a841fc00c7a2378d5.tar.bz2
scala-913e6bd36f0967ed5f53844a841fc00c7a2378d5.zip
- Clear the exit label in Assign nodes processing
- Avoid alocating new local variable for the selector of Switch when it already is a local variable, an argument or a literal
Diffstat (limited to 'sources')
-rw-r--r--sources/scalac/backend/msil/GenMSIL.java31
1 files changed, 12 insertions, 19 deletions
diff --git a/sources/scalac/backend/msil/GenMSIL.java b/sources/scalac/backend/msil/GenMSIL.java
index 0fb23ab868..80bb125131 100644
--- a/sources/scalac/backend/msil/GenMSIL.java
+++ b/sources/scalac/backend/msil/GenMSIL.java
@@ -389,21 +389,6 @@ public final class GenMSIL {
/*
- * Generate code for array of trees
- */
- private Item gen(Tree[] trees, MSILType toType) {
- int n = trees.length;
- if (n == 0)
- return items.VoidItem();
- boolean tmpLastExpr = lastExpr; lastExpr = false;
- for (int i = 0; i < n-1; i++) {
- drop(gen(trees[i], MSILType.VOID));
- }
- lastExpr = tmpLastExpr;
- return gen(trees[n-1], toType);
- }
-
- /*
* Sanity checks for items.
*/
private Item check(Item item) {
@@ -538,10 +523,12 @@ public final class GenMSIL {
case Assign(Tree lhs, Tree rhs):
boolean tmpLastExpr = lastExpr; lastExpr = false;
+ Label tmpExitLabel = exitLabel; exitLabel = null;
MSILType type = msilType(lhs.type);
Item var = gen(lhs, type);
genLoad(rhs, type);
lastExpr = tmpLastExpr;
+ exitLabel = tmpExitLabel;
return check(store(var));
case New(Tree init):
@@ -588,11 +575,17 @@ public final class GenMSIL {
return gen(rhs, toType);
case Switch(Tree test, int[] tags, Tree[] bodies, Tree otherwise):
- LocalBuilder testLoc = code.DeclareLocal(tc.INT);
- Item loc = items.LocalItem(testLoc);
boolean tmpLastExpr = lastExpr; lastExpr = false;
- genLoad(test, MSILType.I4);
- store(loc);
+ Item loc = gen(test, MSILType.I4);
+ switch (loc) {
+ case ArgItem(_):
+ case LocalItem(_):
+ case LiteralItem(_):
+ break;
+ default:
+ loc = items.LocalItem(code.DeclareLocal(tc.INT));
+ store(loc);
+ }
lastExpr = tmpLastExpr;
Label tmpExitLabel = exitLabel;
if (exitLabel == null)