SymbolDecl

public class SymbolDecl

A symbol declaration, i.e. and entry in a SymbolTable.

Fields

accessInfo

public TapList<String> accessInfo

Access info on this symbol e.g. “const” etc.

className

protected String className

copySymbolDecl

protected SymbolDecl copySymbolDecl

Temporary: link to the copy of this SymbolDecl.

defPositions

public TapList<Tree> defPositions

dependsOn

public TapList<SymbolDecl> dependsOn

The list of symbols defined in the same SymbolTable level, that are used by this symbol declaration, and must therefore be declared before this symbol is declared.

hasAllocatableInstruction

public boolean hasAllocatableInstruction

importedFrom

public TapPair<SymbolDecl, SymbolTable> importedFrom

When this SymbolDecl was IMPORTed from another SymbolTable, keeps the link to the original SymbolDecl and SymbolTable

inheritanceTree

protected InheritanceTree inheritanceTree

Useful to know what are the different notations leading to the same copy (a tree of this list)

isATrueSymbolDecl

public boolean isATrueSymbolDecl

isConsideredRemoved

public boolean isConsideredRemoved

Sometimes a SymbolDecl must be replaced with another, but the old SymbolDecl must remain for a while because someone will look for it (see all the “update” functions that replace FOO with FOO_NODIFF). Instead of actually removing the SymbolDecl in a later sweep, we may just mark it as “isConsideredRemoved” to ensure TreeGen will not regenerate a declaration for it.

kind

public int kind

nameTree

public Tree nameTree

symbol

public String symbol

toIsActive

protected ToBool toIsActive

Wrapper around a boolean so that every copy of the same original symbolDecl shares the same differentiation status.

underscoreToFortran

public boolean underscoreToFortran

True for C symbol names ending in “_” that represent a Fortran symbol, thus using the old/default convention that does not require the BIND declaration.

Constructors

SymbolDecl

protected SymbolDecl()

SymbolDecl

protected SymbolDecl(String name, int kind)

SymbolDecl

protected SymbolDecl(Tree identTree, int kind)

Methods

accumulateZones

public void accumulateZones(TapList intTree)

addExtraInfo

public void addExtraInfo(TapList<String> info)

addInfosInList

public static TapList<String> addInfosInList(TapList<String> extraInfo, TapList<String> newInfos, SymbolDecl symbolDecl)

addUsedSymbolsInExpr

public static void addUsedSymbolsInExpr(Tree expression, TapList<SymbolDecl> toUsedSymbols, SymbolTable symbolTable, TapList<String> undeclaredSymbols, boolean top, boolean strict)

Finds all symbols used in “expression”, that must be declared before “expression”, and that are defined in (the current top level of) “symbolTable”. When “top” is true, accumulates only symbols found in the top of “symbolTable”. Accumulates them in the tail of “toUsedSymbols”.

Parameters
  • toUsedSymbols – a hatted list (TapList starting with a null) that accumulates the used symbols

  • top – when true, searches VariableDecl’s only in the top of “symbolTable”.

  • strict – true, variable in Common are added to its “UsedSymbols”

allocateZones

public void allocateZones(ZoneAllocator zoneAllocator, SymbolTable symbolTable, Unit declarationUnit)

Assuming that this SymbolDecl has associated memory, allocate the zones for this memory, and create the corresponding ZoneInfo’s. When these zones are already allocated/created, it means this SymbolDecl is a global, and we must tell the enclosing importsSymbolTable to later build a proxy ZoneInfo for it.

build

public static SymbolDecl build(WrapperTypeSpec typeSpec, TapList<String> accessInfo, boolean isPointer, Tree declarator, int flag, SymbolTable symbolTable, Instruction instruction, TapList<SymbolDecl> typeUsedSymbols)

buildTypeSpecFromArgs

protected static TapList<WrapperTypeSpec> buildTypeSpecFromArgs(SymbolTable symbolTable, Instruction instruction, TapList<SymbolDecl> toTypeUsedSymbols, Tree[] argDecls, ToBool isVariableArgList)

collectImportedSiblingsDecls

public static void collectImportedSiblingsDecls(SymbolDecl symbolDecl, TapList<TapPair<SymbolTable, TapList<SymbolDecl>>> siblingDecls)

collects into siblingDecls (must be a hatted list) for each SymbolDecl’s of which the given “symbolDecl” is a same-name copy built by an import (aka USE), the pair of the original SymbolDecl and the SymbolTable it belongs to.

collectSiblingDecl

public static void collectSiblingDecl(TapList<TapPair<SymbolTable, TapList<SymbolDecl>>> siblingDecls, SymbolDecl symbolDecl, SymbolTable symbolTable)

Collects into the collection “siblingDecls” the pair of “symbolDecl” and the SymbolTable “symbolDecl” belongs to.

Parameters
  • siblingDecls – the current list of “sibling” declarations collected. It is a hatted list, ans all declarations must concern the same symbol with same name. All found declarations are grouped per owner SymbolTable, rootmost last.

  • symbolDecl – The symbolDecl we want to collect into “siblingDecls”

  • symbolTable – The SymbolTable that owns “symbolDecl”.

collectUsedTrees

public void collectUsedTrees(TapList<Tree> toUsedTrees, TapList<TypeSpec> toDejaVu)

Collects into toUsedTrees all expressions that are needed for the declaration of this SymbolDecl.

Parameters
  • toUsedTrees – TapList of used Tree

  • toDejaVu – TapList of TypeSpec

copy

protected static SymbolDecl copy(SymbolDecl symbol2copy)

copy

protected SymbolDecl copy(TapList<TapPair<SymbolTable, SymbolTable>> associationsST, UnitStorage<Unit> associationsUnits)

Build a rather shallow copy of this SymbolDecl, suitable for SymbolTable.copy() TypeDecl’s are not copied. Remember the copy in this symbolDecl’s “copySymbolDecl” field, so as to build a single copy.

copyLinksIntoCopy

protected void copyLinksIntoCopy(SymbolDecl copyDecl, TapList<TapPair<SymbolTable, SymbolTable>> associationsST)

dependsOn

public TapList<SymbolDecl> dependsOn()

dump

public void dump(int indent)

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

Parameters
  • indent – the amount of indentation to be used for this printing (not used at present).

eraseDiffSymbolHolder

protected void eraseDiffSymbolHolder(int diffSort)

extraInfo

public TapList<String> extraInfo()

formalArgRankOrResultZero

public int formalArgRankOrResultZero()

fromImplicitType

public final TypeSpec fromImplicitType()

fromInclude

protected Instruction fromInclude()

getDiffSymbolHolder

public NewSymbolHolder getDiffSymbolHolder(int diffSort, ActivityPattern pattern, int replica)
Returns

the NewSymbolHolder that has been stored by setDiffSymbolHolder() as the differentiated symbol of this SymbolDecl for the given diffSort.

hasDiffSymbolHolders

public boolean hasDiffSymbolHolders()

hasInstructionWithRootOperator

public boolean hasInstructionWithRootOperator(int operator, String value)

hasInstructionWithRootOperatorAndArrayDeclarator

public boolean hasInstructionWithRootOperatorAndArrayDeclarator(int operator)

hasInterfaceInstruction

public boolean hasInterfaceInstruction()

hasMainInstruction

public boolean hasMainInstruction()

hasModifier

public boolean hasModifier(String modifier)

hasOtherCombinableDeclarationPart

public boolean hasOtherCombinableDeclarationPart()

hasOtherInstruction

public boolean hasOtherInstruction()

hasPrivateModifier

protected boolean hasPrivateModifier(TapList<SymbolDecl> addSymbolDecls)

hasProtectedModifier

protected boolean hasProtectedModifier(TapList<SymbolDecl> addSymbolDecls)

hasPublicModifier

protected boolean hasPublicModifier(TapList<SymbolDecl> addSymbolDecls)

isA

public boolean isA(int testKind)
Returns

true when this SymbolDecl is of the given kind “testKind” The kind may be SYMBOL, VARIABLE, FIELD, FUNCTION, TYPE, CONSTANT, FUNCNAME, INTERFACE, CLASS, NAMESPACE.

isActive

public boolean isActive()

isActive true means: for this SymbolDecl, there exists a derivative, i.e. another symbolDecl which contains the derivative of this one.

isActiveSymbolDecl

public boolean isActiveSymbolDecl()

isCconst

public boolean isCconst()

isContainedFunctionDeclDeclared

public boolean isContainedFunctionDeclDeclared(Unit inUnit)

isDifferentiableSymbolDecl

public boolean isDifferentiableSymbolDecl(int diffKind, boolean diffConstants)

isExtern

public boolean isExtern()

isExternal

public boolean isExternal()

isExternalDeclared

public boolean isExternalDeclared(TapList<Instruction> instructions)

isExternalDeclared

public boolean isExternalDeclared(Instruction instruction)

isIntrinsicDeclared

public boolean isIntrinsicDeclared(TapList<Instruction> instructions)

isIntrinsicDeclared

public boolean isIntrinsicDeclared(Instruction instruction)

isOptional

public boolean isOptional()

isPrivate

public boolean isPrivate()

isProtected

public boolean isProtected()

isPublic

public boolean isPublic()

isReference

public boolean isReference()

isShared

public boolean isShared()

isSystemPredefined

public boolean isSystemPredefined()

isTarget

public boolean isTarget(WrapperTypeSpec modelTypeSpec)
Returns

true when this SymbolDecl is a target and its type matches the given “modelTypeSpec”.

isVarDeclared

public boolean isVarDeclared(TapList<Instruction> instructions)

kind

public int kind()

recomputeDependsOn

protected void recomputeDependsOn(SymbolTable symbolTable)

replaceDiffSymbolHolder

protected void replaceDiffSymbolHolder(NewSymbolHolder oldNSH, NewSymbolHolder newNSH)

For every NewSymbolHolder that is stored in this SymbolDecl (in provision of the moment when this Symboldecl will receive its finalname), replace it with newNSH if it was oldNSH. This is used when oldNSH is absorbed by newNSH.

sameOriginDecl

public static boolean sameOriginDecl(SymbolDecl decl1, SymbolDecl decl2)

setActive

public void setActive(boolean act)

setActive

public void setActive()

setCommonInstr

public void setCommonInstr(boolean val)

setCommonWithArrayDeclaratorInstr

public void setCommonWithArrayDeclaratorInstr(boolean val)

setConstantKind

public void setConstantKind()

setDiffSymbolHolder

public void setDiffSymbolHolder(int diffSort, ActivityPattern pattern, int replica, NewSymbolHolder nSH)

Puts the NewSymbolHolder “nSH” as the differentiated symbol of this SymbolDecl, for the given diffSort and for the given ActivityPattern and for the given replica number. This is the default implementation, that uses only “diffSort”, not “pattern” not “replica”. “diffSort” is here because there may be different coexisting derivative symbols for a given original symbol, for example F_FWD, F_BWD, F_B for a given function F. “pattern” is used only for FunctionDecl’s. “replica” is used only for VariableDecl’s.

setExternalInstr

public void setExternalInstr(boolean val)

setExtraInfo

public void setExtraInfo(TapList<String> info)

setFromImplicitType

public final void setFromImplicitType(TypeSpec implicitType)

setFromInclude

protected void setFromInclude(Instruction fromInc)

setInstruction

public void setInstruction(Instruction instr)

Declare that this SymbolDecl already has an existing declaration, made by Instruction “instr” that is located in the given “code”.

Parameters
  • instr – The Instruction that contains the existing declaration of SymbolDecl.

setInstruction

public void setInstruction(SymbolDecl model)

setInterfaceInstr

public void setInterfaceInstr(boolean val)

setMainDeclInstr

public void setMainDeclInstr(boolean val)

setNoneInstruction

public void setNoneInstruction()

setNullInstruction

public void setNullInstruction()

setNullInstructionIfNone

protected void setNullInstructionIfNone()

setReference

public void setReference()

setShared

public void setShared()

setSystemPredefined

public void setSystemPredefined()

setZones

public void setZones(TapList intTree)

shareActivity

public void shareActivity(SymbolDecl model)

shareActivity

public void shareActivity(ToBool sharedActivity)

toString

public String toString()

type

public WrapperTypeSpec type()

zones

public TapList zones()