summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-03-02 17:35:49 +0000
committerpaltherr <paltherr@epfl.ch>2004-03-02 17:35:49 +0000
commitdbb4b1b89d574f00400e9d40cf598f598d5aa78f (patch)
tree6279826167e7382175d23b069bb950a0336ff4c9
parent63e5a79c2b4c2c11ce4c81df1387aca31d34a247 (diff)
downloadscala-dbb4b1b89d574f00400e9d40cf598f598d5aa78f.tar.gz
scala-dbb4b1b89d574f00400e9d40cf598f598d5aa78f.tar.bz2
scala-dbb4b1b89d574f00400e9d40cf598f598d5aa78f.zip
- Named the java access modifiers
-rw-r--r--sources/scalac/symtab/classfile/ClassfileConstants.java16
-rw-r--r--sources/scalac/symtab/classfile/ClassfileParser.java33
2 files changed, 33 insertions, 16 deletions
diff --git a/sources/scalac/symtab/classfile/ClassfileConstants.java b/sources/scalac/symtab/classfile/ClassfileConstants.java
index 4e75050c02..02c07eea4b 100644
--- a/sources/scalac/symtab/classfile/ClassfileConstants.java
+++ b/sources/scalac/symtab/classfile/ClassfileConstants.java
@@ -16,6 +16,22 @@ public interface ClassfileConstants {
int JAVA_MAJOR_VERSION = 45;
int JAVA_MINOR_VERSION = 3;
+ int JAVA_ACC_PUBLIC = 0x0001;
+ int JAVA_ACC_PRIVATE = 0x0002;
+ int JAVA_ACC_PROTECTED = 0x0004;
+ int JAVA_ACC_STATIC = 0x0008;
+ int JAVA_ACC_FINAL = 0x0010;
+ int JAVA_ACC_SUPER = 0x0020;
+ int JAVA_ACC_SYNCHRONIZED = 0x0020;
+ int JAVA_ACC_VOLATILE = 0x0040;
+ int JAVA_ACC_BRIDGE = 0x0040;
+ int JAVA_ACC_TRANSIENT = 0x0080;
+ int JAVA_ACC_NATIVE = 0x0100;
+ int JAVA_ACC_INTERFACE = 0x0200;
+ int JAVA_ACC_ABSTRACT = 0x0400;
+ int JAVA_ACC_STRICT = 0x0800;
+ int JAVA_ACC_SYNTHETIC = 0x1000;
+
int CONSTANT_UTF8 = 1;
int CONSTANT_UNICODE = 2;
int CONSTANT_INTEGER = 3;
diff --git a/sources/scalac/symtab/classfile/ClassfileParser.java b/sources/scalac/symtab/classfile/ClassfileParser.java
index c50b0f93dd..6aa8d599c6 100644
--- a/sources/scalac/symtab/classfile/ClassfileParser.java
+++ b/sources/scalac/symtab/classfile/ClassfileParser.java
@@ -137,19 +137,20 @@ public class ClassfileParser implements ClassfileConstants {
*/
public int transFlags(int flags) {
int res = 0;
- if (((flags & 0x0007) == 0) ||
- ((flags & 0x0002) != 0))
+ if ((flags & JAVA_ACC_PRIVATE) != 0)
res |= Modifiers.PRIVATE;
- else if ((flags & 0x0004) != 0)
+ else if ((flags & JAVA_ACC_PROTECTED) != 0)
res |= Modifiers.PROTECTED;
- if ((flags & 0x0400) != 0)
+ else if ((flags & JAVA_ACC_PUBLIC) == 0)
+ res |= Modifiers.PRIVATE;
+ if ((flags & JAVA_ACC_ABSTRACT) != 0)
res |= Modifiers.DEFERRED;
- if ((flags & 0x0010) != 0)
+ if ((flags & JAVA_ACC_FINAL) != 0)
res |= Modifiers.FINAL;
- if ((flags & 0x0200) != 0)
+ if ((flags & JAVA_ACC_INTERFACE) != 0)
res |= Modifiers.INTERFACE | Modifiers.TRAIT | Modifiers.ABSTRACT;
- if ((flags & 0x1000) != 0)
- res |= Modifiers.SYNTHETIC;
+ if ((flags & JAVA_ACC_SYNTHETIC) != 0)
+ res |= Modifiers.SYNTHETIC;
return res | Modifiers.JAVA;
}
@@ -184,15 +185,15 @@ public class ClassfileParser implements ClassfileConstants {
Name name = (Name)pool.readPool(in.nextChar());
Type type = readType(in.nextChar());
int mods = transFlags(flags);
- if ((flags & 0x0010) == 0)
+ if ((flags & JAVA_ACC_FINAL) == 0)
mods |= Modifiers.MUTABLE;
Symbol owner = c;
- if ((flags & 0x0008) != 0)
+ if ((flags & JAVA_ACC_STATIC) != 0)
owner = c.module().moduleClass();
Symbol s = new TermSymbol(Position.NOPOS, name, owner, mods);
s.setInfo(type);
attrib.readAttributes(s, type, FIELD_ATTR);
- ((flags & 0x0008) != 0 ? statics : locals).enterOrOverload(s);
+ ((flags & JAVA_ACC_STATIC) != 0 ? statics : locals).enterOrOverload(s);
}
/** read a method
@@ -200,15 +201,15 @@ public class ClassfileParser implements ClassfileConstants {
protected void parseMethod() {
int flags = in.nextChar();
int sflags = transFlags(flags);
- if ((flags & 0x0040) != 0)
+ if ((flags & JAVA_ACC_BRIDGE) != 0)
sflags |= Modifiers.BRIDGE;
Name name = (Name)pool.readPool(in.nextChar());
Type type = readType(in.nextChar());
if (CONSTR_N.equals(name)) {
Symbol s = TermSymbol.newConstructor(c, sflags);
// kick out package visible or private constructors
- if (((flags & 0x0002) != 0) ||
- ((flags & 0x0007) == 0)) {
+ if (((flags & JAVA_ACC_PRIVATE) != 0) ||
+ ((flags & (JAVA_ACC_PROTECTED | JAVA_ACC_PUBLIC)) == 0)) {
attrib.readAttributes(s, type, METH_ATTR);
return;
}
@@ -231,13 +232,13 @@ public class ClassfileParser implements ClassfileConstants {
} else {
Symbol s = new TermSymbol(
Position.NOPOS, name,
- ((flags & 0x0008) != 0) ? c.module().moduleClass() : c,
+ ((flags & JAVA_ACC_STATIC) != 0) ? c.module().moduleClass() : c,
sflags);
setParamOwners(type, s);
s.setInfo(type);
attrib.readAttributes(s, type, METH_ATTR);
if ((s.flags & Modifiers.BRIDGE) == 0)
- ((flags & 0x0008) != 0 ? statics : locals).enterOrOverload(s);
+ ((flags & JAVA_ACC_STATIC) != 0 ? statics : locals).enterOrOverload(s);
}
}