summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2005-06-07 16:07:40 +0000
committermihaylov <mihaylov@epfl.ch>2005-06-07 16:07:40 +0000
commitce80365a9dbce1419c0ad631d4d8b4279ea630a8 (patch)
tree1cf667371903685acaf11fbbef4c866821e4264c /sources
parent12be3aab0d822f9c3b7eefcd38fff01c0860d7fd (diff)
downloadscala-ce80365a9dbce1419c0ad631d4d8b4279ea630a8.tar.gz
scala-ce80365a9dbce1419c0ad631d4d8b4279ea630a8.tar.bz2
scala-ce80365a9dbce1419c0ad631d4d8b4279ea630a8.zip
Improved serialization support
Diffstat (limited to 'sources')
-rwxr-xr-xsources/scala/tools/scalac/typechecker/RefCheck.scala5
-rw-r--r--sources/scalac/Global.java30
2 files changed, 29 insertions, 6 deletions
diff --git a/sources/scala/tools/scalac/typechecker/RefCheck.scala b/sources/scala/tools/scalac/typechecker/RefCheck.scala
index 8bee62c5ed..56109ebf07 100755
--- a/sources/scala/tools/scalac/typechecker/RefCheck.scala
+++ b/sources/scala/tools/scalac/typechecker/RefCheck.scala
@@ -902,9 +902,8 @@ class RefCheck(globl: scalac.Global) extends Transformer(globl) {
ts.append(getTypeMethod(clazz));
}
if (clazz.isModuleClass()) {
- val attrs = global.getAttributes(clazz);
- val serializable = attrs != null &&
- attrs.getAttrArguments(defs.SCALA_SERIALIZABLE_CONSTR) != null;
+ val serializable =
+ global.getAttrArguments(clazz, defs.SCALA_SERIALIZABLE_CONSTR) != null;
if (serializable) {
// If you serialize a singleton and then deserialize it twice,
// you will have two instances of your singleton, unless you implement
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java
index 6f6bb899a3..d3e434b4a7 100644
--- a/sources/scalac/Global.java
+++ b/sources/scalac/Global.java
@@ -417,27 +417,51 @@ public abstract class Global {
}
}
- public void addAttribute(Symbol sym, Symbol aSym, AConstant[] params) {
+
+ /** Add attribute for a symbol
+ * @param sym - symbol of the defininition to which the attribute is applied
+ * @param aSym - symbol of the constructor of the attribute class
+ * @param args - arguments to the attribute constructor
+ */
+ public void addAttribute(Symbol sym, Symbol aSym, AConstant[] args) {
AttributeInfo attr = getAttributes(sym);
- attr = new AttributeInfo(aSym, params, attr);
- //mapSymbolAttr.put(sym, attr);
+ attr = new AttributeInfo(aSym, args, attr);
setAttribute(sym, attr);
}
+ /** Add attribute with no arguments
+ * @param sym - symbol of the defininition to which the attribute is applied
+ * @param aSym - symbol of the constructor of the attribute class
+ */
public void addAttribute(Symbol sym, Symbol aSym) {
addAttribute(sym, aSym, AConstant.EMPTY_ARRAY);
}
+ /** Set the attributes for a given symbol
+ */
public void setAttribute(Symbol sym, AttributeInfo attr) {
mapSymbolAttr.put(sym, attr);
if (sym.isModule() && !sym.isModuleClass())
mapSymbolAttr.put(sym.moduleClass(), attr);
}
+ /** Return all attributes for a given symbol
+ */
public AttributeInfo getAttributes(Symbol sym) {
return (AttributeInfo)mapSymbolAttr.get(sym);
}
+ /** Return attribute arguments
+ * @param sym - symbol of the definition
+ * @param aSym - symbol of the constructor of the attribute class
+ */
+ public AConstant[] getAttrArguments(Symbol sym, Symbol aSym) {
+ AttributeInfo attrs = getAttributes(sym);
+ return attrs == null ? null : attrs.getAttrArguments(aSym);
+ }
+
+ /** Remove the attributes for a given symbol
+ */
public AttributeInfo removeAttributes(Symbol sym) {
return (AttributeInfo)mapSymbolAttr.remove(sym);
}