[Fsem-commits] SF.net SVN: fsem: [114] fsem
Status: Beta
Brought to you by:
fabiandortu
|
From: <fab...@us...> - 2007-03-03 11:54:17
|
Revision: 114
http://fsem.svn.sourceforge.net/fsem/?rev=114&view=rev
Author: fabiandortu
Date: 2007-03-03 03:54:14 -0800 (Sat, 03 Mar 2007)
Log Message:
-----------
I changed the structure of the Freefem++ headers
It should now be easier to install Freefem++/FSEM
See the README file in root directory
Another commit will follow to set up symlink (cannot
change a file into a symlink in 1 commit with svn)
Modified Paths:
--------------
fsem/Makefile
fsem/README
fsem/include-freefem/README
fsem/mesh/modules/Misc/include
fsem/mesh/modules/fsem_Mod_MiscCppModules_Load.edp
fsem/models/modules/Semi/AFunction_ext.hpp
fsem/models/modules/Semi/include
fsem/models/modules/Temp/AFunction_ext.hpp
fsem/models/modules/Temp/include
fsem/models/modules/fsem_Mod_SemiCppModules_Load
fsem/patch/freefem++-2.8-2/README
Added Paths:
-----------
fsem/include-freefem/include/
fsem/include-freefem/include/AFunction.hpp
fsem/include-freefem/include/AFunction.hpp.README
fsem/include-freefem/include/AddNewFE.h
fsem/include-freefem/include/AnyType.hpp
fsem/include-freefem/include/BamgFreeFem.hpp
fsem/include-freefem/include/CGNL.hpp
fsem/include-freefem/include/CodeAlloc.hpp
fsem/include-freefem/include/DOperator.hpp
fsem/include-freefem/include/FESpace.hpp
fsem/include-freefem/include/FQuadTree.hpp
fsem/include-freefem/include/InitFunct.hpp
fsem/include-freefem/include/MatriceCreuse.hpp
fsem/include-freefem/include/MatriceCreuse_tpl.hpp
fsem/include-freefem/include/MeshPoint.hpp
fsem/include-freefem/include/Operator.hpp
fsem/include-freefem/include/QuadratureFormular.hpp
fsem/include-freefem/include/README
fsem/include-freefem/include/RNM.hpp
fsem/include-freefem/include/RNM_op.hpp
fsem/include-freefem/include/RNM_opc.hpp
fsem/include-freefem/include/RNM_tpl.hpp
fsem/include-freefem/include/RefCounter.hpp
fsem/include-freefem/include/Serialize.hpp
fsem/include-freefem/include/String.hpp
fsem/include-freefem/include/config-wrapper.h
fsem/include-freefem/include/config.h
fsem/include-freefem/include/environment.hpp
fsem/include-freefem/include/error.hpp
fsem/include-freefem/include/fem.hpp
fsem/include-freefem/include/fem3.hpp
fsem/include-freefem/include/ffstack.hpp
fsem/include-freefem/include/gmres.hpp
fsem/include-freefem/include/lex.hpp
fsem/include-freefem/include/lgfem.hpp
fsem/include-freefem/include/lgsolver.hpp
fsem/include-freefem/include/problem.hpp
fsem/include-freefem/include/rgraph.hpp
fsem/include-freefem/include/showverb.hpp
fsem/include-freefem/include/strversionnumber.hpp
fsem/include-freefem/include/throwassert.hpp
fsem/include-freefem/include/versionnumber.hpp
fsem/include-freefem/load.link
fsem/include-fsem/
fsem/include-fsem/AFunction_ext.hpp
fsem/patch/freefem++-2.8-2/patchfreefem
Removed Paths:
-------------
fsem/README.freefem
fsem/include-freefem/AFunction.hpp
fsem/include-freefem/AFunction.hpp.README
fsem/include-freefem/AddNewFE.h
fsem/include-freefem/AnyType.hpp
fsem/include-freefem/BamgFreeFem.hpp
fsem/include-freefem/CGNL.hpp
fsem/include-freefem/CodeAlloc.hpp
fsem/include-freefem/DOperator.hpp
fsem/include-freefem/FESpace.hpp
fsem/include-freefem/FQuadTree.hpp
fsem/include-freefem/InitFunct.hpp
fsem/include-freefem/MatriceCreuse.hpp
fsem/include-freefem/MatriceCreuse_tpl.hpp
fsem/include-freefem/MeshPoint.hpp
fsem/include-freefem/Operator.hpp
fsem/include-freefem/QuadratureFormular.hpp
fsem/include-freefem/RNM.hpp
fsem/include-freefem/RNM_op.hpp
fsem/include-freefem/RNM_opc.hpp
fsem/include-freefem/RNM_tpl.hpp
fsem/include-freefem/RefCounter.hpp
fsem/include-freefem/Serialize.hpp
fsem/include-freefem/String.hpp
fsem/include-freefem/config-wrapper.h
fsem/include-freefem/config.h
fsem/include-freefem/error.hpp
fsem/include-freefem/fem.hpp
fsem/include-freefem/fem3.hpp
fsem/include-freefem/ffstack.hpp
fsem/include-freefem/gmres.hpp
fsem/include-freefem/lex.hpp
fsem/include-freefem/lgfem.hpp
fsem/include-freefem/lgsolver.hpp
fsem/include-freefem/problem.hpp
fsem/include-freefem/rgraph.hpp
fsem/include-freefem/showverb.hpp
fsem/include-freefem/strversionnumber.hpp
fsem/include-freefem/throwassert.hpp
fsem/include-freefem/versionnumber.hpp
fsem/mesh/modules/Misc/AFunction_ext.hpp
fsem/mesh/modules/Misc/load.link
fsem/models/modules/AFunction_ext.hpp
fsem/models/modules/Semi/load.link
fsem/models/modules/Temp/load.link
Modified: fsem/Makefile
===================================================================
--- fsem/Makefile 2007-03-02 15:57:43 UTC (rev 113)
+++ fsem/Makefile 2007-03-03 11:54:14 UTC (rev 114)
@@ -12,3 +12,4 @@
clean:
cd models/modules/Semi; $(MAKE) clean;
cd models/modules/Temp; $(MAKE) clean;
+ cd mesh/modules/Misc; $(MAKE) clean;
Modified: fsem/README
===================================================================
--- fsem/README 2007-03-02 15:57:43 UTC (rev 113)
+++ fsem/README 2007-03-03 11:54:14 UTC (rev 114)
@@ -7,17 +7,55 @@
To install FSEM:
----------------
+0) In the sequel, we suppose that
+ * Freefem++ sources are available in $ffpp
+ * FSEM sources (the directory where you found this file) are available in $fsem
+
+ $ export ffpp=/home/fabian/tmp/freefem++-2.13
+ $ export fsem=/home/fabian/tmp/fsem/fsem
+
1) A patched version of FreeFEM++ has to be recompiled.
-See patch directory for details.
+ Note that the patch will most probably work on more
+ recent version of freefem++. Latest test was done on version 2.13.
-2) Run 'make' in FSEM's root directory.
-If you relocate FSEM, you have to run make again.
+ $ cd $fsem/patch/freefem++-2.8-2
+ $ ./patchfreefem $ffpp
+2) Compile Freefem++. You can read the doc of Freefem++,
+ but the following command should work:
+ $ cd $ffpp
+ $ ./configure --prefix=/usr/local --enable-download --enable-optim
+ $ make
+
+ become root here
+ $ make install
+ become normal user again
+
+3) Some files have to be synchronized between FSEM and Freefem++:
+
+ $ cp $ffpp/examples++-load/load.link $fsem/include-freefem
+ $ cd $ffpp/examples++-load/
+ $ tar xfz include.tar.gz
+ $ cp $ffpp/examples++-load/include/* $fsem/include-freefem/include
+ $ cp $ffpp/src/fflib/AFunction.hpp $fsem/include-freefem/include
+
+4) Run 'make' in FSEM's root directory.
+ If you relocate FSEM, you have to run make again.
+
+ $ cd $fsem
+ $ make clean
+ $ make
+
+5) check it out:
+
+ $ FreeFem++ fsem_main_Include.edp
+
+
To load FSEM:
-------------
-Just inlcude 'fsem_main_Include.edp' in the top of a Freefem input
+Just inlcude 'fsem_main_Include.edp' in the top of a Freefem++ input
file
For working examples, go in examples-tutorial/ directory.
Deleted: fsem/README.freefem
===================================================================
--- fsem/README.freefem 2007-03-02 15:57:43 UTC (rev 113)
+++ fsem/README.freefem 2007-03-03 11:54:14 UTC (rev 114)
@@ -1 +0,0 @@
-Based on patched (modules with more than 10 args) Freefem++ 2.7-2
Deleted: fsem/include-freefem/AFunction.hpp
===================================================================
--- fsem/include-freefem/AFunction.hpp 2007-03-02 15:57:43 UTC (rev 113)
+++ fsem/include-freefem/AFunction.hpp 2007-03-03 11:54:14 UTC (rev 114)
@@ -1,2837 +0,0 @@
-//file afonction.h
-#ifndef __AFONCTION__
-#define __AFONCTION__
-#include "showverb.hpp"
-
-
-#include <typeinfo>
-#include <cstddef>
-#include <iostream>
-#include <fstream>
-#include <cstring>
-#include "error.hpp"
-#include <map>
-#include <deque>
-#include <list>
-#include <vector>
-#include <queue>
-#include <complex>
-#include <string>
-#include <cstdlib>
-#include <algorithm>
-extern bool showCPU;
-#include <time.h>
-#include "CodeAlloc.hpp"
-
-inline double CPUtime(){
-#ifdef SYSTIMES
- struct tms buf;
- if (times(&buf)!=-1)
- return ((double)buf.tms_utime+(double)buf.tms_stime)/(long) sysconf(_SC_CLK_TCK);
- else
-#endif
- return ((double) clock())/CLOCKS_PER_SEC;
-}
-
-extern long verbosity; // level off printing
-
-
-extern bool withrgraphique;
-
-
-
-using namespace std;
-#include "ffstack.hpp"
-
-#include "AnyType.hpp"
-#include "String.hpp"
-
-
-class basicForEachType;
-class E_F1_funcT_Type;
-class E_F0; // une instruction exec time
-class C_F0; // une instruction complie time
-class ListOfInst;
-class Polymorphic;
-class OneOperator;
-typedef E_F0 * Expression; //
-class AC_F0;
-class basicAC_F0;
-typedef complex<double> Complex;
-
-typedef pair<aType, E_F0 *> Type_Expr ;// to store the type and the expression 29042005 FH
-
- int FindType(const char * name) ;
- void lgerror (const char* s) ;
- void CompileError(string msg="",aType r=0);
- void ExecError(string msg="");
-
-struct UnId {
- const char * id;
- aType r;
- Expression e;
- deque<UnId> * array; // to store a array
- aType re;
- bool ref; // a ref or non
- UnId() :id(0),r(0),e(0),array(0),re(0),ref(false) {}
- UnId(const char * idd) :id(idd),r(0),e(0),array(0),re(0),ref(false) {}
- UnId(const char * idd,const C_F0 & ee,aType rr,bool reff) ;
- UnId(deque<UnId> * d) : id(0),r(0),e(0),array(d?new deque<UnId>(*d):0),re(0),ref(false) {}
- UnId(const UnId & u) :
- id(u.id),r(u.r),e(u.e),
- array(u.array?new deque<UnId>(*u.array):0),
- re(u.re),ref(u.ref) {}
- // Modif 24032005
- void operator= (const UnId & u) {
- id=u.id;
- r=u.r;
- e=u.e;
- re=u.re;
- ref=u.ref;
- if(array) delete array;
- array=0;
- if(u.array) array= new deque<UnId>(*u.array);
- }
-
- ~UnId(){ if( array) delete array;} // Modif 24032005
-
-};
-
-typedef deque<UnId> ListOfId;
-// xxx is a type so xxx can't be a parameter
-#define ATYPE(xxx) map_type[typeid(xxx).name()]
-/* #define NEW_TYPE(type) map_type[typeid(type).name()] = new ForEachType<type >(0,0)
-//#define NEW_TYPE(type) map_type[typeid(type).name()] = new ForEachType<type >()
-#define NEW_TYPE_I(type,i,d) map_type[typeid(type).name()] = new ForEachType<type>(i,d)
-#define NEW_TYPE_Ptr(type) map_type[typeid(type*).name()] = new ForEachTypePtr<type >()
-#define NEW_TYPE_PtrND(type) map_type[typeid(type*).name()] = new ForEachTypePtr<type >(0)
-#define NEW_TYPE_PtrNIND(type) map_type[typeid(type*).name()] = new ForEachTypePtr<type >(0,0)
-//#define NEW_TYPE_PtrI(type) map_type[typeid(type*).name()] = new ForEachTypePtr<type*>(Initialize<type>)
-*/
-
-
-
-
-extern Polymorphic * TheOperators, * TheRightOperators;
-
-// -------------
-extern C_F0 *pOne,*pZero,*pminusOne;
-
-
-typedef AnyType (* Function1)(Stack, const AnyType &);
-typedef AnyType (* Function2)(Stack, const AnyType &,const AnyType &);
-typedef AnyType (* CFunction2)(Stack, E_F0 *, E_F0 *);
-typedef AnyType (* CFunction4)(Stack, E_F0 *, E_F0 *, E_F0 *, E_F0 *);
-
-
-Expression NewExpression(Function1,Expression);
-Expression NewExpression(Function2,Expression,Expression);
-
-
-inline Type_Expr make_Type_Expr(aType t, E_F0 * e) {return make_pair(t,e);}
-inline Type_Expr make_Type_Expr( E_F0 * e,aType t) {return make_pair(t,e);}
-
-struct Keyless : binary_function<const char *,const char *, bool>
- {
- typedef const char * Key;
- bool operator()(const Key& x, const Key& y) const { return strcmp(x,y)<0;} };
-
-
-// un table Iden
-class TableOfIdentifier: public CodeAlloc {
- public:
- struct Value;
- typedef const char * Key;
- typedef map<Key,Value,Keyless> maptype;
- typedef pair<const Key,Value> pKV;
- typedef maptype::iterator iterator;
- typedef maptype::const_iterator const_iterator;
-
- struct Value :public Type_Expr {
- pKV * next; // link all the variable in reverse order to call delete on each variable
- bool del;
- Value(const Type_Expr & vv,pKV * n,bool dd=true) : Type_Expr(vv),next(n),del(dd) {}
- Value(aType t,E_F0 *f,pKV *n,bool dd=true): Type_Expr(t,f),next(n),del(dd) {}
- };// to store the type and the expression
- pKV * listofvar;
-
-// struct Keyless : binary_function<Key,Key, bool>
-// { bool operator()(const Key& x, const Key& y) const{ return strcmp(x,y)<0;} };
-
-
- maptype m;
- C_F0 Find(Key) const ;
- C_F0 Find(Key,const basicAC_F0 &) const ;
-
- const Type_Expr & New(Key k,const Type_Expr & v,bool del=true);
- void Add(Key k,Key op,OneOperator *p0,OneOperator *p1=0,
- OneOperator *p2=0,OneOperator *p3=0,OneOperator *p4=0,
- OneOperator *p5=0,OneOperator *p6=0) ;
- void clear();
-template<class T>
- C_F0 NewVar(Key k,aType t,size_t & top,const C_F0 &i) ;
-template<class T>
- C_F0 NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args) ;
-template<class T,class U>
- C_F0 NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args,const U & data) ;
-// C_F0 NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args,const C_F0& f) ;
-template<class T>
- C_F0 NewVar(Key k,aType t,size_t & top) ;
- C_F0 NewID(aType t,Key k, C_F0 & c,size_t & top,bool del=true);
- C_F0 NewID(aType t,Key k, C_F0 & c,const ListOfId & l,size_t & top,bool del=true);
-template<class T>
- C_F0 NewFESpace(Key k,aType t,size_t & top,const basicAC_F0 &args);
- friend ostream & operator<<(ostream & f,const TableOfIdentifier & );
- C_F0 destroy();
- TableOfIdentifier() ; //: listofvar(0) {};
- ~TableOfIdentifier(); //
-};
-
-
-// for all the type of the language
-class basicForEachType : public CodeAlloc {
- const type_info * ktype; // the real type_info
- // const type_info *ktypefunc;// the type of code
- public:
- const size_t size;
-
-
- typedef OneOperator * CastFunc;
- typedef map<aType,CastFunc>::const_iterator const_cast_iterator;
-
- typedef const char * Key;
-
- // virtual void print(ostream &f,const void *p) const =0;
-
- friend ostream & operator<<(ostream & f,const basicForEachType & e)
- { f << '<' << e.name() << '>' ;return f;}
- void Show(ostream & f) const ;
- const char * name() const { return this ? ktype->name() :"NULL" ;}
- virtual bool CastingFrom(const basicForEachType * t) const ;
- // modif FH ----- A TESTER //
- virtual bool SametypeRight(const basicForEachType * t) const {return this == t || t == un_ptr_type;}
-// virtual Type_Expr init(const Type_Expr & te) const { return Type_Expr(0,0);}
- virtual int TYPEOFID() const {return 0;}
-// bool SametypeLeft(const basicForEachType * t) const {return t == this;}
- // bool To(const basicForEachType * t) const { throwassert(t && this);return un_ptr_type == this ? t->un_ptr_type == this : t == this;}
- virtual C_F0 CastTo(const C_F0 & e) const ;
- virtual void SetArgs(const ListOfId *lid) const ;// { cout << "SetArgs::\n " ;throwassert(lid==0 || lid->size()==0);}
- aType right() const {return un_ptr_type;};
- Expression RightValueExpr(Expression f) const;
- // Type_Expr NewVar(Key k,aType t,size_t & top,const C_F0 &i);
- virtual C_F0 Initialization(const Type_Expr & e) const ;
- virtual Expression Destroy(const C_F0 &) const ;
- virtual bool ExistDestroy() const {return destroy;}
- virtual Type_Expr SetParam(const C_F0 & c,const ListOfId * l,size_t & top) const;
- // { return make_pair<aType,const E_F0 *>(this,c.left());}
-
- protected:
- basicForEachType(const type_info & k ,const size_t ,
- const E_F1_funcT_Type * p=0,basicForEachType *rr=0,
- Function1 iv=0,Function1 id=0) ;
-/* inline basicForEachType(const type_info & k ,const type_info & kf ,const size_t ,
- const E_F1_funcT_Type * p=0,basicForEachType *rr=0,
- Function1 iv=0,Function1 id=0) ;*/
-
-public:
- const basicForEachType * un_ptr_type; // type of right exp
- private:
- // map<aType,CastFunc> mapofcast;
- OneOperator * casting; // list of operator for casting to this type
-
- const E_F1_funcT_Type * un_ptr; // is ptr -> get value function
-
-
- Function1 InitExp; // to init the ptr value
- Function1 destroy;// the destroy function
- TableOfIdentifier ti; // all polymorphisme of the Identifier
- public:
- // basicForEachType * FunctionType() const;// { return funct_type ? funct_type : (funct_type= new FuncForEachType(this));}
- C_F0 Find(const char * k) const; // {return ti->Find(k);}
- C_F0 Find(const char * k,const basicAC_F0 & args) const; // {return ti->Find(k);}
- void New(Key k,Type_Expr v,bool del=true){ti.New(k,v,del);}
-
- void Add(Key k,Key op,OneOperator *p0,OneOperator *p1=0,
- OneOperator *p2=0,OneOperator *p3=0,OneOperator *p4=0,
- OneOperator *p5=0,OneOperator *p6=0)
- {ti.Add(k,op,p0,p1,p2,p3,p4,p5,p6);}
-
- void AddCast(CastFunc f1,CastFunc f2=0,CastFunc f3=0,CastFunc f4=0,
- CastFunc f5=0,CastFunc f6=0,CastFunc f7=0,CastFunc f8=0);
- ostream & ShowTable(ostream & f) const { f << ti; return f;}
-
- // basicForEachType * funct_type;
- virtual ~basicForEachType();
-
-};
-
-
-template<typename T>
-inline basicForEachType * atype() {
- map<const string,basicForEachType *>::iterator ir=map_type.find(typeid(T).name());
- // basicForEachType * r=map_type[];
- if (ir == map_type.end()) { cerr << "Error: aType '" << typeid(T).name() << "', doesn't exist\n";
- ShowType(cerr);
- throw(ErrorExec("exit",1));}
- return ir->second;}
-
-
-// --------
-//typedef basicForEachType TheType;
-
-// const basicForEachType * ktype; // compilation time
-
-// class for all exp
-// a left exp is a pointer expression
-// -------
-// -- exec times le code is just E_F0*(fonction without args)
-class C_LF2;
-class C_LF1;
-
-// 3 types of function/expression 0,1,2 args
-class E_F0 :public CodeAlloc
- {
- public:
-
- struct kless : binary_function<Expression,Expression, bool>
- { bool operator()(const Expression& x, const Expression& y) const{
- //cout << x << " " << y << x->compare(y) << " ::: ";
- int r1 = x->compare(y);// , r2 = y->compare(x);
- //assert(r1+r2==0);
- return r1<0;} };
- typedef map< E_F0 *,int,kless> MapOfE_F0;
-
- virtual AnyType operator()(Stack) const =0;
- virtual bool Empty() const {return !this; }
- // virtual E_F0 * destroy(Stack ) const {return 0;}
- // virtual const E_F0 * Parameter(Stack ) const {return this;}
- virtual size_t nbitem() const {return 1;}
- virtual bool EvaluableWithOutStack() const {return false;} //
- virtual bool MeshIndependent() const {return true;} //
- virtual E_F0 * right_E_F0() const { return 0;}
- virtual bool ReadOnly() const { return true;} // the expression do not change the memory
- virtual ~E_F0() {}
- virtual int compare (const E_F0 *t) const { int r= (t==this) ? 0 : ( ( this<t) ?-1 : 1);
- //cout << "cmp " << typeid(*this).name() << r << endl;
- return r;} // to give a order in instuction
- virtual int Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n) ; // build optimisation
- virtual AnyType operator()(Stack stack,AnyType *) const { return operator()(stack);} // call optim code
- virtual operator aType () const { assert(0);return 0;} // the type of the expression
- virtual ostream & dump(ostream &f) const { f << ' ' << typeid(*this).name() << ' ' << this << ' ' ;return f; }
- // for OPTIMIZATION
-
- int find(const MapOfE_F0 & m) ;
- int insert(Expression opt,deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n) ;
-
- };
-
-inline ostream & operator<<(ostream & f,const E_F0 &e) { if(&e) e.dump(f); else f << " --0-- " ;return f;}
-// a
-class E_F0mps : public E_F0 { public:
- virtual bool MeshIndependent() const {return false;} //
-};
-
-class E_F0info : public E_F0 { public:
- // not a real expression just to pass information
- virtual bool EvaluableWithOutStack() const {return true;} //
- virtual bool MeshIndependent() const {return true;} //
- AnyType operator()(Stack s) const {
- return SetAny<const E_F0 *>(this);}
- operator aType () const { return atype<Expression>();}
-
-
-};
-
-class E_F1 : public CodeAlloc{ public: virtual AnyType operator()(Stack,AnyType &) const =0;};
-class E_F2 : public CodeAlloc{ public: virtual AnyType operator()(Stack,AnyType &,AnyType &) const =0;};
-class E_FN : public CodeAlloc{ public: virtual AnyType operator()(Stack,size_t N,...) const =0;};
-
-// class to play with polymorphisme
-// ---------------------------------
-class basicAC_F0;
-class ArrayOfaType : public CodeAlloc{
- // class for the type of parameter
- aType tt[16];
- protected:
- bool ellipse;
- int n;
- aType * t; // array of type
- void operator=(const ArrayOfaType &); // no set operator
- public:
- // ArrayOfaType() :n(0),t(0),ellipse(false) {}
- explicit ArrayOfaType(bool ell=false)
- :n(0),t(0),ellipse(ell) {}
-
- explicit ArrayOfaType(const aType & a,bool ell=false)
- :n(1),t(tt),ellipse(ell) {t[0]=a;}
-
- explicit ArrayOfaType(const aType & a,const aType & b,bool ell=false)
- :n(2),t(tt),ellipse(ell) {t[0]=a,t[1]=b;}
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,bool ell=false)
- :n(3),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;}
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,bool ell=false)
- :n(4),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d;
- /* cout << * a << *b << * c << * d << " ---------" << endl; */}
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,bool ell=false)
- :n(5),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; }
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,const aType & f,bool ell=false)
- :n(6),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; }
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,
- const aType & f,const aType & g,
- bool ell=false)
- :n(7),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; } // (6 args) Added by Fabian Dortu
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,
- const aType & f,const aType & g,const aType & h,
- bool ell=false)
- :n(8),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; } // (7 args) Added by Fabian Dortu
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,
- const aType & f,const aType & g,const aType & h, const aType & i,
- bool ell=false)
- :n(9),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; } // (8 args) Added by Fabian Dortu
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d, const aType & e,
- const aType & f,const aType & g,const aType & h, const aType & i, const aType & j,
- bool ell=false)
- :n(10),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; t[9]=j; } // (10 args) Added by Fabian Dortu
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,const aType & f,const aType & g,const aType & h, const aType & i, const aType & j, const aType & k,bool ell=false)
- :n(11),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; t[9]=j; t[10]=k; } // (10 args) Added by Fabian Dortu
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,const aType & f,const aType & g,const aType & h, const aType & i, const aType & j, const aType & k, const aType & l, bool ell=false)
- :n(12),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; t[9]=j; t[10]=k; t[11]=l; }
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,const aType & f,const aType & g,const aType & h, const aType & i, const aType & j, const aType & k, const aType & l, const aType & m, bool ell=false)
- :n(13),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; t[9]=j; t[10]=k; t[11]=l; t[12]=m; }
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,const aType & f,const aType & g,const aType & h, const aType & i, const aType & j, const aType & k, const aType & l, const aType & m, const aType & n, bool ell=false)
- :n(14),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; t[9]=j; t[10]=k; t[11]=l; t[12]=m; t[13]=n; }
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,const aType & f,const aType & g,const aType & h, const aType & i, const aType & j, const aType & k, const aType & l, const aType & m, const aType & n, const aType & o,bool ell=false)
- :n(15),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; t[9]=j; t[10]=k; t[11]=l; t[12]=m; t[13]=n; t[14]=o; }
-
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,const aType & f,const aType & g,const aType & h, const aType & i, const aType & j, const aType & k, const aType & l, const aType & m, const aType & n, const aType & o, const aType & p, bool ell=false)
- :n(16),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; t[9]=j; t[10]=k; t[11]=l; t[12]=m; t[13]=n; t[14]=o; t[15]=p; }
-
-
- ArrayOfaType(const basicAC_F0 & ) ;
- ArrayOfaType(const ArrayOfaType & ); //
- ArrayOfaType(const ListOfId * l);
- ~ArrayOfaType() { if(t && t != tt) delete [] t;t=0;n=0;}
- bool WithOutCast( const ArrayOfaType & a) const ;
- bool WithCast( const ArrayOfaType & a,int nbcast=100000) const ; // return the number of cast
- // exactly comparaison
- bool operator==( const ArrayOfaType & a) const {
- if (a.n != n || a.ellipse !=ellipse) return false;
- for (int i=0;i<n;i++)
- if (t[i] != a.t[i])
- return false;
- return true;}
-
- friend ostream & operator<<(ostream & f,const ArrayOfaType & a);
-};
-
-
-
-class OneOperator : public ArrayOfaType {
- friend class MakeVectSpaceN;
- friend class basicForEachType;
- const basicForEachType * r; // return type
- OneOperator *next; // to make a list of OneOperator
- public:
- int pref; // to try to solve ambiguity for binary operator
- // 10 for bool, 20 for int , 30 for long , 40, for float, 50 double, 60 for complex, 70 string
- // string+ 1 => string
- // 1+string => string
- OneOperator(aType rr) ;// : r(rr),ArrayOfaType(),next(0),pref(0) {throwassert(r);}
- OneOperator(aType rr,aType a) ;//: r(rr),ArrayOfaType(a,false),next(0),pref(0) {throwassert(rr && a );}
- OneOperator(aType rr,aType a,aType b);// : r(rr),ArrayOfaType(a,b,false),next(0),pref(0) {
- // throwassert(rr && a && b);}
- OneOperator(aType rr,aType a,aType b,aType c) ;
- //: r(rr),ArrayOfaType(a,b,c,false),next(0),pref(0) {throwassert(rr && a && b && c);}
- OneOperator(aType rr,aType a,aType b,aType c,aType d) ;
- //: r(rr),ArrayOfaType(a,b,c,d,false),next(0),pref(0) {throwassert(rr && a && b && c);}
-
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e) ;
- //: r(rr),ArrayOfaType(a,b,c,d,e,false),next(0),pref(0) {throwassert(rr && a && b && c && d);} // Added by Fabian Dortu (5 parameters)
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f) ;
- //: r(rr),ArrayOfaType(a,b,c,d,e,f,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f);} // Added by Fabian Dortu (6 parameters)
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g);
- // : r(rr),ArrayOfaType(a,b,c,d,e,f,g,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g);} // Added by Fabian Dortu (7 parameters)
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h);
- // : r(rr),ArrayOfaType(a,b,c,d,e,f,g,h,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g && h);} // Added by Fabian Dortu (8 parameters)
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i) ;
- //: r(rr),ArrayOfaType(a,b,c,d,e,f,g,h,i,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g && h && i);} // Added by Fabian Dortu (9 parameters)
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i, aType j);
- // : r(rr),ArrayOfaType(a,b,c,d,e,f,g,h,i,j,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g && h && i && j);} // Added by Fabian Dortu (10 parameters)
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i, aType j, aType k);
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i, aType j, aType k, aType l);
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i, aType j, aType k, aType l, aType m);
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i, aType j, aType k, aType l, aType m, aType n);
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i, aType j, aType k, aType l, aType m, aType n, aType o);
-
-
-
- OneOperator(aType rr,const ArrayOfaType &ta) ;
- //: r(rr),ArrayOfaType(ta),next(0),pref(0) {throwassert(rr);}
- OneOperator(aType rr,bool ellipse) ;
- //: r(rr),ArrayOfaType(ellipse),next(0),pref(0) {throwassert(rr );}
- OneOperator(aType rr,const ListOfId *l) ;
- //: r(rr),ArrayOfaType(l),next(0),pref(0) {throwassert(rr );}
-
- typedef pair<const OneOperator *,int> pair_find;
- void operator+=(OneOperator &a){throwassert(a.next==0);a.next=next;next=&a;}
- // a way to make none recurve delete good
- virtual ~OneOperator();
- pair_find Find(const ArrayOfaType & at) const ;
- pair_find FindWithOutCast(const ArrayOfaType & at) const ; // for
- OneOperator * FindSameR(const ArrayOfaType & at) ;
-
- void Show(const ArrayOfaType & at,ostream &f=cerr) const;
- void Show(ostream &f=cerr) const;
- operator aType () const { return r;}
- virtual E_F0 * code(const basicAC_F0 &) const =0;
- const OneOperator * Simple() const { return next||n?0:this;}
- friend ostream & operator<<(ostream & f,const OneOperator & a);
-
-};
-
-
-class Polymorphic: public E_F0mps {
- // a list of type
- // simple, array or function
- private:
- typedef const char * Key;
- typedef OneOperator * Value;
- // struct Keyless : binary_function<Key,Key, bool>
- // { bool operator()(const Key& x, const Key& y) const{ return strcmp(x,y)<0;} };
-
- typedef map<Key,Value,Keyless> maptype; //
- typedef maptype::const_iterator const_iterator; //
- typedef maptype::iterator iterator; //
- // remark the map is mutable because
- // a expression is const E_F0 *
- // So There is a incompatibility between
- // we save an expression in a variable
- // we have to add thing to a polymorphisme expression
- mutable maptype m; // all polymorphisme of the Identifier
- Expression e; // default expression
- public:
- Polymorphic() : m(),e(0) {}
-
-// by default Empty and do nothing
- virtual AnyType operator()(Stack ) const { return Nothing;}
- virtual bool Empty() const {return true;} // by default Empty
- void clear() { m.clear();}
- const OneOperator * Find(const char *op, const ArrayOfaType &at) const;
- const OneOperator * FindWithOutCast(const char *op,const ArrayOfaType &at) const;
- void Show(const char *op,const ArrayOfaType & at,ostream &f=cerr)const ;
- void Add(const char * op,OneOperator * p0 ,OneOperator * p1=0,OneOperator * p2=0,
- OneOperator * p3=0,OneOperator * p4=0,OneOperator * p5=0,
- OneOperator * p6=0,OneOperator * p7=0,OneOperator * p8=0,
- OneOperator * p9=0,OneOperator * pa=0,OneOperator * pb=0,
- OneOperator * pc=0,OneOperator * pd=0,OneOperator * pe=0
- ) const
- {Addp(op,p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pa,pb,pc,pd,pe,0);}
- void Add(const char * op,OneOperator ** pp) const ;
- private:
- void Addp(const char * op,OneOperator * pp,...) const ;
- friend ostream & operator<<(ostream & f,const Polymorphic & a);
-
-
-};
-
-
-
-
-// the type for polymorphisme of id
-
-
-
-// compile time expression
-class basicAC_F0;
- class C_F0 {
- friend class CC_F0;
- protected:
- Expression f; // the expression code
- aType r; // the expression type
-
- public:
- // the constructeur
- C_F0() :f(0),r(0) {}
- C_F0(const C_F0 & c):f(c.f),r(c.r) {}
- C_F0(const C_F0 & a,const C_F0 & b); // concatenation
- C_F0(const Type_Expr & a):r(a.first),f(a.second) {}
- C_F0(const Polymorphic *,const char *,const basicAC_F0 & );
- C_F0(const Polymorphic *,const char *, AC_F0 & );
- // function, array ..
- C_F0(const C_F0 & e,const char *op,const basicAC_F0 & p) ;
- C_F0(const C_F0 & e,const char *op, AC_F0 & p) ;
- C_F0(const C_F0 & e,const char *op,const C_F0 & ee) ;
- C_F0(const C_F0 & e,const char *op,const C_F0 & a,const C_F0 & b) ;
- C_F0(const C_F0 & e,const char *nm) ;
- // without parameter ex f()
- C_F0(const Polymorphic * pop,const char *op);
- // unary operator
- C_F0(const Polymorphic * pop,const char *op,const C_F0 & a);
- // binary operator
- C_F0(const Polymorphic * pop,const char *op,const C_F0 & a,const C_F0 & b);
- // ternary operator
- C_F0(const Polymorphic * pop,const char *op,const C_F0 & a,const C_F0 & b,const C_F0 & c);
-
-
- C_F0( Expression ff,aType rr ): f(ff),r(rr) {
- // if (!rr && ff) cerr << "Type Null" << endl;
- }
- // operator Expression() const {return f;}
- AnyType eval(Stack s) const {return (*f)(s);}
-
- Expression RightValue() const { return r->RightValueExpr(f);}
- Expression LeftValue() const;
-
- aType left() const {return r;}
- aType right() const {return r->right();}
- C_F0 RightExp() const { return C_F0(RightValue(),right());} // FH add 07/2005
- operator E_F0 * () const {return f;}
- bool Empty() const {return !f || f->Empty();}
- bool NotNull() const {return f;}
- int TYPEOFID() const { return r ? r->TYPEOFID(): 0;}
- int nbitem() const { return f ? f->nbitem() : 0;}
- bool EvaluableWithOutStack() const { return f && f->EvaluableWithOutStack();}
- Expression Destroy() { return r->Destroy(*this);}
- operator const Polymorphic * () const {return dynamic_cast<const Polymorphic *>(f);}
- bool operator==(const C_F0 & a) const {return f==a.f && r == a.r;}
- bool operator!=(const C_F0 & a) const {return f!=a.f || r != a.r;}
-// Type_Expr SetParam(const ListOfId * l,size_t & top) const ;
- bool MeshIndependent() const { return f ==0 ? f->MeshIndependent() : false;}
-private:
-friend class Block;
-friend class TableOfIdentifier;
- C_F0( Expression ff ): f(ff),r(0) {}
- };
-
-
-
-// for bison
-class CListOfInst;
-
-
- // a => b
- // f => t||f
- // t => t
- // (a =>b) <=> (!a || b )
-
-// warning ------------------
-class ForTypeVoid: public basicForEachType{public:
- ForTypeVoid():basicForEachType(typeid(void),0,0,0,0,0) {}
-};
-
-template<class T>
-class ForEachType: public basicForEachType{public:
- ForEachType(Function1 iv=0,Function1 id=0):basicForEachType(typeid(T),sizeof(T),0,0,iv,id) {
- if (sizeof(T) > sizeof(AnyTypeWithOutCheck) )
- {
- cout << " Sorry the " <<typeid(T).name() << " is too large ( " << sizeof(T)
- << " > " << sizeof(AnyTypeWithOutCheck) << " ) " << endl;
- throwassert(sizeof(T) <= sizeof(AnyTypeWithOutCheck) );
- }
- }
-};
-template<class T>
-class ForEachType<T*>: public basicForEachType{public:
- ForEachType(Function1 iv=0,Function1 id=0):basicForEachType(typeid(T),sizeof(T),0,0,iv,id) { }
-};
-
-template<class A,class B> AnyType UnRef(Stack,const AnyType &a) ;
-template<class A> AnyType Initialize(Stack,const AnyType &a) ;
-template<class A> AnyType Destroy(Stack,const AnyType &a) ;
-
-// the type of variable is pointer because we need to write in
-template<class T>
-class ForEachTypePtr: public basicForEachType { public:
- ForEachTypePtr();
- ForEachTypePtr(Function1 init,Function1 dl);
- ForEachTypePtr(Function1 dl);
-};
-
-template<class T>
-class ForEachTypePtr<T*>: public basicForEachType { public:
- ForEachTypePtr();
- ForEachTypePtr(Function1 init,Function1 dl);
- ForEachTypePtr(Function1 dl);
-};
-
-
-template<class T,int RTYPE=1>
-class ForEachTypePtrfspace: public ForEachTypePtr<T> { public:
- ForEachTypePtrfspace():ForEachTypePtr<T>() {}
- int TYPEOFID() const {return RTYPE;}
-};
-
-
-class ForTypeAnyType: public basicForEachType{public:
- ForTypeAnyType(): basicForEachType(typeid(AnyType),sizeof(AnyType)) {}
- bool CastingFrom(const basicForEachType * ) const {return true;}
- C_F0 CastTo(const C_F0 & e) const {return e;}
-};
-
-
-// for cast and get value associed to a pointer
-
-
-template<class A,class B>
- AnyType Cast(Stack,const AnyType &b) {
- return SetAny<A>(static_cast<A>(GetAny<B>(b)));}
-
-template<class A,class B,A F(const B &)>
- AnyType FCast(Stack s,const AnyType &b) {
- return SetAny<A>(Add2StackOfPtr2Free(s,F(GetAny<B>(b))));}
-
-template<class A>
- AnyType UnRef(Stack,const AnyType &a) {
- return SetAny<A>(*PGetAny<A>(a));}
-
-template<class A,class B>
- AnyType UnRef(Stack,const AnyType &a) {
- return SetAny<A>(*PGetAny<B>(a));}
-
-
-template<class A>
- AnyType UnRefCopyPtr(Stack s,const AnyType &a) {
- A ** ppa=PGetAny<A*>(a);
- A * pc = new A(**ppa);
- return SetAny<A*>(Add2StackOfPtr2Free(s,pc)) ;}
-
-
-template<class A> AnyType Initialize(Stack,const AnyType &x){
- A * a=PGetAny<A>(x);
- A *b=new A;//
- memcpy(a,b,sizeof(A));// bitcopy
- ::operator delete(b); // delete with no destruction
- return SetAny<A*>(a);
-}
-
-template<class A> AnyType InitializePtr(Stack stack,const AnyType &x){
- A * a=PGetAny<A>(x);
-SHOWVERB( cout << " init ptr " << typeid(A*).name() << (char *) a - (char*) stack<< endl);
- *a=0;
- return x;
-}
-
-template<class A> inline AnyType Delete(Stack,const AnyType &x){
- A * a=PGetAny<A>(x);
- SHOWVERB(cout << "DESTROY " <<typeid(A).name() << " " << a << endl);
- (*a).~A();
- return Nothing;
-}
-
-template<class A> inline AnyType Destroy(Stack,const AnyType &x){
- A * a=PGetAny<A>(x);
- SHOWVERB(cout << "DESTROY " <<typeid(A).name() << " " << a << endl);
- a->destroy();
- return Nothing;
-}
-
-template<class A> inline AnyType DestroyS(Stack,const AnyType &x){
- A a=GetAny<A>(x);
- SHOWVERB(cout << "DESTROY " <<typeid(A).name() << " " << a << endl);
- a.destroy();
- return Nothing;
-}
-
-template<class A> inline AnyType InitS(Stack,const AnyType &x){
- A a=GetAny<A>(x);
- SHOWVERB(cout << "InitS " <<typeid(A).name() << " " << a << endl);
- a.init();
- return Nothing;
-}
-template<class A> inline AnyType InitP(Stack,const AnyType &x){
- A *a=PGetAny<A>(x);
- SHOWVERB(cout << "InitP " <<typeid(A).name() << " " << a << endl);
- a->init();
- return Nothing;
-}
-
-
-template<class A> inline AnyType DestroyPtr(Stack,const AnyType &x) {
- const A * a=PGetAny<A>(x);
- SHOWVERB(cout << "DestroyPtr " << typeid(A).name() << *a << endl);
- (*a)->destroy();
- // delete *a;
-
- return Nothing;
-};
-template<class A> inline AnyType DeletePtr(Stack,const AnyType &x) {
- const A * a=PGetAny<A>(x);
- SHOWVERB(cout << "DeletePtr " << typeid(A).name() << *a << endl);
- // (*a)->destroy();
- delete *a;
-
- return Nothing;
-};
-
-template<> AnyType inline DestroyPtr<string *>(Stack,const AnyType &x) {
- string ** a=PGetAny<string*>(x);
- SHOWVERB( cout << "DestroyPtr " << typeid(string*).name() << *a << endl);
- delete *a;
- return Nothing;
-};
-
-
-
-template<class A> AnyType Initialize(Stack,const AnyType &x,const AnyType &y){
- A * a=PGetAny<A>(x);
- A *b=new A(GetAny<A>(x));//
- memcpy(a,b,sizeof(A));// bitcopy
- ::operator delete(b); // delete with no destruction
- return SetAny<A*>(a);
-}
-
-
-
-class E_F0_CFunc2 :public E_F0mps { public:
- CFunction2 f2;
- E_F0 *a,*b;
- AnyType operator()(Stack s) const {return f2(s,a,b);}
- E_F0_CFunc2( CFunction2 ff,E_F0 *aa,E_F0 *bb) : f2(ff),a(aa),b(bb){}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack() && b->EvaluableWithOutStack();} //
- operator aType () const { return atype<void>();}
-
-};
-
-class E_F0_CFunc4 :public E_F0mps { public:
- CFunction4 f4;
- E_F0 *a,*b,*c,*d;
- AnyType operator()(Stack s) const {return f4(s,a,b,c,d);}
- E_F0_CFunc4( CFunction4 ff,E_F0 *aa,E_F0 *bb,E_F0 *cc,E_F0 *dd)
- : f4(ff),a(aa),b(bb),c(cc),d(dd){}
- operator aType () const { return atype<void>();}
-
-};
-
-
-
-template<class R,class A>
- class E_F1_F :public E_F1 { public:
- typedef R (*func)(A) ;
- func f;
- E_F1_F(func ff) : f(ff) {}
- AnyType operator()(Stack s,AnyType & a) const
- {return SetAny<R>(f(GetAny<A>(a)));}
-};
-
-template<class R,class A0,class A1>
- class E_F2_F :public E_F2 { public:
- typedef R (*func)(const A0 &,const A1&) ;
- func f;
- E_F2_F(func ff) : f(ff) {}
- AnyType operator()(Stack s,AnyType & a0,AnyType & a1) const
- {return SetAny<R>(f(GetAny<A0>(a0),GetAny<A1>(a1)));}
-};
-
-template<class R,class TA0,bool RO=true>
- class E_F_F0 :public E_F0 { public:
- template <class T> struct remove_reference {typedef T type;};
-// template <class T> struct remove_reference<T&> {typedef T type;};
- template <class T> struct remove_reference<const T&> {typedef T type;};
- typedef typename remove_reference<TA0>::type A0;
-
-
- typedef R (*func)( TA0 ) ;
- func f;
- Expression a;
- E_F_F0(func ff,Expression aa) : f(ff),a(aa) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>(f(GetAny<A0>( (*a)(s) )));}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack();} //
- bool MeshIndependent() const {return a->MeshIndependent();} //
- bool ReadOnly() const { return RO ;}
- int compare (const E_F0 *t) const {
- int rr;
- // cout << "cmp " << typeid(*this).name() << " and " << typeid(t).name() << endl;
- const E_F_F0* tt=dynamic_cast<const E_F_F0 *>(t);
- if (tt && f == tt->f) rr = a->compare(tt->a);
- else rr = E_F0::compare(t);
- return rr;
- } // to give a order in instuction
-
- int Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n) ;
- virtual ostream & dump(ostream &f) const { f << typeid(*this).name() <<" f= " << f << " a= "<< *a << ' ' ;return f; }
-
-};
-
-// modif for xlc++ FH
-template<class R,class TA0,bool RO=true>
-class E_F_F0_Opt: public E_F_F0<R,TA0,RO> { public :
- size_t ia;
- E_F_F0_Opt(const E_F_F0<R,TA0,RO> &t,size_t iaa)
- : E_F_F0<R,TA0,RO>(t) , ia(iaa) {assert(iaa<2000000 && iaa >0);}
- AnyType operator()(Stack s) const
- {
- // A0 x = *static_cast<A0 *>(static_cast<void*>(static_cast<char *>(s)+ia));
- // cout << " opt f (" << x << " ) = " << ": " << ia << endl;
- return SetAny<R>( f( *static_cast<typename E_F_F0<R,TA0>::A0 *>(static_cast<void*>(static_cast<char *>(s)+ia)) ) );}
-
-};
-
-template<class R,class TA0,bool RO>
- int E_F_F0<R,TA0,RO>::Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n)
- {
- int rr = find(m);
- if (rr) return rr;
- return insert(new E_F_F0_Opt<R,TA0,RO>(*this,a->Optimize(l,m,n)),l,m,n);
- }
-// fin modif xlc++
-
-template<class A0>
- class E_VF_F0 :public E_F0 { public:
- typedef void (*func)( A0 ) ;
- func f;
- Expression a;
- E_VF_F0(func ff,Expression aa) : f(ff),a(aa) {}
- AnyType operator()(Stack s) const
- {f(GetAny<A0>( (*a)(s) ));return Nothing;}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack();} //
-
- bool MeshIndependent() const { return a->MeshIndependent(); }
-
-};
-
-inline int clexico(int i,int j) { return i==0 ? j : i;}
-inline int clexico(int i,int j,int k) { int ll=clexico(i,j); return ll==0 ? k : ll;}
-
-template<class R,class TA0,class TA1>
- class E_F_F0F0 :public E_F0 { public:
- template <class T> struct remove_reference {typedef T type;};
- template <class T> struct remove_reference<T&> {typedef T type;};
- typedef typename remove_reference<TA0>::type A0;
- typedef typename remove_reference<TA1>::type A1;
- typedef R (*func)( A0 , A1 ) ;
-
- func f;
- Expression a0,a1;
- E_F_F0F0(func ff,Expression aa0,Expression aa1)
- : f(ff),a0(aa0),a1(aa1) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>( f( GetAny<A0>((*a0)(s)) , GetAny<A1>((*a1)(s)) ) );}
- bool EvaluableWithOutStack() const
- {return a0->EvaluableWithOutStack() && a1->EvaluableWithOutStack();} //
- bool MeshIndependent() const
- {return a0->MeshIndependent() && a1->MeshIndependent();} //
- int compare (const E_F0 *t) const {
- int rr;
- // cout << "cmp " << typeid(*this).name() << " and " << typeid(t).name() << endl;
- const E_F_F0F0* tt=dynamic_cast<const E_F_F0F0 *>(t);
- if (tt && f == tt->f) rr= clexico(a0->compare(tt->a0),a1->compare(tt->a1));
- else rr = E_F0::compare(t);
- return rr;
- } // to give a order in instuction
-
- int Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n) ;
-
-};
-
-// modif for xlc++
-template<class R,class TA0,class TA1>
-class E_F_F0F0_Opt: public E_F_F0F0<R,TA0,TA1> { public :
- size_t ia,ib;
- E_F_F0F0_Opt(const E_F_F0F0<R,TA0,TA1> &t,size_t iaa,size_t ibb)
- : E_F_F0F0<R,TA0,TA1>(t) ,
- ia(iaa),ib(ibb) {}
- AnyType operator()(Stack s) const
- {
- //A0 aa =*static_cast<A0 *>(static_cast<void*>(static_cast<char *>(s)+ia));
- //A1 bb=*static_cast<A1 *>(static_cast<void*>(static_cast<char *>(s)+ib)) ;
- //cout << ia << " " << ib << "f( " << aa << "," << bb << " ) = "<< f(aa,bb) << endl;
- return SetAny<R>( f( *static_cast<typename E_F_F0F0<R,TA0,TA1>::A0 *>(static_cast<void*>(static_cast<char *>(s)+ia)) ,
- *static_cast<typename E_F_F0F0<R,TA0,TA1>::A1 *>(static_cast<void*>(static_cast<char *>(s)+ib)) ) );}
-
-};
-
-
-template<class R,class TA0,class TA1>
- int E_F_F0F0<R,TA0,TA1>::Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n)
- {
-
- int rr = find(m);
- if (rr) return rr;
-
- return insert(new E_F_F0F0_Opt<R,TA0,TA1>(*this,a0->Optimize(l,m,n),a1->Optimize(l,m,n)),l,m,n);
- }
-// add modif for xlc++
-
-
-
-template<class R,class A0>
- class E_F_F0_ :public E_F0 { public:
- typedef R (*func)(const A0& ) ;
- func f;
- Expression a;
- E_F_F0_(func ff,Expression aa) : f(ff),a(aa) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>(f(GetAny<A0>( (*a)(s) )));}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack() ;} //
- bool MeshIndependent() const
- {return a->MeshIndependent();} //
-
-};
-
-template<class R,class A0>
- class E_F_F0s_ :public E_F0mps { public:
- typedef R (*func)(Stack stack,const A0& ) ;
- func f;
- Expression a;
- E_F_F0s_(func ff,Expression aa) : f(ff),a(aa) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>(f(s,GetAny<A0>( (*a)(s) )));}
- bool MeshIndependent() const
- {return true;} //
-
- operator aType () const { return atype<R>();}
-
-};
-
-template<class R,class A0,class A1,class E=E_F0>
- class E_F_F0F0_ :public E { public:
- typedef R (*func)(const A0 &,const A1 & ) ;
- func f;
- Expression a0,a1;
- E_F_F0F0_(func ff,Expression aa0,Expression aa1)
- : f(ff),a0(aa0),a1(aa1) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>( f( GetAny<A0>((*a0)(s)) , GetAny<A1>((*a1)(s)) ) );}
- bool MeshIndependent() const
- {return a0->MeshIndependent() && a1->MeshIndependent();} //
-
-};
-
-template<class R,class A0,class A1,class A2,class E=E_F0>
- class E_F_F0F0F0_ :public E { public:
- typedef R (*func)(const A0 &,const A1 & , const A2 &) ;
- func f;
- Expression a0,a1,a2;
- E_F_F0F0F0_(func ff,Expression aa0,Expression aa1,Expression aa2)
- : f(ff),a0(aa0),a1(aa1),a2(aa2) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>( f( GetAny<A0>((*a0)(s)) , GetAny<A1>((*a1)(s)),GetAny<A2>((*a2)(s)) ) );}
- virtual size_t nbitem() const {return a2->nbitem(); }
- bool MeshIndependent() const
- {return a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent();} //
-
-};
-
-template<class R,class A0,class A1,class A2,class E=E_F0>
- class E_F_stackF0F0F0_ :public E_F0mps { public:
- typedef R (*func)(Stack, const A0 &,const A1 & , const A2 &) ;
- func f;
- Expression a0,a1,a2;
- E_F_stackF0F0F0_(func ff,Expression aa0,Expression aa1,Expression aa2)
- : f(ff),a0(aa0),a1(aa1),a2(aa2) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>( f(s, GetAny<A0>((*a0)(s)) , GetAny<A1>((*a1)(s)),GetAny<A2>((*a2)(s)) ) );}
- virtual size_t nbitem() const {return a2->nbitem(); }
- bool MeshIndependent() const { return true;}
-};
-
-template<class R,class A0,class A1>
- class E_F_F0F0_NC :public E_F0 { public:
- typedef R (*func)( A0 &,const A1 & ) ;
- func f;
- Expression a0,a1;
- E_F_F0F0_NC(func ff,Expression aa0,Expression aa1)
- : f(ff),a0(aa0),a1(aa1) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>( f( GetAny<A0>((*a0)(s)) , GetAny<A1>((*a1)(s)) ) );}
- bool MeshIndependent() const
- {return a0->MeshIndependent() && a1->MeshIndependent() ; } //
-
-};
-
-
-
-
- class E_F_StackF0F0 :public E_F0mps { public:
- typedef AnyType (*func)(Stack,Expression ,Expression ) ;
- func f;
- Expression a0,a1;
- E_F_StackF0F0(func ff,Expression aa0,Expression aa1)
- : f(ff),a0(aa0),a1(aa1) { }
- AnyType operator()(Stack s) const
- {return (*f)(s, a0 , a1) ;}
-
-};
-
-
-/*
- class E_F_F0F0_<AnyType,AnyType,AnyType> :public E_F0 { public:
- typedef AnyType (*func)(const AnyType &,const AnyType & ) ;
- func f;
- Expression a0,a1;
- E_F_F0F0_(func ff,Expression aa0,Expression aa1)
- : f(ff),a0(aa0),a1(aa1) {}
- AnyType operator()(Stack s) const
- {return f( (*a0)(s) , (*a1)(s) );}
- bool MeshIndependent() const
- {return a0->MeshIndependent() && a1->MeshIndependent() ; } //
-
-};
-*/
-
-class E_F2_func :public E_F2 { public:
- Function2 f;
- AnyType operator()(Stack s,AnyType & a,AnyType & b) const {return f(s,a,b);}
- E_F2_func( Function2 ff) : f(ff) {}
-};
-
-class E_F0_Func1 :public E_F0 { public:
- Function1 f;
- E_F0 *a;
- AnyType operator()(Stack s) const {return f(s,(*a)(s));}
- E_F0_Func1( Function1 f1,E_F0 *aa) : f(f1),a(aa){}
- bool EvaluableWithOutStack() const {return a->EvaluableWithOutStack();} //
- bool MeshIndependent() const {return a->MeshIndependent();} //
- int compare (const E_F0 *t) const {
- int rr;
- const E_F0_Func1* tt=dynamic_cast<const E_F0_Func1 *>(t);
- if (tt && f == tt->f) rr = a->compare(tt->a);
- else rr = E_F0::compare(t);
- if(tt && 0)
- {
- cout << "\n\t\t\t -------- " << (void *) f << " " << (void *) tt->f << " rr=" << a->compare(tt->a) << endl;
- cout << "\t\t\tcmp E_F0_Func1 " << rr <<" << " << *this << " cmp " << *t << " " << tt << ">>\n";
- }
- return rr;
- } // to give a order in instuction
- // int Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n) const; // build optimisation
-
- virtual ostream & dump(ostream &f) const { f << "E_F0_Func1 f= " << f << " a= "<< *a << ' ' ;return f; }
-
-};
-class E_F0_Func2 :public E_F0 { public:
- Function2 f;
- E_F0 *a,*b;
- AnyType operator()(Stack s) const {return f(s,(*a)(s),(*b)(s));}
- E_F0_Func2( Function2 f1,E_F0 *aa,E_F0 *bb) : f(f1),a(aa),b(bb){}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack() &&b->EvaluableWithOutStack();} //
- bool MeshIndependent() const {return a->MeshIndependent() && b->MeshIndependent();} //
-
-};
-
-
-
-// the variable offset / stack (local variable)
-template<class R> class Value1:public E_F0
- {
- size_t offset;
- public:
- AnyType operator()(Stack s) const { return SetAny<R*>(static_cast<R *>(static_cast<void *>( static_cast<char *>(s)+offset)));}
- Value1(size_t o):offset(o) {}
-};
-
-// the variable globale
-template<class R> class GValue:public E_F0
- {
- mutable R v;
- public:
- AnyType operator()(Stack ) const { return SetAny<R*>(static_cast<R *>(static_cast<void *>(&v)));}
- GValue(R o):v(o) {}
- bool EvaluableWithOutStack() const {return true;} //
-
-};
-
-// a constante value
-template<class R> int ccompare(const R & a,const R& b){ return a==b ? 0 :( a<b ? -1 : +1);}
-template<class R> int ccompare(const complex<R> & a,const complex<R>& b){
- int c=ccompare(a.real(),b.real());
- return c==0 ? ccompare(a.imag(),b.imag()): c ;}
-
-template<class R> class EConstant:public E_F0
- {
- const R v;
- public:
- AnyType operator()(Stack ) const { /*cout << " ()" << v << endl*/;return SetAny<R>(v);}
- EConstant(const R & o):v(o) { /*cout << "New constant " << o << endl;*/}
- bool EvaluableWithOutStack() const {return true;} //
- operator aType () const { return atype<R>();}
- int compare (const E_F0 *t) const {
- int rr;
- const EConstant * tt=dynamic_cast<const EConstant *>(t);
- if (tt) rr = ccompare(v,tt->v);
- else rr = E_F0::compare(t);
- return rr;
- }
- ostream & dump(ostream &f) const { f << " ((" <<typeid(R).name() << ") " << v << ") " ;return f;}
-};
-
-
-
-
-
-// the variable offset / stack (local variable)
-
- class LocalVariable:public E_F0
- {
- size_t offset;
- aType t; // type of the variable just for check
- public:
- AnyType operator()(Stack s) const {
- SHOWVERB( cout << "\n\tget var " << offset << " " << t->name() << endl);
-// return PtrtoAny(static_cast<void *>(static_cast<char *>(s)+offset),t);}
- return PtrtoAny(Stack_offset<void>(s,offset),t);}
-
- LocalVariable(size_t o,aType tt):offset(o),t(tt) {throwassert(tt);
- SHOWVERB(cout << "\n--------new var " << offset << " " << t->name() << endl);
- }
-};
-
-
-class LocalVariableFES : public LocalVariable { public:
- size_t data;
- LocalVariableFES(size_t o,aType tt,const size_t & d)
- : LocalVariable(o,tt),data(d) {}
- size_t nbitem() const { return data;}
-};
-
-template <class U>
-class LocalVariablePlus : public LocalVariable { public:
- U data;
- LocalVariablePlus(size_t o,aType tt,const U & d)
- : LocalVariable(o,tt),data(d) {}
-};
-
-// global variable bof bof
-template<class T> class PValue:public E_F0
- {
- T * p;
- public:
- AnyType operator()(Stack ) const { return p;}
- PValue(T * pp):p(pp) {}
-};
-template<class R> class PPValue:public E_F0
- {
- R ** p;
- public:
- AnyType operator()(Stack ) const { return SetAny<R*>(*p);}
- PPValue(R ** pp):p(pp) {}
-};
-
-
-template<class R>
-Type_Expr CPValue(R & v)
- {
- throwassert(map_type[typeid(R*).name()]);
- return make_pair(map_type[typeid(R*).name()],new PValue<R>(&v));
- }
-template<class R>
-Type_Expr CPPValue(R *& v)
- {
- throwassert(map_type[typeid(R*).name()]);
- return make_pair(map_type[typeid(R*).name()],new PPValue<R>(&v));
- }
-
-template<class R >
-Type_Expr CConstant(const R & v)
- {
- throwassert(map_type[typeid(R).name()]);
- return make_pair(map_type[typeid(R).name()],new EConstant<R>(v));
- }
-
-
-class CC_F0 {
- Expression f;
- aType r;
-public:
- void operator=(const C_F0& c) { f=c.f;r=c.r;;}
- void operator=(const AC_F0& a) ; //{ f=new E_Array(a); f= atype<E_Array>();};
- void operator=(long ) {f=0;r=0;}
- void operator=(const CListOfInst& c);//{ C_FO cc=c;f=cc.f;r=cc.r}
- operator C_F0 () const {return C_F0(f,r);}
- bool Empty() const {return !f || f->Empty();}
- aType left() const {return r;}
- // operator const C_F0 &() const {return *this;}
-};
-
-
-class ListOfInst : public E_F0mps {
- int n;
- Expression * list;
- int * linenumber;
- const int nx;
- public:
- ListOfInst():n(0),list(0),linenumber(0),nx(10){}
- ListOfInst(int nn):n(0),list(0),linenumber(0),nx(nn?nn:10){}
- void Add(const C_F0 & ins);
- AnyType operator()(Stack s) const;
- operator aType () const { return n ? (aType) * (list[n-1]) : atype<void>();}
-
- Expression &operator[](int i){return list[i];}
- bool empty() const {return n==0;}
- int size() const {return n;}
- Expression * ptr() const {return list;}
- int * nlines() const {return linenumber;}
- // void destroy() { if (list) delete [] list; list=0;}
- ~ListOfInst(){ cout << " ----- ~ListOfInst " << endl;
- if(list) delete [] list;list=0;if(linenumber) delete[] linenumber; linenumber=0;}
-};
-
-class CListOfInst { private:
- ListOfInst * f;
- const basicForEachType *r;
- public:
- void operator=(const CC_F0 &a){
- f=new ListOfInst();
- if( !a.Empty() ) {
- f->Add(a);
- r=a.left(); }}
- CListOfInst & operator+=(const CC_F0 & a);//{ if( !a.Empty()){ f->Add(a);r=a.left();};return *this;}
- operator C_F0 () const { return C_F0(f,r);}
- void eval(Stack s) {(*f)(s);}
- int size() const {return f->size();}
- Expression * ptr() const {return f->ptr();}
- int * nlines() const { return f->nlines();}
-};
-
-
-AnyType FWhile(Stack ,E_F0 * test,E_F0 * ins);
-AnyType FFor(Stack s ,E_F0 * i0,E_F0 * i1,E_F0 * i2,E_F0 * ins);
-AnyType FIf(Stack s ,E_F0 * test,E_F0 * i1,E_F0 * i2,E_F0 * notuse);
-AnyType TTry(Stack s ,E_F0 * i0,E_F0 * i1,E_F0 * i2,E_F0 * notuse);
-
-
-
-extern TableOfIdentifier Global;
-void ShowType(ostream & );
-
-template<class T>
-inline C_F0 to(const C_F0 & a) { return map_type[typeid(T).name()]->CastTo(a);}
-
-
-/*
-inline C_F0 toBool(const C_F0 & a) {return ATYPE(bool)->CastTo(a);}
-inline C_F0 toInt(const C_F0 & a) {return ATYPE(int)->CastTo(a);}
-inline C_F0 toLong(const C_F0 & a) {return ATYPE(long)->CastTo(a);}
-inline C_F0 toDouble(const C_F0 & a) {return ATYPE(double)->CastTo(a);}
-inline C_F0 toComplex(const C_F0 & a) {return ATYPE(Complex)->CastTo(a);}
-*/
-inline C_F0 While(C_F0 test,C_F0 ins) {return C_F0(new E_F0_CFunc2(FWhile,to<bool>(test),ins),0);}
-inline C_F0 For(C_F0 i0,C_F0 i1,C_F0 i2,C_F0 ins) {return C_F0(new E_F0_CFunc4(FFor,i0,to<bool>(i1),i2,ins),0);}
-inline C_F0 Try(C_F0 i0,C_F0 i1,C_F0 i2) {return C_F0(new E_F0_CFunc4(TTry,i0,i1,i2,0),0);}
-inline C_F0 FIf(C_F0 i0,C_F0 i1,C_F0 i2) {return C_F0(new E_F0_CFunc4(FIf,to<bool>(i0),i1,i2,0),0);}
-inline C_F0 FIf(C_F0 i0,C_F0 i1) {return C_F0(new E_F0_CFunc4(FIf,to<bool>(i0),i1,0,0),0);}
-//inline C_F0 C_F0::PtrValue() const{
-// if (!(r && r->un_ptr)) { cerr << "PtrValue: Not a Left value " << *r << endl;CompileError();}
-// return C_F0(new E_F0_Func1(r->un_ptr->f,f),r->un_ptr->r);}
-
-
-
-class basicAC_F0 {
-// version de base d'un tableau d'un parametres
-// pour les operateurs unaire, binaire, ,
-// pas d'allocation
- friend class E_Array; // for mapping fonction
- protected:
- typedef const C_F0 const_C_F0;
- int nb;
- C_F0 *a;
- public:
- ...
[truncated message content] |