diff options
author | schinz <schinz@epfl.ch> | 2003-03-13 13:53:52 +0000 |
---|---|---|
committer | schinz <schinz@epfl.ch> | 2003-03-13 13:53:52 +0000 |
commit | 38ec9ea7d1e586f421b2ed956f516753a51069a1 (patch) | |
tree | f251476297fbba8e49ee0e1c166605b3a1152476 /sources/scalac/backend/jvm | |
parent | fa5c556780e147bc1ecc2ffc2e0754e4f0f4b89f (diff) | |
download | scala-38ec9ea7d1e586f421b2ed956f516753a51069a1.tar.gz scala-38ec9ea7d1e586f421b2ed956f516753a51069a1.tar.bz2 scala-38ec9ea7d1e586f421b2ed956f516753a51069a1.zip |
- inside of a module, use "this" directly to ac...
- inside of a module, use "this" directly to access the current module
instance - (small crash fixed)
Diffstat (limited to 'sources/scalac/backend/jvm')
-rw-r--r-- | sources/scalac/backend/jvm/GenJVM.java | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/sources/scalac/backend/jvm/GenJVM.java b/sources/scalac/backend/jvm/GenJVM.java index 1454c7afaa..92fb946206 100644 --- a/sources/scalac/backend/jvm/GenJVM.java +++ b/sources/scalac/backend/jvm/GenJVM.java @@ -582,11 +582,16 @@ class JVMGenerator { } protected byte genLoadModule(Symbol sym) { - int moduleInstIdx = - currPool.addFieldref(javaName(sym), - MODULE_INSTANCE_FIELD_NAME, - typeStoJ(sym.info()).getSignature()); - currIL.append(new GETSTATIC(moduleInstIdx)); + String javaSymName = javaName(sym); + if (javaSymName.equals(currClassName)) + currIL.append(ic.THIS); + else { + int moduleInstIdx = + currPool.addFieldref(javaSymName, + MODULE_INSTANCE_FIELD_NAME, + typeStoJ(sym.info()).getSignature()); + currIL.append(new GETSTATIC(moduleInstIdx)); + } return cst.T_OBJECT; } @@ -826,11 +831,20 @@ class JVMGenerator { boolean intCompareWithZero = false; for (int i = 0; i < args.length; ++i) { boolean isIntZero = false; - switch (args[i]) { - case Literal(Object val): - if ((maxTypeIdx <= intTypeIdx) && ((Number)val).intValue() == 0) { - isIntZero = true; - if (i == 0) prim = prim.swap(); + if (maxTypeIdx <= intTypeIdx) { + switch (args[i]) { + case Literal(Object val): + int intVal; + if (val instanceof Number) + intVal = ((Number)val).intValue(); + else if (val instanceof Character) + intVal = ((Character)val).charValue(); + else + throw Debug.abort("unknown literal", val); + if (intVal == 0) { + isIntZero = true; + if (i == 0) prim = prim.swap(); + } } } if (intCompareWithZero || !isIntZero) @@ -1460,7 +1474,7 @@ class JVMGenerator { case cst.T_DOUBLE: inst = new DSTORE(pos); break; case cst.T_ARRAY: case cst.T_OBJECT: inst = new ASTORE(pos); break; - default: throw Debug.abort("unexpected type"); + default: throw Debug.abort("unexpected type", type); } } |