summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2007-03-22 09:54:47 +0000
committerIulian Dragos <jaguarul@gmail.com>2007-03-22 09:54:47 +0000
commitf70a92677c714ebdc4831e4a093567325125e690 (patch)
treecc4be1a647a4baa6ed419afdd1097d6cf1429801
parent0c96403c277c5b937392affa701f69f4d16cf82d (diff)
downloadscala-f70a92677c714ebdc4831e4a093567325125e690.tar.gz
scala-f70a92677c714ebdc4831e4a093567325125e690.tar.bz2
scala-f70a92677c714ebdc4831e4a093567325125e690.zip
Rolled back changes for assignments that carry ...
Rolled back changes for assignments that carry their rhs value.
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala68
1 files changed, 38 insertions, 30 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index bd18576e3a..0dab705502 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -142,12 +142,48 @@ abstract class GenICode extends SubComponent {
var currentCtx = ctx
for (val t <- trees)
- currentCtx = genLoad(t, currentCtx, UNIT)
+ currentCtx = genStat(t, currentCtx)
currentCtx
}
/**
+ * Generate code for the given tree. The trees should contain statements
+ * and not produce any value. Use genLoad for expressions which leave
+ * a value on top of the stack.
+ *
+ * @param tree ...
+ * @param ctx ...
+ * @return a new context. This is necessary for control flow instructions
+ * which may change the current basic block.
+ */
+ private def genStat(tree: Tree, ctx: Context): Context = {
+
+ tree match {
+ case Assign(lhs @ Select(_, _), rhs) =>
+ if (isStaticSymbol(lhs.symbol)) {
+ val ctx1 = genLoad(rhs, ctx, toTypeKind(lhs.symbol.info))
+ ctx1.bb.emit(STORE_FIELD(lhs.symbol, true), tree.pos)
+ ctx1
+ } else {
+ var ctx1 = genLoadQualifier(lhs, ctx)
+ ctx1 = genLoad(rhs, ctx1, toTypeKind(lhs.symbol.info))
+ ctx1.bb.emit(STORE_FIELD(lhs.symbol, false), tree.pos)
+ ctx1
+ }
+
+ case Assign(lhs, rhs) =>
+ val ctx1 = genLoad(rhs, ctx, toTypeKind(lhs.symbol.info))
+ val Some(l) = ctx.method.lookupLocal(lhs.symbol)
+ ctx1.bb.emit(STORE_LOCAL(l), tree.pos)
+ ctx1
+
+ case _ =>
+ genLoad(tree, ctx, UNIT)
+ }
+ }
+
+ /**
* Generate code for trees that produce values on the stack
*
* @param tree The tree to be translated
@@ -863,38 +899,10 @@ abstract class GenICode extends SubComponent {
case Typed(expr, _) =>
genLoad(expr, ctx, expectedType)
- case Assign(lhs @ Select(_, _), rhs) =>
- generatedType = UNIT
- val rhsType = toTypeKind(lhs.symbol.info)
- val static = isStaticSymbol(lhs.symbol)
- var ctx1: Context = ctx
-
- if (!static)
- ctx1 = genLoadQualifier(lhs, ctx)
- ctx1 = genLoad(rhs, ctx1, rhsType)
- if (expectedType == rhsType) {
- ctx1.bb.emit(DUP(rhsType))
- generatedType = rhsType
- }
- ctx1.bb.emit(STORE_FIELD(lhs.symbol, static), tree.pos)
- ctx1
-
- case Assign(lhs, rhs) =>
- generatedType = UNIT
- val rhsType = toTypeKind(lhs.symbol.info)
- val ctx1 = genLoad(rhs, ctx, rhsType)
- if (expectedType == rhsType) {
- ctx1.bb.emit(DUP(rhsType))
- generatedType = rhsType
- }
- val Some(l) = ctx.method.lookupLocal(lhs.symbol)
- ctx1.bb.emit(STORE_LOCAL(l), tree.pos)
- ctx1
-/*
case Assign(_, _) =>
generatedType = UNIT
genStat(tree, ctx)
-*/
+
case ArrayValue(tpt @ TypeTree(), elems) =>
var ctx1 = ctx
val elmKind = toTypeKind(tpt.tpe)