Compiler Anonymous Types

Data Structures

struct  AnonType


#define AMSTAT   0
#define ATDEBUG   0
#define INSTANCES_PER_AT   2
#define ANONEXPECTED   200
#define ANONTABLESIZE   1024
#define Asc_GetAnonType(atl, n)   ((struct AnonType *)gl_fetch((atl),(n)))
#define Asc_GetAnonCount(atl, n)   gl_length(Asc_GetAnonType((atl),(n))->instances)
#define Asc_GetAnonTypeInstance(at, c)   (struct Instance *)gl_fetch((at)->instances,(c))


struct gl_list_tPass2CollectAnonProtoVars (struct Instance *i)
void Pass2DestroyAnonProtoVars (struct gl_list_t *indexpathlist)
void Pass2CopyAnonProto (struct Instance *proto, struct BitList *protoblist, struct gl_list_t *protovarindices, struct Instance *i)
VOIDPTR Asc_AnonMergeMarkIPs (struct Instance *root)
int Asc_AnonMergeCmpInstances (CONST struct Instance *i1, CONST struct Instance *i2)
void Asc_AnonMergeUnmarkIPs (VOIDPTR vp)
void Asc_AnonMergeWriteList (FILE *fp, struct Instance *i)
struct InstanceAsc_GetAnonPrototype (struct AnonType *at)
ASC_DLLSPEC void Asc_DestroyAnonList (struct gl_list_t *atl)
ASC_DLLSPEC struct gl_list_tAsc_DeriveAnonList (struct Instance *root)
ASC_DLLSPEC void Asc_WriteAnonList (FILE *fp, struct gl_list_t *atl, struct Instance *root, int mlists)

Define Documentation

#define AMSTAT   0

If want to collect/report some statistics, set to 1. what statistics are written and where depends on flags defined in anonmerg.c. this is for debugging purposes only.

Definition at line 156 of file anonmerg.h.

#define ATDEBUG   0

For debugging set =1, for performance set = 0

Definition at line 104 of file anontype.h.

#define INSTANCES_PER_AT   2

The initial number of instances to expect for each AT. Tuning this may be hard. E.g. relations and some atoms will grow to a huge number, but many constant types will only have 1-3 instances shared universally. In a distillation MODEL there are ~400 anon types and most of these fall in the constant types.

Definition at line 126 of file anontype.h.

#define ANONEXPECTED   200

Define the expected maximum number of anonymous types. This should not be too low or the code will do memory reallocation of gl_list, atl.

Definition at line 133 of file anontype.h.

Referenced by Asc_DeriveAnonList().

#define ANONTABLESIZE   1024

Define the size for the hash tables keyed by the formal type name and secondarily keyed by type ptr. The secondary key is required because mixed simulations may be created by pathological users and we must not get confused when classifying. One such hash table is used while classifying an instance tree into AT groups. The user never sees this table, however. This size must be even power of 2 and shouldn't be messed with.

Definition at line 145 of file anontype.h.

#define Asc_GetAnonType ( atl,
 )     ((struct AnonType *)gl_fetch((atl),(n)))

Return the nth element of anon type list n. The return type is AnonType*.

Definition at line 151 of file anontype.h.

#define Asc_GetAnonCount ( atl,
 )     gl_length(Asc_GetAnonType((atl),(n))->instances)

Return the number of instances associated with the nth position in anonymous type list n. The return value is type unsigned long.

Definition at line 159 of file anontype.h.

#define Asc_GetAnonTypeInstance ( at,
 )     (struct Instance *)gl_fetch((at)->instances,(c))

Returns the cth member of an anonymous type clique represented by at. The return value is type Instance*.

at an AnonType*, such as returned by: at = Asc_GetAnonType(atl,n);
c index: 1 <= c <= Asc_GetAnonCount(atl,n)

Definition at line 168 of file anontype.h.

Function Documentation

struct gl_list_t* Pass2CollectAnonProtoVars ( struct Instance i  )  [read]

Returns a gl_list of index paths through i to reach the vars occurring in relations (or relation arrays) of i. i must be a MODEL.

Each var will only occur once in the path list returned. An index path can be followed through any instance isomorphic to i and will end at a variable semantically equivalent to the one in i that generated the path.

At the expense of a visit tree call (which we need anyway) this returns the list unsorted and never searched.

The list returned should be destroyed with Pass2DestroyAnonProtoVars().

Definition at line 319 of file anoncopy.c.

References ASC_NEW_ARRAY, ASCERR, ascfree, FPRINTF, GetArrayBaseType, GetBaseType, gl_create(), IndexedVisitInstanceTree(), InstanceChild(), InstanceKind, InstanceTypeDesc(), len, NULL, NumberChildren(), relation_type, SilentVisitInstanceTree(), WriteInstanceName(), WriteRelation(), and ZeroTmpNums().

void Pass2DestroyAnonProtoVars ( struct gl_list_t indexpathlist  ) 

Deallocate the indexpathlist collected by Pass2CollectAnonProtoVars().

Definition at line 392 of file anoncopy.c.

References gl_free_and_destroy().

void Pass2CopyAnonProto ( struct Instance proto,
struct BitList protoblist,
struct gl_list_t protovarindices,
struct Instance i 

Copies all the local relations (including those in arrays) of the MODEL instance proto to the instance i using only local information. No global information is needed, but we need to arrange that the tmpnums all start and end 0 so we can avoid extra 0ing of them.

Definition at line 466 of file anoncopy.c.

References ASCERR, blist, BlackBoxData::common, FPRINTF, gl_destroy(), InitBBox(), InstanceBitList(), InstanceChild(), InstanceInList(), InstanceKind, InstanceTypeDesc(), NULL, NumberChildren(), OverwriteBList(), pairlist_create(), pairlist_destroy(), pairlist_length(), pairlist_valueAt(), RemoveInstance(), and WriteInstanceName().

VOIDPTR Asc_AnonMergeMarkIPs ( struct Instance root  ) 

This function finds merged instances, anon or otherwise, and records the merges at the scope most appropriate. On return, an InterfacePointers in the tree of root point to some data we understand iff anonflags contains data we understand, so don't mess with anonflags while we have marked instances. When done using these IPs, the caller should call AnonMergeDestroyIPs(vp); This function uses the push/pop protocol for ips, so ip data of other clients may be lost if Unmark is not called properly. Generally, both functions should be called from the same scope.

! ! Assumes that tmpnums are all 0 on entry, and leaves any it has touched 0 on exit.

Does not record recursive merges, i.e. if a,b ARE_THE_SAME, don't record a.i,b.i ARE_THE_SAME. This is simple to detect as a.i,b.i have the same childnumber/instanceparent pair.

Does not record 'merges' that are explicitly accounted for by an ALIASES statement in a type definition.

Definition at line 1678 of file anonmerg.c.

References AnonMergeCountTree(), ASCERR, AnonMergeIPData::fp, FPRINTF, AnonMergeIPData::ipused, AnonMergeVisitInfo::nim, AnonMergeVisitInfo::nip, NULL, AnonMergeIPData::num_iwithmerge, AnonMergeIPData::num_mergelists, SilentVisitInstanceTreeTwo(), and VOIDPTR.

Referenced by Asc_DeriveAnonList().

int Asc_AnonMergeCmpInstances ( CONST struct Instance i1,
CONST struct Instance i2 

Returns the comparison of the merge information stored in two instances. These instances must of the same formal type and have children of the same anonymous types. It doesn't make sense to call the function on ATOM-like instances, since they can have no deeper merged structures. Objects which are not supposed to have a list of merges will always return 2. If the comparison is valid, it will return 0,1,-1. UNIVERSAL instances will always return 0. (Think about it.) Comparing i1 to i1 is fatal.

Definition at line 1857 of file anonmerg.c.

References AnonMergeIP::amlist, GetAnonFlags(), GetInterfacePtr(), InstanceTypeDesc(), and NULL.

void Asc_AnonMergeUnmarkIPs ( VOIDPTR  vp  ) 

Frees data structure returned by AnonMergeMarkIPs. Neglect to call this and you will cause trouble. You really haven't the slightest need to know what the contents of vp are.

Definition at line 1886 of file anonmerg.c.

References ASC_PANIC, AnonMergeIPData::fp, FPRINTF, AnonMergeIPData::oldips, PopInterfacePtrs(), AnonMergeIPData::root, SilentVisitInstanceTreeTwo(), and VOIDPTR.

Referenced by Asc_DeriveAnonList().

void Asc_AnonMergeWriteList ( FILE *  fp,
struct Instance i 

Writes the AnonMerge path lists for instance i. The function is for debugging only. it will not work except after anonmergmarkip is called and before the closing unmarkip is called. if i is bogus, this may crash.

Definition at line 1910 of file anonmerg.c.

References AnonMergeIP::amlist, ASC_PANIC, FPRINTF, GetAnonFlags(), GetInterfacePtr(), IsCompoundInstance, and NULL.

struct Instance* Asc_GetAnonPrototype ( struct AnonType at  )  [read]

Returns the first element of the instance list associated with the AT given. Does not normally return unless there is such a creature.

Definition at line 308 of file anontype.c.

References gl_fetch, gl_length, AnonType::instances, and NULL.

ASC_DLLSPEC void Asc_DestroyAnonList ( struct gl_list_t atl  ) 

Destroys the anonlist we returned from a call to classify. Do not destroy this list any other way.

Definition at line 1487 of file anontype.c.

References gl_destroy(), gl_fetch, gl_length, and NULL.

ASC_DLLSPEC struct gl_list_t* Asc_DeriveAnonList ( struct Instance i  )  [read]

This function classifies an instance tree and returns the list described above. root may be at any place in an instance tree. The list should be destroyed with Asc_DestroyAnonList.

This function classifies an instance tree from the bottom up and returns the list described above. The list should be destroyed with Asc_DestroyAnonList.

Definition at line 1506 of file anontype.c.

References ANONEXPECTED, Asc_AnonMergeMarkIPs(), Asc_AnonMergeUnmarkIPs(), Asc_WriteAnonList(), ASCERR, AnonVisitInfo::atl, AnonVisitInfo::errors, FPRINTF, gl_create(), AnonVisitInfo::nextfamily, NULL, PATH_MAX, AnonVisitInfo::root, SilentVisitInstanceTreeTwo(), AnonVisitInfo::t, VOIDPTR, and ZeroTmpNums().

ASC_DLLSPEC void Asc_WriteAnonList ( FILE *  fp,
struct gl_list_t atl,
struct Instance root,
int  mlists 

Writes a list of anon type info in atl, mainly for debugging purposes, to the file given. root is the instance that Asc_DeriveAnonList was called with, for the proper writing of names. If root is NULL, arbitrary names will be made up. If mlists != 0 and merge info exists, merge info will be written with the AT info.

Definition at line 1653 of file anontype.c.

References array_type, CONST, FPRINTF, GAP, GetArrayBaseIsLogRel, GetArrayBaseIsRelation, GetArrayBaseType, GetBaseType, GetName, gl_fetch, gl_length, ICOMP, InstanceIndirected(), InstanceKind, AnonType::instances, InstanceTypeDesc(), LONG_MAX, model_type, AnonType::next, NULL, AnonType::prev, SCP, and AnonType::visited.

Referenced by Asc_DeriveAnonList().

Generated on Mon Mar 4 17:48:43 2013 for libascend by  doxygen 1.6.3