From ce80365a9dbce1419c0ad631d4d8b4279ea630a8 Mon Sep 17 00:00:00 2001 From: mihaylov Date: Tue, 7 Jun 2005 16:07:40 +0000 Subject: Improved serialization support --- sources/scalac/Global.java | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'sources/scalac') 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); } -- cgit v1.2.3