diff options
author | mihaylov <mihaylov@epfl.ch> | 2007-02-06 16:43:20 +0000 |
---|---|---|
committer | mihaylov <mihaylov@epfl.ch> | 2007-02-06 16:43:20 +0000 |
commit | a27f9a3b43732372c5e48159d188036fe323e561 (patch) | |
tree | 06429264f0dd549ca00917ff287c07403f627e91 | |
parent | 56f672fec177cd45175f1f71e0e21e6bca201c1b (diff) | |
download | scala-a27f9a3b43732372c5e48159d188036fe323e561.tar.gz scala-a27f9a3b43732372c5e48159d188036fe323e561.tar.bz2 scala-a27f9a3b43732372c5e48159d188036fe323e561.zip |
Use tuple syntax instead of Pair/Triple in the ...
Use tuple syntax instead of Pair/Triple in the backend
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 63 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala | 62 |
2 files changed, 63 insertions, 62 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 7dc3b8524f..2da62c7806 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -480,47 +480,48 @@ abstract class GenICode extends SubComponent { val kind = toTypeKind(tree.tpe) var handlers = for (val CaseDef(pat, _, body) <- catches.reverse) yield pat match { - case Typed(Ident(nme.WILDCARD), tpt) => Triple(tpt.tpe.symbol, kind, { + case Typed(Ident(nme.WILDCARD), tpt) => {tpt.tpe.symbol, kind, { ctx: Context => ctx.bb.emit(DROP(REFERENCE(tpt.tpe.symbol))); val ctx1 = genLoad(body, ctx, kind); genLoad(finalizer, ctx1, UNIT); - }) + }} - case Ident(nme.WILDCARD) => Triple(definitions.ThrowableClass, kind, { + case Ident(nme.WILDCARD) => {definitions.ThrowableClass, kind, { ctx: Context => ctx.bb.emit(DROP(REFERENCE(definitions.ThrowableClass))) val ctx1 = genLoad(body, ctx, kind) genLoad(finalizer, ctx1, UNIT) - }) + }} case Bind(name, _) => val exception = new Local(pat.symbol, toTypeKind(pat.symbol.tpe), false) ctx.method.addLocal(exception); - Triple(pat.symbol.tpe.symbol, kind, { - ctx: Context => - ctx.bb.emit(STORE_LOCAL(exception), pat.pos); - val ctx1 = genLoad(body, ctx, kind); - genLoad(finalizer, ctx1, UNIT); - }) + {pat.symbol.tpe.symbol, kind, { + ctx: Context => + ctx.bb.emit(STORE_LOCAL(exception), pat.pos); + val ctx1 = genLoad(body, ctx, kind); + genLoad(finalizer, ctx1, UNIT); + }} } if (finalizer != EmptyTree) - handlers = Triple(NoSymbol, kind, { - ctx: Context => - val exception = new Local(ctx.method.symbol.newVariable(finalizer.pos, unit.fresh.newName("exc")) - .setFlag(Flags.SYNTHETIC) - .setInfo(definitions.ThrowableClass.tpe), - REFERENCE(definitions.ThrowableClass), false); - ctx.method.addLocal(exception); - ctx.bb.emit(STORE_LOCAL(exception)); - val ctx1 = genLoad(finalizer, ctx, UNIT); - ctx1.bb.emit(LOAD_LOCAL(exception)); - ctx1.bb.emit(THROW()); - ctx1.bb.enterIgnoreMode; - ctx1 - }) :: handlers; + handlers = { NoSymbol, kind, { + ctx: Context => + val exception = new Local(ctx.method.symbol + .newVariable(finalizer.pos, unit.fresh.newName("exc")) + .setFlag(Flags.SYNTHETIC) + .setInfo(definitions.ThrowableClass.tpe), + REFERENCE(definitions.ThrowableClass), false); + ctx.method.addLocal(exception); + ctx.bb.emit(STORE_LOCAL(exception)); + val ctx1 = genLoad(finalizer, ctx, UNIT); + ctx1.bb.emit(LOAD_LOCAL(exception)); + ctx1.bb.emit(THROW()); + ctx1.bb.enterIgnoreMode; + ctx1 + }} :: handlers; ctx.Try( bodyCtx => { @@ -1265,9 +1266,9 @@ abstract class GenICode extends SubComponent { def genComparisonOp(l: Tree, r: Tree, code: Int): Unit = { // special-case reference (in)equality test for null if (code == scalaPrimitives.ID || code == scalaPrimitives.NI) { - val expr: Tree = Pair(l, r) match { - case Pair(Literal(Constant(null)), expr) => expr - case Pair(expr, Literal(Constant(null))) => expr + val expr: Tree = {l, r} match { + case {Literal(Constant(null)), expr} => expr + case {expr, Literal(Constant(null))} => expr case _ => null } if (expr ne null) { @@ -1383,15 +1384,15 @@ abstract class GenICode extends SubComponent { local } - Pair(l, r) match { + {l, r} match { // null == expr -> expr eq null - case Pair(Literal(Constant(null)), expr) => + case {Literal(Constant(null)), expr} => val ctx1 = genLoad(expr, ctx, ANY_REF_CLASS) ctx1.bb.emit(CZJUMP(thenCtx.bb, elseCtx.bb, EQ, ANY_REF_CLASS)) ctx1.bb.close // expr == null -> if(expr eq null) true else expr.equals(null) - case Pair(expr, Literal(Constant(null))) => + case {expr, Literal(Constant(null))} => val eqEqTempLocal = getTempLocal var ctx1 = genLoad(expr, ctx, ANY_REF_CLASS) ctx1.bb.emit(DUP(ANY_REF_CLASS)) @@ -1774,7 +1775,7 @@ abstract class GenICode extends SubComponent { * } ))</code> */ def Try(body: Context => Context, - handlers: List[Triple[Symbol, TypeKind, (Context => Context)]], + handlers: List[{Symbol, TypeKind, (Context => Context)}], finalizer: Tree) = { val outerCtx = this.dup val afterCtx = outerCtx.newBlock diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index c719a939bb..34e52699da 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -135,7 +135,7 @@ abstract class GenJVM extends SubComponent { log("Generating class " + c.symbol + " flags: " + Flags.flagsToString(c.symbol.flags)) clasz = c - innerClasses = ListSet.Empty + innerClasses = ListSet.empty var parents = c.symbol.info.parents var ifaces = JClass.NO_INTERFACES @@ -202,7 +202,7 @@ abstract class GenJVM extends SubComponent { } def addExceptionsAttribute(sym: Symbol): Unit = { - val Pair(excs, others) = sym.attributes.partition((a => a match { + val {excs, others} = sym.attributes.partition((a => a match { case AttrInfo(ThrowsAttr, _, _) => true case _ => false })) @@ -288,7 +288,7 @@ abstract class GenJVM extends SubComponent { buf.putShort(cpool.addUtf8("value").toShort) emitElement(consts.head) } - for (val Pair(name, value) <- nvPairs) { + for (val {name, value} <- nvPairs) { buf.putShort(cpool.addUtf8(name.toString()).toShort) emitElement(value) } @@ -592,7 +592,7 @@ abstract class GenJVM extends SubComponent { if (! (covered contains b) ) { if (start >= 0) { // we're inside a handler range end = labels(b).getAnchor() - ranges = Pair(start, end) :: ranges + ranges = {start, end} :: ranges start = -1 } } else { @@ -611,7 +611,7 @@ abstract class GenJVM extends SubComponent { * code! */ if (start >= 0) { - ranges = Pair(start, jcode.getPC()) :: ranges; + ranges = {start, jcode.getPC()} :: ranges; } if (covered != Nil) @@ -1074,67 +1074,67 @@ abstract class GenJVM extends SubComponent { abort("Unknown arithmetic primitive " + primitive) } - case Logical(op, kind) => Pair(op, kind) match { - case Pair(AND, LONG) => + case Logical(op, kind) => {op, kind} match { + case {AND, LONG} => jcode.emitLAND() - case Pair(AND, INT) => + case {AND, INT} => jcode.emitIAND() - case Pair(AND, _) => + case {AND, _} => jcode.emitIAND() if (kind != BOOL) jcode.emitT2T(javaType(INT), javaType(kind)); - case Pair(OR, LONG) => + case {OR, LONG} => jcode.emitLOR() - case Pair(OR, INT) => + case {OR, INT} => jcode.emitIOR() - case Pair(OR, _) => + case {OR, _} => jcode.emitIOR() if (kind != BOOL) jcode.emitT2T(javaType(INT), javaType(kind)); - case Pair(XOR, LONG) => + case {XOR, LONG} => jcode.emitLXOR() - case Pair(XOR, INT) => + case {XOR, INT} => jcode.emitIXOR() - case Pair(XOR, _) => + case {XOR, _} => jcode.emitIXOR() if (kind != BOOL) jcode.emitT2T(javaType(INT), javaType(kind)); } - case Shift(op, kind) => Pair(op, kind) match { - case Pair(LSL, LONG) => + case Shift(op, kind) => {op, kind} match { + case {LSL, LONG} => jcode.emitLSHL() - case Pair(LSL, INT) => + case {LSL, INT} => jcode.emitISHL() - case Pair(LSL, _) => + case {LSL, _} => jcode.emitISHL() jcode.emitT2T(javaType(INT), javaType(kind)) - case Pair(ASR, LONG) => + case {ASR, LONG} => jcode.emitLSHR() - case Pair(ASR, INT) => + case {ASR, INT} => jcode.emitISHR() - case Pair(ASR, _) => + case {ASR, _} => jcode.emitISHR() jcode.emitT2T(javaType(INT), javaType(kind)) - case Pair(LSR, LONG) => + case {LSR, LONG} => jcode.emitLUSHR() - case Pair(LSR, INT) => + case {LSR, INT} => jcode.emitIUSHR() - case Pair(LSR, _) => + case {LSR, _} => jcode.emitIUSHR() jcode.emitT2T(javaType(INT), javaType(kind)) } - case Comparison(op, kind) => Pair(op, kind) match { - case Pair(CMP, LONG) => jcode.emitLCMP() - case Pair(CMPL, FLOAT) => jcode.emitFCMPL() - case Pair(CMPG, FLOAT) => jcode.emitFCMPG() - case Pair(CMPL, DOUBLE) => jcode.emitDCMPL() - case Pair(CMPG, DOUBLE) => jcode.emitDCMPL() + case Comparison(op, kind) => {op, kind} match { + case {CMP, LONG} => jcode.emitLCMP() + case {CMPL, FLOAT} => jcode.emitFCMPL() + case {CMPG, FLOAT} => jcode.emitFCMPG() + case {CMPL, DOUBLE} => jcode.emitDCMPL() + case {CMPG, DOUBLE} => jcode.emitDCMPL() } case Conversion(src, dst) => |