My Project
Loading...
Searching...
No Matches
LeftvDeep Class Reference

This class wraps leftv by taking into account memory allocation, destruction as well as deeply copying of a given leftv, i.e. More...

#include <countedref.h>

Data Structures

struct  copy_tag
 Construct even deeper copy: Skip identifier (if any) and take care of the data on our own. More...
 

Private Types

typedef LeftvDeep self
 

Access via shallow copy to avoid invalidating the stored handle

leftv m_data
 Store the actual data.
 
 operator LeftvShallow ()
 Store the actual data.
 
LeftvShallow operator* ()
 Store the actual data.
 
bool like (const self &rhs) const
 Determine whether we point to the same data.
 
selfoperator= (leftv rhs)
 Reassign a new deep copy by occupieing another leftv.
 
BOOLEAN brokenid (idhdl context) const
 Check a given context for our identifier.
 
BOOLEAN put (leftv result)
 Put a shallow copy to given leftv.
 
BOOLEAN retrieve (leftv res)
 Get additional data (e.g. subexpression data) from likewise instances.
 
BOOLEAN isid () const
 Check for being an identifier.
 
BOOLEAN ringed ()
 Test whether we reference to ring-dependent data.
 
BOOLEAN unassigned () const
 Check whether (all-zero) initialized data was never assigned.
 
leftv idify (idhdl *root)
 Wrap data by identifier, if not done yet.
 
void clearid (idhdl *root)
 Erase identifier handles by *this.
 

Do not permit copying (avoid inconsistence)

selfoperator= (const self &)
 Allocate all-zero object by default.
 
 LeftvDeep (const self &)
 Allocate all-zero object by default.
 
 LeftvDeep ()
 Allocate all-zero object by default.
 
 LeftvDeep (leftv data)
 Store a deep copy of the data @ note Occupies the provided leftv and invalidates the latter.
 
 LeftvDeep (leftv data, copy_tag)
 Allocate all-zero object by default.
 
 ~LeftvDeep ()
 Really clear data.
 

Additional Inherited Members

- Static Public Member Functions inherited from LeftvHelper
static leftv idify (leftv head, idhdl *root)
 
static idhdl newid (leftv head, idhdl *root)
 
static void clearid (idhdl handle, idhdl *root)
 
template<class Type>
static Type * cpy (Type *result, Type *data)
 
template<class Type>
static Type * cpy (Type *data)
 
template<class Type>
static Type * recursivecpy (Type *data)
 
template<class Type>
static Type * shallowcpy (Type *result, Type *data)
 
template<class Type>
static Type * shallowcpy (Type *data)
 
template<class Type>
static void recursivekill (Type *current)
 
static leftv allocate ()
 

Detailed Description

This class wraps leftv by taking into account memory allocation, destruction as well as deeply copying of a given leftv, i.e.

we also take over ownership of the leftv data.

We have two variants:

Note
It invalidats leftv on input.

Definition at line 334 of file countedref.h.


Data Structure Documentation

◆ LeftvDeep::copy_tag

struct LeftvDeep::copy_tag

Construct even deeper copy: Skip identifier (if any) and take care of the data on our own.

Definition at line 357 of file countedref.h.

Member Typedef Documentation

◆ self

typedef LeftvDeep LeftvDeep::self
private

Definition at line 336 of file countedref.h.

Constructor & Destructor Documentation

◆ LeftvDeep() [1/4]

LeftvDeep::LeftvDeep ( const self & )
private

Allocate all-zero object by default.

◆ LeftvDeep() [2/4]

LeftvDeep::LeftvDeep ( )
inline

Allocate all-zero object by default.

Definition at line 346 of file countedref.h.

346: m_data(allocate()) {}
leftv m_data
Store the actual data.
Definition countedref.h:450
static leftv allocate()
Definition countedref.h:273

◆ LeftvDeep() [3/4]

LeftvDeep::LeftvDeep ( leftv data)
inline

Store a deep copy of the data @ note Occupies the provided leftv and invalidates the latter.

Definition at line 350 of file countedref.h.

350 : m_data(cpy(data)) {
351 data->e = NULL; // occupy subexpression
352 if(!isid()) m_data->data=data->CopyD();
353 }
BOOLEAN isid() const
Check for being an identifier.
Definition countedref.h:426
static Type * cpy(Type *result, Type *data)
Definition countedref.h:244
void * CopyD(int t)
Definition subexpr.cc:714
Subexpr e
Definition subexpr.h:105
#define NULL
Definition omList.c:12

◆ LeftvDeep() [4/4]

LeftvDeep::LeftvDeep ( leftv data,
copy_tag  )
inline

Allocate all-zero object by default.

Definition at line 358 of file countedref.h.

358: m_data(allocate()) { m_data->Copy(data); }

◆ ~LeftvDeep()

LeftvDeep::~LeftvDeep ( )
inline

Really clear data.

Definition at line 361 of file countedref.h.

361{ m_data->CleanUp(); }

Member Function Documentation

◆ brokenid()

BOOLEAN LeftvDeep::brokenid ( idhdl context) const
inline

Check a given context for our identifier.

Definition at line 389 of file countedref.h.

389 {
390 assume(isid());
391 return (context == NULL) ||
392 ((context != (idhdl) m_data->data) && brokenid(IDNEXT(context)));
393 }
BOOLEAN brokenid(idhdl context) const
Check a given context for our identifier.
Definition countedref.h:389
#define IDNEXT(a)
Definition ipid.h:118
#define assume(x)
Definition mod2.h:389
idrec * idhdl
Definition ring.h:22

◆ clearid()

void LeftvDeep::clearid ( idhdl * root)
inline

Erase identifier handles by *this.

Note
Assumes that we reference an identifier and that we own the latter. This is useful to clear the result of a subsequent call of idify.

Definition at line 442 of file countedref.h.

442 {
443 assume(isid());
444 if (--((idhdl)m_data->data)->ref <= 0) // clear only if we own
445 LeftvHelper::clearid((idhdl)m_data->data, root);
446 }
static void clearid(idhdl handle, idhdl *root)
Definition countedref.h:237

◆ idify()

leftv LeftvDeep::idify ( idhdl * root)
inline

Wrap data by identifier, if not done yet.

Definition at line 433 of file countedref.h.

433 {
435 ++(((idhdl)res->data)->ref);
436 return res;
437 }
static leftv idify(leftv head, idhdl *root)
Definition countedref.h:215
CanonicalForm res
Definition facAbsFact.cc:60
sleftv * leftv
Definition structs.h:53

◆ isid()

BOOLEAN LeftvDeep::isid ( ) const
inline

Check for being an identifier.

Definition at line 426 of file countedref.h.

426{ return m_data->rtyp==IDHDL;}
#define IDHDL
Definition tok.h:31

◆ like()

bool LeftvDeep::like ( const self & rhs) const
inline

Determine whether we point to the same data.

Definition at line 370 of file countedref.h.

370{ return m_data->data == rhs.m_data->data; }

◆ operator LeftvShallow()

LeftvDeep::operator LeftvShallow ( )
inline

Store the actual data.

Definition at line 365 of file countedref.h.

365{ return m_data; }

◆ operator*()

LeftvShallow LeftvDeep::operator* ( )
inline

Store the actual data.

Definition at line 366 of file countedref.h.

366{return *this; }

◆ operator=() [1/2]

self & LeftvDeep::operator= ( const self & )
private

Allocate all-zero object by default.

◆ operator=() [2/2]

self & LeftvDeep::operator= ( leftv rhs)
inline

Reassign a new deep copy by occupieing another leftv.

Note
clears *this in the first

Definition at line 374 of file countedref.h.

374 {
375 if(isid()) {
376 m_data->e = rhs->e;
377 rhs->e = NULL;
378 IDTYP((idhdl)m_data->data) = rhs->Typ();
379 IDDATA((idhdl)m_data->data) = (char*) rhs->CopyD();
380 }
381 else {
382 m_data->CleanUp();
383 m_data->Copy(rhs);
384 }
385 return *this;
386 }
int Typ()
Definition subexpr.cc:1048
#define IDDATA(a)
Definition ipid.h:126
#define IDTYP(a)
Definition ipid.h:119

◆ put()

BOOLEAN LeftvDeep::put ( leftv result)
inline

Put a shallow copy to given leftv.

Note
attrib should read the attributes of the identifier

Definition at line 396 of file countedref.h.

396 {
398 result->next = NULL;
399 result->CleanUp();
400
402 result->next = next;
403
404 /// @note @c attrib should read the attributes of the identifier
405 if (isid()) {
406 result->attribute = ((idhdl)m_data->data)->attribute;
407 result->flag = ((idhdl)m_data->data)->flag;
408
409 }
410 return FALSE;
411 }
#define FALSE
Definition auxiliary.h:97
static Type * shallowcpy(Type *result, Type *data)
Definition countedref.h:259
leftv next
Definition subexpr.h:86
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
return result
ListNode * next
Definition janet.h:31

◆ retrieve()

BOOLEAN LeftvDeep::retrieve ( leftv res)
inline

Get additional data (e.g. subexpression data) from likewise instances.

Definition at line 414 of file countedref.h.

414 {
415 if (res->data == m_data->data) {
416 if(m_data->e != res->e) recursivekill(m_data->e);
417 cpy(m_data, res);
418 res->Init();
419 return TRUE;
420 }
421 return FALSE;
422 }
#define TRUE
Definition auxiliary.h:101
static void recursivekill(Type *current)
Definition countedref.h:268

◆ ringed()

BOOLEAN LeftvDeep::ringed ( )
inline

Test whether we reference to ring-dependent data.

Definition at line 428 of file countedref.h.

428{ return m_data->RingDependend(); }

◆ unassigned()

BOOLEAN LeftvDeep::unassigned ( ) const
inline

Check whether (all-zero) initialized data was never assigned.

Definition at line 430 of file countedref.h.

430{ return m_data->Typ()==0; }

Field Documentation

◆ m_data

leftv LeftvDeep::m_data
private

Store the actual data.

Definition at line 450 of file countedref.h.


The documentation for this class was generated from the following file: