Difference between revisions of "XCSG:Variable"

From AtlasWiki
Jump to: navigation, search
(Specifications: reordering)
(Specifications: Add "restrict" tag)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
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).
+
A Variable in XCSG is a named assignable entity.
 
+
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.  
+
  
 +
The semantics of Variable are those common to all its subtypes.
  
 
== Specifications ==
 
== Specifications ==
 
{{Node
 
{{Node
| extends = AddressableEntity
+
| 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.
+
| description = A named assignable entity that represents a portion of the system’s state.
 
}}
 
}}
  
Line 18: Line 15:
  
 
{{XCSGTag
 
{{XCSGTag
| name = volatile
+
| name = volatileVariable
 
| description = Present if the code indicates the variable requires special treatment because the variable's value can be changed externally, e.g. by hardware.
 
| description = Present if the code indicates the variable requires special treatment because the variable's value can be changed externally, e.g. by hardware.
 
}}
 
}}
  
 
{{XCSGTag
 
{{XCSGTag
| name = memoryBarrier
+
| name = happensBefore
 
| description = Indicates that reading from the variable creates a "happens before" relationship to any code (in any thread) that previously wrote to the variable.
 
| description = Indicates that reading from the variable creates a "happens before" relationship to any code (in any thread) that previously wrote to the variable.
 
| 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]
 
}}
 
}}
 +
 +
{{XCSGTag
 +
| name = restrict
 +
| description = Indicates a promise on the part of the programmer that the tagged [[Variable]] (which must be an instance of a [[Pointer]] type) is the only way to access the memory it points to; that is, that no other pointer will be used to alias the same range of memory, permitting the compiler to perform optimizations that would cause errors if the promise is not fulfilled.
 +
}}
 +
 +
{{TaggedWithEnumeration | Visibility}}
  
 
== Language mappings ==
 
== Language mappings ==
  
The <code>volatile</code> tag maps exactly to the <code>volatile</code> 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 <code>volatile</code> and <code>memoryBarrier</code> tags should be present.
+
The <code>volatile</code> tag maps exactly to the <code>volatile</code> keyword in C and C++. Note that other languages, notably Java (since 1.5), use the same keyword, but additionally require a memory barrier or "happens before" relationship between writes to the variable and later reads; for such variables, both the <code>volatile</code> and <code>memoryBarrier</code> tags should be present.
  
 
Individual language mappings are provided for each subtype of Variable (Attribute, AssociationEnd, ArrayElement, Parameter, and LocalVariable).
 
Individual language mappings are provided for each subtype of Variable (Attribute, AssociationEnd, ArrayElement, Parameter, and LocalVariable).

Latest revision as of 20:31, 9 December 2014

A Variable in XCSG is a named assignable entity.

The semantics of Variable are those common to all its subtypes.

Specifications

Metaclass Variable
Extends Node
Description A named assignable entity that represents a portion of the system’s state.
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 volatileVariable
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 happensBefore
Description Indicates that reading from the variable creates a "happens before" relationship to any code (in any thread) that previously wrote to the variable.
Tag restrict
Description Indicates a promise on the part of the programmer that the tagged Variable (which must be an instance of a Pointer type) is the only way to access the memory it points to; that is, that no other pointer will be used to alias the same range of memory, permitting the compiler to perform optimizations that would cause errors if the promise is not fulfilled.
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 Java (since 1.5), use the same keyword, but additionally require a memory barrier or "happens before" relationship between writes to the variable and later reads; 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).