?? 1076_7.html
字號:
<i>function</i>_name [ ( actual_parameter_part ) ]
actual_parameter_part ::= <i>parameter</i>_association_list
</pre>
<p>For each formal parameter of a function, a function call must specify exactly one corresponding actual parameter. This actual parameter is specified either explicitly, by an association element (other than the actual part <b>open</b>) in the association list, or in the absence of such an association element, by a default expression (see <a href = "1076_4.HTM#4.3.2"> 4.3.2 </a> ).
<p>Evaluation of a function call includes evaluation of the actual parameter expressions specified in the call and evaluation of the default expressions associated with formal parameters of the function that do not have actual parameters associated with them. In both cases, the resulting value must belong to the subtype of the associated formal parameter. (If the formal parameter is of an unconstrained array type, then the formal parameter takes on the subtype of the actual parameter.) The function body is executed using the actual parameter values and default expression values as the values of the corresponding formal parameters.
<p>NOTE--If a name (including one used as a prefix) has an interpretation both as a function call and an indexed name, then the innermost complete context is used to disambiguate the name. If, after applying this rule, there is not exactly one interpretation of the name, then the name is ambiguous. See <a href = "1076_10.HTM#10.5"> 10.5 </a> .
<h3><a name="7.3.4"> <a href = "1076_7.HTM#7.3.4"> 7.3.4 </a> Qualified expressions</a></h3>
<p>A qualified expression is a basic operation (see the introduction to Section 3)that is used to explicitly state the type, and possibly the subtype, of an operand that is an expression or an aggregate.
<pre> qualified_expression ::=
type_mark ' ( expression )
| type_mark ' aggregate
</pre>
<p>The operand must have the same type as the base type of the type mark. The value of a qualified expression is the value of the operand. The evaluation of a qualified expression evaluates the operand and checks that its value belongs to the subtype denoted by the type mark.
<p>NOTE--Whenever the type of an enumeration literal or aggregate is not known from the context, a qualified expression can be used to state the type explicitly.
<h3><a name="7.3.5"> <a href = "1076_7.HTM#7.3.5"> 7.3.5 </a> Type conversions</a></h3>
<p>A type conversion provides for explicit conversion between closely related types.
<pre> type_conversion ::= type_mark ( expression )
</pre>
<p>The target type of a type conversion is the base type of the type mark. The type of the operand of a type conversion must be determinable independent of the context (in particular, independent of the target type). Furthermore, the operand of a type conversion is not allowed to be the literal <b>null</b>, an allocator, an aggregate, or a string literal. An expression enclosed by parentheses is allowed as the operand of a type conversion only if the expression alone is allowed.
<p>If the type mark denotes a subtype, conversion consists of conversion to the target type followed by a check that the result of the conversion belongs to the subtype.
<p>Explicit type conversions are allowed between <i>closely related types</i>. In particular, a type is closely related to itself. Other types are closely related only under the following conditions:
<ol type="a">
<li><i>Abstract Numeric Types</i>--Any abstract numeric type is closely related to any other abstract numeric type. In an explicit type conversion where the type mark denotes an abstract numeric type, the operand can be of any integer or floating point type. The value of the operand is converted to the target type, which must also be an integer or floating point type. The conversion of a floating point value to an integer type rounds to the nearest integer; if the value is halfway between two integers, rounding may be up or down.
<li><i>Array Types</i>--Two array types are closely related if and only if
<ul>
<p>-- The types have the same dimensionality;
<p>-- For each index position, the index types are either the same or are closely related; and
<p>-- The element types are the same.
</ul>
<p>In an explicit type conversion where the type mark denotes an array type, the following rules apply: if the type mark denotes an unconstrained array type and if the operand is not a null array, then, for each index position, the bounds of the result are obtained by converting the bounds of the operand to the corresponding index type of the target type. If the type mark denotes a constrained array subtype, then the bounds of the result are those imposed by the type mark. In either case, the value of each element of the result is that of the matching element of the operand (see <a href = "1076_7.HTM#7.2.2"> 7.2.2 </a> ).
</ol>
<p>No other types are closely related.
<p>In the case of conversions between numeric types, it is an error if the result of the conversion fails to satisfy a constraint imposed by the type mark.
<p>In the case of conversions between array types, a check is made that any constraint on the element subtype is the same for the operand array type as for the target array type. If the type mark denotes an unconstrained array type, then, for each index position, a check is made that the bounds of the result belong to the corresponding index subtype of the target type. If the type mark denotes a constrained array subtype, a check is made that for each element of the operand there is a matching element of the target subtype, and vice versa. It is an error if any of these checks fail.
<p>In certain cases, an implicit type conversion will be performed. An implicit conversion of an operand of type <i>universal_integer</i> to another integer type, or of an operand of type <i>universal_real</i> to another floating point type, can only be applied if the operand is either a numeric literal or an attribute, or if the operand is an expression consisting of the division of a value of a physical type by a value of the same type; such an operand is called a <i>convertible</i> universal operand. An implicit conversion of a convertible universal operand is applied if and only if the innermost complete context determines a unique (numeric) target type for the implicit conversion, and there is no legal interpretation of this context without this conversion.
<p>NOTE--Two array types may be closely related even if corresponding index positions have different directions.
<h3><a name="7.3.6"> <a href = "1076_7.HTM#7.3.6"> 7.3.6 </a> Allocators</a></h3>
<p>The evaluation of an allocator creates an object and yields an access value that designates the object.
<pre> allocator ::=
<b>new</b> subtype_indication
| <b>new</b> qualified_expression
</pre>
<p>The type of the object created by an allocator is the base type of the type mark given in either the subtype indication or the qualified expression. For an allocator with a subtype indication, the initial value of the created object is the same as the default initial value for an explicitly declared variable of the designated subtype. For an allocator with a qualified expression, this expression defines the initial value of the created object.
<p>The type of the access value returned by an allocator must be determinable solely from the context, but using the fact that the value returned is of an access type having the named designated type.
<p>The only allowed form of constraint in the subtype indication of an allocator is an index constraint. If an allocator includes a subtype indication and if the type of the object created is an array type, then the subtype indication must either denote a constrained subtype or include an explicit index constraint. A subtype indication that is part of an allocator must not include a resolution function.
<p>If the type of the created object is an array type, then the created object is always constrained. If the allocator includes a subtype indication, the created object is constrained by the subtype. If the allocator includes a qualified expression, the created object is constrained by the bounds of the initial value defined by that expression. For other types, the subtype of the created object is the subtype defined by the subtype of the access type definition.
<p>For the evaluation of an allocator, the elaboration of the subtype indication or the evaluation of the qualified expression is first performed. The new object is then created, and the object is then assigned its initial value. Finally, an access value that designates the created object is returned.
<p>In the absence of explicit deallocation, an implementation must guarantee that any object created by the evaluation of an allocator remains allocated for as long as this object or one of its subelements is accessible directly or indirectly; that is, as long as it can be denoted by some name.
<h4>NOTES</h4>
<p>1--Procedure Deallocate is implicitly declared for each access type. This procedure provides a mechanism for explicitly deallocating the storage occupied by an object created by an allocator.
<p>2--An implementation may (but need not) deallocate the storage occupied by an object created by an allocator, once this object has become inaccessible.
<p><i>Examples:</i>
<pre> <b>new</b> NODE -- Takes on default initial value.
<b>new</b> NODE'(15 ns, <b>null</b>) -- Initial value is specified.
<b>new</b> NODE'(Delay => 5 ns, \Next\ => Stack) -- Initial value is specified.
<b>new</b> BIT_VECTOR'("00110110") -- Constrained by initial value.
<b>new</b> STRING (1 <b>to</b> 10) -- Constrained by index constraint.
<b>new</b><i> STRING -- Illegal: must be constrained</i>.
</pre>
<h2><a name="7.4"> <a href = "1076_7.HTM#7.4"> 7.4 </a> Static expressions</a></h2>
<p>Certain expressions are said to be <i>static</i>. Similarly, certain discrete ranges are said to be static, and the type marks of certain subtypes are said to denote static subtypes.
<p>There are two categories of static expression. Certain forms of expression can be evaluated during the analysis of the design unit in which they appear; such an expression is said to be <i>locally static</i>. Certain forms of expression can be evaluated as soon as the design hierarchy in which they appear is elaborated; such an expression is said to be <i>globally static</i>.
<h3><a name="7.4.1"> <a href = "1076_7.HTM#7.4.1"> 7.4.1 </a> Locally static primaries</a></h3>
<p>An expression is said to be locally static if and only if every operator in the expression denotes an implicitly defined operator whose operands and result are scalar and if every primary in the expression is a <i>locally static primary</i>, where a locally static primary is defined to be one of the following:
<ol type="a">
<li>A literal of any type other than type TIME
<li>A constant (other than a deferred constant) explicitly declared by a constant declaration and initialized with a locally static expression
<li>An alias whose aliased name (given in the corresponding alias declaration) is a locally static primary
<li>A function call whose function name denotes an implicitly defined operator, and whose actual parameters are each locally static expressions
<li>A predefined attribute that is a value, other than the predefined attribute 'PATH_NAME, and whose prefix is either a locally static subtype or is an object name that is of a locally static subtype
<li>A predefined attribute that is a function, other than the predefined attributes 'EVENT, 'ACTIVE, 'LAST_EVENT, 'LAST_ACTIVE, 'LAST_VALUE, 'DRIVING, and 'DRIVING_VALUE, whose prefix is either a locally static subtype or is an object that is of a locally static subtype, and whose actual parameter (if any)is a locally static expression
<li>A user-defined attribute whose value is defined by a locally static expression
<li>A qualified expression whose operand is a locally static expression
<li>A type conversion whose expression is a locally static expression
<li>A locally static expression enclosed in parentheses
</ol>
<p>A locally static range is either a range of the second form (see <a href = "1076_3.HTM#3.1"> 3.1 </a> ) whose bounds are locally static expressions, or a range of the first form whose prefix denotes either a locally static subtype or an object that is of a locally static subtype. A locally static range constraint is a range constraint whose range is locally static. A locally static scalar subtype is either a scalar base type or a scalar subtype formed by imposing on a locally static subtype a locally static range constraint. A locally static discrete range is either a locally static subtype or a locally static range.
<p>A locally static index constraint is an index constraint for which each index subtype of the corresponding array type is locally static and in which each discrete range is locally static. A locally static array subtype is a constrained array subtype formed by imposing on an unconstrained array type a locally static index constraint. A locally static record subtype is a record type whose fields are all of locally static subtypes. A locally static access subtype is a subtype denoting an access type. A locally static file subtype is a subtype denoting a file type.
<p>A locally static subtype is either a locally static scalar subtype, a locally static array subtype, a locally static record subtype, a locally static access subtype, or a locally static file subtype.
<h3><a name="7.4.2"> <a href = "1076_7.HTM#7.4.2"> 7.4.2 </a> Globally static primaries</a></h3>
<p>An expression is said to be globally static if and only if every operator in the expression denotes a pure function and every primary in the expression is a <i>globally</i> <i>static primary</i>, where a globally static primary is a primary that, if it denotes an object or a function, does not denote a dynamically elaborated named entity (see <a href = "1076_12.HTM#12.5"> 12.5 </a> ) and is one of the following:
<ol type="a">
<li>A literal of type TIME
<li>A locally static primary
<li>A generic constant
<li>A generate parameter
<li>A constant (including a deferred constant)
<li>An alias whose aliased name (given in the corresponding alias declaration) is a globally static primary
<li>An array aggregate, if and only if
<ul>
<p>1) All expressions in its element associations are globally static expressions, and
<p>2) All ranges in its element associations are globally static ranges
</ul>
<li>A record aggregate, if and only if all expressions in its element associations are globally static expressions
<li>A function call whose function name denotes a pure function and whose actual parameters are each globally static expressions
<li>A predefined attribute that is a value and whose prefix is either a globally static subtype or is an object or function call that is of a globally static subtype
<li>A predefined attribute that is a function, other than the predefined attributes 'EVENT, 'ACTIVE, 'LAST_EVENT, 'LAST_ACTIVE, 'LAST_VALUE, 'DRIVING,and 'DRIVING_VALUE, whose prefix is either a globally static subtype or is an object or function call that is of a globally static subtype, and whose actual parameter (if any) is a globally static expression
<li>A user-defined attribute whose value is defined by a globally static expression
<li>A qualified expression whose operand is a
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -