-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTabIdent.java
More file actions
80 lines (63 loc) · 2.28 KB
/
TabIdent.java
File metadata and controls
80 lines (63 loc) · 2.28 KB
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
import java.util.HashMap;
//import com.modeliosoft.modelio.javadesigner.annotations.objid;
public class TabIdent {
private HashMap<String, Ident> globaux;
private HashMap<String, Ident> locaux;
public int iterateurVariable = -2;
public int iterateurParametre = 4;
public Yaka yaka;
public TabIdent() {
this.globaux = new HashMap<String, Ident>(); //ne contient que les fonctions
this.locaux = new HashMap<String, Ident>();
}
public Ident chercheIdent(String clef){
if(this.existeIdentGlobaux(clef)){
return this.globaux.get(clef);}
else if(this.existeIdentLocaux(clef)){
return this.locaux.get(clef);}
else{System.out.println("ERREUR: Ident doesn't exist ( all )"); return new IdConst(Constante.type.ERREUR,42);}
}
public Ident chercheIdentGlobaux(String clef) /*throws ParseException */{
if(this.existeIdentGlobaux(clef)){
return this.globaux.get(clef);}
System.out.println("ERREUR: Ident doesn't exist ( globaux )");
return new IdConst(Constante.type.ERREUR,42);
}
public Ident chercheIdentLocaux(String clef) /*throws ParseException */{
if(this.existeIdentLocaux(clef)){
return this.locaux.get(clef);}
System.out.println("ERREUR: Ident doesn't exist ( locaux )");
return new IdConst(Constante.type.ERREUR,42);
}
public boolean existeIdentGlobaux(String clef) {
return this.globaux.containsKey(clef);
}
public boolean existeIdentLocaux(String clef) {
return this.locaux.containsKey(clef);
}
public void rangeIdentGlobaux(String clef, Ident id) {
this.globaux.put(clef, id);
}
public void rangeIdentLocaux(String clef, Ident id) {
this.locaux.put(clef, id);
if(id.estVariable()){
this.iterateurVariable -= 2;
}
else if (id.estParametre())
this.iterateurParametre += 2;
}
public int getIterateurVariable(){
return this.iterateurVariable;
}
public int getIterateurParametre(){
return this.iterateurParametre;
}
public void viderLocaux(){
this.locaux.clear();
this.iterateurVariable = -2;
this.iterateurParametre = 4;
}
public String toString(){
return (this.globaux.toString() + "\n" + this.locaux.toString());
}
}