7fd59977 |
1 | // Copyright: Matra-Datavision 1992 |
2 | // File: ExprIntrp_Analysis.cxx |
3 | // Created: Tue Feb 25 17:47:25 1992 |
4 | // Author: Arnaud BOUZY |
5 | // <adn> |
6 | |
7 | #define _ExprIntrp_Analysis_SourceFile |
8 | |
9 | #include <ExprIntrp_Analysis.ixx> |
10 | #include <Expr_NamedUnknown.hxx> |
11 | |
12 | ExprIntrp_Analysis::ExprIntrp_Analysis() {} |
13 | |
14 | |
15 | void ExprIntrp_Analysis::Push(const Handle(Expr_GeneralExpression)& exp) |
16 | { |
17 | myGEStack.Push(exp); |
18 | } |
19 | |
20 | void ExprIntrp_Analysis::PushRelation(const Handle(Expr_GeneralRelation)& rel) |
21 | { |
22 | myGRStack.Push(rel); |
23 | } |
24 | |
25 | void ExprIntrp_Analysis::PushFunction(const Handle(Expr_GeneralFunction)& func) |
26 | { |
27 | myGFStack.Push(func); |
28 | } |
29 | |
30 | void ExprIntrp_Analysis::PushName(const TCollection_AsciiString& name) |
31 | { |
32 | myNameStack.Push(name); |
33 | } |
34 | |
35 | void ExprIntrp_Analysis::PushValue(const Standard_Integer val) |
36 | { |
37 | myValueStack.Push(val); |
38 | } |
39 | |
40 | Handle(Expr_GeneralExpression) ExprIntrp_Analysis::Pop() |
41 | { |
42 | Handle(Expr_GeneralExpression) res; |
43 | if (!myGEStack.IsEmpty()) { |
44 | res = myGEStack.Top(); |
45 | myGEStack.Pop(); |
46 | } |
47 | return res; |
48 | } |
49 | |
50 | Handle(Expr_GeneralRelation) ExprIntrp_Analysis::PopRelation() |
51 | { |
52 | Handle(Expr_GeneralRelation) res; |
53 | if (!myGRStack.IsEmpty()) { |
54 | res = myGRStack.Top(); |
55 | myGRStack.Pop(); |
56 | } |
57 | return res; |
58 | } |
59 | |
60 | Handle(Expr_GeneralFunction) ExprIntrp_Analysis::PopFunction() |
61 | { |
62 | Handle(Expr_GeneralFunction) res; |
63 | if (!myGFStack.IsEmpty()) { |
64 | res = myGFStack.Top(); |
65 | myGFStack.Pop(); |
66 | } |
67 | return res; |
68 | } |
69 | |
70 | TCollection_AsciiString ExprIntrp_Analysis::PopName() |
71 | { |
72 | TCollection_AsciiString res; |
73 | if (!myNameStack.IsEmpty()) { |
74 | res = myNameStack.Top(); |
75 | myNameStack.Pop(); |
76 | } |
77 | return res; |
78 | } |
79 | |
80 | Standard_Integer ExprIntrp_Analysis::PopValue() |
81 | { |
82 | Standard_Integer res =0; |
83 | if (!myValueStack.IsEmpty()) { |
84 | res = myValueStack.Top(); |
85 | myValueStack.Pop(); |
86 | } |
87 | return res; |
88 | } |
89 | |
90 | Standard_Boolean ExprIntrp_Analysis::IsExpStackEmpty() const |
91 | { |
92 | return myGEStack.IsEmpty(); |
93 | } |
94 | |
95 | Standard_Boolean ExprIntrp_Analysis::IsRelStackEmpty() const |
96 | { |
97 | return myGRStack.IsEmpty(); |
98 | } |
99 | |
100 | void ExprIntrp_Analysis::ResetAll() |
101 | { |
102 | myGEStack.Clear(); |
103 | myGRStack.Clear(); |
104 | myGFStack.Clear(); |
105 | myNameStack.Clear(); |
106 | myValueStack.Clear(); |
107 | myFunctions.Clear(); |
108 | myNamed.Clear(); |
109 | } |
110 | |
111 | void ExprIntrp_Analysis::SetMaster(const Handle(ExprIntrp_Generator)& agen) |
112 | { |
113 | ResetAll(); |
114 | myMaster = agen; |
115 | myFunctions = myMaster->GetFunctions(); |
116 | myNamed = myMaster->GetNamed(); |
117 | } |
118 | |
119 | void ExprIntrp_Analysis::Use(const Handle(Expr_NamedFunction)& func) |
120 | { |
121 | myFunctions.Append(func); |
122 | myMaster->Use(func); |
123 | } |
124 | |
125 | void ExprIntrp_Analysis::Use(const Handle(Expr_NamedExpression)& named) |
126 | { |
127 | myNamed.Append(named); |
128 | myMaster->Use(named); |
129 | } |
130 | |
131 | Handle(Expr_NamedExpression) ExprIntrp_Analysis::GetNamed(const TCollection_AsciiString& name) |
132 | { |
133 | for (Standard_Integer i=1; i<= myNamed.Length();i++) { |
134 | if (name == myNamed(i)->GetName()) { |
135 | return myNamed(i); |
136 | } |
137 | } |
138 | Handle(Expr_NamedExpression) curnamed; |
139 | return curnamed; |
140 | } |
141 | |
142 | Handle(Expr_NamedFunction) ExprIntrp_Analysis::GetFunction(const TCollection_AsciiString& name) |
143 | { |
144 | for (Standard_Integer i=1; i<= myFunctions.Length();i++) { |
145 | if (name == myFunctions(i)->GetName()) { |
146 | return myFunctions(i); |
147 | } |
148 | } |
149 | Handle(Expr_NamedFunction) curfunc; |
150 | return curfunc; |
151 | } |