From 0f88183f98998ccff74003ea5c373ad0401edb10 Mon Sep 17 00:00:00 2001 From: paltherr Date: Tue, 1 Feb 2005 13:36:43 +0000 Subject: - Added method getOrigin and setOrigin --- sources/scalac/symtab/Symbol.java | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index 6a50761c02..b7d228d001 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -868,6 +868,24 @@ public abstract class Symbol implements Modifiers, Kinds { return name; } +// Symbol origin -------------------------------------------------------------- + + /** Returns the origin of this symbol. */ + public SymbolOrigin getOrigin() { + if (isModule()) + return moduleClass().getOrigin(); + if (isConstructor()) + return constructorClass().getOrigin(); + if (isCaseFactory()) + return type().resultType().symbol().getOrigin(); + return owner().getOrigin(); + } + + /** Sets the origin of this symbol. */ + public void setOrigin(SymbolOrigin origin) { + throw Debug.abort("not a class", this); + } + // Acess to related symbols ----------------------------------------------------- /** Get type parameters */ @@ -2079,6 +2097,9 @@ final class AbsTypeSymbol extends TypeSymbol { /** A class for class symbols. */ public class ClassSymbol extends TypeSymbol { + /** The origin of this symbol */ + private SymbolOrigin origin; + /** The given type of self, or NoType, if no explicit type was given. */ private Symbol thisSym = this; @@ -2135,6 +2156,16 @@ public class ClassSymbol extends TypeSymbol { return newTerm(pos, SYNTHETIC, Names.this_, IS_THISTYPE); } + /** Returns the origin of this symbol. */ + public SymbolOrigin getOrigin() { + return origin != null ? origin : super.getOrigin(); + } + + /** Sets the origin of this symbol. */ + public void setOrigin(SymbolOrigin origin) { + this.origin = origin; + } + public Type thisType() { Global global = Global.instance; if (global.currentPhase.id > global.PHASE.ERASURE.id()) return type(); @@ -2316,6 +2347,11 @@ final class NoSymbol extends Symbol { super.setInfo(Type.NoType); } + /** Returns the origin of this symbol. */ + public SymbolOrigin getOrigin() { + return SymbolOrigin.Unknown; + } + /** Set type */ public Symbol setInfo(Type info) { assert info == Type.NoType : info; -- cgit v1.2.3