Changeset 4427439 in tol


Ignore:
Timestamp:
Jan 17, 2011, 8:52:00 AM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
11e604b
Parents:
6a96b5f
Message:

Fixes #881
BUserFunction creates its own BUserFunCode

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

Location:
tol/btol
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/bgrammar/spfuninst.cpp

    r6a96b5f r4427439  
    10931093{
    10941094  static BText _name_ = "Copy";
    1095     BSyntaxObject* result = NIL;
    1096     BInt nb = BSpecialFunction::NumBranches(tre);
    1097     if(BSpecialFunction::TestNumArg(_name_, 1, nb, 1))
    1098     {
    1099         BSyntaxObject* toCopy = gra->EvaluateTree(Branch(tre,1));
    1100         if(toCopy)
    1101         {
     1095  BSyntaxObject* result = NIL;
     1096  BInt nb = BSpecialFunction::NumBranches(tre);
     1097  if(BSpecialFunction::TestNumArg(_name_, 1, nb, 1))
     1098  {
     1099    BGrammar::IncLevel();
     1100    int stackPos = BGrammar::StackSize();
     1101    BSyntaxObject* toCopy = gra->EvaluateTree(Branch(tre,1));
     1102          if(toCopy)
     1103          {
    11021104            result = toCopy->CopyContens();
    1103             if(result!=toCopy)
    1104             {
    1105                 SAFE_DESTROY(toCopy,result);
    1106             }
    1107         }
    1108     }
    1109     result=BSpecialFunction::TestResult(_name_,result,tre,NIL,BTRUE);
    1110     return(result);
     1105          }
     1106    BGrammar::DestroyStackUntil(stackPos, result);   
     1107    BGrammar::DecLevel();
     1108  }
     1109  result=BSpecialFunction::TestResult(_name_,result,tre,NIL,BTRUE);
     1110  return(result);
    11111111}
    11121112
  • tol/btol/code_type/codgra.cpp

    r6a96b5f r4427439  
    4747{
    4848  Contens();
     49}
     50
     51//--------------------------------------------------------------------
     52  BUserFunCode::BUserFunCode()
     53//--------------------------------------------------------------------
     54: BContensCode()
     55{
    4956}
    5057
  • tol/btol/code_type/tol_bcodgra.h

    r6a96b5f r4427439  
    4747{
    4848public:
     49  BUserFunCode();
    4950  BUserFunCode(const BText& name, const BCode& aCode, const BText& desc);
    5051  BUserFunCode(const BText& name, BStandardOperator* opr, const BText& desc);
  • tol/btol/set_type/setgra.cpp

    r6a96b5f r4427439  
    22652265BSyntaxObject* CopyCode(BSyntaxObject* obj)
    22662266{
    2267   BCode cod;
    2268   cod.Replicate(Code(obj));
    2269   return(new BContensCode("",cod,""));
     2267  BCode& cod = Code(obj);
     2268  BUserFunction* opr = (BUserFunction*)cod.Operator();
     2269  if(opr)
     2270  {
     2271    BUserFunction* usf = new BUserFunction("",opr->Grammar());
     2272    BUserFunCode* result = usf->GetCode();
     2273    usf->PutName(opr->Name());
     2274    usf->PutDescription(opr->Description());
     2275    usf->SetExpression(opr->Declaration(), opr->Definition());
     2276    result->PutName(opr->Name());
     2277    result->PutDescription(opr->Description());
     2278    return(result);
     2279  }
     2280  else
     2281  {
     2282    Error(BText("Cannot copy Code ")<<obj->Identify());
     2283    return(NULL);
     2284  }
    22702285};
    22712286/*
Note: See TracChangeset for help on using the changeset viewer.