summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2004-03-22 10:34:30 +0000
committermihaylov <mihaylov@epfl.ch>2004-03-22 10:34:30 +0000
commitef1bee05f0fb8809b11f8f14a87a9a004aa00367 (patch)
treebdc96a84b18d58a0dc49f11ed8dd50fcbf980e4f /sources
parente0ae9dedb091915dd8b951a6d8ddca9d975db8d8 (diff)
downloadscala-ef1bee05f0fb8809b11f8f14a87a9a004aa00367.tar.gz
scala-ef1bee05f0fb8809b11f8f14a87a9a004aa00367.tar.bz2
scala-ef1bee05f0fb8809b11f8f14a87a9a004aa00367.zip
- Added support for bitwise logical operations ...
- Added support for bitwise logical operations on .NET enumerations.
Diffstat (limited to 'sources')
-rw-r--r--sources/scalac/backend/msil/GenMSIL.java6
-rw-r--r--sources/scalac/symtab/classfile/CLRClassParser.java17
2 files changed, 17 insertions, 6 deletions
diff --git a/sources/scalac/backend/msil/GenMSIL.java b/sources/scalac/backend/msil/GenMSIL.java
index 41c3159a9f..c583647f47 100644
--- a/sources/scalac/backend/msil/GenMSIL.java
+++ b/sources/scalac/backend/msil/GenMSIL.java
@@ -866,13 +866,10 @@ public final class GenMSIL {
qualifier, right, resType);
}
- //Primitive enumCmp = enumCmp(sym);
-
Symbol owner = sym.owner();
Type t = tc.getType(owner);
assert t != null;
if (t.IsEnum()) {
- System.out.println("Enumeration class: " + t);
Primitive enumOp = null;
if (sym.name == Names.EQ) enumOp = Primitive.EQ;
else if (sym.name == Names.NE) enumOp = Primitive.NE;
@@ -880,6 +877,9 @@ public final class GenMSIL {
else if (sym.name == Names.LE) enumOp = Primitive.LE;
else if (sym.name == Names.GT) enumOp = Primitive.GT;
else if (sym.name == Names.GE) enumOp = Primitive.GE;
+ else if (sym.name == Names.OR) enumOp = Primitive.OR;
+ else if (sym.name == Names.AND) enumOp = Primitive.AND;
+ else if (sym.name == Names.XOR) enumOp = Primitive.XOR;
if (enumOp != null) {
assert args.length == 1;
return primitiveOp(enumOp, qualifier, args[0], resType);
diff --git a/sources/scalac/symtab/classfile/CLRClassParser.java b/sources/scalac/symtab/classfile/CLRClassParser.java
index db2a85164e..8ac897cca5 100644
--- a/sources/scalac/symtab/classfile/CLRClassParser.java
+++ b/sources/scalac/symtab/classfile/CLRClassParser.java
@@ -36,6 +36,8 @@ public class CLRClassParser extends SymbolLoader {
private static Name[] ENUM_CMP_NAMES = new Name[]
{ Names.EQ, Names.NE, Names.LT, Names.LE, Names.GT, Names.GE };
+ private static Name[] ENUM_BIT_LOG_NAMES = new Name[]
+ { Names.OR, Names.AND, Names.XOR };
protected String doComplete(Symbol clazz) {
try { return doComplete0(clazz); }
@@ -183,9 +185,9 @@ public class CLRClassParser extends SymbolLoader {
importer.map(method, methods[i]);
}
- // for enumerations introduce dummy comparison methods;
- // the backend should recognize and replace them with
- // comparison operations on the primitive underlying type
+ // for enumerations introduce comparison and bitwise logical operations;
+ // the backend should recognize and replace them with comparison or
+ // bitwise logical operations on the primitive underlying type
if (type.IsEnum()) {
scalac.symtab.Type[] argTypes = new scalac.symtab.Type[] {ctype};
int mods = Modifiers.JAVA | Modifiers.FINAL;
@@ -200,6 +202,15 @@ public class CLRClassParser extends SymbolLoader {
enumCmp.setInfo(enumCmpType);
members.enterOrOverload(enumCmp);
}
+ for (int i = 0; i < ENUM_BIT_LOG_NAMES.length; i++) {
+ scalac.symtab.Type enumBitLogType = make.methodType
+ (argTypes, ctype, scalac.symtab.Type.EMPTY_ARRAY);
+ Symbol enumBitLog = clazz.newMethod
+ (Position.NOPOS, mods, ENUM_BIT_LOG_NAMES[i]);
+ setParamOwners(enumBitLogType, enumBitLog);
+ enumBitLog.setInfo(enumBitLogType);
+ members.enterOrOverload(enumBitLog);
+ }
}
ConstructorInfo[] constrs = type.getConstructors();