Difference between revisions of "XCSG:Variable"

From AtlasWiki
Jump to: navigation, search
(Specifications: removing AddressableEntity abstraction)
(Specifications: Variables may be tagged with a Visibility)
Line 27: Line 27:
 
| references = [http://docs.oracle.com/javase/specs/jls/se5.0/html/classes.html#8.3.1.4 JLS, SE 5.0: volatile fields]
 
| references = [http://docs.oracle.com/javase/specs/jls/se5.0/html/classes.html#8.3.1.4 JLS, SE 5.0: volatile fields]
 
}}
 
}}
 +
 +
{{TaggedWithEnumeration | Visibility}}
  
 
== Language mappings ==
 
== Language mappings ==

Revision as of 18:08, 15 April 2014

The term variable is used by many authors to refer to any assignable entity. Unfortunately the same term is used by others to refer only to local variables. In XCIL, we use the terms Variable (for any assignable entity) and LocalVariable (for a variable defined by a method body).

The semantics of Variable are those common to all its subtypes, i.e. Attribute, AssociationEnd, ArrayElement, Parameter, and LocalVariable.

The meaning of volatile is that common to C++ and Java.


Specifications

Metaclass Variable
Extends Node
Description An assignable entity that represents a portion of the system’s state, i.e. an attribute, an array element, an out or inout parameter, or a local variable.
Direct Subkinds CallInput, Field, ProgramVariable, StackVariable
All Superkinds Node, ModelElement
Specified In Edges
In Edge Predecessor Multiplicity Description
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
Out Edge Successor Multiplicity Description
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
In Edge Predecessor Multiplicity Description
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.

Inherited From In Edge Predecessor Multiplicity Description
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
InterproceduralDataFlow DataFlow (Node) Represents data flows between Functions, or involving Variables visible to multiple Functions.

Inherited From Out Edge Successor Multiplicity Description
Node Contains Node Indicates that the predecessor contains the successor in a sense specified by the specific type of Contains edge.
Tag immutable
Description Present if the variable cannot be changed after initialization.
Tag volatile
Description Present if the code indicates the variable requires special treatment because the variable's value can be changed externally, e.g. by hardware.
Tag memoryBarrier
Description Indicates that reading from the variable creates a "happens before" relationship to any code (in any thread) that previously wrote to the variable.
Enumeration Visibility
Description The visibility of a Type, Variable, or Function in its Namespace.

Language mappings

The volatile tag maps exactly to the volatile keyword in C and C++. Note that other languages, notably C# and Java (since 1.5), use the same keyword, but additionally require a memory barrier or "happens after" relationship; for such variables, both the volatile and memoryBarrier tags should be present.

Individual language mappings are provided for each subtype of Variable (Attribute, AssociationEnd, ArrayElement, Parameter, and LocalVariable).