Changeset 3905
 Timestamp:
 Sep 12, 2008, 3:04:40 PM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

toimperative/trunk/opents/samples/trefal.hh
r3903 r3905 19 19 class TExpr : public ts::TVar<Expr> { 20 20 public: 21 TExpr () {};22 TExpr (const GExpr& _e);23 TExpr (TExpr& _e, size_t _start, size_t len); // subexpression24 TExpr (Term& _t); // dereference: _t is EXPR or CONST25 bool operator== (TExpr& _e);26 TExpr operator+ (TExpr& _e);27 TExpr operator() ();21 inline TExpr () {}; 22 inline TExpr (const GExpr& _e); 23 inline TExpr (TExpr& _e, size_t _start, size_t len); // subexpression 24 inline TExpr (Term& _t); // dereference: _t is EXPR or CONST 25 inline bool operator== (TExpr& _e); 26 inline TExpr operator+ (TExpr& _e); 27 inline TExpr operator() (); 28 28 }; 29 29 … … 66 66 GExpr () : terms(0), size(0) {} 67 67 68 GExpr (TExpr& _e);68 inline GExpr (TExpr& _e); 69 69 70 70 GExpr (int size) : terms(new Term[size]), size(0) {} 71 71 72 72 void init (int size) { 73 if (terms != 0) // must be uni tialized73 if (terms != 0) // must be uninitialized 74 74 throw 0; 75 75 terms = new Term[size]; … … 77 77 78 78 GExpr& operator= (const GExpr& e) { 79 if (terms != 0) // must be uni tialized79 if (terms != 0) // must be uninitialized 80 80 throw 0; 81 81 terms = e.terms; … … 104 104 } 105 105 106 void add (const GExpr& e);106 inline void add (const GExpr& e); 107 107 108 108 void concat (const GExpr& x) { 109 109 for (size_t i = 0; i < x.size; i++) 110 terms[size++] = x.terms[i]; 110 add(x.terms[i]); 111 } 112 113 GExpr subexpr (size_t from, size_t len) { 114 GExpr e; 115 e.terms = terms + from; 116 e.size = len; 117 return e; 111 118 } 112 119 … … 124 131 GExpr* exprs; 125 132 126 GlobalExprs () : size ( 200), free_idx(0), exprs(new GExpr[200]) {}133 GlobalExprs () : size (8), free_idx(0), exprs(new GExpr[8]) {} 127 134 128 135 int add_global_expr (const GExpr& expr) { … … 131 138 exprs = new GExpr[2*size]; 132 139 memcpy(exprs, old_exprs, size*sizeof(GExpr)); 133 delete old_exprs;140 delete[] old_exprs; 134 141 size *= 2; 135 142 }
Note: See TracChangeset
for help on using the changeset viewer.