SymbolTable

public final class SymbolTable

Symbol Table. Scoping is implemented through layered Symbol Tables. Each Symbol Table, except the root, has access to its enclosing Symbol Table.

Fields

associationByAddressTypes

public TapList<TypeSpec> associationByAddressTypes

containerFileName

public String containerFileName

The name of the (past or future) container file. This is temporary until TranslationUnits become Units.

danglingCircularTypes

public TapList<WrapperTypeSpec> danglingCircularTypes

List of all types used in this SymbolTable that have not been finished yet because they are circular. Must be solved when all types have been prepared.

dataList

protected TapList<Tree> dataList

List of data Tree’s.

declarationsBlock

public Block declarationsBlock

Block that contains the Instructions corresponding to these declarations.

implicits

public WrapperTypeSpec[] implicits

The Fortran “implicit” typing information at this level.

inheritedClass

public Unit inheritedClass

When this is the copy of the Symbol Table of an IMPORT’d class, contains this IMPORT’d class.

isImports

public boolean isImports

true when this SymbolTable (basis of a public SymbolTable) is for symbols IMPORTed or for global variables

isPublic

public boolean isPublic

true when this SymbolTable is the public SymbolTable of some Unit (contains public variables or formal parameters)

nameListList

public TapList<Tree> nameListList

List of nameList Tree’s.

nameSpaceName

public String nameSpaceName

When this is the SymbolTable of a nameSpace, holds the nameSpace name.

needNoAtomic

public BoolVector needNoAtomic

For lack of a better place, zones that need no multithread atomic

nestedIntIndexSymbolHolders

public TapList<NewSymbolHolder> nestedIntIndexSymbolHolders

Ordered list of the NewSymbolHolder’s used in this SymbolTable for the indexes of nested do loops.

newSymbolHolders

public TapList<NewSymbolHolder> newSymbolHolders

List of all NewSymbolHolder’s that are waiting for declaration in this SymbolTable.

nonPrivForwardDeclarations

public TapList<Unit> nonPrivForwardDeclarations

Contains the Units for which we need to add a forward declaration (non-private? case) This field is (non-empty/used) ONLY for a “TranslationUnit” SymbolTable This field will probably move into the TranslationUnit Unit when we implement one.

privateForwardDeclarations

public TapList<Unit> privateForwardDeclarations

Contains the Units for which we need to add a forward declaration (private? case) This field is (non-empty/used) ONLY for a “TranslationUnit” SymbolTable This field will probably move into the TranslationUnit Unit when we implement one.

saveList

public TapList<Tree> saveList

List of save Tree’s.

unit

public Unit unit

The enclosing Unit. Never null with translationUnit.

Constructors

SymbolTable

public SymbolTable(SymbolTable basisSymbolTable)

Creates a new SymbolTable as a layer under the existing SymbolTable “basisSymbolTable”. If “basisSymbolTable” is null, creates a root SymbolTable.

Methods

addAllocatableDeclaration

public void addAllocatableDeclaration(Tree decl, Instruction instrDecl)

addConstDeclaration

public void addConstDeclaration(Tree decl, Instruction instrDecl)

Creates and inserts the new SymbolDecl coming from the constant declaration Tree “decl”. or adds the constant declaration into the variableDecl.

addData

public void addData(Instruction instr)

Processes a DATA declaration. Adds it into the list of DATA trees, and declares all variable names found inside “decl” into this SymbolTable

addExternalOrForwardDeclaration

public void addExternalOrForwardDeclaration(Tree externalTree, Instruction instrDecl, boolean isPrivate)

Declares a list of external function names. or a forward or external function (for C/C++).

addImplicit

public void addImplicit(Tree decl, SymbolTable refST)

Updates this symbolTable with respect to the implicit typing declaration Tree “decl”. This typing is analyzed with respect to SymbolTable “refST”.

addInterfaceDecl

protected InterfaceDecl addInterfaceDecl(Tree interfaceTreeOrig, Unit containerUnit)

Declares an interface name Assumes interfaceTree is an op_ident. For generic interfaces: declare the generic name of the interfaceDecl.

addIntrinsicDeclaration

public void addIntrinsicDeclaration(Tree intrinsicTree, Instruction instrDecl)

Declares a list of intrinsic function names. Assumes intrinsicTree is an op_intrinsic.

addNameList

public void addNameList(Instruction instr)

Processes a namelist declaration. Adds it into the list of namelist trees, and declares all variable names found addSymbolDecls inside “decl” into this SymbolTable.

addNameSpaceDecl

public NameSpaceDecl addNameSpaceDecl(String name, SymbolTable nameSpaceSymbolTable)

addNewSymbolDecl

protected void addNewSymbolDecl(SymbolDecl symbolDecl)

Plainly inserts the given “symbolDecl” into this SymbolTable.

addNewSymbolHolder

public void addNewSymbolHolder(NewSymbolHolder newSymbolHolder)

Adds a new NewSymbolHolder into the current list of waiting NewSymbolHolder’s.

addPrimitiveTypes

public void addPrimitiveTypes()

addSave

public void addSave(Instruction instr)

Processes a SAVE declaration. Adds it into the list of SAVE trees, and declares all variable names found inside “decl” into this SymbolTable.

addSymbolDecl

public void addSymbolDecl(SymbolDecl symbolDecl)

Inserts the given “symbolDecl” into this SymbolTable. Inserts it at the current top level of the SymbolTable, except for special case of Fortran that lets one declare local variable mixed with formal params and commons. Checks for double declaration. Combines declarations when done in multiple steps (e.g. type then dimension).

addSystemSymbolDecl

public void addSystemSymbolDecl(SymbolDecl symbolDecl)

addTypeDeclaration

public void addTypeDeclaration(Tree typeNameTree, Tree typeDef, Instruction instrDecl, TapList<String> modifiers)

addVarDeclaration

public TapList<WrapperTypeSpec> addVarDeclaration(Tree decl, Instruction instrDecl, boolean isATrueVariable, ToBool addInstruction)

Creates and inserts the SymbolDecl coming from the variable declaration Tree “decl”.

addVarDimDeclaration

public void addVarDimDeclaration(Tree decl, Instruction instrDecl)

Creates and inserts the SymbolDecl coming from the variable dimension declaration Tree “decl”.

addWaitingZoneInfo

public void addWaitingZoneInfo(ZoneInfo proxyZoneInfo)

addressChain

public String addressChain()

For debugging, returns the chain of hashcodes of the SymbolTable’s from this to root SymbolTable.

allSymbolTableRoots

public TapList<SymbolTable> allSymbolTableRoots()
Returns

the list of all the root SymbolTables of this SymbolTable, including this SymbolTable. The resulting list is ordered with the rootmost SymbolTable first.

allSymbolTableRoots

public TapList<SymbolTable> allSymbolTableRoots(SymbolTable limit)

Same as allSymbolTableRoots(), but stops going rootwards when reaching the given SymbolTable “limit”. The result is ordered rootmost SymbolTable first, never contains the “limit”, and contains “this” only when “this” is not the “limit”.

allocateZones

protected void allocateZones(ZoneAllocator zoneAllocator, Unit declarationUnit)

basisNotImportedSymbolTable

public SymbolTable basisNotImportedSymbolTable()
Returns

the enclosing level SymbolTable skips the imported symbolTables between this and result.

basisSymbolTable

public SymbolTable basisSymbolTable()
Returns

the enclosing level SymbolTable.

buildExternalUnit

public Unit buildExternalUnit(String name, boolean isPrivate)

buildZoneVisibleAccessTree

public Tree buildZoneVisibleAccessTree(ZoneInfo zoneInfo)
Returns

a reference expression that may be used from the scope of this SymbolTable, to access (exactly) the given zone (i.e. zoneInfo). In most cases this will be the same as zoneInfo.accessTree, but not always e.g. when the variable is declared extern, with a type which is different from its type in its basis, reference declaration. cf non-regression set08/lh068. Warning: The current mechanism uses the initial pointer destination zones, so this mechanism might still be wrong if pointers have been redirected, in which case the returned expression might point to a different location, and the given zone may even become inaccessible !!

checkTypeSpecValidity

protected void checkTypeSpecValidity()

cleanCopySymbolDecls

public void cleanCopySymbolDecls()

After copying, cleans the association between origin SymbolDecl’s and their copies.

collectAddressTakenZones

public TapList<ZoneInfo> collectAddressTakenZones(Tree tree, Instruction instruction, TapList<ZoneInfo> collected)

Collects the ZoneInfo of all expressions of which “tree” takes the address (e.g. “&v”).

combineNumeric

public TypeSpec combineNumeric(TypeSpec lhsType, TypeSpec rhsType, Tree instrOrExpr)

Very similar to canCombineNumeric(), but doesn’t modify lhsType nor rhsType.

computeFirstDeclaredZone

protected void computeFirstDeclaredZone(int[] globalFirstZone, SymbolTable basisNumberingST)

Computes the rank of the first zone of kind “whichKind”, declared at this level.

computeIntConstant

public Integer computeIntConstant(Tree tree)

constantZones

public TapIntList constantZones()

declareAllSymbolDecls

protected void declareAllSymbolDecls()

declareAllSymbolsIn

public TapList<SymbolDecl> declareAllSymbolsIn(Tree decl, Tree topDeclTree, TapList<String> commonNames, Tree modifier, int symbolKind, boolean delayedDeclaration, boolean noFunctionCall, Instruction instr)

Searches inside “decl” for all used identifiers that are not yet declared in this SymbolTable (at this level or above). Each missing SymbolDecl is created and then either inserted in this SymbolTable or returned in the result, depending on the value of “delayedDeclaration”.

Parameters
  • decl – the declaration expression in which symbols must be searched.

  • topDeclTree – the “decl” passed to the initial top recursive call.

  • commonNames – collected name of enclosing common ?? ([llh] not sure it is used correctly?)

  • modifier – collected modifier to be applied to identifiers found. ([llh] not sure it is used correctly?)

  • symbolKind – the kind of declaration “decl” e.g. VARIABLE,

  • delayedDeclaration – true when new SymbolDecl’s must be returned instead of inserted.

  • noFunctionCall – true when the expression “decl” is in a place that guarantees it cannot be a function call (e.g. left of assign, overwritten…)

  • instr – the Instruction that contains the given expression “decl”.

Returns

the list of missing SymbolDecl’s that have been found but not yet inserted because delayedDeclaration is true.

declareFormalParamsLevel

public void declareFormalParamsLevel()

Declares that this current SymbolTable is the level that contains the declarations of the formal parameters. This is because this level has special behavior (for Fortran).

declaredZoneInfo

public ZoneInfo declaredZoneInfo(int zone, int whichKind)
Returns

the ZoneInfo for the zone of kind “whichKind” number “zone”.

declaredZonesNb

public int declaredZonesNb(int whichKind)
Returns

the number of declared zones of kind “whichKind”, visible from this SymbolTable level.

delNewSymbolHolder

public void delNewSymbolHolder(NewSymbolHolder newSymbolHolder)

Deletes a NewSymbolHolder from the current list of waiting NewSymbolHolder’s.

dump

public void dump(int indent)

Prints in detail the contents of this SymbolTable, onto TapEnv.curOutputStream().

Parameters
  • indent – the amount of indentation to be used for this printing.

dumpDeclaredZones

public void dumpDeclaredZones(String stRanks)

equalValues

public boolean equalValues(Tree exp1, Tree exp2)
Returns

true when expressions “exp1” and “exp2” can be proved to return equal values.

fillImportedZones

protected void fillImportedZones(int[] zoneNumbers, TapList<ZoneInfo> allStaticZones)

Fills the declaredZoneInfos attached to this SymbolTable, which is some Unit’s importsSymbolTable)

Parameters
  • zoneNumbers – the total numbers (one per kind) of ZoneInfo’s that will be declared by this import SymbolTable.

  • allStaticZones – is the list of all static zones created, ordered from zoneNb 0 up.

findAssocAddresTypeDeclSymbolTable

protected SymbolTable findAssocAddresTypeDeclSymbolTable()

findCompositeTypeSpec

protected WrapperTypeSpec findCompositeTypeSpec(String name)

findProtectedSymbolDecls

protected TapList<SymbolDecl> findProtectedSymbolDecls()
Returns

the list of all protected symbolDecl of the top level of this SymbolTable.

findPublicSymbolDecls

protected TapList<SymbolDecl> findPublicSymbolDecls()
Returns

the list of all public symbolDecl of the top level of this SymbolTable.

firstDeclaredZone

public int firstDeclaredZone(int whichKind)
Returns

the rank of the first zone of kind “whichKind”, declared at this level.

firstDeclaredZone4

public int[] firstDeclaredZone4()

fixImplicits

protected void fixImplicits()

Fixes all incomplete types in the top level of this SymbolTable, that can be fixed using the implicit typing mechanism.

fixImportedDeclarations

protected void fixImportedDeclarations()

Fixes all incomplete types in the top level of this SymbolTable, that can be fixed using the imported symbolTables.

focusToKind

public BoolVector focusToKind(BoolVector vectorAllKind, int kind)

Returns a translation of the given “vectorAllKind”, which is based on the ALLKIND zones numbering, into its subset dealing only with “kind” zones, and using the “kind” zones numbering.

freeDeclaredZone

public int freeDeclaredZone(int whichKind)
Returns

the rank of the last zone of kind “whichKind” (ALLKIND, REALKIND or INTKIND) declared here, plus one. This is also equal to the number of zones declared here and in enclosing SymbolTable’s.

freeDeclaredZone4

public int[] freeDeclaredZone4()

getAdditionalDuplicatedDeclaredZoneInfos

public TapList<Int2ZoneInfo>[] getAdditionalDuplicatedDeclaredZoneInfos()

getAllInterfaceDecls

public TapList<InterfaceDecl> getAllInterfaceDecls(String name)
Returns

all the visible declarations of “name” as an interface.

getAllInterfacedFunctionDecls

public TapList<FunctionDecl> getAllInterfacedFunctionDecls()
Returns

the FunctionDecl’s declarations of this SymbolTable that have an interface.

getAllTopFunctionDecls

public TapList<SymbolDecl> getAllTopFunctionDecls()
Returns

the function declarations in the top level of this SymbolTable.

getAllTopSymbolDecls

public TapList<SymbolDecl> getAllTopSymbolDecls()
Returns

the symbol declarations in the top level of this SymbolTable.

getAllTopVariableDecls

public TapList<SymbolDecl> getAllTopVariableDecls()
Returns

the variable declarations in the top level of this SymbolTable.

getAllTypeDecls

public TapList<SymbolDecl> getAllTypeDecls()
Returns

the all type declarations in this SymbolTable.

getAllVariableDecls

public TapList<SymbolDecl> getAllVariableDecls()
Returns

the variable declarations from this SymbolTable.

getCallGraph

public CallGraph getCallGraph()

getClassDecl

public ClassDecl getClassDecl(Tree classNameTree)

getClassDecl

public ClassDecl getClassDecl(String name)

getCommonRoot

public SymbolTable getCommonRoot(SymbolTable otherSymbolTable)
Returns

null if there is no common enclosing SymbolTable.

getConstantDecl

public VariableDecl getConstantDecl(String name)
Returns

the declaration of constant “name” in this SymbolTable. @return null if no declaration is found.

getDecl

public SymbolDecl getDecl(String name, int kind, boolean top)

Searches symbol “name” in this SymbolTable. Searches and returns the declaration of symbol “name” as a “kind”, that may be TYPE, VARIABLE, FUNCTION, or SYMBOL(meaning any kind). The search is performed only in the top level of this SymbolTable when “top” is true. At all levels otherwise.

Returns

the SymbolDecl when found, null otherwise.

getDecl

public SymbolDecl getDecl(String name, int kind, boolean top, ToObject<SymbolTable> toST)

Same as getDecl(name,kind,top), but returns in “toST” a handle to the container SymbolTable.

getDecl

public SymbolDecl getDecl(String name, int kind1, int kind2, boolean top, ToObject<SymbolTable> toST)

Searches symbol “name” in this SymbolTable. Searches and returns the declaration of symbol “name” as a “kind”, that may be TYPE, VARIABLE, FUNCTION, or SYMBOL(meaning any kind). The search is performed only in the top level of this SymbolTable when “top” is true. At all levels otherwise.

Returns

the SymbolDecl when found, null otherwise.

getDecl

public SymbolDecl getDecl(String name, int kind1, int kind2, int kind3, boolean top)

Searches symbol “name” in this SymbolTable. Searches and returns the declaration of symbol “name” as a “kind”, that may be TYPE, VARIABLE, FUNCTION, or SYMBOL(meaning any kind). The search is performed only in the top level of this SymbolTable when “top” is true. At all levels otherwise.

Returns

the SymbolDecl when found, null otherwise.

getDeclaredKindZones

public TapIntList getDeclaredKindZones(TapIntList zones, int whichKind, boolean withTmps)
Returns

the TapIntList of the “whichKind”-kind zones for all zones in “zones” (ALLKIND declared zones) that are actually of type “whichKind”. [llh] TODO: This method shouldn’t be used, it should be redesigned because for “tmp” zones, there is no notion of whichKind-zones, so WHEN “withTmps” IS TRUE, we return the “zone” itself, whatever “whichKind” is!! Also this method doesn’t take into account side-effect zones. It should be replaced by something like DataFlowAnalyzer.mapExtendedDeclaredToVectorIndex(…).

getDeclaredZoneInfos

public ZoneInfo[] getDeclaredZoneInfos(int kind)

getExistingCopy

public final SymbolTable getExistingCopy(TapList<TapPair<SymbolTable, SymbolTable>> associationsST)

getExistingOrig

public SymbolTable getExistingOrig(TapList<TapPair<SymbolTable, SymbolTable>> associationsST)

getFunctionDecl

public TapList<FunctionDecl> getFunctionDecl(String name, TypeSpec returnType, TypeSpec[] argumentsTypes, boolean checkArgsTypes)
Returns

the declarations of function/method “name” in this SymbolTable with a “returnType” and some “argumentsType”. @return null if no declaration is found.

getFunctionDecl

public TapList<FunctionDecl> getFunctionDecl(String name, TypeSpec returnType, TypeSpec[] argumentsTypes, String className, boolean checkArgsTypes)

getFunctionNotExternalNorInterfaceDecl

protected FunctionDecl getFunctionNotExternalNorInterfaceDecl(String name)

Same as getFunctionDecl, but discards external.

getFunctionNotInterfaceDecl

protected FunctionDecl getFunctionNotInterfaceDecl(String name)

Same as getFunctionDecl, but discards interfaces.

getModule

protected Unit getModule(String name)

When this SymbolTable sees a module named “name”.

Returns

its Unit.

getModuleDecl

public FunctionDecl getModuleDecl(String name)
Returns

the declaration of module “name” in this SymbolTable. @return null if no declaration is found.

getNameSpaceDecl

public NameSpaceDecl getNameSpaceDecl(String name)

getNamedScope

public SymbolTable getNamedScope(String prefixName)

getPointerDestinationVector

public BoolVector getPointerDestinationVector(int pointerRowIndex, Instruction instruction, Block block, BoolMatrix pointerInfo, boolean upstream)
Parameters
  • upstream – true when one must use the pointer destinations upstream the instruction.

Returns

null when not found only: when the pointer dests row is null, meaning implicit-identity, returns explicit-identity non-null BoolVector. This function can be called in 2 ways/contexts: EITHER (during pointer analysis) given the complete pointer info matrix at this time (in arg “pointerInfo”), OR (during any later analysis), with a null “pointerInfo”, but given the current “instruction” and its containing “block”. In this case, the search goes upstream in the instructions and if no info is found, the pointer destination info at the begining of the block is used.

getPointerDestinationZonesTreeHere

public TapList getPointerDestinationZonesTreeHere(TapIntList pointerZones, Instruction instruction, Block block, BoolMatrix pointerInfo, WrapperTypeSpec type, Unit calledUnit, boolean upstream)
Parameters
  • pointerZones – The list of the extended declared ALLKIND zones of the pointer(s).

  • instruction – (Optional) The current Instruction (at which these destinations are required).

  • block – The current Block (which contains the current Instruction).

  • pointerInfo – (Optional) The current info on pointers destination.

  • type – The type of these pointers’ destination.

  • calledUnit – When on a call, the called Unit. May be null otherwise.

  • upstream – true when one must use the pointer destinations upstream the instruction.

Returns

the TapList tree of zones of the destination of the pointer(s) whose zone(s) is in “pointerZones”. The type of the destination of the pointer must be given in “type”. This search is done in the pointer destination context pointerInfo, or that of Instruction “instruction”, or of the beginning of Block “block”. If instruction and block and pointerInfo are null, we have no pointer info available, and therefore we return all possible “target” variables.

getPrefixedNamedScope

public SymbolTable getPrefixedNamedScope(Tree prefixTree)
Returns

the scope, i.e. a SymbolTable, in which must be found the symbols prefixed by “prefixTree::”. For instance if looking for “prefix::a”, getPrefixedNamedScope(ident:”prefix”) is the scope in which we expect to find declaration of “a”. “prefix” may be the name of a nameSpace or of a class. We first search “prefix” as a class name, then as a nameSpace name. If not found (error), we create a nameSpace with that name.

getRequiredDiffVars

public BoolVector getRequiredDiffVars(ActivityPattern pattern)

getSetNameSpaceDecl

public NameSpaceDecl getSetNameSpaceDecl(Tree nameSpaceTree)

getSymbolDecl

public SymbolDecl getSymbolDecl(String name)
Returns

null if no declaration is found.

getSymbolDecl

public SymbolDecl getSymbolDecl(Tree tree)

getToDecl

protected TapList<SymbolDecl> getToDecl(String name, int kind, boolean top, ToObject<SymbolTable> toST)

If toST is provided non-null, fills its head with the definition SymbolTable.

getToDecl

protected TapList<SymbolDecl> getToDecl(String name, int kind1, int kind2, boolean top, ToObject<SymbolTable> toST)

getToDecl

protected TapList<SymbolDecl> getToDecl(String name, int kind1, int kind2, int kind3, boolean top, ToObject<SymbolTable> toST)

getTopClassDecl

public ClassDecl getTopClassDecl(String name)

getTopDecl

public SymbolDecl getTopDecl(String name, int kind)

getTopFunctionDecl

public TapList<FunctionDecl> getTopFunctionDecl(String name, TypeSpec returnType, TypeSpec[] argumentsTypes, boolean checkArgsTypes)
Returns

null if no declaration is found.

getTopFunctionDecl

public TapList<FunctionDecl> getTopFunctionDecl(String name, TypeSpec returnType, TypeSpec[] argumentsTypes, String className, boolean checkArgsTypes)
Returns

null if no declaration is found.

getTopInterfaceDecl

public InterfaceDecl getTopInterfaceDecl(String name)
Returns

the declaration of interface “name” in this SymbolTable. @return null if no declaration is found.

getTopModuleDecl

public FunctionDecl getTopModuleDecl(String name)
Returns

the declaration of module “name” in the toplevel of this SymbolTable. @return null if no declaration is found.

getTopNameSpaceDecl

public NameSpaceDecl getTopNameSpaceDecl(String name)

getTopSymbolDecl

public SymbolDecl getTopSymbolDecl(String name)
Returns

the declaration of symbol “name” in the toplevel of this SymbolTable. @return null if no declaration is found.

getTopTypeDecl

protected TypeDecl getTopTypeDecl(String name)
Returns

the declaration of type “name” in the toplevel of this SymbolTable. @return null if no declaration is found.

getTopVariableDecl

public VariableDecl getTopVariableDecl(String name)
Returns

the declaration of variable “name” in the toplevel of this SymbolTable or null if no declaration is found.

getTopVariableOrConstantDecl

public VariableDecl getTopVariableOrConstantDecl(String name)
Returns

the declaration of variable or constant “name” in the toplevel of this SymbolTable or null if no declaration is found.

getTypeDecl

public TypeDecl getTypeDecl(String name)
Returns

null if no declaration is found.

getTypedFunctionDecl

public FunctionDecl getTypedFunctionDecl(String name, WrapperTypeSpec returnType, WrapperTypeSpec[] argumentsTypes, boolean top, Tree callTree)
Returns

the declaration of function “name” in this SymbolTable. @return null if no declaration is found.

getVariableDecl

public VariableDecl getVariableDecl(String name)
Returns

the declaration of variable “name” in this SymbolTable. @return null if no declaration is found.

getVariableDeclOfRank

public VariableDecl getVariableDeclOfRank(int rank)

getVariableOrConstantDecl

public VariableDecl getVariableOrConstantDecl(String name)
Returns

the declaration of variable or constant “name” in this SymbolTable. @return null if no declaration is found.

getVariableOrConstantOrFuncNameDecl

protected VariableDecl getVariableOrConstantOrFuncNameDecl(String name)
Returns

null if no declaration is found.

hasNoDeclaredZoneInfos

public boolean hasNoDeclaredZoneInfos(int kind)

hidesRef

public boolean hidesRef(Tree tree1, Tree tree2)
Returns

true if write reference “tree1” completely hides “tree2”. Assumes tree1 and tree2 refer to a common zone.

identIsAFunction

public boolean identIsAFunction(Tree varTree)
Returns

true when this “varTree” is an identifier which is known as a function name (or a variable that holds a function name) in the current symbolTable.

importAllClassSymbolTable

protected void importAllClassSymbolTable(SymbolTable parentClassSymbolTable, Unit classUnit, Unit inheritedClassUnit, boolean isVirtualInheritance)

Copy every symbol from parentClassSymbolTable to this. Add a marker containing the inherited class unit.

Parameters
  • parentClassSymbolTable

  • classUnit

  • inheritedClassUnit

  • isVirtualInheritance

importModuleSymbolTable

protected void importModuleSymbolTable(TapTriplet<Unit, Tree, Instruction> oneUse, boolean checkExist)

inCommonZones

public TapIntList inCommonZones()

includePointedElementsInZonesTree

public TapList includePointedElementsInZonesTree(TapList<?> zonesTree, Instruction instruction, BoolMatrix pointerInfo, boolean upstream)

Builds a copy of the given “zonesTree”, in which all pointer zones are followed with the zonesTree of their possible destinations at the current point. The current point in the code is represented by either the ‘instruction” or the current “pointerInfo” matrix. If both “instruction” and “pointerInfo” are null, we make the conservative assumption that all “target” vars may be destinations.

Parameters
  • instruction – The actual Instruction of the expression which gave the “zonesTree”. Used to find current pointer destinations, which is dynamic.

  • pointerInfo – The BoolMatrix of pointer destinations. Needed only when the pointer info is not stored in the instruction, i.e. during pointer analysis itself. Can be null when pointer analysis is done.

  • upstream – true when one must use the pointer destinations upstream the instruction.

isAllocatableAndTarget

public boolean isAllocatableAndTarget(Tree assignedVar)

isCaseDependent

public boolean isCaseDependent()
Returns

whether this SymbolTable is case dependent (e.g. c, java, …) instead of case independent (fortran77, 90, 95).

isEmptyTranslationUnitST

public boolean isEmptyTranslationUnitST()
Returns

true if translationUnit contains global variables definitions either static (variableDecl defined in this translationUnit-symbolTable or global (variable defined in this translationUnit-symbolTable.declarationsBlock with variableDecl in rootCSymbolTable).

isFormalParamsLevel

public boolean isFormalParamsLevel()
Returns

true when this current SymbolTable is the level that contains the declarations of the formal parameters.

isFunctionNamed

public boolean isFunctionNamed(String funcName, String refFuncName)
Returns

true if given “funcName” in the context of this SymbolTable is actually a reference to a function named “refFuncName”. Can be nontrivial with mixed language calls.

isGlobalSymbolTable

public boolean isGlobalSymbolTable()

isTranslationUnitSymbolTable

public boolean isTranslationUnitSymbolTable()

isUseless

protected boolean isUseless()
Returns

true when this SymbolTable defines absolutely nothing new with respect to its basisSymbolTable.

language

public int language()

The language of this SymbolTable. May be -1 for the root SymbolTable.

listOfPointedDestinations

public TapList<String> listOfPointedDestinations(BoolVector destsRow, int[] elemMap, WrapperTypeSpec destinationType)
Returns

a list of Strings that designates all the possible pointer destinations found in the zone vector “destsRow”, including possibly NULL, Undef, or Unknown.

listOfZonesOfValue

public TapIntList listOfZonesOfValue(Tree refExpr, ToBool total, Instruction instruction)

Assuming that “refExpr” is a reference to a memory location, returns the list of the zones that contain the value of “refExpr”. Otherwise complains and returns null.

Parameters
  • refExpr – the given memory reference expression.

  • total – Contains true upon exit iff the value is the complete contents of “refExpr” (out). May be null, in which case it is not used.

  • instruction – The actual Instruction which contains “refExpr”. Used to find dynamic info, such as pointer destinations (in). May be null, in which case conservative assumptions are made.

Returns

“extendedDeclared” zones as defined in DataFlowAnalyzer.

localDeclaredZoneInfo

public ZoneInfo localDeclaredZoneInfo(int zoneNumber, int whichKind)

moveSymbolDeclListUpRec

protected void moveSymbolDeclListUpRec(TapList<SymbolDecl> symbolDecls, SymbolTable targetSymbolTable)

Moves all SymbolDecls in symbolDecls, and all those recursively used, into targetSymbolTable. Sweeps all SymbolTables on the way from this to targetSymbolTable. all SymbolDecls in symbolDecls or recursively used are collected and removed from where they were. Finally they are all inserted back into targetSymbolTable.

mustBeCreated

public boolean mustBeCreated()
Returns

true if translationUnit file must be created.

nestedIn

public boolean nestedIn(SymbolTable symbolTable)
Returns

true iff this SymbolTable is nested in the given “symbolTable”. In other words, “symbolTable” is “this” or a recursive root of “this”.

offsetRef

public static Tree offsetRef(Tree refToStart, WrapperTypeSpec type, int offset)
Returns

an IL expression which is a reference to the place with the given “offset” into the memory object returned by the given expression “refToStart” (“refToStart is of type “type”).

origUnit

public Unit origUnit()

When this SymbolTable’s enclosing Unit results from differentiation of an original Unit.

Returns

this original Unit.

rank

public int rank()
Returns

A unique number used mostly to identify this SymbolTable in debug and trace. Positive number, default initialized to -1.

refOffset

protected int refOffset(Tree ref)

removeDecl

public void removeDecl(String name, int kind, boolean top)

Removes an entry of this SymbolTable.

removeInterfaceDecl

public void removeInterfaceDecl(String name, int kind, boolean top)

retrieveWaitingPtrZoneInfo

public ZoneInfo retrieveWaitingPtrZoneInfo(int ptrZoneNb)

reuseNewSymbolHolder

public NewSymbolHolder reuseNewSymbolHolder(String name, WrapperTypeSpec type, TapList<NewSymbolHolder> excluded)
Returns

an existing NewSymbolHolder of the given name and type in this SymbolTable, excluding the given “excluded” ones (e.g. because they are already in use).

setAdditionalDuplicatedDeclaredZoneInfos

public void setAdditionalDuplicatedDeclaredZoneInfos(TapList<Int2ZoneInfo> additionalZoneInfos, int kind)

setBasisSymbolTable

public void setBasisSymbolTable(SymbolTable basis)

Sets the enclosing level SymbolTable of this SymbolTable.

setCaseDependent

public void setCaseDependent(boolean caseDependent)

Sets the property whether this SymbolTable is case dependent.

setConformingDimension

protected WrapperTypeSpec setConformingDimension(WrapperTypeSpec resultType, WrapperTypeSpec type1, WrapperTypeSpec type2, Tree expression)

setDeclaredZoneInfos

public void setDeclaredZoneInfos(ZoneInfo[] zoneInfos, int kind)

setEmptyImportedZones

protected void setEmptyImportedZones()

setFreeDeclaredZone

public void setFreeDeclaredZone(int freeDZ, int kind)

setImplicitLetters

public void setImplicitLetters(char fromChar, char toChar, WrapperTypeSpec defaultType)

Sets all implicit definitions in this current SymbolTable, from letter “fromStr” to letter “toStr”, to type “defaultType”.

setIsGlobal

public void setIsGlobal()

setIsTranslationUnit

public void setIsTranslationUnit()

setLanguage

public void setLanguage(int language)

Set the language of this SymbolTable. May be -1 for the root SymbolTable.

setOrCumulRequiredDiffVars

public void setOrCumulRequiredDiffVars(ActivityPattern pattern, BoolVector diffVars)

setRank

public void setRank(int rank)

setRootCallGraph

public void setRootCallGraph(CallGraph cg)

setShortName

public void setShortName(String shortName)

Set a short name to designate this SymbolTable.

shortName

public String shortName()

smartCopy

public SymbolTable smartCopy(TapList<TapPair<SymbolTable, SymbolTable>> associationsST, Object targetUnitOrCG, CallGraph targetCG, UnitStorage<Unit> associationsUnits, String copyPrefix)
Returns

a copy of this SymbolTable. When the basis SymbolTable has also been copied, the basis of the copy is set to the copy of the basis. Similarly for copied CallGraph and Unit’s.

solveNewSymbolHolders

public void solveNewSymbolHolders(boolean noCopySuffix)

Solves all the NewSymbolHolder’s that are waiting for declaration in this SymbolTable.

staticValue

protected Object staticValue(Tree tree)

subTreeOfPointedZones

public TapList subTreeOfPointedZones(BoolVector destsRow, int[] elemMap, WrapperTypeSpec destinationType, Tree pathToSubTree)

Same as treeOfPointedZones(), but returns only the sub-tree of zones that concerns the access sub-path “pathToSubTree”. Maybe we can rewrite more efficiently without constructing the complete pointerDestsTree?

symbolDeclOf

protected SymbolDecl symbolDeclOf(Tree instrOrExpr)
Returns

the (deep) SymbolDecl of reference expression “instrOrExpr”.

systemPredefinedZones

public TapIntList systemPredefinedZones()

terminateFunctionDeclarationInstructions

protected void terminateFunctionDeclarationInstructions(Tree declTree)

Terminate Instructions that declare a function name, i.e. : (a) annotate function names with “isFunctionName” true. (b) replace “none” typeTree with the true final return type (without dimensions!).

toString

public String toString()

traceShowAssociationsST

public static void traceShowAssociationsST(TapList<TapPair<SymbolTable, SymbolTable>> associationsST)

Show for trace the associations context from original SymbolTable’s to (smart)copied SymbolTable’s

treeOfZonesOfValue

public TapList<?> treeOfZonesOfValue(Tree instrOrExpr, ToBool total, Instruction instruction, BoolMatrix pointerInfo)
Parameters
  • instrOrExpr – The var-reference expression whose tree of zones is requested (in).

  • total – Contains true upon exit iff the value is the complete contents of all these zones. May be null, in which case it is not used.

  • instruction – The actual Instruction which contains “instrOrExpr”. Used to find dynamic info, such as pointer destinations (in). May be null, in which case conservative assumptions are made.

  • pointerInfo – The BoolMatrix of pointer destinations. Used to find dynamic info on pointer destinations (in). Needed only when the pointer info is not stored in the instruction, i.e. during pointer analysis itself. Can be null when pointer analysis is done.

Returns

the tree of the (structured) zones of the value of “instrOrExpr”. Therefore returns a TapList-tree with TapIntList leaves.

typeCheck

protected WrapperTypeSpec typeCheck(Tree instrOrExpr, boolean expectResult, boolean noFunctionCall, boolean onType, Instruction instruction, ToBool isBeginning, Unit currentUnit)

Type-checks expression “instrOrExpr”, which is an atomic instruction or an expression, in the context of this SymbolTable. @return the computed type for “instrOrExpr”, or null when it has no meaningful type, or when type-checking returned an error. Caution: the returned type may also be (or contain) WrapperTypeSpec(null), which is completely different, and represents an unknown type, that may be infered by side-effect later.

Parameters
  • instrOrExpr – the expression that must be type-checked.

  • expectResult – true when the expression is expected to return a value by its context.

  • noFunctionCall – true means caller guarantees that the expression is in a place that cannot be a function call (e.g. left of assign, overwritten…)

  • onType – true when the expression is a type.

  • instruction – the Instruction that contains the given expression instrOrExpr.

  • isBeginning – contains true when the place of the instruction is such that it may be the definition of a statement-function.

Returns

the type of the given instrOrExpr.

typeOf

public WrapperTypeSpec typeOf(Tree instrOrExpr)
Returns

the type of expression “instrOrExpr” or unKnownType if no type is found.

typesOf

public WrapperTypeSpec[] typesOf(Tree instrOrExpr)
Returns

the types of expression “instrOrExpr”.

unfocusFromKind

public BoolVector unfocusFromKind(BoolVector vectorKind, int kind)

Reciprocal of focusToKind(). Fills the other zones with false

updateImportedFroms

public void updateImportedFroms(TapList<TapPair<SymbolTable, SymbolTable>> associationsST)

At the end of copying for differentiation, update the “importedFrom” pointers from each imported SymbolDecl to the original SymbolDecl that it imports.

varHasModifier

public boolean varHasModifier(Tree assignedVar, String modifier)
Parameters
  • assignedVar – tree containing a Variable.

  • modifier – String “allocatable”, “target”, …

Returns

true if the corresponding Variable has a modifier equals to the modifier parameter.

varIsIntentIn

public boolean varIsIntentIn(Tree varTree)
Returns

true when this “varTree” is a reference to a variable which is declared as “INTENT IN”.

zonesNb

public final int zonesNb(int zoneKind)
Returns

the number of zones of kind “zoneKind” at the scope of this SymbolTable.

zonesOfDestination

public TapList zonesOfDestination(TapList<?> treeOfZones, WrapperTypeSpec pointerType, Instruction instruction, BoolMatrix pointerInfo)

Utility identical to the op_pointerAccess case of treeOfZonesOfValue().

zonesUsedByExp

public BoolVector zonesUsedByExp(Tree instrOrExpr, Instruction instruction)
Returns

a BoolVector of all the (private) (extended declared) (ALLKIND) zones that are used (i.e. actually read) during the evaluation of expression “instrOrExpr”. Each zone is encoded as a single bit in the resulting BoolVector. The map of the zones in the resulting BoolVector is: {0 ; 0 ; nDZones}.