When including arrayinst.h, make sure these files are included first:
include "utilities/ascConfig.h"
include "instance_enum.h"
include "compiler.h"
include "setvalinst.h"
include "pool.h"
include "list.h"
Notes on the structure implemented for ASCEND arrays.
ASCEND arrays are 'associative arrays.' That is they are not sequential in memory, rather they are accessed by names of the elements. So there really isn't a difference between a dense rectangular array and a sparse array except it is algorithmically easier to construct the dense array.
For example:
a[1..2]['a','f'] IS_A foo;
yields an internal data structure (a, uai1 and uai2 are ArrayInstances as described in instance_types.h) like so:
a -------------------|-----------------------| <=== gl_list_t
V V *childlist.
ArrayChild{ ArrayChild{
name.int = 1 name.int = 2
unnamed array inst|} unnamed array inst|}
/--------------------------/ /------------------/
V V
uai1 ------|-------| uai2 -----|-----| <=== gl_list_t's
V V V V
AC AC AC AC
name.str='a' name.str='f' name.str='a' name.str='f'
inst --\ inst --\ inst --\ inst --\
| | | |
V V V V
fooinst fooinst fooinst fooinst
Unnamed array instances actually DO have a compiler generated internal name, but it is not useful for anything except avoiding core dumps in routines that assume all insts have names.
Navigating these structures during assembly is terribly dangerous so all that is handled by this file.
All the indirection in these structures makes interesting tricks for sparse and dense arrays possible.
One trick in particular, however, is NOT to be attempted because it plays havoc with the semantics of the ASCEND language: thou shalt not declare an array over one set and then later expand it to have more elements. This would be trivial to implement because the elements exist in gl_lists, but so far every potential application proposed for it has been the result of sloppy and/or lazy thinking. In the end we may find a need for a genuine multidimensional ListInstance that has much in common with arrays, but such a creature should be implemented as its own creature and not a sloppy graft on top of arrays.
#include "setinstval.h"
#include "expr_types.h"
#include "instance_enum.h"
#include "compiler.h"
#include <general/pool.h>
Include dependency graph for arrayinst.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | CAC(acp) ((struct ArrayChild *)(acp)) |
| #define | MALLOCPOOLAC CAC(pool_get_element(g_array_child_pool)) |
| #define | FREEPOOLAC(ac) pool_free_element(g_array_child_pool,(ac)) |
Typedefs | |
| typedef void(*) | AVProc (struct Instance *) |
Functions | |
| void | InitInstanceNanny (void) |
| void | DestroyInstanceNanny (void) |
| void | ReportInstanceNanny (FILE *f) |
| gl_list_t * | CollectArrayInstances (CONST struct Instance *i, struct gl_list_t *list) |
| void | ArrayVisitLocalLeaves (struct Instance *mch, AVProc func) |
| ASC_DLLSPEC struct Instance * | ChildByChar (CONST struct Instance *i, symchar *str) |
| int | RectangleArrayExpanded (CONST struct Instance *i) |
| int | RectangleSubscriptsMatch (CONST struct Instance *context, CONST struct Instance *ary, CONST struct Name *subscripts) |
| unsigned long | NextToExpand (CONST struct Instance *i) |
| unsigned long | NumberofDereferences (CONST struct Instance *i) |
| CONST struct Set * | IndexSet (CONST struct Instance *i, unsigned long num) |
| void | ExpandArray (struct Instance *i, unsigned long num, struct set_t *set, struct Instance *rhsinst, struct Instance *arginst, struct gl_list_t *rhslist) |
| Instance * | FindOrAddIntChild (struct Instance *i, long v, struct Instance *rhsinst, struct Instance *arginst) |
| Instance * | FindOrAddStrChild (struct Instance *i, symchar *sym, struct Instance *rhsinst, struct Instance *arginst) |
| int | CmpArrayInsts (struct Instance *i1, struct Instance *i2) |
Variables | |
| pool_store_t | g_array_child_pool |
1.5.1