Package com.ibm.wala.cast.tree
Interface CAstEntity
-
- All Known Implementing Classes:
AbstractClassEntity
,AbstractCodeEntity
,AbstractEntity
,AbstractGlobalEntity
,AbstractScriptEntity
,DelegatingEntity
public interface CAstEntity
The assumption is that abstract syntax trees pertain to particular programming language constructs, such as classes, methods, programs and the like. Thus, the expectation is that users of CAst will typically be communicating such entities, and this interface is meant to give them a mechanism to do this. The set of kinds that are currently in this file is not meant to be exhaustive, and should be extended as needed for any new languages that come along.
-
-
Field Summary
Fields Modifier and Type Field Description static int
FIELD_ENTITY
This entity is a field in an object-oriented language.static int
FILE_ENTITY
This entity is a source file (i.e.static int
FUNCTION_ENTITY
This entity is a function.static int
GLOBAL_ENTITY
This entity represents a global variblestatic int
MACRO_ENTITY
This entity is a macro.static int
RULE_ENTITY
This entity represents a rule in a logic language.static int
SCRIPT_ENTITY
This entity is a program script for a scripting language.static int
SUB_LANGUAGE_BASE
Languages that introduce new kinds of CAstEntity should use this number as the base of integers chosen to denote the new entity types.static int
TYPE_ENTITY
This entity is a type in an object-oriented language.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Map<CAstNode,Collection<CAstEntity>>
getAllScopedEntities()
Some programming language constructs have a lexical structure.Collection<CAstAnnotation>
getAnnotations()
Returns the set of any annotations this entity may haveint
getArgumentCount()
Some programming language constructs have a specific number of arguments.CAstNode[]
getArgumentDefaults()
Some programming language constructs allow arguments to have default values.String[]
getArgumentNames()
Some programming language constructs have named arguments.CAstNode
getAST()
The CAPA AST of this entity.CAstControlFlowMap
getControlFlow()
The control flow map for the CAPA AST of this entity.int
getKind()
What kind of entity is this? The answer should be one of the constants in this file.String
getName()
Some programming language constructs have names.CAstNodeTypeMap
getNodeTypeMap()
The map from CAstNodes to types.CAstSourcePositionMap.Position
getPosition()
The source position of this entity.Collection<CAstQualifier>
getQualifiers()
Returns an Iterator over the qualifiers of the given entity, if it has any, e.g., "final", "private".Iterator<CAstEntity>
getScopedEntities(CAstNode construct)
Some programming language constructs have a lexical structure.String
getSignature()
Some programming language constructs have signatures, which are like names but usually have some detail to distinguish the construct from others with the same name.CAstSourcePositionMap
getSourceMap()
The map of CAstNodes to source positions for the CAPA AST of this entity.CAstType
getType()
The CAst type of this entity.
-
-
-
Field Detail
-
FUNCTION_ENTITY
static final int FUNCTION_ENTITY
This entity is a function. Children: in JavaScript, FUNCTION_ENTITY's; in Java, none.- See Also:
- Constant Field Values
-
SCRIPT_ENTITY
static final int SCRIPT_ENTITY
This entity is a program script for a scripting language. Children: in JavaScript, FUNCTION_ENTITY's(?); doesn't occur in Java.- See Also:
- Constant Field Values
-
TYPE_ENTITY
static final int TYPE_ENTITY
This entity is a type in an object-oriented language. Children: typically, immediately enclosed FIELD_ENTITY's, FUNCTION_ENTITY's, and TYPE_ENTITY's.- See Also:
- Constant Field Values
-
FIELD_ENTITY
static final int FIELD_ENTITY
This entity is a field in an object-oriented language. Children: usually, none- See Also:
- Constant Field Values
-
FILE_ENTITY
static final int FILE_ENTITY
This entity is a source file (i.e. a compilation unit).- See Also:
- Constant Field Values
-
RULE_ENTITY
static final int RULE_ENTITY
This entity represents a rule in a logic language.- See Also:
- Constant Field Values
-
MACRO_ENTITY
static final int MACRO_ENTITY
This entity is a macro. A macro is a code body that only makes sense when expanded in the context of another code body.- See Also:
- Constant Field Values
-
GLOBAL_ENTITY
static final int GLOBAL_ENTITY
This entity represents a global varible- See Also:
- Constant Field Values
-
SUB_LANGUAGE_BASE
static final int SUB_LANGUAGE_BASE
Languages that introduce new kinds of CAstEntity should use this number as the base of integers chosen to denote the new entity types.- See Also:
- Constant Field Values
-
-
Method Detail
-
getKind
int getKind()
What kind of entity is this? The answer should be one of the constants in this file. This has no meaning to the CAPA AST interfaces, but should be meaningful to a given producer and consumer of an entity.
-
getName
String getName()
Some programming language constructs have names. This should be it, if appropriate, and null otherwise.
-
getSignature
String getSignature()
Some programming language constructs have signatures, which are like names but usually have some detail to distinguish the construct from others with the same name. Signatures often denote typing information as well, but this is not required. This method should return a signature if appropriate, and null otherwise.
-
getArgumentNames
String[] getArgumentNames()
Some programming language constructs have named arguments. This should be their names, if appropriate. Otherwise, please return an array of size 0, since null can be a pain.
-
getArgumentDefaults
CAstNode[] getArgumentDefaults()
Some programming language constructs allow arguments to have default values. This should be those defaults, one per named argument above. Otherwise, please return an array of size 0, since null can be a pain.
-
getArgumentCount
int getArgumentCount()
Some programming language constructs have a specific number of arguments. This should be that number, if appropriate, and 0 otherwise.
-
getAllScopedEntities
Map<CAstNode,Collection<CAstEntity>> getAllScopedEntities()
Some programming language constructs have a lexical structure. This should be those constructs that are directly inside the current one. The result of this method is a map from source construct to the set of entities induced by that construct. Entities induced by no particular construct are mapped by the null key.
-
getScopedEntities
Iterator<CAstEntity> getScopedEntities(CAstNode construct)
Some programming language constructs have a lexical structure. This should be those constructs that are directly inside the current one. The result of this method is the scoped entities induced by the construct `construct' (i.e. a node of the AST returned by Enclosed entities not induced by a specific AST node are mapped by the construct 'null'.
-
getAST
CAstNode getAST()
The CAPA AST of this entity.
-
getControlFlow
CAstControlFlowMap getControlFlow()
The control flow map for the CAPA AST of this entity.
-
getSourceMap
CAstSourcePositionMap getSourceMap()
The map of CAstNodes to source positions for the CAPA AST of this entity.
-
getPosition
CAstSourcePositionMap.Position getPosition()
The source position of this entity.
-
getNodeTypeMap
CAstNodeTypeMap getNodeTypeMap()
The map from CAstNodes to types. Valid for nodes that have an explicitly declared type (e.g. local vars).
-
getQualifiers
Collection<CAstQualifier> getQualifiers()
Returns an Iterator over the qualifiers of the given entity, if it has any, e.g., "final", "private".
-
getType
CAstType getType()
The CAst type of this entity.
-
getAnnotations
Collection<CAstAnnotation> getAnnotations()
Returns the set of any annotations this entity may have
-
-