class SgType

Types are associated with each identifier and expression

Inheritance:

SgType


Public Fields

PTR_TYPE thetype

Public Methods

void addAttribute(SgAttribute *att)
void addAttribute(void *a, int size)
void addAttribute(int type)
void addAttribute(int type, void *a, int size)
int attributeType(int i)
void* attributeValue(int i, int type)
void* attributeValue(int i)
SgType* baseType()
SgType& copy()
SgType* copyPtr()
void* deleteAttribute(int i)
int equivalentToType(SgType &type)
int equivalentToType(SgType *type)
SgAttribute* getAttribute(int i)
SgAttribute* getAttribute(int i, int type)
SgType* getTrueType(int mask = MASK_MOST_DESCRIPTORS, int follow_typedefs = 0)
Since Sage stores dereferenced pointers as PTR(-1) -> PTR(1) -> BASE_TYPE, we may need to follow the chain of dereferencing to find the type which we expect
int hasBaseType()
int id()
SgType* internalBaseType()
int isTheElementType()
SgExpression* length()
SgType* maskDescriptors(int mask)
This routine strips many descriptive type traits which you are probably not interested in cloning for variable declarations, etc
SgType* next()
int numberOfAttributes(int type)
int numberOfAttributes()
SgType(int var, SgExpression *len, SgType *base)
SgType(int variant)
SgType(int var, SgSymbol *symb)
SgType(int var, SgSymbol *firstfield, SgStatement *structstmt)
SgType(SgType &)
SgType(PTR_TYPE type)
SgSymbol* symbol()
int variant()

Documentation

Types are associated with each identifier and expression
PTR_TYPE thetype

SgType(int variant)

SgType(int var, SgExpression *len, SgType *base)

SgType(int var, SgSymbol *symb)

SgType(int var, SgSymbol *firstfield, SgStatement *structstmt)

SgType(PTR_TYPE type)

SgType(SgType &)

int variant()

int id()

SgSymbol* symbol()

SgType& copy()

SgType* copyPtr()

SgType* next()

int isTheElementType()

int equivalentToType(SgType &type)

int equivalentToType(SgType *type)

SgType* internalBaseType()

int hasBaseType()

SgType* baseType()

SgExpression* length()

SgType* maskDescriptors(int mask)
This routine strips many descriptive type traits which you are probably not interested in cloning for variable declarations, etc.

Returns the getTrueType of the base type being described IF there are no descriptors which are not masked out. The following masks can be specified as an optional second argument: MASK_NO_DESCRIPTORS: Do not mask out anything. MASK_MOST_DESCRIPTORS: Only leave in: signed, unsigned, short, long, const, volatile. MASK_ALL_DESCRIPTORS: Mask out everything.

If you build your own mask, you should make sure that the traits you want to set out have their bits UN-set, and the rest should have their bits set. The complementation (~) operator is a good one to use.

See libSage++.h, where the MASK_*_DESCRIPTORS variables are defined.

SgType* getTrueType(int mask = MASK_MOST_DESCRIPTORS, int follow_typedefs = 0)
Since Sage stores dereferenced pointers as PTR(-1) -> PTR(1) -> BASE_TYPE, we may need to follow the chain of dereferencing to find the type which we expect.

This code currently assumes that: o If you follow the dereferencing pointer (PTR(-1)), you find another pointer type or an array type.

We do NOT assume that the following situation cannot occur: PTR(-1) -> PTR(-1) -> PTR(1) -> PTR(1) -> PTR(-1) -> PTR(1)

This means there may be more pointers to follow after we come to an initial "equilibrium".

ALGORITHM:

T_POINTER: [WARNING: No consideration is given to pointers with attributes (ls_flags) set. For instance, a const pointer is treated the same as any other pointer.]

1. Return the same type we got if it is not a pointer type or the pointer is not a dereferencing pointer type.

2. Repeat { get next pointer , add its indirection to current total } until the current total is 0. We have reached an equilibrium, so the next type will not necessarily be a pointer type.

3. Check the next type for further indirection with another call to getTrueType.

T_DESCRIPT: Returns the result of maskDescriptors called with the given type and mask.

T_ARRAY: If the array has zero dimensions, we pass over it. This type arose for me in the following situation: double x[2]; x[1] = 0;

T_DERIVED_TYPE: If we have been told to follow typedefs, get the type of the symbol from which this type is derived from, and continue digging. Otherwise return this type.

HITCHES: Some programs may dereference a T_ARRAY as a pointer, so we need to be prepared to deal with that.

int numberOfAttributes()

int numberOfAttributes(int type)

void* attributeValue(int i)

int attributeType(int i)

void* attributeValue(int i, int type)

void* deleteAttribute(int i)

void addAttribute(int type, void *a, int size)

void addAttribute(int type)

void addAttribute(void *a, int size)

void addAttribute(SgAttribute *att)

SgAttribute* getAttribute(int i)

SgAttribute* getAttribute(int i, int type)


Direct child classes:
SgReferenceType
SgPointerType
SgFunctionType
SgDescriptType
SgDerivedType
SgDerivedTemplateType
SgDerivedCollectionType
SgDerivedClassType
SgClassType
SgArrayType

alphabetic index hierarchy of classes


Email contact: zgs@npac.syr.edu

generated by doc++