blob: 4c598768f557490c8ed9d41477ab81fc718a3bb0 (
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 scalac.transformer.matching;
import ch.epfl.lamp.util.Position;
import scalac.*;
import scalac.ast.*;
import scalac.symtab.*;
import scalac.typechecker.*;
/** intermediary data structure for algebraic matching
*/
public class PatternNode {
public int pos = Position.NOPOS;
public Type type;
public PatternNode or;
public PatternNode and;
public case Header(Tree selector, Header next);
public case Body(Tree.ValDef[][] bound, Tree[] guard, Tree[] body);
public case DefaultPat();
public case ConstrPat(Symbol casted);
public case SequencePat(Symbol casted, int len);
public case ConstantPat(Object value);
public case VariablePat(Tree tree);
public Symbol symbol() {
switch (this) {
case ConstrPat(Symbol casted):
return casted;
case SequencePat(Symbol casted, _):
return casted;
default:
return Symbol.NONE;
}
}
public String toString() {
switch (this) {
case Header(Tree selector, Header next):
return "Header(" + selector + ")";
case Body(_, _, _):
return "Body";
case DefaultPat():
return "DefaultPat";
case ConstrPat(Symbol casted):
return "ConstrPat(" + casted + ")";
case SequencePat(Symbol casted, int len):
return "SequencePat(" + casted + ", " + len + ")";
case ConstantPat(Object value):
return "ConstantPat(" + value + ")";
case VariablePat(Tree tree):
return "VariablePat";
default:
return "<unknown pat>";
}
}
}
|