summaryrefslogtreecommitdiff
path: root/sources/scalac/ast/TreeCreator.java
blob: 3c4acc2956cf6a3b70775c209352bacae26b5998 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
**                                                                      **
** $Id$
\*                                                                      */

package scalac.ast;

import Tree.*;
import scalac.util.Name;


public class DefaultTreeFactory implements TreeFactory {

    public Tree Bad(int pos) {
        Tree t = new ExtBad();
        t.pos = pos;
        return t;
    }

    public Tree ClassDef(int pos,
                         int mods,
                         Name name,
                         TypeDef[] tparams,
                         ValDef[][] vparams,
			 Tree tpe,
                         Template impl) {
        Tree t = new ExtClassDef(mods, name, tparams, vparams, tpe, impl);
        t.pos = pos;
        return t;
    }

    public Tree PackageDef(int pos,
                           Tree packaged,
                           Template impl) {
        Tree t = new PackageDef(packaged, impl);
        t.pos = pos;
        return t;
    }

    public Tree ModuleDef(int pos,
                          int mods,
                          Name name,
                          Tree tpe,
                          Template body) {
        Tree t = new ExtModuleDef(mods, name, tpe, body);
        t.pos = pos;
        return t;
    }

    public Tree ValDef(int pos,
                       int mods,
                       Name name,
                       Tree tpe,
                       Tree rhs) {
        Tree t = new ExtValDef(mods, name, tpe, rhs);
        t.pos = pos;
        return t;
    }

    public Tree PatDef(int pos,
                       int mods,
                       Tree pat,
                       Tree rhs) {
        Tree t = new PatDef(mods, pat, rhs);
        t.pos = pos;
        return t;
    }

    public Tree DefDef(int pos,
                       int mods,
                       Name name,
                       TypeDef[] tparams,
                       ValDef[][] vparams,
                       Tree tpe,
                       Tree rhs) {
        Tree t = new ExtDefDef(mods, name, tparams, vparams, tpe, rhs);
        t.pos = pos;
        return t;
    }


    public Tree TypeDef(int pos,
                        int mods,
                        Name name,
                        Tree rhs) {
        Tree t = new ExtTypeDef(mods, name, rhs);
        t.pos = pos;
        return t;
    }

    public Tree Import(int pos,
                       Tree expr,
		       Name[] selectors) {
        Tree t = new ExtImport(expr, selectors);
        t.pos = pos;
        return t;
    }

    public CaseDef CaseDef(int pos,
			   Tree pat,
			   Tree guard,
			   Tree body) {
        CaseDef t = new CaseDef(pat, guard, body);
        t.pos = pos;
        return t;
    }

    public Template Template(int pos,
                             Tree[] baseClasses,
                             Tree[] body) {
        Template t = new ExtTemplate(baseClasses, body);
        t.pos = pos;
        return t;
    }

    public Tree LabelDef(int pos,
			 Tree[] params,
			 Tree body) {
	Tree t = new ExtLabelDef(params,body);
	t.pos = pos;
	return t;
    }

    public Tree Block(int pos,
                      Tree[] stats) {
        Tree t = new Block(stats);
        t.pos = pos;
        return t;
    }

    public Tree Tuple(int pos,
                      Tree[] trees) {
        Tree t = new Tuple(trees);
        t.pos = pos;
        return t;
    }

    public Tree Visitor(int pos,
                        CaseDef[] cases) {
        Tree t = new Visitor(cases);
        t.pos = pos;
        return t;
    }

    public Tree Function(int pos,
                         ValDef[] vparams,
                         Tree body) {
        Tree t = new Function(vparams, body);
        t.pos = pos;
        return t;
    }

    public Tree Assign(int pos,
                       Tree lhs,
                       Tree rhs) {
        Tree t = new Assign(lhs, rhs);
        t.pos = pos;
        return t;
    }

    public Tree If(int pos,
                   Tree cond,
                   Tree thenp,
                   Tree elsep) {
        Tree t = new If(cond, thenp, elsep);
        t.pos = pos;
        return t;
    }

    public Tree New(int pos,
                    Template templ) {
        Tree t = new New(templ);
        t.pos = pos;
        return t;
    }

    public Tree Typed(int pos,
                      Tree expr,
                      Tree tpe) {
        Tree t = new Typed(expr, tpe);
        t.pos = pos;
        return t;
    }

    public Tree TypeApply(int pos,
                          Tree fun,
                          Tree[] tparams) {
        Tree t = new TypeApply(fun, tparams);
        t.pos = pos;
        return t;
    }

    public Tree Apply(int pos,
                      Tree fun,
                      Tree[] vparam) {
        Tree t = new Apply(fun, vparam);
        t.pos = pos;
        return t;
    }

    public Tree Super(int pos,
                      Tree tpe) {
        Tree t = new Super(tpe);
        t.pos = pos;
        return t;
    }

    public Tree This(int pos,
		     Tree qualifier) {
        Tree t = new This(qualifier);
        t.pos = pos;
        return t;
    }

    public Tree Select(int pos,
                       Tree qualifier,
                       Name selector) {
        Tree t = new ExtSelect(qualifier, selector);
        t.pos = pos;
        return t;
    }

    public Tree Ident(int pos,
                      Name name) {
        Tree t = new ExtIdent(name);
        t.pos = pos;
        return t;
    }

    public Tree Literal(int pos,
                        Object value) {
        Tree t = new Literal(value);
        t.pos = pos;
        return t;
    }


    public Tree TypeTerm(int pos) {
	Tree t = new TypeTerm();
	t.pos = pos;
	return t;
    }

    public Tree SingletonType(int pos, Tree ref) {
        Tree t = new SingletonType(ref);
        t.pos = pos;
        return t;
    }

    public Tree SelectFromType(int pos,
			       Tree qualifier,
			       Name selector) {
        Tree t = new ExtSelectFromType(qualifier, selector);
        t.pos = pos;
        return t;
    }

    public Tree FunType(int pos,
                        Tree[] argtpes,
                        Tree restpe) {
        Tree t = new FunType(argtpes, restpe);
        t.pos = pos;
        return t;
    }

    public Tree CompoundType(int pos,
                             Tree[] mixins,
                             Tree[] fields) {
        Tree t = new CompoundType(mixins, fields);
        t.pos = pos;
        return t;
    }

    public Tree AppliedType(int pos,
                            Tree tpe,
                            Tree[] args) {
        Tree t = new AppliedType(tpe, args);
        t.pos = pos;
        return t;
    }

    public Tree CovariantType(int pos,
			      Tree tpe) {
        Tree t = new CovariantType(tpe);
        t.pos = pos;
        return t;
    }
}