summaryrefslogtreecommitdiff
path: root/sources/meta/scalac/ast/TreeType.java
blob: f15e7ec6769e7ec85fd6d63af488a4d95b3b4fd1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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();
        }
    }

    //########################################################################
}