Data Structures | Public Member Functions | Private Types | Private Attributes
LeftvDeep Class Reference

This class wraps leftv by taking into acount 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...
 

Public Member Functions

 LeftvDeep ()
 Allocate all-zero object by default. More...
 
 LeftvDeep (leftv data)
 Store a deep copy of the data @ note Occupies the provided leftv and invalidates the latter. More...
 
 LeftvDeep (leftv data, copy_tag)
 
 ~LeftvDeep ()
 Really clear data. More...
 
bool like (const self &rhs) const
 Determine whether we point to the same data. More...
 
selfoperator= (leftv rhs)
 Reassign a new deep copy by occupieing another leftv. More...
 
BOOLEAN brokenid (idhdl context) const
 Check a given context for our identifier. More...
 
BOOLEAN put (leftv result)
 Put a shallow copy to given leftv. More...
 
BOOLEAN retrieve (leftv res)
 Get additional data (e.g. subexpression data) from likewise instances. More...
 
BOOLEAN isid () const
 Check for being an identifier. More...
 
BOOLEAN ringed ()
 Test whether we reference to ring-dependent data. More...
 
BOOLEAN unassigned () const
 Check whether (all-zero) initialized data was never assigned. More...
 
leftv idify (idhdl *root)
 Wrap data by identifier, if not done yet. More...
 
void clearid (idhdl *root)
 Erase identifier handles by *this. More...
 
Access via shallow copy to avoid invalidating the stored handle
 operator LeftvShallow ()
 
LeftvShallow operator* ()
 

Private Types

typedef LeftvDeep self
 

Private Member Functions

Do not permit copying (avoid inconsistence)
selfoperator= (const self &)
 
 LeftvDeep (const self &)
 

Private Attributes

leftv m_data
 Store the actual data. More...
 

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 acount 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

§ 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  }
Subexpr e
Definition: subexpr.h:107
void * data
Definition: subexpr.h:90
leftv m_data
Store the actual data.
Definition: countedref.h:450
#define NULL
Definition: omList.c:10
static Type * cpy(Type *result, Type *data)
Definition: countedref.h:244
BOOLEAN isid() const
Check for being an identifier.
Definition: countedref.h:426
void * CopyD(int t)
Definition: subexpr.cc:679

§ LeftvDeep() [4/4]

LeftvDeep::LeftvDeep ( leftv  data,
copy_tag   
)
inline

Definition at line 358 of file countedref.h.

358 : m_data(allocate()) { m_data->Copy(data); }
leftv m_data
Store the actual data.
Definition: countedref.h:450
void Copy(leftv e)
Definition: subexpr.cc:660
static leftv allocate()
Definition: countedref.h:273

§ ~LeftvDeep()

LeftvDeep::~LeftvDeep ( )
inline

Really clear data.

Definition at line 361 of file countedref.h.

361 { m_data->CleanUp(); }
leftv m_data
Store the actual data.
Definition: countedref.h:450
void CleanUp(ring r=currRing)
Definition: subexpr.cc:320

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  }
#define IDNEXT(a)
Definition: ipid.h:115
void * data
Definition: subexpr.h:90
leftv m_data
Store the actual data.
Definition: countedref.h:450
#define assume(x)
Definition: mod2.h:403
idrec * idhdl
Definition: ring.h:18
#define NULL
Definition: omList.c:10
BOOLEAN isid() const
Check for being an identifier.
Definition: countedref.h:426
BOOLEAN brokenid(idhdl context) const
Check a given context for our identifier.
Definition: countedref.h:389

§ 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
446  }
Definition: idrec.h:34
void * data
Definition: subexpr.h:90
leftv m_data
Store the actual data.
Definition: countedref.h:450
#define assume(x)
Definition: mod2.h:403
static void clearid(idhdl handle, idhdl *root)
Definition: countedref.h:237
BOOLEAN isid() const
Check for being an identifier.
Definition: countedref.h:426

§ idify()

leftv LeftvDeep::idify ( idhdl root)
inline

Wrap data by identifier, if not done yet.

Definition at line 433 of file countedref.h.

433  {
434  leftv res = (isid()? m_data: LeftvHelper::idify(m_data, root));
435  ++(((idhdl)res->data)->ref);
436  return res;
437  }
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
void * data
Definition: subexpr.h:90
poly res
Definition: myNF.cc:322
leftv m_data
Store the actual data.
Definition: countedref.h:450
static leftv idify(leftv head, idhdl *root)
Definition: countedref.h:215
idrec * idhdl
Definition: ring.h:18
BOOLEAN isid() const
Check for being an identifier.
Definition: countedref.h:426

§ 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
leftv m_data
Store the actual data.
Definition: countedref.h:450
int rtyp
Definition: subexpr.h:93

§ 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; }
void * data
Definition: subexpr.h:90
leftv m_data
Store the actual data.
Definition: countedref.h:450

§ operator LeftvShallow()

LeftvDeep::operator LeftvShallow ( )
inline

Definition at line 365 of file countedref.h.

365 { return m_data; }
leftv m_data
Store the actual data.
Definition: countedref.h:450

§ operator*()

LeftvShallow LeftvDeep::operator* ( )
inline

Definition at line 366 of file countedref.h.

366 {return *this; }

§ operator=() [1/2]

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

§ 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  }
Subexpr e
Definition: subexpr.h:107
int Typ()
Definition: subexpr.cc:979
Definition: idrec.h:34
void * data
Definition: subexpr.h:90
#define IDTYP(a)
Definition: ipid.h:116
leftv m_data
Store the actual data.
Definition: countedref.h:450
void Copy(leftv e)
Definition: subexpr.cc:660
#define NULL
Definition: omList.c:10
void CleanUp(ring r=currRing)
Definition: subexpr.cc:320
#define IDDATA(a)
Definition: ipid.h:123
BOOLEAN isid() const
Check for being an identifier.
Definition: countedref.h:426
void * CopyD(int t)
Definition: subexpr.cc:679

§ 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  {
397  leftv next = result->next;
398  result->next = NULL;
399  result->CleanUp();
400 
401  shallowcpy(result, m_data);
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  }
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
static Type * shallowcpy(Type *result, Type *data)
Definition: countedref.h:259
BITSET flag
Definition: subexpr.h:92
#define FALSE
Definition: auxiliary.h:97
void * data
Definition: subexpr.h:90
leftv m_data
Store the actual data.
Definition: countedref.h:450
idrec * idhdl
Definition: ring.h:18
leftv next
Definition: subexpr.h:88
#define NULL
Definition: omList.c:10
void CleanUp(ring r=currRing)
Definition: subexpr.cc:320
attr attribute
Definition: subexpr.h:91
BOOLEAN isid() const
Check for being an identifier.
Definition: countedref.h:426
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  }
Subexpr e
Definition: subexpr.h:107
#define FALSE
Definition: auxiliary.h:97
#define TRUE
Definition: auxiliary.h:101
void Init()
Definition: subexpr.h:109
void * data
Definition: subexpr.h:90
leftv m_data
Store the actual data.
Definition: countedref.h:450
static void recursivekill(Type *current)
Definition: countedref.h:268
static Type * cpy(Type *result, Type *data)
Definition: countedref.h:244

§ 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(); }
leftv m_data
Store the actual data.
Definition: countedref.h:450
BOOLEAN RingDependend()
Definition: subexpr.cc:391

§ 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; }
int Typ()
Definition: subexpr.cc:979
leftv m_data
Store the actual data.
Definition: countedref.h:450

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: