125 return complain(
"Back-reference broken");
129 return complain(
"Referenced identifier not from current ring");
132 complain(
"Referenced identifier not available in ring anymore");
138 complain(
"Referenced identifier not available in current context");
217 int typ = arg->
Typ();
240 return m_data->assign(result,arg);
257 res->
data = (
void *)outcast();
295 return resolve(arg) || construct(res,
operator*()->data == arg->
data);
305 return construct(res,
Tok2Cmdname(
operator*()->Typ()));
314 return self(
static_cast<data_type*
>(data));
320 return self::cast(arg->
Data());
332 res->
data = (
void*) data;
359 else PrintS(
"<unassigned reference or shared memory>");
386 if (result->
Typ() == arg->
Typ())
393 WerrorS(
"Can only take reference from identifier");
401 WerrorS(
"Noninitialized access");
517 return static_cast<self&
>(base::operator=(rhs));
524 static self cast(
void* arg) {
return base::cast(arg); }
569 int typ = head->
Typ();
583 int typ = head->
Typ();
604 (
char*) next->
Data(): (
char*)next->
Name());
607 if (strcmp(name,
"help") == 0)
609 PrintS(
"system(<ref>, ...): extended functionality for reference/shared data <ref>\n");
610 PrintS(
" system(<ref>, count) - number of references pointing to <ref>\n");
611 PrintS(
" system(<ref>, enumerate) - unique number for identifying <ref>\n");
612 PrintS(
" system(<ref>, undefined) - checks whether <ref> had been assigned\n");
613 PrintS(
" system(<ref>, \"help\") - prints this information message\n");
614 PrintS(
" system(<ref>, \"typeof\") - actual type referenced by <ref>\n");
615 PrintS(
" system(<ref1>, same, <ref2>) - tests for identic reference objects\n");
618 if (strncmp(name,
"undef", 5) == 0)
627 if (strcmp(name,
"same") == 0)
return obj.
same(res, next);
629 if (strncmp(name,
"like", 4) == 0)
return obj.
likewise(res, next);
631 if (strncmp(name,
"count", 5) == 0)
return obj.
count(res);
632 if (strncmp(name,
"enum", 4) == 0)
return obj.
enumerate(res);
633 if (strcmp(name,
"name") == 0)
return obj.
name(res);
634 if (strncmp(name,
"typ", 3) == 0)
return obj.
type(res);
657 if (result->
Typ() == arg->
Typ())
682 memset(&l,0,
sizeof(l));
694 leftv data=f->m->Read(f);
706 blackbox *bbx = (blackbox*)
omAlloc0(
sizeof(blackbox));
730 blackbox *bbxshared = (blackbox*)
omAlloc0(
sizeof(blackbox));
LeftvDeep::copy_tag copy_tag
BOOLEAN complain(const char *text) const
Raise error message and return TRUE.
BOOLEAN countedref_Op1(int op, leftv res, leftv head)
blackbox support - unary operations
LeftvShallow operator*() const
Extract (shallow) copy of stored data.
ring_ptr m_ring
Store namespace for ring-dependent objects.
static BOOLEAN countedref_Op3_(int op, leftv res, leftv head, leftv arg1, leftv arg2)
static self cast(void *arg)
Recovering outcasted CountedRefShared object from raw data.
BOOLEAN dereference(leftv arg)
Replaces argument by a shallow copy of the references data.
CountedRefShared()
Default constructor for initialized, but all-zero, shared data object.
CountedRefShared(const self &rhs)
Construct new reference to internal data.
void invalidate()
Mark weak reference as invalid.
Class used for (list of) interpreter objects.
count_type ref
Number of references.
BOOLEAN put(leftv res)
Write (shallow) copy to given handle.
static BOOLEAN is_ref(leftv arg)
Check whether argument is already a reference type.
char * countedref_String(blackbox *, void *ptr)
blackbox support - convert to string representation
LeftvDeep m_data
Singular object.
BOOLEAN outcast(leftv res, int typ)
Construct reference data object marked by given identifier number.
BOOLEAN countedref_deserialize(blackbox **, void **d, si_link f)
back_ptr m_back
Reference to actual object for wrap structures.
back_ptr weakref()
Gerenate weak (but managed) reference to *this.
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
data_type * outcast()
Construct raw reference data.
static BOOLEAN construct(leftv res, const char *data)
Construct string.
CountedRefData(leftv data, copy_tag do_copy)
Construct reference for Singular object.
BOOLEAN iiExprArith3(leftv res, int op, leftv a, leftv b, leftv c)
static BOOLEAN countedref_Op3__(int op, leftv res, leftv head, leftv arg1, leftv arg2)
BOOLEAN broken() const
Check whether identifier became invalid.
BOOLEAN isid() const
Check for being an identifier.
BOOLEAN enumerate(leftv res)
CountedRefData(leftv data)
Reference Singular object.
BOOLEAN likewise(leftv res, leftv arg)
Check for likewise identifiers.
static ring parent(leftv rhs)
Store ring for ring-dependent objects.
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
void * countedref_Init(blackbox *)
blackbox support - initialization
void destruct()
Kills a link to the referenced object.
void WerrorS(const char *s)
BOOLEAN rering()
Determine active ring when ring dependency changes.
data_ptr m_data
Store pointer to actual data.
self & operator=(leftv rhs)
Replace with other Singular data.
static BOOLEAN resolve(leftv arg)
If necessary dereference.
This file defines reusable classes supporting reference counted interpreter objects and initiates the...
void countedref_destroyShared(blackbox *, void *ptr)
blackbox support - destruction
CountedRefData data_type
Name type for handling referenced data.
BOOLEAN unassigned() const
Check whether (all-zero) initialized data was never assigned.
CountedRef(const self &rhs)
Construct copy.
CountedRefPtr< ring, true > ring_ptr
Fix smart pointer type to ring.
BOOLEAN retrieve(leftv res)
Recover additional information (e.g. subexpression) from likewise object.
BOOLEAN countedref_CheckAssign(blackbox *, leftv, leftv)
We use the function pointer as a marker of reference types for CountedRef::is_ref(leftv), see the latter for details.
static self cast(leftv arg)
Recover the actual object from Singular interpreter object.
BOOLEAN countedref_serialize(blackbox *, void *d, si_link f)
This class implements implements a refernce counter which we can use as a public base of objects mana...
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
void CountedRefPtr_kill(ring r)
Overloading ring destruction.
int newstruct_desc_size()
This class wraps leftv by taking into acount memory allocation, destruction as well as deeply copying...
~CountedRef()
Kills the link to the referenced object.
BOOLEAN retrieve(leftv res)
Get additional data (e.g. subexpression data) from likewise instances.
Construct even deeper copy: Skip identifier (if any) and take care of the data on our own...
leftv m_data
Store the actual data.
Ths class wraps leftv by taking into acount memory allocation, destruction as well as shallowly copyi...
BOOLEAN count(leftv res)
Get number of references pointing here, too.
BOOLEAN assign(leftv result, leftv arg)
Reassign actual object.
BOOLEAN retrieve(leftv res, int typ)
Recover more information (e.g. subexpression data) from computed result.
BOOLEAN unassigned() const
Check whether data is all-zero.
This class stores a reference counter as well as a Singular interpreter object.
BOOLEAN assign(leftv result, leftv arg)
self & operator=(const self &rhs)
Replace reference.
BOOLEAN countedref_Op3(int op, leftv res, leftv head, leftv arg1, leftv arg2)
blackbox support - ternary operations
BOOLEAN name(leftv res)
Get (possibly) internal identifier name.
CountedRefShared(leftv arg)
Construct internal copy of Singular interpreter object.
BOOLEAN broken()
Check whether object in valid in current context.
BOOLEAN put(leftv result)
Put a shallow copy to given leftv.
BOOLEAN blackboxDefaultOp1(int op, leftv l, leftv r)
default procedure blackboxDefaultOp1, to be called as "default:" branch
BOOLEAN brokenid(idhdl context) const
Check a given context for our identifier.
BOOLEAN countedref_Op1Shared(int op, leftv res, leftv head)
Blackbox support - unary operation for shared data.
void PrintS(const char *s)
CountedRefShared(data_ptr rhs)
Generate from data pointer.
char name(const Variable &v)
BOOLEAN countedref_CheckInit(leftv res, leftv arg)
CountedRefData()
Construct shared memory empty Singular object.
static BOOLEAN construct(leftv res)
Construct void-style object.
LeftvShallow operator*()
Extract (shallow) copy of stored data.
static BOOLEAN countedref_Op2_(int op, leftv res, leftv head, leftv arg)
blackbox support - binary operations (resolve seocnd argument)
CountedRef(data_ptr arg)
Recover previously constructed reference.
BOOLEAN countedref_Op2Shared(int op, leftv res, leftv head, leftv arg)
blackbox support - binary operations
BOOLEAN countedref_Assign(leftv result, leftv arg)
blackbox support - assign element
CountedRef(leftv arg)
Reference given Singular data.
self & operator=(const self &rhs)
Change reference to shared data.
CountedRefPtr< CountedRefData * > data_ptr
Fix smart pointer type to referenced data.
BOOLEAN countedref_OpM(int op, leftv res, leftv args)
blackbox support - n-ary operations
BOOLEAN unassigned() const
Check whether (shared) data was initialized but not assigned yet.
BOOLEAN countedref_Op2(int op, leftv res, leftv head, leftv arg)
CountedRefShared(const base &rhs)
Reinterprete CountedRef as CountedRefShared.
BOOLEAN jjLIST_PL(leftv res, leftv v)
leftv idify(idhdl *root)
Wrap data by identifier, if not done yet.
bool unassigned() const
Test whether reference was never used.
const char * Tok2Cmdname(int tok)
void * countedref_InitShared(blackbox *)
Blackbox support - generate initialized, but all-zero - shared data.
BOOLEAN same(leftv res, leftv arg)
Check for identical reference objects.
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
BOOLEAN outcast(leftv res)
Construct reference data object from *this.
CountedRefWeakPtr< self * > back_ptr
static BOOLEAN construct(leftv res, long data)
Construct integer value.
BOOLEAN countedref_AssignShared(leftv result, leftv arg)
blackbox support - assign element
self wrapid()
Temporarily wrap with identifier for '[' and '.' operation.
void clearid(idhdl *root)
Erase identifier handles by *this.
void countedref_Print(blackbox *, void *ptr)
blackbox support - convert to string representation
BOOLEAN type(leftv res)
Get type of references data.
static self cast(void *data)
Recover the actual object from raw Singular data.
self & operator=(const self &)
ptr_type wrapid()
Generate object for indexing.
back_ptr::ptr_type ptr_type
Fix smart pointer type to referenced data.
~CountedRefData()
Destruct.
void * countedref_Copy(blackbox *, void *ptr)
blackbox support - copy element
void countedref_reference_load()
Initialize blackbox types 'reference' and 'shared', or both.
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
CountedRefData(leftv wrapid, back_ptr back)
Generate object linked to other reference (e.g. for subscripts)
BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
void countedref_destroy(blackbox *, void *ptr)
blackbox support - destruction
BOOLEAN ringed()
Test whether we reference to ring-dependent data.
~CountedRefShared()
Desctruct.
void countedref_shared_load()
idhdl * root()
Get the current context.
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
data_type::back_ptr weakref()
Generate weak reference (may get invalid)
static self cast(leftv arg)
Recovering outcasted CountedRefShared object from interpreter object.
int id_type
name type for identifiers