Changeset 180efc0 in git


Ignore:
Timestamp:
Aug 21, 2012, 3:57:12 PM (10 years ago)
Author:
Alexander Dreyer <alexander.dreyer@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'ad2543eab51733612ba7d118afc77edca719600e')
Children:
babfe48c6b91ec9f26e998cdcf95c8df192b1c05
Parents:
d2a236583625dd880d06a25cf10d02aefee3ba89
git-author:
Alexander Dreyer <alexander.dreyer@itwm.fraunhofer.de>2012-08-21 15:57:12+02:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-09-05 15:52:16+02:00
Message:
new: some comments debugging features for references and shared
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/countedref.cc

    rd2a236 r180efc0  
    340340  ~CountedRef() { destruct(); }
    341341
     342  /// Replaces argument by a shallow copy of the references data
    342343  BOOLEAN dereference(leftv arg) {
    343344    assume(is_ref(arg));
     
    345346  }
    346347
    347 
    348   /// Get the actual object
    349   /// @note It may change leftv. It is common practice, so we are fine with it.
    350 
     348  /// Get number of references pointing here, too
     349  BOOLEAN count(leftv res) { return construct(res, m_data->count() - 1); }
     350
     351  /// Get internal indentifier
     352  BOOLEAN hash(leftv res) { return construct(res, (long)m_data); }
     353
     354  /// Check for likewise identifiers
     355  BOOLEAN likewise(leftv res, leftv arg) {
     356    return resolve(arg) || construct(res, operator*()->data == arg->data);
     357  }
     358
     359  /// Check for identical reference objects
     360  BOOLEAN same(leftv res, leftv arg) {
     361    return construct(res, m_data == arg->Data());
     362  }
     363
     364  /// Get type of references data
     365  BOOLEAN type(leftv res) {
     366    return construct(res, Tok2Cmdname(operator*()->Typ()));
     367  };
     368
     369  /// Get (possibly) internal identifier name
     370  BOOLEAN name(leftv res) { return construct(res, operator*()->Name()); }
     371
     372  /// Recover the actual object from Singular interpreter object
    351373  static self cast(void* data) {
    352374    assume(data != NULL);
     
    354376  }
    355377
     378  /// Recover the actual object from raw Singular data
    356379  static self cast(leftv arg) {
    357380    assume((arg != NULL) && is_ref(arg));
     
    360383
    361384  /// If necessary dereference.
    362   /// @note The may change leftv. It is common practice, so we are fine with it.
    363385  static BOOLEAN resolve(leftv arg) {
    364386    assume(arg != NULL);
     
    367389  }
    368390
    369   //private:
    370391protected:
     392
     393  /// Construct integer value
     394  static BOOLEAN construct(leftv res, long data) {
     395    res->data = (void*) data;
     396    res->rtyp = INT_CMD;
     397    return FALSE;
     398  }
     399
     400  /// Construct string
     401  static BOOLEAN construct(leftv res, const char* data) {
     402    res->data = (void*)omStrDup(data);
     403    res->rtyp = STRING_CMD;
     404    return FALSE;
     405  }
    371406  /// Store pointer to actual data
    372407  data_type* m_data;
     
    447482{
    448483  if (args->Data() == NULL) return FALSE;
     484
     485  if(op == SYSTEM_CMD) {
     486    if (args->next) {
     487      leftv next = args->next;
     488      args->next = NULL;
     489      CountedRef obj = CountedRef::cast(args);
     490      char* name = (next->Typ() == STRING_CMD?
     491                    (char*) next->Data(): (char*)next->Name());
     492      if (strcmp(name, "count") == 0) return obj.count(res);
     493      if (strcmp(name, "hash") == 0) return obj.hash(res);
     494      if (strcmp(name, "same") == 0)
     495        return (next->next == NULL) ||  obj.same(res, next->next);
     496      if ((strcmp(name, "like") == 0) || (strcmp(name, "likewise") == 0))
     497        return (next->next == NULL) ||  obj.likewise(res, next->next);
     498      if (strcmp(name, "name") == 0) return obj.name(res);
     499      if ((strcmp(name, "type") == 0) || (strcmp(name, "typeof") == 0))
     500        return obj.type(res);
     501      return TRUE;
     502    }
     503    return TRUE;
     504  }
    449505  return CountedRef::cast(args).dereference(args) || iiExprArithM(res, args, op);
    450506}
     
    500556    arg->data = handle;
    501557    arg->rtyp = IDHDL;
     558    arg->name = omStrDup(IDID(handle));
    502559    return arg;
    503560  }
Note: See TracChangeset for help on using the changeset viewer.