Salome HOME
Merge from V6_main 01/04/2013
[modules/med.git] / src / INTERP_KERNEL / ExprEval / InterpKernelFunction.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #include "InterpKernelFunction.hxx"
22 #include "InterpKernelValue.hxx"
23
24 #include <cmath>
25
26 using namespace INTERP_KERNEL;
27
28 const char IdentityFunction::REPR[]="Id";
29
30 const char PositiveFunction::REPR[]="+";
31
32 const char NegateFunction::REPR[]="-";
33
34 const char CosFunction::REPR[]="cos";
35
36 const char SinFunction::REPR[]="sin";
37
38 const char TanFunction::REPR[]="tan";
39
40 const char ACosFunction::REPR[]="acos";
41
42 const char ASinFunction::REPR[]="asin";
43
44 const char ATanFunction::REPR[]="atan";
45
46 const char CoshFunction::REPR[]="cosh";
47
48 const char SinhFunction::REPR[]="sinh";
49
50 const char TanhFunction::REPR[]="tanh";
51
52 const char SqrtFunction::REPR[]="sqrt";
53
54 const char AbsFunction::REPR[]="abs";
55
56 const char PlusFunction::REPR[]="+";
57
58 const char MinusFunction::REPR[]="-";
59
60 const char MultFunction::REPR[]="*";
61
62 const char DivFunction::REPR[]="/";
63
64 const char PowFunction::REPR[]="^";
65
66 const char ExpFunction::REPR[]="exp";
67
68 const char LnFunction::REPR[]="ln";
69
70 const char LogFunction::REPR[]="log";
71
72 const char Log10Function::REPR[]="log10";
73
74 const char MaxFunction::REPR[]="max";
75
76 const char MinFunction::REPR[]="min";
77
78 const char GreaterThanFunction::REPR[]=">";
79
80 const char LowerThanFunction::REPR[]="<";
81
82 const char IfFunction::REPR[]="if";
83
84 Function *FunctionsFactory::buildFuncFromString(const char *type, int nbOfParams) throw(INTERP_KERNEL::Exception)
85 {
86   switch(nbOfParams)
87     {
88     case 1:
89       return buildUnaryFuncFromString(type);
90     case 2:
91       return buildBinaryFuncFromString(type);
92     case 3:
93       return buildTernaryFuncFromString(type);
94     default:
95       throw INTERP_KERNEL::Exception("Invalid number of params detected : limited to 2 !");
96     }
97 }
98
99 Function *FunctionsFactory::buildUnaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception)
100 {
101   std::string tmp(type);
102   if(tmp.empty())
103     return new IdentityFunction;
104   if(tmp==CosFunction::REPR)
105     return new CosFunction;
106   if(tmp==SinFunction::REPR)
107     return new SinFunction;
108   if(tmp==TanFunction::REPR)
109     return new TanFunction;
110   if(tmp==ACosFunction::REPR)
111     return new ACosFunction;
112   if(tmp==ASinFunction::REPR)
113     return new ASinFunction;
114   if(tmp==ATanFunction::REPR)
115     return new ATanFunction;
116   if(tmp==CoshFunction::REPR)
117     return new CoshFunction;
118   if(tmp==SinhFunction::REPR)
119     return new SinhFunction;
120   if(tmp==TanhFunction::REPR)
121     return new TanhFunction;
122   if(tmp==SqrtFunction::REPR)
123     return new SqrtFunction;
124   if(tmp==AbsFunction::REPR)
125     return new AbsFunction;
126   if(tmp==PositiveFunction::REPR)
127     return new PositiveFunction;
128   if(tmp==NegateFunction::REPR)
129     return new NegateFunction;
130   if(tmp==ExpFunction::REPR)
131     return new ExpFunction;
132   if(tmp==LnFunction::REPR)
133     return new LnFunction;
134   if(tmp==LogFunction::REPR)
135     return new LogFunction;
136   if(tmp==Log10Function::REPR)
137     return new Log10Function;
138   //
139   std::string msg("Invalid unary function detected : \"");
140   msg+=type; msg+="\"";
141   throw INTERP_KERNEL::Exception(msg.c_str());
142 }
143
144 Function *FunctionsFactory::buildBinaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception)
145 {
146   std::string tmp(type);
147   if(tmp==PositiveFunction::REPR)
148     return new PlusFunction;
149   if(tmp==NegateFunction::REPR)
150     return new MinusFunction;
151   if(tmp==MultFunction::REPR)
152     return new MultFunction;
153   if(tmp==DivFunction::REPR)
154     return new DivFunction;
155   if(tmp==PowFunction::REPR)
156     return new PowFunction;
157   if(tmp==MaxFunction::REPR)
158     return new MaxFunction;
159   if(tmp==MinFunction::REPR)
160     return new MinFunction;
161   if(tmp==GreaterThanFunction::REPR)
162     return new GreaterThanFunction;
163   if(tmp==LowerThanFunction::REPR)
164     return new LowerThanFunction;
165   std::string msg("Invalid binary function detected : \"");
166   msg+=type; msg+="\"";
167   throw INTERP_KERNEL::Exception(msg.c_str());
168 }
169
170 Function *FunctionsFactory::buildTernaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception)
171 {
172   std::string tmp(type);
173   if(tmp==IfFunction::REPR)
174     return new IfFunction();
175   std::string msg("Invalid ternary function detected : \"");
176   msg+=type; msg+="\"";
177   throw INTERP_KERNEL::Exception(msg.c_str());
178 }
179
180 Function *FunctionsFactory::buildBinaryFuncFromString(char type) throw(INTERP_KERNEL::Exception)
181 {
182   char tmp[2]; tmp[0]=type; tmp[1]='\0';
183   return buildBinaryFuncFromString(tmp);
184 }
185
186 Function::~Function()
187 {
188 }
189
190 IdentityFunction::~IdentityFunction()
191 {
192 }
193
194 void IdentityFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
195 {
196 }
197
198 void IdentityFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
199 {
200 }
201
202 const char *IdentityFunction::getRepr() const
203 {
204   return REPR;
205 }
206
207 bool IdentityFunction::isACall() const
208 {
209   return false;
210 }
211
212 PositiveFunction::~PositiveFunction()
213 {
214 }
215
216 int UnaryFunction::getNbInputParams() const
217 {
218   return 1;
219 }
220
221 void PositiveFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
222 {
223 }
224
225 void PositiveFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
226 {
227 }
228
229 const char *PositiveFunction::getRepr() const
230 {
231   return REPR;
232 }
233
234 bool PositiveFunction::isACall() const
235 {
236   return false;
237 }
238
239 NegateFunction::~NegateFunction()
240 {
241 }
242
243 void NegateFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
244 {
245   Value *val=stack.back();
246   val->negate();
247 }
248
249 void NegateFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
250 {
251   asmb.push_back("fchs");
252 }
253
254 const char *NegateFunction::getRepr() const
255 {
256   return REPR;
257 }
258
259 bool NegateFunction::isACall() const
260 {
261   return false;
262 }
263
264 CosFunction::~CosFunction()
265 {
266 }
267
268 void CosFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
269 {
270   Value *val=stack.back();
271   val->cos();
272 }
273
274 void CosFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
275 {
276   asmb.push_back("fcos");
277 }
278
279 const char *CosFunction::getRepr() const
280 {
281   return REPR;
282 }
283
284 bool CosFunction::isACall() const
285 {
286   return true;
287 }
288
289 SinFunction::~SinFunction()
290 {
291 }
292
293 void SinFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
294 {
295   Value *val=stack.back();
296   val->sin();
297 }
298
299 void SinFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
300 {
301   asmb.push_back("fsin");
302 }
303
304 const char *SinFunction::getRepr() const
305 {
306   return REPR;
307 }
308
309 bool SinFunction::isACall() const
310 {
311   return true;
312 }
313
314 TanFunction::~TanFunction()
315 {
316 }
317
318 void TanFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
319 {
320   Value *val=stack.back();
321   val->tan();
322 }
323
324 void TanFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
325 {
326   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
327 }
328
329 const char *TanFunction::getRepr() const
330 {
331   return REPR;
332 }
333
334 bool TanFunction::isACall() const
335 {
336   return true;
337 }
338
339 ACosFunction::~ACosFunction()
340 {
341 }
342
343 void ACosFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
344 {
345   Value *val=stack.back();
346   val->acos();
347 }
348
349 void ACosFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
350 {
351   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
352 }
353
354 const char *ACosFunction::getRepr() const
355 {
356   return REPR;
357 }
358
359 bool ACosFunction::isACall() const
360 {
361   return true;
362 }
363
364 ASinFunction::~ASinFunction()
365 {
366 }
367
368 void ASinFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
369 {
370   Value *val=stack.back();
371   val->asin();
372 }
373
374 void ASinFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
375 {
376   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
377 }
378
379 const char *ASinFunction::getRepr() const
380 {
381   return REPR;
382 }
383
384 bool ASinFunction::isACall() const
385 {
386   return true;
387 }
388
389 ATanFunction::~ATanFunction()
390 {
391 }
392
393 void ATanFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
394 {
395   Value *val=stack.back();
396   val->atan();
397 }
398
399 void ATanFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
400 {
401   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
402 }
403
404 const char *ATanFunction::getRepr() const
405 {
406   return REPR;
407 }
408
409 bool ATanFunction::isACall() const
410 {
411   return true;
412 }
413
414 CoshFunction::~CoshFunction()
415 {
416 }
417
418 void CoshFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
419 {
420   Value *val=stack.back();
421   val->cosh();
422 }
423
424 void CoshFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
425 {
426   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
427 }
428
429 const char *CoshFunction::getRepr() const
430 {
431   return REPR;
432 }
433
434 bool CoshFunction::isACall() const
435 {
436   return true;
437 }
438
439 SinhFunction::~SinhFunction()
440 {
441 }
442
443 void SinhFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
444 {
445   Value *val=stack.back();
446   val->sinh();
447 }
448
449 void SinhFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
450 {
451   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
452 }
453
454 const char *SinhFunction::getRepr() const
455 {
456   return REPR;
457 }
458
459 bool SinhFunction::isACall() const
460 {
461   return true;
462 }
463
464 TanhFunction::~TanhFunction()
465 {
466 }
467
468 void TanhFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
469 {
470   Value *val=stack.back();
471   val->tanh();
472 }
473
474 void TanhFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
475 {
476   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
477 }
478
479 const char *TanhFunction::getRepr() const
480 {
481   return REPR;
482 }
483
484 bool TanhFunction::isACall() const
485 {
486   return true;
487 }
488
489 SqrtFunction::~SqrtFunction()
490 {
491 }
492
493 void SqrtFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
494 {
495   Value *val=stack.back();
496   val->sqrt();
497 }
498
499 void SqrtFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
500 {
501   asmb.push_back("fsqrt");
502 }
503
504 const char *SqrtFunction::getRepr() const
505 {
506   return REPR;
507 }
508
509 bool SqrtFunction::isACall() const
510 {
511   return true;
512 }
513
514 AbsFunction::~AbsFunction()
515 {
516 }
517
518 void AbsFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
519 {
520   Value *val=stack.back();
521   val->abs();
522 }
523
524 void AbsFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
525 {
526   asmb.push_back("fabs");
527 }
528
529 const char *AbsFunction::getRepr() const
530 {
531   return REPR;
532 }
533
534 bool AbsFunction::isACall() const
535 {
536   return false;
537 }
538
539 void ExpFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
540 {
541   Value *val=stack.back();
542   val->exp();
543 }
544
545 void ExpFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
546 {
547   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
548 }
549
550 const char *ExpFunction::getRepr() const
551 {
552   return REPR;
553 }
554
555 bool ExpFunction::isACall() const
556 {
557   return true;
558 }
559
560 LnFunction::~LnFunction()
561 {
562 }
563
564 void LnFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
565 {
566   Value *val=stack.back();
567   val->ln();
568 }
569
570 void LnFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
571 {
572   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
573 }
574
575 const char *LnFunction::getRepr() const
576 {
577   return REPR;
578 }
579
580 bool LnFunction::isACall() const
581 {
582   return true;
583 }
584
585 LogFunction::~LogFunction()
586 {
587 }
588
589 void LogFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
590 {
591   Value *val=stack.back();
592   val->ln();
593 }
594
595 void LogFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
596 {
597   throw INTERP_KERNEL::Exception("Assembly for log Not implemented yet !");
598 }
599
600 const char *LogFunction::getRepr() const
601 {
602   return REPR;
603 }
604
605 bool LogFunction::isACall() const
606 {
607   return true;
608 }
609
610 Log10Function::~Log10Function()
611 {
612 }
613
614 void Log10Function::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
615 {
616   Value *val=stack.back();
617   val->log10();
618 }
619
620 void Log10Function::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
621 {
622   throw INTERP_KERNEL::Exception("Assembly for log Not implemented yet !");
623 }
624
625 const char *Log10Function::getRepr() const
626 {
627   return REPR;
628 }
629
630 bool Log10Function::isACall() const
631 {
632   return true;
633 }
634
635 int BinaryFunction::getNbInputParams() const
636 {
637   return 2;
638 }
639
640 PlusFunction::~PlusFunction()
641 {
642 }
643
644 void PlusFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
645 {
646   Value *val1=stack.back();
647   stack.pop_back();
648   Value *& val2=stack.back();
649   Value *val3;
650   try
651     {
652       val3=val1->plus(val2);
653     }
654   catch(INTERP_KERNEL::Exception& e)
655     {
656       delete val1;
657       throw e;
658     }
659   delete val1;
660   delete val2;
661   val2=val3;
662 }
663
664 void PlusFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
665 {
666   asmb.push_back("faddp st1");
667 }
668
669 const char *PlusFunction::getRepr() const
670 {
671   return REPR;
672 }
673
674 bool PlusFunction::isACall() const
675 {
676   return false;
677 }
678
679 MinusFunction::~MinusFunction()
680 {
681 }
682
683 void MinusFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
684 {
685   Value *val1=stack.back();
686   stack.pop_back();
687   Value *& val2=stack.back();
688   Value *val3;
689   try
690     {
691       val3=val1->minus(val2);
692     }
693   catch(INTERP_KERNEL::Exception& e)
694     {
695       delete val1;
696       throw e;
697     }
698   delete val1;
699   delete val2;
700   val2=val3;
701 }
702
703 void MinusFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
704 {
705   asmb.push_back("fsubp st1");
706 }
707
708 const char *MinusFunction::getRepr() const
709 {
710   return REPR;
711 }
712
713 bool MinusFunction::isACall() const
714 {
715   return false;
716 }
717
718 MultFunction::~MultFunction()
719 {
720 }
721
722 void MultFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
723 {
724   Value *val1=stack.back();
725   stack.pop_back();
726   Value *& val2=stack.back();
727   Value *val3=val1->mult(val2);
728   delete val1;
729   delete val2;
730   val2=val3;
731 }
732
733 void MultFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
734 {
735   asmb.push_back("fmulp st1");
736 }
737
738 const char *MultFunction::getRepr() const
739 {
740   return REPR;
741 }
742
743 bool MultFunction::isACall() const
744 {
745   return false;
746 }
747
748 DivFunction::~DivFunction()
749 {
750 }
751
752 void DivFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
753 {
754   Value *val1=stack.back();
755   stack.pop_back();
756   Value *& val2=stack.back();
757   Value *val3;
758   try
759     {
760       val3=val1->div(val2);
761     }
762   catch(INTERP_KERNEL::Exception& e)
763     {
764       delete val1;
765       throw e;
766     }
767   delete val1;
768   delete val2;
769   val2=val3;
770 }
771
772 void DivFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
773 {
774   asmb.push_back("fdivp st1");
775 }
776
777 const char *DivFunction::getRepr() const
778 {
779   return REPR;
780 }
781
782 bool DivFunction::isACall() const
783 {
784   return false;
785 }
786
787 PowFunction::~PowFunction()
788 {
789 }
790
791 void PowFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
792 {
793   Value *val1=stack.back();
794   stack.pop_back();
795   Value *& val2=stack.back();
796   Value *val3;
797   try
798     {
799       val3=val1->pow(val2);
800     }
801   catch(INTERP_KERNEL::Exception& e)
802     {
803       delete val1;
804       throw e;
805     }
806   delete val1;
807   delete val2;
808   val2=val3;
809 }
810
811 void PowFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
812 {
813   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
814 }
815
816 const char *PowFunction::getRepr() const
817 {
818   return REPR;
819 }
820
821 bool PowFunction::isACall() const
822 {
823   return true;
824 }
825
826 ExpFunction::~ExpFunction()
827 {
828 }
829
830 MaxFunction::~MaxFunction()
831 {
832 }
833
834 void MaxFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
835 {
836   Value *val1=stack.back();
837   stack.pop_back();
838   Value *& val2=stack.back();
839   Value *val3;
840   try
841     {
842       val3=val1->max(val2);
843     }
844   catch(INTERP_KERNEL::Exception& e)
845     {
846       delete val1;
847       throw e;
848     }
849   delete val1;
850   delete val2;
851   val2=val3;
852 }
853
854 void MaxFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
855 {
856   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
857 }
858
859 const char *MaxFunction::getRepr() const
860 {
861   return REPR;
862 }
863
864 bool MaxFunction::isACall() const
865 {
866   return false;
867 }
868
869 MinFunction::~MinFunction()
870 {
871 }
872
873 void MinFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
874 {
875   Value *val1=stack.back();
876   stack.pop_back();
877   Value *& val2=stack.back();
878   Value *val3;
879   try
880     {
881       val3=val1->min(val2);
882     }
883   catch(INTERP_KERNEL::Exception& e)
884     {
885       delete val1;
886       throw e;
887     }
888   delete val1;
889   delete val2;
890   val2=val3;
891 }
892
893 void MinFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
894 {
895   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
896 }
897
898 const char *MinFunction::getRepr() const
899 {
900   return REPR;
901 }
902
903 bool MinFunction::isACall() const
904 {
905   return false;
906 }
907
908 GreaterThanFunction::~GreaterThanFunction()
909 {
910 }
911
912 void GreaterThanFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
913 {
914   Value *val1=stack.back();
915   stack.pop_back();
916   Value *& val2=stack.back();
917   Value *val3;
918   try
919     {
920       val3=val1->greaterThan(val2);
921     }
922   catch(INTERP_KERNEL::Exception& e)
923     {
924       delete val1;
925       throw e;
926     }
927   delete val1;
928   delete val2;
929   val2=val3;
930 }
931
932 void GreaterThanFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
933 {
934   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
935 }
936
937 const char *GreaterThanFunction::getRepr() const
938 {
939   return REPR;
940 }
941
942 bool GreaterThanFunction::isACall() const
943 {
944   return false;
945 }
946
947 LowerThanFunction::~LowerThanFunction()
948 {
949 }
950
951 void LowerThanFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
952 {
953   Value *val1=stack.back();
954   stack.pop_back();
955   Value *& val2=stack.back();
956   Value *val3;
957   try
958     {
959       val3=val1->lowerThan(val2);
960     }
961   catch(INTERP_KERNEL::Exception& e)
962     {
963       delete val1;
964       throw e;
965     }
966   delete val1;
967   delete val2;
968   val2=val3;
969 }
970
971 void LowerThanFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
972 {
973   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
974 }
975
976 const char *LowerThanFunction::getRepr() const
977 {
978   return REPR;
979 }
980
981 bool LowerThanFunction::isACall() const
982 {
983   return false;
984 }
985
986 int TernaryFunction::getNbInputParams() const
987 {
988   return 3;
989 }
990
991 IfFunction::~IfFunction()
992 {
993 }
994
995 void IfFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
996 {
997   Value *val1=stack.back();
998   stack.pop_back();
999   Value *val2=stack.back();
1000   stack.pop_back();
1001   Value *&val3=stack.back();
1002   Value *val4;
1003   try
1004     {
1005       val4=val1->ifFunc(val2,val3);
1006     }
1007   catch(INTERP_KERNEL::Exception& e)
1008     {
1009       delete val1;
1010       delete val2;
1011       throw e;
1012     }
1013   delete val1;
1014   delete val2;
1015   delete val3;
1016   val3=val4;
1017 }
1018
1019 void IfFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
1020 {
1021   throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
1022 }
1023
1024 const char *IfFunction::getRepr() const
1025 {
1026   return REPR;
1027 }
1028
1029 bool IfFunction::isACall() const
1030 {
1031   return false;
1032 }
1033