diff options
author | paltherr <paltherr@epfl.ch> | 2003-04-14 14:26:02 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-04-14 14:26:02 +0000 |
commit | e38818336a932006340aca4bb3579e875b291689 (patch) | |
tree | a50d7eaba16a412a0cbe294a6d1a501cbc58a9a4 /sources/meta/scalac/ast/TreeType.java | |
parent | 0aa5643808efec65ae5fccbd40fc97bebf0de526 (diff) | |
download | scala-e38818336a932006340aca4bb3579e875b291689.tar.gz scala-e38818336a932006340aca4bb3579e875b291689.tar.bz2 scala-e38818336a932006340aca4bb3579e875b291689.zip |
- Added Phase.java
- Added Tree.java
- Added TreeField.java
- Added TreeKind.java
- Added TreeNode.java
- Added TreeSymbol.java
- Added TreeType.java
Diffstat (limited to 'sources/meta/scalac/ast/TreeType.java')
-rw-r--r-- | sources/meta/scalac/ast/TreeType.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/sources/meta/scalac/ast/TreeType.java b/sources/meta/scalac/ast/TreeType.java new file mode 100644 index 0000000000..f15e7ec676 --- /dev/null +++ b/sources/meta/scalac/ast/TreeType.java @@ -0,0 +1,66 @@ +/* ____ ____ ____ ____ ______ *\ +** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** +** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** +** /_____/\____/\___/\____/____/ ** +\* */ + +// $Id$ + +package meta.scalac.ast; + +import meta.java.Type; + +/** This class describes types used in tree nodes. */ +public class TreeType extends Type { + + //######################################################################## + // Public Constants + + // !!! + public static final String NAME_PACKAGE = "scalac.util"; + public static final String NAME_NAME = "Name"; + public static final String NAME_FULLNAME = NAME_PACKAGE + "." + NAME_NAME; + public static final String TREE_PACKAGE = meta.scalac.ast.Tree.PACKAGE; + public static final String TREE_NAME = meta.scalac.ast.Tree.NAME; + public static final String TREE_FULLNAME = TREE_PACKAGE + "." + TREE_NAME; + + //######################################################################## + // Public Cases + + public case Name(TreeKind kind); + public case Tree(TreeKind kind); + public case Node(TreeNode node); + + //######################################################################## + // Public Methods + + /** Returns the type's (possibly fully qualified) name. */ + public String getName(boolean qualified) { + switch (this) { + case Name(_): + return qualified ? NAME_FULLNAME : NAME_NAME; + case Tree(_): + return qualified ? TREE_FULLNAME : TREE_NAME; + case Node(TreeNode node): + return qualified ? TREE_FULLNAME + "." + node.name : node.name; + default: + return super.getName(qualified); + } + } + + /** Returns the type's owner (its package or enclosing type). */ + public String getOwner() { + switch (this) { + case Name(_): + return NAME_PACKAGE; + case Tree(_): + return TREE_PACKAGE; + case Node(TreeNode node): + return TREE_FULLNAME; + default: + return super.getOwner(); + } + } + + //######################################################################## +} |