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