summaryrefslogtreecommitdiff
path: root/sources/meta/scalac/ast/TreeField.java
blob: 19df9cb42e1904607c27ddb51ec5f745529f0fcd (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
/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
\*                                                                      */

// $Id$

package meta.scalac.ast;

import meta.java.Type;
import meta.java.JavaWriter;

/** This class describes a tree node field. */
public class TreeField {

    //########################################################################
    // Public Fields

    public final Type type;
    public final String name;
    public final TreeFieldLink link;

    //########################################################################
    // Public Constructors

    public TreeField(Type type, String name) {
        this(type, name, null);
    }

    public TreeField(Type type, String name, TreeFieldLink link) {
        this.type = type;
        this.name = name;
        this.link = link;
    }

    //########################################################################
    // Public Function

    public static JavaWriter print(JavaWriter writer, TreeField[] fields,
        boolean withType)
    {
        for (int i = 0; i < fields.length; i++) {
            if (i > 0) writer.print(", ");
            fields[i].print(writer, withType);
        }
        return writer;
    }

    //########################################################################
    // Public Methods

    public JavaWriter print(JavaWriter writer, boolean withType) {
        if (withType) writer.print(type).space();
        return writer.print(name);
    }

    public String toString() {
        return name;
    }

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