blob: a90bd5bb0616e51cc953cfe167d7bab03fcbbcee (
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
|
/* ____ ____ ____ ____ ______ *\
** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
** /_____/\____/\___/\____/____/ **
\* */
// $Id$
package scalac.transformer.matching;
import scalac.ast.Traverser;
import scalac.ast.Tree;
import Tree.Ident;
import Tree.Bind;
import scalac.util.Name;
import scalac.util.FreshNameCreator;
import scalac.symtab.*;
import java.util.HashMap;
import java.util.Vector;
/** A tree traverser for handling fresh variables
* todo: access method instead of
* @author Burak Emir
* @version 1.0
*/
class FreshVariableTraverser extends VariableTraverser {
int pos;
Symbol owner;
FreshNameCreator fresh;
/**
*/
private HashMap helpMap;
/**
* @param pos
* @param owner
* @param fresh
*/
public FreshVariableTraverser(int pos,
Symbol owner,
FreshNameCreator fresh) {
this.pos = pos;
this.owner = owner;
this.fresh = fresh;
helpMap = new HashMap();
}
public HashMap getHelpMap() {
return helpMap;
}
/**
* @param sym
*/
void handleVariableSymbol(Symbol sym) {
Symbol helpVar =
new TermSymbol(pos,
fresh.newName(sym.name.toString()),
owner,
0);
helpVar.setType(sym.type());
helpMap.put(sym, helpVar);
}
public static HashMap getVars( Tree t, Symbol owner, FreshNameCreator fresh ) {
FreshVariableTraverser fvt = new FreshVariableTraverser( t.pos, owner, fresh );
fvt.traverse( t );
return fvt.helpMap;
}
}
|