|
1 |
| package edu.rice.cs.dynamicjava.interpreter; |
|
2 |
| |
|
3 |
| import edu.rice.cs.dynamicjava.symbol.*; |
|
4 |
| import edu.rice.cs.dynamicjava.symbol.type.ClassType; |
|
5 |
| import edu.rice.cs.dynamicjava.symbol.type.VariableType; |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| public class FunctionSignatureContext extends DelegatingContext { |
|
12 |
| |
|
13 |
| private Function _f; |
|
14 |
| |
|
15 |
637
| public FunctionSignatureContext(TypeContext next, Function f) {
|
|
16 |
637
| super(next);
|
|
17 |
637
| _f = f;
|
|
18 |
| } |
|
19 |
| |
|
20 |
0
| protected FunctionSignatureContext duplicate(TypeContext next) {
|
|
21 |
0
| return new FunctionSignatureContext(next, _f);
|
|
22 |
| } |
|
23 |
| |
|
24 |
3
| @Override public boolean typeExists(String name, TypeSystem ts) {
|
|
25 |
3
| return declaredTypeVariable(name) != null || super.typeExists(name, ts);
|
|
26 |
| } |
|
27 |
| |
|
28 |
0
| @Override public boolean typeVariableExists(String name, TypeSystem ts) {
|
|
29 |
0
| return declaredTypeVariable(name) != null || super.typeVariableExists(name, ts);
|
|
30 |
| } |
|
31 |
| |
|
32 |
487
| @Override public VariableType getTypeVariable(String name, TypeSystem ts) {
|
|
33 |
487
| VariableType result = declaredTypeVariable(name);
|
|
34 |
487
| return (result == null) ? super.getTypeVariable(name, ts) : result;
|
|
35 |
| } |
|
36 |
| |
|
37 |
0
| @Override public boolean topLevelClassExists(String name, TypeSystem ts) {
|
|
38 |
0
| return (declaredTypeVariable(name) == null) ? super.topLevelClassExists(name, ts) : false;
|
|
39 |
| } |
|
40 |
| |
|
41 |
897
| @Override public DJClass getTopLevelClass(String name, TypeSystem ts) throws AmbiguousNameException {
|
|
42 |
897
| return (declaredTypeVariable(name) == null) ? super.getTopLevelClass(name, ts) : null;
|
|
43 |
| } |
|
44 |
| |
|
45 |
0
| @Override public boolean memberClassExists(String name, TypeSystem ts) {
|
|
46 |
0
| return (declaredTypeVariable(name) == null) ? super.memberClassExists(name, ts) : false;
|
|
47 |
| } |
|
48 |
| |
|
49 |
372
| @Override public ClassType typeContainingMemberClass(String name, TypeSystem ts) throws AmbiguousNameException {
|
|
50 |
372
| return (declaredTypeVariable(name) == null) ? super.typeContainingMemberClass(name, ts) : null;
|
|
51 |
| } |
|
52 |
| |
|
53 |
1759
| private VariableType declaredTypeVariable(String name) {
|
|
54 |
1759
| for (VariableType t : _f.typeParameters()) {
|
|
55 |
0
| if (t.symbol().name().equals(name)) { return t; }
|
|
56 |
| } |
|
57 |
1759
| return null;
|
|
58 |
| } |
|
59 |
| |
|
60 |
| } |