Changeset f88521 in git


Ignore:
Timestamp:
Aug 30, 2012, 4:13:11 PM (12 years ago)
Author:
Alexander Dreyer <alexander.dreyer@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '79dfb9a6d258bfeb991428bdb25b8f55e9e809b2')
Children:
a5e907a16ec70a7bfd4c506efb3f1a7b48693387
Parents:
2fbb4e014a0f3dda591b3df6f317ef27d9856de7
git-author:
Alexander Dreyer <alexander.dreyer@itwm.fraunhofer.de>2012-08-30 16:13:11+02:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-09-05 15:52:16+02:00
Message:
fix: allow shared(newstr.sh)=value; assignment for non-shared rhs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/countedref.cc

    r2fbb4e0 rf88521  
    9494
    9595  //{ @name Reference count interface
    96   count_type count() const { return (*this? m_ptr->ref: 1); }
     96  count_type count() const { return (*this? m_ptr->ref: 0); }
    9797  void reclaim() { if (*this) ++m_ptr->ref; }
    9898  void release() {
     
    284284    return *this;
    285285  }
    286 
     286  int Typ() const {return m_data->Typ(); }
    287287   leftv access() { return m_data; }
    288288};
     
    381381
    382382  CountedRefPtr<ring, true> Ring() { return m_ring; }
    383 
     383  int Typ() const {return m_data->Typ(); }
    384384private:
     385
    385386  /// Raise error message and return @c TRUE
    386387  BOOLEAN complain(const char* text) const  {
     
    415416
    416417
     418
    417419inline void CountedRefPtr_kill(CountedRefData* data) { delete data; }
    418420
     
    430432  static BOOLEAN is_ref(leftv arg) {
    431433    int typ = arg->Typ();
    432     return ((typ > MAX_TOK) &&
    433            (getBlackboxStuff(typ)->blackbox_Init == countedref_Init));
     434    return ((typ==CountedRefEnv::ref_id())  ||(typ==CountedRefEnv::sh_id()) ||
     435            (typ==CountedRefEnv::idx_id()) );
     436    //    return ((typ > MAX_TOK) &&
     437    //            (getBlackboxStuff(typ)->blackbox_Init == countedref_Init));
    434438  }
    435439
     
    465469
    466470  /// Construct reference data object from
    467   BOOLEAN outcast(leftv result) {
    468     if (result->rtyp == IDHDL)
    469       IDDATA((idhdl)result->data) = (char *)outcast();
     471  BOOLEAN outcast(leftv res) {
     472    if (res->rtyp == IDHDL)
     473      IDDATA((idhdl)res->data) = (char *)outcast();
    470474    else
    471       result->data = (void *)outcast();
     475      res->data = (void *)outcast();
    472476    return FALSE;
    473477  }
     
    518522  BOOLEAN name(leftv res) { return construct(res, operator*()->Name()); }
    519523
     524  /// Check whther argument is not defined yet
     525  BOOLEAN undefined(leftv res) { return construct(res, operator*()->Typ() == NONE); }
     526
    520527  /// Recover the actual object from raw Singular data
    521528  static self cast(void* data) {
     
    536543    return (arg->next != NULL) && resolve(arg->next);
    537544  }
    538 
     545  int Typ() const {return m_data->Typ(); }
    539546protected:
    540547  /// Construct integer value
     
    612619    return blackboxDefaultOp1(op, res, head);
    613620
     621
    614622  if (countedref_CheckInit(res, head)) return TRUE;
    615 
    616   if(op == head->Typ()) {
    617     res->rtyp = op;
     623 
     624  if ((op == DEF_CMD) || (op == head->Typ())) {
     625    res->rtyp = head->Typ();
    618626    return iiAssign(res, head);
    619627  }
    620628
    621   if(op == DEF_CMD) {
    622     res->rtyp = DEF_CMD;
     629  if(op == LINK_CMD) {
     630    res->rtyp =  DEF_CMD;
    623631    return CountedRef::cast(head).dereference(head) || iiAssign(res, head);
    624632  }
     
    748756};
    749757
    750 
     758void* countedref_InitShared(blackbox*)
     759{
     760  LeftvDeep empty;
     761  return CountedRefShared(LeftvShallow(empty).operator->()).outcast();
     762}
    751763
    752764/// blackbox support - binary operations
     
    793805      if (strcmp(name, "name") == 0) return obj.name(res);
    794806      if (strncmp(name, "type", 4) == 0) return obj.type(res);
     807      if (strncmp(name, "undef", 5) == 0) return obj.undefined(res);
    795808    }
    796809    return TRUE;
    797810  }
     811  if (op == LIST_CMD){
     812    res->rtyp=op;
     813    return jjLIST_PL(res, args);
     814  }
     815
    798816  return CountedRef::cast(args).dereference(args) || iiExprArithM(res, args, op);
    799817}
     818
    800819/// blackbox support - assign element
    801820BOOLEAN countedref_AssignShared(leftv result, leftv arg)
    802821{
    803822  /// Case: replace assignment behind reference
    804   if ((result->Data()) != NULL) {
     823  if ((result->Data() != NULL)  && (CountedRefShared::cast(result).Typ() !=0 )) {
    805824    if (CountedRefShared::resolve(arg)) return TRUE;
    806825    CountedRefShared::cast(result) = arg;
     
    809828 
    810829  /// Case: new reference to already shared data
    811   if (result->Typ() == arg->Typ())
     830  if (result->Typ() == arg->Typ()) {
     831    if (result->Data() != NULL)
     832      CountedRefShared::cast(result).destruct();
    812833    return CountedRefShared::cast(arg).outcast(result);
    813 
     834  } 
     835  if(CountedRefShared::cast(result).Typ() == 0) {
     836    CountedRefShared::cast(result) = arg;
     837    return FALSE;
     838  }
     839   
    814840  /// Case: new shared data
    815841  return CountedRefShared(arg).outcast(result);
     
    845871  bbxshared->blackbox_destroy = countedref_destroyShared;
    846872  bbxshared->blackbox_Op2     = countedref_Op2Shared;
     873  bbxshared->blackbox_Init    = countedref_InitShared;
    847874  bbxshared->data             = omAlloc0(newstruct_desc_size());
    848875  CountedRefEnv::sh_id()=setBlackboxStuff(bbxshared, "shared");
     876
    849877
    850878  blackbox *bbxindexed =
Note: See TracChangeset for help on using the changeset viewer.