0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / ExprIntrp / ExprIntrp_yaccintrf.cxx
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif
4 #include <ExprIntrp_yaccintrf.hxx>
5 #include <ExprIntrp_yaccanal.hxx>
6 #include <Expr_GeneralExpression.hxx>
7 #include <Expr_NamedExpression.hxx>
8 #include <Expr_NamedUnknown.hxx>
9 #include <Expr_NamedConstant.hxx>
10 #include <Expr_NamedFunction.hxx>
11 #include <Expr_NumericValue.hxx>
12 #include <Expr_UnaryFunction.hxx>
13 #include <Expr_BinaryFunction.hxx>
14 #include <Expr_PolyFunction.hxx>
15 #include <Expr_Exponentiate.hxx>
16 #include <Expr_Absolute.hxx>
17 #include <Expr_ArcCosine.hxx>
18 #include <Expr_ArcSine.hxx>
19 #include <Expr_ArcTangent.hxx>
20 #include <Expr_ArgCosh.hxx>
21 #include <Expr_ArgSinh.hxx>
22 #include <Expr_ArgTanh.hxx>
23 #include <Expr_Cosh.hxx>
24 #include <Expr_Cosine.hxx>
25 #include <Expr_Exponential.hxx>
26 #include <Expr_LogOf10.hxx>
27 #include <Expr_LogOfe.hxx>
28 #include <Expr_Sign.hxx>
29 #include <Expr_Sine.hxx>
30 #include <Expr_Sinh.hxx>
31 #include <Expr_SquareRoot.hxx>
32 #include <Expr_Tangent.hxx>
33 #include <Expr_Tanh.hxx>
34 #include <Expr_Equal.hxx>
35 #include <Expr_SystemRelation.hxx>
36 #include <Expr_UnknownIterator.hxx>
37 #include <Expr_FunctionDerivative.hxx>
38 #include <Expr.hxx>                    // ATTENTION POUR PROTECTION BUG STACK
39
40 #include <Expr_SequenceOfGeneralExpression.hxx>
41 #include <Expr_Operators.hxx>
42 #include <ExprIntrp_SyntaxError.hxx>
43 #include <Expr_Array1OfNamedUnknown.hxx>
44 #include <Expr_Array1OfGeneralExpression.hxx>
45 #ifdef HAVE_STRINGS_H
46 # include <strings.h>
47 #endif
48
49 extern char yysbuf[];
50 extern char *yysptr;
51 static char ExprIntrp_assname[30];
52 TCollection_AsciiString ExprIntrp_funcdefname;
53 static Standard_Integer ExprIntrp_nbargs;
54 static Standard_Integer ExprIntrp_nbdiff;
55
56
57 extern "C" void ExprIntrp_StartFunction()
58 {
59   int nbcar;
60   char funcname[100];
61   nbcar = ExprIntrp_GetResult(funcname);
62   TCollection_AsciiString name(funcname);
63   ExprIntrp_Recept.PushName(name);
64   ExprIntrp_nbargs = 0;
65 }
66
67 extern "C" void ExprIntrp_StartDerivate()
68 {
69   int nbcar;
70   char funcname[100];
71   nbcar = ExprIntrp_GetResult(funcname);
72   TCollection_AsciiString name(funcname);
73   ExprIntrp_Recept.PushName(name);
74 }
75
76 extern "C" void ExprIntrp_EndDerivate()
77 {
78   int degree;
79   degree = ExprIntrp_GetDegree();
80   ExprIntrp_Recept.PushValue(degree);
81 }
82
83 extern "C" void ExprIntrp_Derivation()
84 {
85   ExprIntrp_Recept.PushValue(1);
86   char name[100];
87   ExprIntrp_GetResult(name);
88   TCollection_AsciiString thename(name);
89   Handle(Expr_NamedExpression) namexp = ExprIntrp_Recept.GetNamed(thename);
90   if (namexp.IsNull()) {
91     namexp = new Expr_NamedUnknown(thename);
92   }
93   if (!namexp->IsKind(STANDARD_TYPE(Expr_NamedUnknown))) {
94     ExprIntrp_SyntaxError::Raise();
95   }
96   ExprIntrp_Recept.Push(namexp);
97 }
98
99 extern "C" void ExprIntrp_DerivationValue()
100 {
101   char num[30];
102   int nbcar;
103   nbcar = ExprIntrp_GetResult(num);
104   Standard_Integer degree = ExprIntrp_Recept.PopValue();
105   degree = atoi(num);
106   ExprIntrp_Recept.PushValue(degree);
107 }
108
109 extern "C" void ExprIntrp_EndDerivation()
110 {
111   Standard_Integer degree = ExprIntrp_Recept.PopValue();
112   Handle(Expr_NamedUnknown) var = Handle(Expr_NamedUnknown)::DownCast(ExprIntrp_Recept.Pop());
113   Handle(Expr_GeneralExpression) exp = ExprIntrp_Recept.Pop();
114   exp = exp->NDerivative(var,degree);
115   ExprIntrp_Recept.Push(exp);
116 }
117
118 extern "C" void ExprIntrp_StartDifferential()
119 {
120   ExprIntrp_StartDerivate();
121   ExprIntrp_nbdiff = 0;
122 }
123
124 extern "C" void ExprIntrp_DiffDegreeVar()
125 {
126   char name[100];
127   ExprIntrp_GetResult(name);
128 #ifndef WNT 
129   if (strncasecmp(name,"X",1)) {
130 #else
131   if (  name[ 0 ] != 'X' && name[ 0 ] != 'x'  ) {
132 #endif  // WNT
133     ExprIntrp_SyntaxError::Raise();
134   }
135   char* s = name;
136   s++;
137   Standard_Integer rank = atoi(s);
138   ExprIntrp_Recept.PushValue(rank);
139   ExprIntrp_nbdiff++;
140 }
141
142 extern "C" void ExprIntrp_DiffVar()
143 {
144   ExprIntrp_Recept.PushValue(1);
145   ExprIntrp_DiffDegreeVar();
146 }
147
148 extern "C" void ExprIntrp_DiffDegree()
149 {
150   char name[100];
151   ExprIntrp_GetResult(name);
152   Standard_Integer deg = atoi(name);
153   ExprIntrp_Recept.PushValue(deg);
154 }
155
156 extern "C" void ExprIntrp_VerDiffDegree()
157 {
158   char name[100];
159   ExprIntrp_GetResult(name);
160   Standard_Integer deg = atoi(name);
161   Standard_Integer thedeg = ExprIntrp_Recept.PopValue();
162   if (deg != thedeg) {
163     ExprIntrp_SyntaxError::Raise();
164   }
165   ExprIntrp_Recept.PushValue(deg);
166 }
167
168 extern "C" void ExprIntrp_EndDifferential()
169 {
170   TCollection_AsciiString name = ExprIntrp_Recept.PopName();
171   Handle(Expr_GeneralFunction) thefunc = ExprIntrp_Recept.GetFunction(name);
172   if (thefunc.IsNull()) {
173     ExprIntrp_SyntaxError::Raise();
174   }
175   Standard_Integer rank,degree;
176   Handle(Expr_NamedUnknown) thediff;
177   Standard_Integer nbvars = thefunc->NbOfVariables();
178
179   for (Standard_Integer i=1; i<= ExprIntrp_nbdiff; i++) {
180     rank = ExprIntrp_Recept.PopValue();
181     degree = ExprIntrp_Recept.PopValue();
182     if ((rank > nbvars) || (rank < 1)) {
183       ExprIntrp_SyntaxError::Raise();
184     }
185     thediff = thefunc->Variable(rank);
186     thefunc = new Expr_FunctionDerivative(thefunc,thediff,degree);
187   }
188   ExprIntrp_Recept.PushFunction(thefunc);
189 }
190
191 extern "C" void ExprIntrp_EndDiffFunction()
192 {
193   Handle(Expr_GeneralFunction) thefunc = ExprIntrp_Recept.PopFunction();
194   if (thefunc.IsNull()) {
195     ExprIntrp_SyntaxError::Raise();
196   }
197   Standard_Integer nbargs = thefunc->NbOfVariables();
198   if (nbargs == 1) {
199     Handle(Expr_GeneralExpression) op = ExprIntrp_Recept.Pop();
200     Handle(Expr_UnaryFunction) res = 
201       new Expr_UnaryFunction(thefunc,op);
202     ExprIntrp_Recept.Push(res);
203   }
204   else if (nbargs == 2) {
205     Handle(Expr_GeneralExpression) arg2 = ExprIntrp_Recept.Pop();
206     Handle(Expr_GeneralExpression) arg1 = ExprIntrp_Recept.Pop();
207     if (arg1.IsNull()) {
208       ExprIntrp_SyntaxError::Raise();
209     }
210     Handle(Expr_BinaryFunction) res =
211       new Expr_BinaryFunction(thefunc,arg1,arg2);
212     ExprIntrp_Recept.Push(res);
213   }
214   else {
215     Expr_Array1OfGeneralExpression tabarg(1,nbargs);
216     Handle(Expr_GeneralExpression) arg;
217     for (Standard_Integer i = 1; i<= nbargs; i++) {
218       arg = ExprIntrp_Recept.Pop();
219       if (arg.IsNull()) {
220         ExprIntrp_SyntaxError::Raise();
221       }
222       tabarg(nbargs-i+1) = arg;
223     }
224     Handle(Expr_PolyFunction) res = 
225       new Expr_PolyFunction(thefunc,tabarg);
226     ExprIntrp_Recept.Push(res);
227   }
228 }
229   
230 static Handle(Expr_GeneralExpression) ExprIntrp_StandardFunction(const TCollection_AsciiString& name, const Handle(Expr_GeneralExpression)& op)
231 {
232 // return standard functions equivalent corresponding to <name> 
233 // with given operand <op> if exists. Returns null value if not.
234 // <name> is not case sensitive
235
236   Handle(Expr_GeneralExpression) res;
237   if ((name == "abs") || (name == "Abs")) {
238     res = new Expr_Absolute(op);
239   }
240   else if ((name == "acos") || (name == "ACos")) {
241     res = new Expr_ArcCosine(op);
242   }
243   else if ((name == "asin") || (name == "ASin")) {
244     res = new Expr_ArcSine(op);
245   }
246   else if ((name == "atan") || (name == "ATan")) {
247     res = new Expr_ArcTangent(op);
248   }
249   else if ((name == "acosh") || (name == "ACosh")) {
250     res = new Expr_ArgCosh(op);
251   }
252   else if ((name == "asinh") || (name == "ASinh")) {
253     res = new Expr_ArgSinh(op);
254   }
255   else if ((name == "atanh") || (name == "ATanh")) {
256     res = new Expr_ArgTanh(op);
257   }
258   else if ((name == "cosh") || (name == "Cosh")) {
259     res = new Expr_Cosh(op);
260   }
261   else if ((name == "cos") || (name == "Cos")) {
262     res = new Expr_Cosine(op);
263   }
264   else if ((name == "exp") || (name == "Exp")) {
265     res = new Expr_Exponential(op);
266   }
267   else if (name == "log") {
268     res = new Expr_LogOf10(op);
269   }
270   else if ((name == "Log") || (name == "Ln")) {
271     res = new Expr_LogOfe(op);
272   }
273   else if ((name == "sign") || (name == "Sign")) {
274     res = new Expr_Sign(op);
275   }
276   else if ((name == "sin") || (name == "Sin")) {
277     res = new Expr_Sine(op);
278   }
279   else if ((name == "sinh") || (name == "Sinh")) {
280     res = new Expr_Sinh(op);
281   }
282   else if ((name == "sqrt") || (name == "Sqrt")) {
283     res = new Expr_SquareRoot(op);
284   }
285   else if ((name == "tan") || (name == "Tan")) {
286     res = new Expr_Tangent(op);
287   }
288   else if ((name == "tanh") || (name == "Tanh")) {
289     res = new Expr_Tanh(op);
290   }
291   return res;
292 }
293
294
295 extern "C" void ExprIntrp_EndDerFunction()
296 {
297   TCollection_AsciiString name = ExprIntrp_Recept.PopName();
298   Handle(Expr_GeneralExpression) op = ExprIntrp_Recept.Pop();
299   Handle(Expr_GeneralExpression) resstand = ExprIntrp_StandardFunction(name,op);
300
301   if (!resstand.IsNull()) {
302     Handle(Expr_NamedUnknown) var;
303     Expr_UnknownIterator rit(resstand);
304     while (rit.More()) {
305       if (!var.IsNull()) {
306         ExprIntrp_SyntaxError::Raise();
307       }
308       else {
309         var = rit.Value();
310         if (var->IsAssigned()) {
311           var.Nullify();
312         }
313       }
314       rit.Next();
315     }
316     if (var.IsNull()) {
317       ExprIntrp_SyntaxError::Raise();
318     }
319     else {
320       Handle(Expr_GeneralExpression) res = resstand->NDerivative(var,ExprIntrp_Recept.PopValue());
321       ExprIntrp_Recept.Push(res);
322     }
323   }
324   else {
325     Handle(Expr_NamedFunction) thefunc = ExprIntrp_Recept.GetFunction(name);
326     if (thefunc.IsNull()) {
327       ExprIntrp_SyntaxError::Raise();
328     }
329     Standard_Integer nbargs = thefunc->NbOfVariables();
330     if (nbargs != 1) {
331       ExprIntrp_SyntaxError::Raise();
332     }
333     Handle(Expr_NamedUnknown) var = thefunc->Variable(1);
334     Handle(Expr_FunctionDerivative) thefuncder = 
335       new Expr_FunctionDerivative(thefunc,var,ExprIntrp_Recept.PopValue());
336     Handle(Expr_UnaryFunction) res = 
337       new Expr_UnaryFunction(thefuncder,op);
338     ExprIntrp_Recept.Push(res);
339   }
340 }
341     
342 extern "C" void ExprIntrp_EndFunction()
343 {
344   TCollection_AsciiString name = ExprIntrp_Recept.PopName();
345   Handle(Expr_GeneralExpression) op = ExprIntrp_Recept.Pop();
346
347   Handle(Expr_GeneralExpression) resstand = ExprIntrp_StandardFunction(name,op);
348   if (!resstand.IsNull()) {
349     ExprIntrp_Recept.Push(resstand->ShallowSimplified());
350   }
351   else {
352     Handle(Expr_NamedFunction) thefunc = ExprIntrp_Recept.GetFunction(name);
353     if (thefunc.IsNull()) {
354       ExprIntrp_SyntaxError::Raise();
355       }
356     Standard_Integer nbargs = thefunc->NbOfVariables();
357     if (nbargs == 1) {
358       Handle(Expr_UnaryFunction) res = 
359         new Expr_UnaryFunction(thefunc,op);
360       ExprIntrp_Recept.Push(res);
361     }
362     else if (nbargs == 2) {
363       Handle(Expr_GeneralExpression) arg1 = ExprIntrp_Recept.Pop();
364       if (arg1.IsNull()) {
365         ExprIntrp_SyntaxError::Raise();
366       }
367       Handle(Expr_BinaryFunction) res =
368         new Expr_BinaryFunction(thefunc,arg1,op);
369       ExprIntrp_Recept.Push(res);
370     }
371     else {
372       Expr_Array1OfGeneralExpression tabarg(1,nbargs);
373       Handle(Expr_GeneralExpression) arg;
374       tabarg(nbargs) = op;
375       for (Standard_Integer i = 1; i< nbargs; i++) {
376         arg = ExprIntrp_Recept.Pop();
377         if (arg.IsNull()) {
378           ExprIntrp_SyntaxError::Raise();
379         }
380         tabarg(nbargs-i) = arg;
381       }
382       Handle(Expr_PolyFunction) res = 
383         new Expr_PolyFunction(thefunc,tabarg);
384       ExprIntrp_Recept.Push(res);
385     }
386   }
387 }
388
389 extern "C" void ExprIntrp_NextFuncArg()
390 {
391   ExprIntrp_nbargs++;
392 }
393
394 extern "C" void ExprIntrp_EndFuncArg()
395 {
396   ExprIntrp_nbargs++;
397 }
398
399 extern "C" void ExprIntrp_SumOperator()
400 {
401   Handle(Expr_GeneralExpression) op2 = ExprIntrp_Recept.Pop();
402   Handle(Expr_GeneralExpression) op1 = ExprIntrp_Recept.Pop();
403   Handle(Expr_Sum) sres = op1 + op2;
404   Handle(Expr_GeneralExpression) res = sres->ShallowSimplified();
405   ExprIntrp_Recept.Push(res);
406 }
407
408 extern "C" void ExprIntrp_MinusOperator()
409 {
410   Handle(Expr_GeneralExpression) op2 = ExprIntrp_Recept.Pop();
411   Handle(Expr_GeneralExpression) op1 = ExprIntrp_Recept.Pop();
412   Handle(Expr_Difference) res = op1 - op2;
413   ExprIntrp_Recept.Push(res->ShallowSimplified());
414 }
415
416 extern "C" void ExprIntrp_DivideOperator()
417 {
418   Handle(Expr_GeneralExpression) op2 = ExprIntrp_Recept.Pop();
419   Handle(Expr_GeneralExpression) op1 = ExprIntrp_Recept.Pop();
420   Handle(Expr_Division) res = op1 / op2;
421   ExprIntrp_Recept.Push(res->ShallowSimplified());
422 }
423
424 extern "C" void ExprIntrp_ExpOperator()
425 {
426   Handle(Expr_GeneralExpression) op2 = ExprIntrp_Recept.Pop();
427   Handle(Expr_GeneralExpression) op1 = ExprIntrp_Recept.Pop();
428   Handle(Expr_Exponentiate) res = new Expr_Exponentiate(op1,op2);
429   ExprIntrp_Recept.Push(res->ShallowSimplified());
430 }
431
432 extern "C" void ExprIntrp_ProductOperator()
433 {
434   Handle(Expr_GeneralExpression) op2 = ExprIntrp_Recept.Pop();
435   Handle(Expr_GeneralExpression) op1 = ExprIntrp_Recept.Pop();
436   Handle(Expr_Product) res = op1 * op2;
437   ExprIntrp_Recept.Push(res->ShallowSimplified());
438 }
439
440 extern "C" void ExprIntrp_UnaryMinusOperator()
441 {
442   Handle(Expr_GeneralExpression) op = ExprIntrp_Recept.Pop();
443   Handle(Expr_UnaryMinus) res = new Expr_UnaryMinus(op);
444   ExprIntrp_Recept.Push(res->ShallowSimplified());
445 }
446
447 extern "C" void ExprIntrp_VariableIdentifier()
448 {
449   char name[30];
450   int nbcar;
451   nbcar = ExprIntrp_GetResult(name);
452   TCollection_AsciiString thename(name);
453   Handle(Expr_NamedExpression) nameexp = ExprIntrp_Recept.GetNamed(thename);
454   if (nameexp.IsNull()) {
455     nameexp = new Expr_NamedUnknown(thename);
456     ExprIntrp_Recept.Use(nameexp);
457   }
458   ExprIntrp_Recept.Push(nameexp);
459 }
460
461 extern "C" void ExprIntrp_NumValue()
462 {
463   char num[30];
464   int nbcar;
465   nbcar = ExprIntrp_GetResult(num);
466   Standard_Real value = atof(num);
467   Handle(Expr_NumericValue) nval = new Expr_NumericValue(value);
468   ExprIntrp_Recept.Push(nval);
469 }
470
471 extern "C" void ExprIntrp_AssignVariable()
472 {
473   int nbcar;
474   nbcar = ExprIntrp_GetResult(ExprIntrp_assname);
475 }
476
477 extern "C" void ExprIntrp_Deassign()
478 {
479   int nbcar;
480   char name[100];
481   nbcar = ExprIntrp_GetResult(name);
482   TCollection_AsciiString thename(name);
483   Handle(Expr_NamedExpression) nameexp = ExprIntrp_Recept.GetNamed(thename);
484   if (nameexp.IsNull()) {
485     ExprIntrp_SyntaxError::Raise();
486   }
487   if (!nameexp->IsKind(STANDARD_TYPE(Expr_NamedUnknown))) {
488     ExprIntrp_SyntaxError::Raise();
489   }
490   Handle(Expr_NamedUnknown) var = Handle(Expr_NamedUnknown)::DownCast(nameexp);
491   var->Deassign();
492 }
493
494 extern "C" void ExprIntrp_DefineFunction()
495 {
496   ExprIntrp_funcdefname = ExprIntrp_Recept.PopName();
497   ExprIntrp_Recept.PushValue(ExprIntrp_nbargs);
498 }
499
500 extern "C" void ExprIntrp_close()
501 {
502   ExprIntrp_stop_string();
503 }
504
505 extern "C" void ExprIntrperror(char* msg)
506 {
507   ExprIntrp_close();
508   ExprIntrp_SyntaxError::Raise(msg);
509 }
510
511
512 extern "C" void ExprIntrp_EndOfEqual()
513 {
514   Handle(Expr_GeneralExpression) memb2 = ExprIntrp_Recept.Pop();
515   Handle(Expr_GeneralExpression) memb1 = ExprIntrp_Recept.Pop();
516   Handle(Expr_Equal) res = new Expr_Equal(memb1,memb2);
517   ExprIntrp_Recept.PushRelation(res);
518 }
519
520 extern "C" void ExprIntrp_EndOfRelation()
521 {
522   Handle(Expr_SystemRelation) sys;
523   Handle(Expr_GeneralRelation) currel;
524   Handle(Expr_GeneralRelation) oldrel;
525   while (!ExprIntrp_Recept.IsRelStackEmpty()) {
526     currel = ExprIntrp_Recept.PopRelation();
527     if (!sys.IsNull()) {
528       sys->Add(currel);
529     }
530     else if (!oldrel.IsNull()) {
531       sys = new Expr_SystemRelation(oldrel);
532       sys->Add(currel);
533     }
534     else {
535       oldrel = currel;
536     }
537   }
538   if (sys.IsNull()) {
539     ExprIntrp_Recept.PushRelation(currel);
540   }
541   else {
542     ExprIntrp_Recept.PushRelation(sys);
543   }
544 }
545
546 extern "C" void ExprIntrp_EndOfAssign()
547 {
548   Handle(Expr_NamedExpression) namexp = ExprIntrp_Recept.GetNamed(ExprIntrp_assname);
549   Handle(Expr_NamedUnknown) namu;
550   if (namexp.IsNull()) {
551     namu = new Expr_NamedUnknown(ExprIntrp_assname);
552     ExprIntrp_Recept.Use(namu);
553   }
554   else {
555     if (!namexp->IsKind(STANDARD_TYPE(Expr_NamedUnknown))) {
556       ExprIntrp_SyntaxError::Raise();
557     }
558     namu = Handle(Expr_NamedUnknown)::DownCast(namexp);
559   }
560   namu->Assign(ExprIntrp_Recept.Pop());
561 }
562
563 extern "C" void ExprIntrp_EndOfFuncDef()
564 {
565   Handle(Expr_GeneralExpression) theexp = ExprIntrp_Recept.Pop();
566   Standard_Integer nbargs = ExprIntrp_Recept.PopValue();
567   Expr_Array1OfNamedUnknown vars(1,nbargs);
568   Expr_Array1OfNamedUnknown internvars(1,nbargs);
569   Standard_Integer i;
570   for (i=nbargs; i > 0; i--) {
571     vars(i) = Handle(Expr_NamedUnknown)::DownCast(ExprIntrp_Recept.Pop());
572     internvars(i) = Handle(Expr_NamedUnknown)::DownCast(vars(i)->Copy());
573   }
574   theexp = Expr::CopyShare(theexp);  // ATTENTION, PROTECTION BUG STACK
575   for (i=1; i<= nbargs; i++) {
576     if (theexp->Contains(vars(i))) {
577       theexp->Replace(vars(i),internvars(i));
578     }
579     else {
580       if (theexp == vars(i)) {
581         theexp = internvars(i);
582       }
583     }
584   }
585   Handle(Expr_NamedFunction) thefunc = 
586     new Expr_NamedFunction(ExprIntrp_funcdefname,
587                            theexp,
588                            internvars);
589   ExprIntrp_Recept.Use(thefunc);
590 }
591
592 extern "C" void ExprIntrp_ConstantIdentifier()
593 {
594   char name[100];
595   ExprIntrp_GetResult(name);
596   TCollection_AsciiString thename(name);
597   ExprIntrp_Recept.PushName(thename);
598 }
599
600 extern "C" void ExprIntrp_ConstantDefinition()
601 {
602   TCollection_AsciiString name = ExprIntrp_Recept.PopName();
603   char num[30];
604   int nbcar;
605   nbcar = ExprIntrp_GetResult(num);
606   Standard_Real val = atof(num);
607   Handle(Expr_NamedConstant) theconst = new Expr_NamedConstant(name,val);
608   ExprIntrp_Recept.Use(theconst);
609   ExprIntrp_Recept.Push(theconst);
610 }
611
612
613 extern "C" void ExprIntrp_Sumator()
614 {
615   Handle(Expr_NumericValue) number = Handle(Expr_NumericValue)::DownCast(ExprIntrp_Recept.Pop());
616   Standard_Integer nb = (Standard_Integer) number->GetValue();
617   Handle(Expr_GeneralExpression) inc = ExprIntrp_Recept.Pop();
618   Handle(Expr_GeneralExpression) first = ExprIntrp_Recept.Pop();
619   Handle(Expr_NamedUnknown) var = Handle(Expr_NamedUnknown)::DownCast(ExprIntrp_Recept.Pop());
620   Handle(Expr_GeneralExpression) theexp = ExprIntrp_Recept.Pop();
621   Standard_Boolean thesame = (theexp == var);
622   Handle(Expr_GeneralExpression) cur = Expr::CopyShare(first);
623   Handle(Expr_GeneralExpression) res;
624   Handle(Expr_GeneralExpression) member;
625   Expr_SequenceOfGeneralExpression seq;
626   for (Standard_Integer i=1; i<= nb; i++) {
627     if (thesame) {
628       member = cur;
629     }
630     else {
631       member = Expr::CopyShare(theexp);
632       member->Replace(var,cur);
633     }
634     seq.Append(member);
635     cur = (cur + inc)->ShallowSimplified();
636   }
637   res = new Expr_Sum(seq);
638   ExprIntrp_Recept.Push(res->ShallowSimplified());
639 }
640
641 extern "C" void ExprIntrp_Productor()
642 {
643   Handle(Expr_NumericValue) number = Handle(Expr_NumericValue)::DownCast(ExprIntrp_Recept.Pop());
644   Standard_Integer nb = (Standard_Integer) number->GetValue();
645   Handle(Expr_GeneralExpression) inc = ExprIntrp_Recept.Pop();
646   Handle(Expr_GeneralExpression) first = ExprIntrp_Recept.Pop();
647   Handle(Expr_NamedUnknown) var = Handle(Expr_NamedUnknown)::DownCast(ExprIntrp_Recept.Pop());
648   Handle(Expr_GeneralExpression) theexp = ExprIntrp_Recept.Pop();
649   Standard_Boolean thesame = (theexp == var);
650   Handle(Expr_GeneralExpression) cur = Expr::CopyShare(first);
651   Handle(Expr_GeneralExpression) res;
652   Handle(Expr_GeneralExpression) member;
653   Expr_SequenceOfGeneralExpression seq;
654   for (Standard_Integer i=1; i<= nb; i++) {
655     if (thesame) {
656       member = cur;
657     }
658     else {
659       member = Expr::CopyShare(theexp);
660       member->Replace(var,cur);
661     }
662     seq.Append(member);
663     cur = (cur + inc)->ShallowSimplified();
664   }
665   res = new Expr_Product(seq);
666   ExprIntrp_Recept.Push(res->ShallowSimplified());
667 }