00001 #ifndef wali_wpds_ewpds_EWPDS_GUARD
00002 #define wali_wpds_ewpds_EWPDS_GUARD 1
00003
00004
00005
00006
00007
00008 #include "wali/Common.hpp"
00009 #include "wali/SemElemPair.hpp"
00010 #include "wali/IMergeFn.hpp"
00011 #include "wali/wpds/WPDS.hpp"
00012 #include <set>
00013
00014 namespace wali
00015 {
00016 class SemElem;
00017 template< typename T > class Worklist;
00018
00019 namespace wpds
00020 {
00021 class Config;
00022 class rule_t;
00023 class RuleFunctor;
00024 class ConstRuleFunctor;
00025 class Wrapper;
00026
00027 namespace ewpds
00028 {
00029
00030 using ::wali::wfa::WFA;
00031 class ERule;
00032 typedef ref_ptr<ERule> erule_t;
00033
00034
00035
00036
00037
00038
00039 class EWPDS : public WPDS
00040 {
00041 public:
00042
00043
00044
00045
00046 static const std::string XMLTag;
00047
00048 public:
00049 typedef HashMap< KeyTriple, rule_t > merge_rule_hash_t;
00050
00051 public:
00052
00053 friend class TransCopyPairLinker;
00054
00055 public:
00056
00057 EWPDS();
00058 EWPDS( ref_ptr<Wrapper> wrapper );
00059 EWPDS( const EWPDS& e );
00060
00061 virtual ~EWPDS();
00062
00063
00064
00065
00066
00067
00068
00069
00070 virtual bool add_rule(
00071 Key from_state,
00072 Key from_stack,
00073 Key to_state,
00074 sem_elem_t se );
00075
00076
00077
00078
00079
00080
00081
00082
00083 virtual bool add_rule(
00084 Key from_state,
00085 Key from_stack,
00086 Key to_state,
00087 Key to_stack1,
00088 sem_elem_t se );
00089
00090
00091
00092
00093
00094
00095
00096
00097 virtual bool add_rule(
00098 wali::Key from_state,
00099 wali::Key from_stack,
00100 wali::Key to_state,
00101 wali::Key to_stack1,
00102 wali::Key to_stack2,
00103 sem_elem_t se);
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 virtual bool add_rule(
00114 wali::Key from_state,
00115 wali::Key from_stack,
00116 wali::Key to_state,
00117 wali::Key to_stack1,
00118 wali::Key to_stack2,
00119 sem_elem_t se,
00120 merge_fn_t mf);
00121
00122
00123
00124
00125
00126
00127
00128
00129 virtual bool replace_rule(
00130 wali::Key from_state,
00131 wali::Key from_stack,
00132 wali::Key to_state,
00133 wali::Key to_stack1,
00134 wali::Key to_stack2,
00135 sem_elem_t se);
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 virtual bool replace_rule(
00146 wali::Key from_state,
00147 wali::Key from_stack,
00148 wali::Key to_state,
00149 wali::Key to_stack1,
00150 wali::Key to_stack2,
00151 sem_elem_t se,
00152 merge_fn_t mf);
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 virtual void prestar( WFA const & input, WFA& output );
00168
00169 virtual wfa::WFA prestar( wfa::WFA const & input ) {
00170 return this->WPDS::prestar(input);
00171 }
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 virtual std::ostream & print( std::ostream & o ) const;
00183
00184
00185
00186
00187
00188
00189
00190
00191 virtual std::ostream & marshall( std::ostream & o ) const;
00192
00193
00194
00195
00196
00197 virtual void operator()( wfa::ITrans const * t );
00198
00199 rule_t lookup_rule(wali::Key to_state, wali::Key to_stack1, wali::Key to_stack2) const;
00200
00201
00202
00203
00204
00205
00206
00207 virtual bool replace_rule(
00208 Key from_state,
00209 Key from_stack,
00210 Key to_state,
00211 sem_elem_t se )
00212 {
00213 return this->WPDS::replace_rule(from_state, from_stack,
00214 to_state, se);
00215 }
00216
00217 virtual bool replace_rule(
00218 Key from_state,
00219 Key from_stack,
00220 Key to_state,
00221 Key to_stack1,
00222 sem_elem_t se )
00223 {
00224 return this->WPDS::replace_rule(from_state, from_stack,
00225 to_state, to_stack1, se);
00226 }
00227
00228
00229
00230 protected:
00231
00232
00233
00234
00235
00236 virtual bool add_rule(
00237 wali::Key from_state,
00238 wali::Key from_stack,
00239 wali::Key to_state,
00240 wali::Key to_stack1,
00241 wali::Key to_stack2,
00242 sem_elem_t se,
00243 merge_fn_t mf,
00244 bool replace_weight);
00245
00246
00247
00248
00249
00250 virtual void prestar_handle_call(
00251 wfa::ITrans *t1,
00252 wfa::ITrans *t2,
00253 rule_t &r,
00254 sem_elem_t delta
00255 );
00256
00257
00258
00259
00260 virtual void prestar_handle_trans(
00261 wfa::ITrans * t,
00262 WFA & ca ,
00263 rule_t & r,
00264 sem_elem_t delta );
00265
00266
00267
00268
00269 virtual void poststar_handle_trans(
00270 wfa::ITrans * t ,
00271 WFA & ca ,
00272 rule_t & r,
00273 sem_elem_t delta
00274 );
00275
00276 virtual void update_etrans(
00277 Key from
00278 , Key stack
00279 , Key to
00280 , sem_elem_t se
00281 , Config * cfg
00282 );
00283
00284 virtual void update(
00285 Key from
00286 , Key stack
00287 , Key to
00288 , sem_elem_t se
00289 , Config * cfg
00290 );
00291
00292 virtual wfa::ITrans* update_prime(
00293 Key from,
00294 wfa::ITrans* call,
00295 rule_t r,
00296 sem_elem_t delta,
00297 sem_elem_t wWithRule
00298 );
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312 virtual bool add_rule(
00313 Key from_state,
00314 Key from_stack,
00315 Key to_state,
00316 Key to_stack1,
00317 Key to_stack2,
00318 sem_elem_t se,
00319 bool replace_weight,
00320 rule_t& r )
00321 {
00322 return this->WPDS::add_rule(from_state, from_stack, to_state, to_stack1, to_stack2,
00323 se, replace_weight, r);
00324 }
00325
00326 virtual bool add_rule(
00327 Key from_state,
00328 Key from_stack,
00329 Key to_state,
00330 Key to_stack1,
00331 Key to_stack2,
00332 sem_elem_t se,
00333 rule_t& r )
00334 {
00335 return this->WPDS::add_rule(from_state, from_stack, to_state,
00336 to_stack1, to_stack2, se, r);
00337 }
00338
00339
00340 private:
00341 merge_rule_hash_t merge_rule_hash;
00342 protected:
00343 bool addEtrans;
00344
00345 };
00346
00347 }
00348
00349 }
00350
00351 }
00352
00353 #endif // wali_wpds_ewpds_EWPDS_GUARD
00354