Changeset 180efc0 in git for Singular/countedref.cc
- Timestamp:
- Aug 21, 2012, 3:57:12 PM (12 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/countedref.cc
rd2a236 r180efc0 340 340 ~CountedRef() { destruct(); } 341 341 342 /// Replaces argument by a shallow copy of the references data 342 343 BOOLEAN dereference(leftv arg) { 343 344 assume(is_ref(arg)); … … 345 346 } 346 347 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 351 373 static self cast(void* data) { 352 374 assume(data != NULL); … … 354 376 } 355 377 378 /// Recover the actual object from raw Singular data 356 379 static self cast(leftv arg) { 357 380 assume((arg != NULL) && is_ref(arg)); … … 360 383 361 384 /// If necessary dereference. 362 /// @note The may change leftv. It is common practice, so we are fine with it.363 385 static BOOLEAN resolve(leftv arg) { 364 386 assume(arg != NULL); … … 367 389 } 368 390 369 //private:370 391 protected: 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 } 371 406 /// Store pointer to actual data 372 407 data_type* m_data; … … 447 482 { 448 483 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 } 449 505 return CountedRef::cast(args).dereference(args) || iiExprArithM(res, args, op); 450 506 } … … 500 556 arg->data = handle; 501 557 arg->rtyp = IDHDL; 558 arg->name = omStrDup(IDID(handle)); 502 559 return arg; 503 560 }
Note: See TracChangeset
for help on using the changeset viewer.