summaryrefslogtreecommitdiff
path: root/sources/scalac
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2005-06-24 15:24:03 +0000
committermihaylov <mihaylov@epfl.ch>2005-06-24 15:24:03 +0000
commit5271830578a79246ff1a5b3f5284641ed8c261b4 (patch)
treeb9e13c1cffb27385d3aa4341ad8c1704fb9b751f /sources/scalac
parent43e1f829ef446e1f5d8e4a360b2be68b1a7065c6 (diff)
downloadscala-5271830578a79246ff1a5b3f5284641ed8c261b4.tar.gz
scala-5271830578a79246ff1a5b3f5284641ed8c261b4.tar.bz2
scala-5271830578a79246ff1a5b3f5284641ed8c261b4.zip
Implemented support for the scala.Cloneable att...
Implemented support for the scala.Cloneable attribute
Diffstat (limited to 'sources/scalac')
-rw-r--r--sources/scalac/backend/msil/GenMSIL.java21
-rw-r--r--sources/scalac/symtab/classfile/CLRClassParser.java3
2 files changed, 17 insertions, 7 deletions
diff --git a/sources/scalac/backend/msil/GenMSIL.java b/sources/scalac/backend/msil/GenMSIL.java
index ec490359d9..8aab417000 100644
--- a/sources/scalac/backend/msil/GenMSIL.java
+++ b/sources/scalac/backend/msil/GenMSIL.java
@@ -42,7 +42,6 @@ import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
-import java.io.IOException;
/**
* Generates MS IL code via Reflection.Emit-like API
@@ -209,9 +208,6 @@ public final class GenMSIL {
* Generate the code for a class definition
*/
private void genClass(Symbol clazz, Tree[] body) {
-// AttrInfo attrs = global.getAttributes(clazz);
-// if (attrs != null)
-// System.out.println("" + attrs + Debug.show(clazz));
Symbol outerClass = currentClass;
currentClass = clazz;
if (clazz.isModuleClass()) {
@@ -253,6 +249,20 @@ public final class GenMSIL {
+ Debug.show(body[i]);
}
}
+ if (tc.isCloneable(clazz)) {
+ Symbol cloneSym = clazz.lookup(Names.clone);
+ if (cloneSym.isNone()) {
+ short mods = MethodAttributes.Public
+ | MethodAttributes.Virtual
+ | MethodAttributes.HideBySig;
+ ILGenerator code =
+ type.DefineMethod("Clone", mods, tc.OBJECT, Type.EmptyTypes)
+ .GetILGenerator();
+ code.Emit(OpCodes.Ldarg_0);
+ code.Emit(OpCodes.Call, tc.MEMBERWISE_CLONE);
+ code.Emit(OpCodes.Ret);
+ }
+ }
currentClass = outerClass;
} //genClass()
@@ -278,9 +288,6 @@ public final class GenMSIL {
* Generate code for constructors and methods.
*/
private void genDef(Symbol sym, ValDef[] parameters, Tree rhs, MSILType toType) {
-// AttrInfo attrs = global.getAttributes(sym);
-// if (attrs != null)
-// System.out.println("" + attrs + Debug.show(sym));
MethodBase method = tc.getMethod(sym);
params.clear();
diff --git a/sources/scalac/symtab/classfile/CLRClassParser.java b/sources/scalac/symtab/classfile/CLRClassParser.java
index 1c19932c92..92b9409492 100644
--- a/sources/scalac/symtab/classfile/CLRClassParser.java
+++ b/sources/scalac/symtab/classfile/CLRClassParser.java
@@ -300,6 +300,9 @@ public class CLRClassParser extends SymbolLoader {
if (name.equals("Equals") && params.length == 1
&& params[0].ParameterType == clrTypes.OBJECT)
return Names.equals;
+ // TODO: check if the type implements ICloneable?
+ if (name.equals("Clone") && params.length == 0)
+ return Names.clone;
return Name.fromString(name);
}