From 491ecd7b8b2e5a0ee1f185f26042a80e11e46568 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 17 Oct 2010 06:59:23 +0000 Subject: Reverted previous commit as I think it is wedgi... Reverted previous commit as I think it is wedging under -optimise. No review. --- .../scala/tools/nsc/backend/jvm/GenJVM.scala | 17 ++------------- src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java | 25 ---------------------- src/fjbg/ch/epfl/lamp/fjbg/JClass.java | 11 ++-------- src/fjbg/ch/epfl/lamp/fjbg/JCode.java | 1 + src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java | 14 ++++++------ src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java | 2 +- src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java | 6 +++--- src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java | 2 +- src/fjbg/ch/epfl/lamp/fjbg/JMember.java | 1 + src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java | 8 +++---- src/fjbg/ch/epfl/lamp/fjbg/JType.java | 2 +- 11 files changed, 23 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 7afa36c0ba..5a02de0907 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -15,8 +15,6 @@ import scala.tools.nsc.symtab._ import scala.tools.nsc.symtab.classfile.ClassfileConstants._ import ch.epfl.lamp.fjbg._ -import FJBGContext.FJBGWrapper -import JCode.OffsetTooBigException import JAccessFlags._ import JObjectType.{ JAVA_LANG_STRING, JAVA_LANG_OBJECT } import java.io.{ DataOutputStream } @@ -140,15 +138,6 @@ abstract class GenJVM extends SubComponent { val emitLines = debugLevel >= 2 val emitVars = debugLevel >= 3 - def analyzeException(culprit: String, t: Throwable): Unit = t match { - case x: FJBGWrapper => - analyzeException(x.culprit, x.getCause()) - case _: OffsetTooBigException => - clasz.cunit.error(clasz.symbol.pos, "cannot emit bytecode for " + culprit + ": " + t.getMessage) - case x => - throw x - } - /** Write a class to disk, adding the Scala signature (pickled type * information) and inner classes. * @@ -159,10 +148,8 @@ abstract class GenJVM extends SubComponent { addInnerClasses(jclass) val outfile = getFile(sym, jclass, ".class") val outstream = new DataOutputStream(outfile.bufferedOutput) - try jclass.writeTo(outstream) - catch { case x => analyzeException(jclass.getName(), x) } - finally outstream.close() - + jclass.writeTo(outstream) + outstream.close() informProgress("wrote " + outfile) } diff --git a/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java b/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java index cfc4ed00e5..569a9ac272 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java @@ -28,31 +28,6 @@ public class FJBGContext { MINOR_VERSION = minor; } - public static class FJBGWrapper extends RuntimeException { - public String culprit; - public FJBGWrapper(Throwable cause) { - super(cause); - this.culprit = ""; - } - public FJBGWrapper(String culprit, Throwable cause) { - super(cause); - this.culprit = culprit; - } - } - - static FJBGWrapper mkFatal(String culprit, Throwable t) { - return new FJBGWrapper(culprit, t); - } - static FJBGWrapper mkFatal(Throwable t) { - return new FJBGWrapper(t); - } - static RuntimeException mkFatal(Object obj) { - return new FJBGWrapper(new java.lang.Error(obj.toString())); - } - static RuntimeException mkFatal(String message) { - return new FJBGWrapper(new java.lang.Error(message)); - } - // Factory methods ////////////////////////////////////////////////////////////////////// diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JClass.java b/src/fjbg/ch/epfl/lamp/fjbg/JClass.java index 3839af4156..0fc604424a 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JClass.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JClass.java @@ -310,15 +310,8 @@ public class JClass extends JMember { stream.writeShort(methods.size()); Iterator methodsIt = methods.iterator(); - while (methodsIt.hasNext()) { - JMethod m = (JMethod)methodsIt.next(); - try { - m.writeTo(stream); - } - catch (Throwable t) { - throw FJBGContext.mkFatal(name + "." + m.getName(), t); - } - } + while (methodsIt.hasNext()) + ((JMethod)methodsIt.next()).writeTo(stream); // Attributes JAttribute.writeTo(attributes, stream); diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JCode.java b/src/fjbg/ch/epfl/lamp/fjbg/JCode.java index 2506a06c03..f7d275c8a7 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JCode.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JCode.java @@ -889,6 +889,7 @@ public class JCode { public OffsetTooBigException() { super(); } public OffsetTooBigException(String message) { super(message); } } + protected void checkOffset16(int offset) throws OffsetTooBigException { if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) throw new OffsetTooBigException("offset too big to fit" diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java b/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java index 5ca4f14215..34b38c828d 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java @@ -125,7 +125,7 @@ public class JCodeIterator { else return 4; } else - throw FJBGContext.mkFatal("Unknown size for instruction " + opcode); + throw new Error("Unknown size for instruction " + opcode); } /** @@ -144,7 +144,7 @@ public class JCodeIterator { int npairsPos = pc + 1 + pad4(pc + 1) + 4; return 1 + codeArray.getS4(npairsPos); } else - throw FJBGContext.mkFatal("Unknown successors for instruction " + opcode); + throw new Error("Unknown successors for instruction " + opcode); } /** @@ -185,7 +185,7 @@ public class JCodeIterator { return pc + codeArray.getS4(defaultPos + 2*4 + 4 + 8 * (index - 1)); } default: - throw FJBGContext.mkFatal(""); + throw new Error(); } } @@ -226,7 +226,7 @@ public class JCodeIterator { else return 0; // (IINC) } default : - throw FJBGContext.mkFatal(opcode.toString()); + throw new Error(opcode.toString()); } } else return JType.getTotalSize(opcode.getProducedDataTypes()); @@ -281,7 +281,7 @@ public class JCodeIterator { case JOpcode.cMULTIANEWARRAY : return codeArray.getU1(pc + 3); default: - throw FJBGContext.mkFatal(opcode.toString()); + throw new Error(opcode.toString()); } } } @@ -315,7 +315,7 @@ public class JCodeIterator { return 0; // (IINC) } default: - throw FJBGContext.mkFatal("JOpcode implementation error"); + throw new Error("JOpcode implementation error"); } } } @@ -358,7 +358,7 @@ public class JCodeIterator { // return JOpcode.OPCODES[op].getConsumedDataTypes().length; // else return 0; // (IINC) // case 197 : return codeArray.getU1(pc + 3); // MULTIANEWARRAY -// default : throw FJBGContext.mkFatal("JOpcode implementation error"); +// default : throw new Error("JOpcode implementation error"); // } // } else return opcode.getConsumedDataTypes().length; // } diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java b/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java index 765411d5fb..0df4498d8e 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java @@ -104,7 +104,7 @@ public class JConstantPool { case 12 : return "Methodref"; case 13 : return "InterfaceMethodref"; case 14 : return "NameAndType"; - default : throw FJBGContext.mkFatal("invalid constant pool tag : " + tag); + default : throw new Error("invalid constant pool tag : " + tag); } } diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java index cbb0ce37db..69b522b622 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java @@ -463,7 +463,7 @@ public class JExtendedCode extends JCode { JOpcode[] conv = typeConversions[fromType.getTag() - 4][toType.getTag() - 4]; if (conv == forbidden) { - throw FJBGContext.mkFatal("inconvertible types : " + fromType.toString() + throw new Error("inconvertible types : " + fromType.toString() + " -> " + toType.toString()); } else if (conv != nothingToDo) { for (int i = 0; i < conv.length; i++) { @@ -518,7 +518,7 @@ public class JExtendedCode extends JCode { try { emitGOTO(label); } catch (OffsetTooBigException e) { - throw FJBGContext.mkFatal(e); + throw new Error(e); } } } @@ -532,7 +532,7 @@ public class JExtendedCode extends JCode { try { emitGOTO(targetPC); } catch (OffsetTooBigException e) { - throw FJBGContext.mkFatal(e); + throw new Error(e); } } } diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java b/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java index b97657c196..fec7310bdf 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java @@ -110,7 +110,7 @@ abstract public class JFieldOrMethod extends JMember { freeze(); } catch (JCode.OffsetTooBigException e) { - throw FJBGContext.mkFatal(owner.name + "." + name, e); + throw new Error(e); } } stream.writeShort(accessFlags); diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JMember.java b/src/fjbg/ch/epfl/lamp/fjbg/JMember.java index 3b4ce38094..8d082fb90d 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JMember.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JMember.java @@ -13,6 +13,7 @@ import java.util.Iterator; */ abstract public class JMember { + protected boolean frozen = false; protected final FJBGContext context; diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java b/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java index ca144a6b8d..f7ee688784 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java @@ -1201,7 +1201,7 @@ public class JOpcode { case cDUP2_X2: return 6; default: - throw FJBGContext.mkFatal(this.toString()); + throw new Error(this.toString()); } } } @@ -1220,7 +1220,7 @@ public class JOpcode { case cDUP2_X2: return 4; default: - throw FJBGContext.mkFatal(this.toString()); + throw new Error(this.toString()); } } } @@ -1240,7 +1240,7 @@ public class JOpcode { case cDUP_X1: return 3; default: - throw FJBGContext.mkFatal(this.toString()); + throw new Error(this.toString()); } } } @@ -1256,7 +1256,7 @@ public class JOpcode { case cDUP2: case cDUP2_X1: case cPOP2: case cSWAP: return 2; default: - throw FJBGContext.mkFatal(this.toString()); + throw new Error(this.toString()); } } } diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JType.java b/src/fjbg/ch/epfl/lamp/fjbg/JType.java index a62925d1b0..b926a59f5a 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JType.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JType.java @@ -100,7 +100,7 @@ abstract public class JType { } catch (IllegalArgumentException e) { throw new IllegalArgumentException("invalid signature " + signature); } catch (IOException e) { - throw FJBGContext.mkFatal(e); + throw new Error(e); } } -- cgit v1.2.3