Difference between revisions of "XCSG:TypeAlias"

From AtlasWiki
Jump to: navigation, search
(Created page with "An AliasType introduces a synonym for an existing type analogous to the use of typedef in C++. The semantics of AliasType are those common to the UML Meta-Object Facility (MO...")
 
m (TheodoreMurdock moved page TypeAlias to XCSG:TypeAlias)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
An AliasType introduces a synonym for an existing type analogous to the use of typedef in C++.
+
A TypeAlias introduces a synonym for an existing type, representing a typedef in C or C++, or any similar language construct that creates a new name for a type, but not a new type.
  
The semantics of AliasType are those common to the UML Meta-Object Facility (MOF) definition of AliasType and the C++ definition of typedef.
+
A TypeAlias in XCSG is not considered a [[Type]], but provides a synonym (alias) for a given type, the [[AliasedType]].  This type may be an existing type, or an instantiation of a type with template parameters.
  
An AliasType does not introduce a new type, but provides a synonym (alias) for a given type, the referenced type.  This type may be an existing type. or an instantiation of a type with template parameters.
+
A TypeAlias is never the [[TypeOf]] a [[Variable]] or [[DataFlow (Node)|DataFlow]] node, instead the [[TypeOf]] edge points directly to the aliased [[Type]], while an additional [[DefinedAs]] edge points to the TypeAlias used to declare the type.
  
An AliasType may appear anywhere the referenced type may appear.
+
A TypeAlias defined using another TypeAlias points its [[AliasedType]] edge to that TypeAlias, rather than directly to the [[Type]] it is an alias of.
  
The semantics of the model are unchanged if all occurences of an AliasType are replaced by occurences of the referenced type.
+
It is generally considered preferable that DataFlow nodes should be connected to a TypeAlias via a [[DefinedAs]] edge if they are closely associated with a [[Variable]] defined using a TypeAlias, such as [[Assignment]] nodes representing the static single assignment form of a [[LocalVariable]] (provided this is consistent with the language's rules regarding the type of the result of an assignment).  Whether such information should be retained in forward data flow from that point is left to the analyzer (but, again, should never continue forward if doing so would violate the type rules of the language indexed).
  
An AliasType is similar to a subtype of a UML Class or Datatype.  AliaasTypes differ from subtypes, however, in that a) they cannot extend their parent classifier definition, and b) if more than one alias is created for a type, they are treated as the same type with regard to assignment and type compatibility.
+
== Specification ==
 
+
{{Node
In this regard, the use of subtypes is generally preferable since subtypes can be extended to include new attributes and operations, and since they are strongly typed (are not treated as the same type, but as distinct types, with explicit conversions between them).
+
| extends = Node
 
+
| description = An alias for an existing type.
== Specifications ==
+
}}
 
+
{| class="atlaswikitable" style="width:100%"
+
! width="160" align="left" | Metaclass
+
| AliasType
+
|-
+
! Extends
+
| [[Classifier]]
+
|-
+
! Description
+
| An alias for an existing type
+
|-
+
! References
+
| AliasType [6, p. 3-15, table entry], [6, p. 3-32, Figure 3-4, MOF Data Type Elements], [6, p. 3-36], typedef [44], [46]
+
|}
+
 
+
 
+
 
+
== Language mappings ==
+
AliasType maps to typedef in C++.
+

Latest revision as of 17:11, 30 May 2014

A TypeAlias introduces a synonym for an existing type, representing a typedef in C or C++, or any similar language construct that creates a new name for a type, but not a new type.

A TypeAlias in XCSG is not considered a Type, but provides a synonym (alias) for a given type, the AliasedType. This type may be an existing type, or an instantiation of a type with template parameters.

A TypeAlias is never the TypeOf a Variable or DataFlow node, instead the TypeOf edge points directly to the aliased Type, while an additional DefinedAs edge points to the TypeAlias used to declare the type.

A TypeAlias defined using another TypeAlias points its AliasedType edge to that TypeAlias, rather than directly to the Type it is an alias of.

It is generally considered preferable that DataFlow nodes should be connected to a TypeAlias via a DefinedAs edge if they are closely associated with a Variable defined using a TypeAlias, such as Assignment nodes representing the static single assignment form of a LocalVariable (provided this is consistent with the language's rules regarding the type of the result of an assignment). Whether such information should be retained in forward data flow from that point is left to the analyzer (but, again, should never continue forward if doing so would violate the type rules of the language indexed).

Specification

Metaclass TypeAlias
Extends Node
Description An alias for an existing type.
Direct Subkinds C:Enum
All Superkinds Node, ModelElement
Specified In Edges
In Edge Predecessor Multiplicity Description
AliasedType TypeAlias Connects a TypeAlias to the Type or TypeAlias it was declared to duplicate.
DefinedAs Variable Connects a Variable or DataFlow node which received its Type via a TypeAlias (such as a C/C++ typedef) to that TypeAlias.
DataFlow (Node)
Specified Out Edges
Out Edge Successor Multiplicity Description
AliasedType Type 0..1 Connects a TypeAlias to the Type or TypeAlias it was declared to duplicate.
TypeAlias 0..1
Known Possible In Edges

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

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.