Пример #1
0
 virtual void VisitExpr( const  SymbolicExpr& v) 
  { 
     SymbolicVal in1, fr1;
     bool _hasfrac = hasfrac;
     SymbolicExpr::OpdIterator opds = v.GetOpdIterator();
     for ( ; !opds.ReachEnd(); ++opds) {
        if (operator()(v.Term2Val(*opds), inp, frp)) {
              _hasfrac = true;
                break;  
        }
     }
     if (opds.ReachEnd()) {
        if (inp != 0) *inp = v;
     }
     else {
         if (inp == 0 && frp == 0)
             return;
         SymbolicExpr* inv = (inp == 0)? 0 : v.DistributeExpr(SYMOP_NIL, SymbolicVal());
         SymbolicExpr* frv = (frp == 0)? 0 : v.DistributeExpr(SYMOP_NIL, SymbolicVal());
         SymbolicExpr::OpdIterator opd1 = v.GetOpdIterator();
         for ( ; opd1 != opds ; ++opd1) {
             if (inv != 0)
                 inv->AddOpd(*opd1);
             if (frv != 0)
                 frv->AddOpd(*opd1);
           }
          if (inv != 0)
              inv->ApplyOpd(*inp);
          if (frv != 0)
              frv->ApplyOpd(*frp);
          for (++opd1; !opd1.ReachEnd(); ++opd1) {
             SymbolicVal cur = v.Term2Val(*opd1);
             if (operator()(cur, inp, frp)) {
                if (inv != 0)
                    inv->ApplyOpd(*inp);
                if (frv != 0)
                    frv->ApplyOpd(*frp);
             }
             else {
                if (inv != 0)
                    inv->AddOpd(*opd1);
                if (frv != 0)
                    frv->AddOpd(*opd1);
             }
          }   
          if (inp != 0) 
               *inp = GetExprVal(inv);
          if (frp != 0)
               *frp = GetExprVal(frv);
    }
    hasfrac = _hasfrac;
  }
Пример #2
0
 void VisitExpr( const SymbolicExpr &v)
 {
     if (target.GetValType() == VAL_EXPR && cur == target)
         result = true;
     else {
         for (SymbolicExpr::OpdIterator iter = v.GetOpdIterator();
                 !iter.ReachEnd(); iter.Advance()) {
             SymbolicVal tmp = v.Term2Val(iter.Current());
             cur = tmp;
             cur.Visit(this);
             if (result)
                 break;
         }
     }
 }