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