diff options
author | Miguel Garcia <miguelalfredo.garcia@epfl.ch> | 2012-07-01 17:50:31 +0200 |
---|---|---|
committer | Miguel Garcia <miguelalfredo.garcia@epfl.ch> | 2012-07-01 17:50:31 +0200 |
commit | c6955118cb514af13007321f2e6087521ec86ea8 (patch) | |
tree | 35379d02d48b91162b89da56fcf22fad5b015873 /src/compiler | |
parent | 848295e4486cc33791fd41af5782e0a82ee4f474 (diff) | |
download | scala-c6955118cb514af13007321f2e6087521ec86ea8.tar.gz scala-c6955118cb514af13007321f2e6087521ec86ea8.tar.bz2 scala-c6955118cb514af13007321f2e6087521ec86ea8.zip |
readability of MethodTFA.mutatingInterpret()
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala | 143 |
1 files changed, 37 insertions, 106 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala index 06edaf17d2..c3fbf31cc6 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala @@ -174,11 +174,8 @@ abstract class TypeFlowAnalysis { } i match { - case THIS(clasz) => - stack push toTypeKind(clasz.tpe) - - case CONSTANT(const) => - stack push toTypeKind(const.tpe) + case THIS(clasz) => stack push toTypeKind(clasz.tpe) + case CONSTANT(const) => stack push toTypeKind(const.tpe) case LOAD_ARRAY_ITEM(kind) => stack.pop2 match { @@ -194,139 +191,73 @@ abstract class TypeFlowAnalysis { stack push (if (t == typeLattice.bottom) local.kind else t) case LOAD_FIELD(field, isStatic) => - if (!isStatic) - stack.pop + if (!isStatic) { stack.pop } stack push toTypeKind(field.tpe) - case LOAD_MODULE(module) => - stack push toTypeKind(module.tpe) - - case STORE_ARRAY_ITEM(kind) => - stack.pop3 - - case STORE_LOCAL(local) => - val t = stack.pop - bindings += (local -> t) + case LOAD_MODULE(module) => stack push toTypeKind(module.tpe) + case STORE_ARRAY_ITEM(kind) => stack.pop3 + case STORE_LOCAL(local) => val t = stack.pop; bindings += (local -> t) + case STORE_THIS(_) => stack.pop - case STORE_THIS(_) => - stack.pop - - case STORE_FIELD(field, isStatic) => - if (isStatic) - stack.pop - else - stack.pop2 + case STORE_FIELD(field, isStatic) => if (isStatic) stack.pop else stack.pop2 case CALL_PRIMITIVE(primitive) => primitive match { - case Negation(kind) => - stack.pop; stack.push(kind) + case Negation(kind) => stack.pop; stack.push(kind) + case Test(_, kind, zero) => stack.pop - if (!zero) stack.pop + if (!zero) { stack.pop } stack push BOOL; - case Comparison(_, _) => - stack.pop2 - stack push INT + + case Comparison(_, _) => stack.pop2; stack push INT case Arithmetic(op, kind) => stack.pop - if (op != NOT) - stack.pop + if (op != NOT) { stack.pop } val k = kind match { case BYTE | SHORT | CHAR => INT case _ => kind } stack push k - case Logical(op, kind) => - stack.pop2 - stack push kind - - case Shift(op, kind) => - stack.pop2 - stack push kind - - case Conversion(src, dst) => - stack.pop - stack push dst - - case ArrayLength(kind) => - stack.pop - stack push INT - - case StartConcat => - stack.push(ConcatClass) - - case EndConcat => - stack.pop - stack.push(STRING) - - case StringConcat(el) => - stack.pop2 - stack push ConcatClass + case Logical(op, kind) => stack.pop2; stack push kind + case Shift(op, kind) => stack.pop2; stack push kind + case Conversion(src, dst) => stack.pop; stack push dst + case ArrayLength(kind) => stack.pop; stack push INT + case StartConcat => stack.push(ConcatClass) + case EndConcat => stack.pop; stack.push(STRING) + case StringConcat(el) => stack.pop2; stack push ConcatClass } case cm @ CALL_METHOD(_, _) => stack pop cm.consumed cm.producedTypes foreach (stack push _) - case BOX(kind) => - stack.pop - stack.push(BOXED(kind)) - - case UNBOX(kind) => - stack.pop - stack.push(kind) - - case NEW(kind) => - stack.push(kind) - - case CREATE_ARRAY(elem, dims) => - stack.pop(dims) - stack.push(ARRAY(elem)) - - case IS_INSTANCE(tpe) => - stack.pop - stack.push(BOOL) - - case CHECK_CAST(tpe) => - stack.pop - stack.push(tpe) - - case SWITCH(tags, labels) => - stack.pop - - case JUMP(whereto) => - () - - case CJUMP(success, failure, cond, kind) => - stack.pop2 + case BOX(kind) => stack.pop; stack.push(BOXED(kind)) + case UNBOX(kind) => stack.pop; stack.push(kind) - case CZJUMP(success, failure, cond, kind) => - stack.pop + case NEW(kind) => stack.push(kind) - case RETURN(kind) => - if (kind != UNIT) - stack.pop; + case CREATE_ARRAY(elem, dims) => stack.pop(dims); stack.push(ARRAY(elem)) - case THROW(_) => - stack.pop + case IS_INSTANCE(tpe) => stack.pop; stack.push(BOOL) + case CHECK_CAST(tpe) => stack.pop; stack.push(tpe) - case DROP(kind) => - stack.pop + case _: SWITCH => stack.pop + case _: JUMP => () + case _: CJUMP => stack.pop2 + case _: CZJUMP => stack.pop - case DUP(kind) => - stack.push(stack.head) + case RETURN(kind) => if (kind != UNIT) { stack.pop } + case THROW(_) => stack.pop - case MONITOR_ENTER() => - stack.pop + case DROP(kind) => stack.pop + case DUP(kind) => stack.push(stack.head) - case MONITOR_EXIT() => - stack.pop + case MONITOR_ENTER() | MONITOR_EXIT() => stack.pop - case SCOPE_ENTER(_) | SCOPE_EXIT(_) => - () + case SCOPE_ENTER(_) | SCOPE_EXIT(_) => () case LOAD_EXCEPTION(clasz) => stack.pop(stack.length) |