XCSG:ProgramVariable

From AtlasWiki
Revision as of 19:26, 15 May 2014 by Pi (Talk | contribs) (Text from StaticLocalVariable for integration/cleanup)

Jump to: navigation, search

A ProgramVariable has a program lifetime, in other words after it is first initialized it remains until the program ends. Examples of ProgramVariables are static fields in C++ and Java, and static local variables in C.

Specification

Metaclass ProgramVariable
Extends Variable
Description A Variable that remains until the program ends.
Direct Subkinds ClassVariable, Enumerator, GlobalVariable, C:StaticLocalVariable
All Superkinds Variable, Node, ModelElement
Specified In Edges
In Edge Predecessor Multiplicity Description
HasVariable Package 1 Links a Classifier or Package to one of its Variables.
Classifier 1
InterproceduralDataFlow Assignment Represents data flows between Functions, or involving Variables visible to multiple Functions.

Inherited From In Edge Predecessor Multiplicity Description
Variable DataFlow (Edge) DataFlow (Node) Connects DataFlow nodes to one another and to Variables, linking the origin of data to locations that it is modified or consumed.
Specified Out Edges

Inherited From Out Edge Successor Multiplicity Description
Variable DataFlow (Edge) DataFlow (Node) Connects DataFlow nodes to one another and to Variables, linking the origin of data to locations that it is modified or consumed.

DefinedAs TypeAlias 0..1 Connects a Variable or DataFlow node which received its Type via a TypeAlias (such as a C/C++ typedef) to that TypeAlias.
InstanceVariableWritten InstanceVariableAssignment Connects a value (DataFlow (Node) or Variable) representing an object instance to an InstanceVariableAssignment representing a write to a field of that object.
TypeOf Type 1 Links a Variable or DataFlow node to its Type
Known Possible In Edges

Inherited From In Edge Predecessor Multiplicity Description
Variable HasVariable Namespace 1 Links a Classifier or Package to one of its Variables.

InterproceduralDataFlow Assignment Represents data flows between Functions, or involving Variables visible to multiple Functions.
Node Contains Node 1 Indicates that the predecessor contains the successor in a sense specified by the specific type of Contains edge.
Known Possible Out Edges
Out Edge Successor Multiplicity Description
LocalDataFlow DataFlow (Node) Within the scope of a particular Function, connects Parameters to DataFlow nodes, and DataFlow nodes to one another, indicating flow of information within that Function.

Inherited From Out Edge Successor Multiplicity Description
Variable InterproceduralDataFlow DataFlow (Node) Represents data flows between Functions, or involving Variables visible to multiple Functions.
Node Contains Node Indicates that the predecessor contains the successor in a sense specified by the specific type of Contains edge.

Text from StaticLocalVariable for integration/cleanup

Static local variables are variables that are visible only within a particular Function, but are only initialized once, and retain their value between invocations of that function.

Static local variables are typically treated in DataFlow in a manner similar to Parameters: the StaticLocalVariable node itself represents the initial value of the variable when the method was invoked, and Assignment nodes represent the values which may be assigned to it later, in a manner resembling static single assignment.

The StaticLocalVariable node itself will receive incoming DataFlow edges from its one-time Initialization, from any Assignment node which represents the final value of the static local variable for some possible execution path, and possibly from itself, if its initial value can also be its final value for some execution path. The initialization is typically LocalDataFlow, the cross-invocation edges are InterproceduralDataFlow.

This analysis excludes data flows that may be possible if the Function can be called concurrently from multiple threads, and is not serialized using some form of mutual exclusion. In the rare case that such flows must be considered, it may instead be preferable to connect each assignment to, and each read from the StaticLocalVariable node using InterproceduralDataFlow edges.