Changeset 3902
 Timestamp:
 Sep 10, 2008, 9:27:11 PM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

toimperative/trunk/opents/samples/trefal.hh
r3901 r3902 13 13 class GExpr; 14 14 class Term; 15 class GlobalExprs; 15 16 16 17 class TExpr : public ts::TVar<Expr> … … 85 86 86 87 GExpr & operator+ (const Term& t) { 87 int old_size = size;88 size_t old_size = size; 88 89 Term* old_terms = terms; 89 90 … … 91 92 terms = new Term[size]; 92 93 93 for ( inti = 0; i < old_size; i++)94 for (unsigned i = 0; i < old_size; i++) 94 95 *(terms++) = *(old_terms++); 95 96 *terms = t; 96 97 97 98 delete old_terms; 98 return this;99 return *this; 99 100 } 100 101 101 102 GExpr & operator+ (const GExpr& x) { 102 int old_size = size;103 size_t old_size = size; 103 104 Term* old_terms = terms; 104 105 … … 106 107 terms = new Term[size]; 107 108 108 for ( inti = 0; i < old_size; i++)109 for (unsigned i = 0; i < old_size; i++) 109 110 *(terms++) = *(old_terms++); 110 111 Term* new_terms = x.terms; 111 for ( inti = 0; i < x.size; i++)112 for (unsigned i = 0; i < x.size; i++) 112 113 *(terms++) = *(new_terms++); 113 114 114 115 delete old_terms; 115 return this; 116 } 117 118 GExpr & operator() () { 119 Term t; 120 t.init_const(global_exprs.add_global_expr(this)); 121 return new GExpr(t); 122 } 116 return *this; 117 } 118 119 GExpr operator() () const; 123 120 124 121 void clear() { … … 126 123 } 127 124 }; 128 129 extern GlobalExprs global_exprs;130 125 131 126 class GlobalExprs { … … 134 129 135 130 public: 136 GExpr exprs[];131 GExpr* exprs; 137 132 138 133 GlobalExprs () : size (8), free_idx(0), exprs(new GExpr[8]) {} … … 142 137 } 143 138 144 int add_global_expr (const GExpr 139 int add_global_expr (const GExpr& expr) { 145 140 if (free_idx == size) { 146 141 GExpr* old_exprs = exprs; … … 154 149 } 155 150 }; 151 152 extern GlobalExprs global_exprs; 153 154 GExpr GExpr::operator() () const 155 { 156 Term t; 157 t.init_const(global_exprs.add_global_expr(*this)); 158 return GExpr(t); 159 } 156 160 157 161 class Expr : private ts::TExtData
Note: See TracChangeset
for help on using the changeset viewer.