Changeset 240ad0a in tol


Ignore:
Timestamp:
Mar 4, 2011, 5:14:20 PM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
4ea7b59
Parents:
c92025e
Message:

Fixes #1113

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@3265 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/set_type/setgra.cpp

    rc92025e r240ad0a  
    131131  BSyntaxObject* Evaluator(BList* arg) const
    132132  {
     133  //InitTotalTime("BSetAppend::Evaluator");
    133134    if(CheckNonDeclarativeAction("Append")) { return(NULL); }
    134135    BList* lst = arg;
    … …  
    143144    uSet1->Contens().Append(uSet2->Contens(),incrementalIndexByName);
    144145    SAFE_DESTROY(arg, uSet1);
     146  //SumPartialTime;
    145147    return(uSet1);
    146148  }
    … …  
    157159  : BExternalOperator
    158160    (
    159       "Remove", GraSet(), "Set Real Real", NIL, 3, 3,
    160       "(Set set, Real n, Real deleteOld)",
     161      "Remove", GraSet(), "Set Real Real", NIL, 2, 3,
     162      "(Set set, Real n [, Real deleteOld=True])",
    161163                  I2("Removes the n-th element of a set and tries to delete it "
    162164         "from memory if deleteOld is true. Returns the own set "
    … …  
    182184    BUserSet* uSet = USet(lst->Car()); lst = lst->Cdr();
    183185    BUserDat* uDat = UDat(lst->Car()); lst = lst->Cdr();
    184     BUserDat* uDel = UDat(lst->Car());
     186    bool do_deletion = true;
     187    if(lst)
     188    {
     189      Deprecated("Optional argument deleteOld of function Set Remove "
     190                 "will be eliminated taken true value");
     191      BUserDat* uDel = UDat(lst->Car());
     192      do_deletion = uDel->Contens().Value()!=0.0;
     193    }
    185194    uSet->Contens().Remove(
    186195     (int)(uDat->Contens().Value())-1,
    187      uDel->Contens().Value()!=0.0);
     196     do_deletion);
    188197    SAFE_DESTROY(arg, uSet);
    189198    return(uSet);
    … …  
    201210  : BExternalOperator
    202211    (
    203       "Replace", GraSet(), "Set Real Anything Real", NIL, 4, 4,
    204       "(Set set, Real n, Anything new, Real deleteOld)",
     212      "Replace", GraSet(), "Set Real Anything Real", NIL, 3, 4,
     213      "(Set set, Real n, Anything new [, Real deleteOld])",
    205214                  I2("Replaces the n-th element of a set by a another new one "
    206215         "and tries to delete the old one from memory if deleteOld "
    … …  
    228237    BUserDat* uDat = UDat(lst->Car()); lst = lst->Cdr();
    229238    BSyntaxObject* uNew = (BSyntaxObject*)(lst->Car()); lst = lst->Cdr();
    230     BUserDat* uDel = UDat(lst->Car());
     239    bool do_deletion = true;
     240    if(lst)
     241    {
     242      Deprecated("Optional argument deleteOld of function Set Replace "
     243                 "will be eliminated taken true value");
     244      BUserDat* uDel = UDat(lst->Car());
     245      do_deletion = uDel->Contens().Value()!=0.0;
     246    }
    231247    uSet->Contens().Replace(
    232248      (int)(uDat->Contens().Value())-1,
    233249      uNew,
    234       uDel->Contens().Value()!=0.0);
     250      do_deletion);
    235251    SAFE_DESTROY(arg, uSet);
    236252    return(uSet);
    … …  
    18021818//--------------------------------------------------------------------
    18031819{
     1820//InitTotalTime("BSetFor::CalcContens");
    18041821  BStandardOperator* opr  = (BStandardOperator*)GetOperator(UCode(Arg(3)));
    18051822  int from  = (int)Real(Arg(1));
    … …  
    18091826  int n;
    18101827
    1811   if(from>until) { return; }
    1812   contens_.PrepareStore(until-from+1);
    1813   if(!opr || (opr->MaxArg()!=1) || (opr->GrammarForArg(1)!=GraReal()))
    1814   {
    1815     Error(I2("Wrong argument function in For function calling."
    1816        "It must have just one argument of Real type.",
    1817        "Función argumento errónea en llamada a la función For."
    1818        "Ésta debe tener exactamente un argumento de tipo Real."));
    1819     return;
    1820   }
    1821   for(n = from; n<=until; n++)
    1822   {
    1823     arg = new BContensDat(n);
    1824     BCore::MemAssignInfo mai(arg);
    1825     if(objCode = opr->Evaluator(NCons(arg)))
    1826     {
    1827       contens_.AddElement(objCode);
     1828  if(from<=until)
     1829  {
     1830    contens_.PrepareStore(until-from+1);
     1831    if(!opr || (opr->MaxArg()!=1) || (opr->GrammarForArg(1)!=GraReal()))
     1832    {
     1833      Error(I2("Wrong argument function in For function calling."
     1834         "It must have just one argument of Real type.",
     1835         "Función argumento errónea en llamada a la función For."
     1836         "Ésta debe tener exactamente un argumento de tipo Real."));
    18281837    }
    18291838    else
    18301839    {
    1831       mai.SafeDestroy();
    1832       char es[64];
    1833       char en[64];
    1834       sprintf(en, "<For> function failed at iteration %d.", n);
    1835       sprintf(es, "Fallo en función <For> en iteración %d.", n);
    1836       Error(I2(en ,es));
    1837       return;
    1838     }
    1839   }
     1840      for(n = from; n<=until; n++)
     1841      {
     1842        arg = new BContensDat(n);
     1843        BCore::MemAssignInfo mai(arg);
     1844        if(objCode = opr->Evaluator(NCons(arg)))
     1845        {
     1846          contens_.AddElement(objCode);
     1847        }
     1848        else
     1849        {
     1850          mai.SafeDestroy();
     1851          char es[64];
     1852          char en[64];
     1853          sprintf(en, "<For> function failed at iteration %d.", n);
     1854          sprintf(es, "Fallo en función <For> en iteración %d.", n);
     1855          Error(I2(en ,es));
     1856        }
     1857      }
     1858    }
     1859  }
     1860//SumPartialTime;
    18401861}
    18411862
    … …  
    21542175//--------------------------------------------------------------------
    21552176{
    2156     BMat          mat    = Mat (Arg(1));
    2157     BUserTimeSet* dating = Tms (Arg(2));        if(!dating) { return; }
    2158     BDate         first  = Date(Arg(3));
    2159     BDate         last   = dating->Next(first,mat.Columns()-1);
    2160     BList*        result = NIL;
    2161     BList*        aux    = NIL;
    2162     BInt          i;
    2163     for(i = 0; i < mat.Rows(); i++)
    2164     {
    2165         BTsrPrimary* serie = new BTsrPrimary("","",dating,first,last,
    2166                                              mat.SubRow(i).Data());
    2167         serie->PutName(BText("S")+(i+1));
    2168         LstFastAppend(result, aux, serie);
    2169     }
    2170     contens_.RobStruct(result,NIL,BSet::Table);
     2177  BMat& mat = Mat (Arg(1));
     2178  BUserTimeSet* dating = Tms (Arg(2)); 
     2179  if(!dating) { return; }
     2180  BDate& first = Date(Arg(3));
     2181  BDate last = dating->Next(first,mat.Columns()-1);
     2182  BList*          result = NIL;
     2183  BList*          aux    = NIL;
     2184  BInt    i;
     2185  for(i=0; i<mat.Rows(); i++)
     2186  {
     2187    BTsrPrimary* serie = new BTsrPrimary(
     2188     "","",dating,first,last,mat.SubRow(i).Data());
     2189    serie->PutName(BText("S")+(i+1));
     2190    LstFastAppend(result, aux, serie);
     2191  }
     2192  contens_.RobStruct(result,NIL,BSet::Table);
    21712193}
    21722194
Note: See TracChangeset for help on using the changeset viewer.