File: type.html

package info (click to toggle)
eclipse-titan 8.2.0-1
  • links: PTS
  • area: main
  • in suites: bookworm, sid
  • size: 103,544 kB
  • sloc: cpp: 271,008; ansic: 33,683; yacc: 23,419; makefile: 15,483; lex: 9,204; java: 4,848; perl: 4,555; sh: 2,242; xml: 1,378; javascript: 85; awk: 48; php: 32; python: 13
file content (327 lines) | stat: -rw-r--r-- 15,033 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<!--
 Copyright (c) 2000-2021 Ericsson Telecom AB
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v2.0
 which accompanies this distribution, and is available at
 https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html

 Contributors:
  Baji, Laszlo
  Balasko, Jeno
  Farkas, Laszlo
  Forstner, Matyas
  Szabados, Kristof
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-us">
<title>type</title>
</head>
<body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258">
<table align="left" border="0" cellspacing="0" cellpadding="0" valign=top>
  <tr>
    <td width=105 height=40><a href="https://projects.eclipse.org/projects/tools.titan"><img src="../images/titan_transparent.gif" border=0 width=105 height=40 align="left" alt="Titan"></a></td>
  </tr>
</table>
<table border="0" align="right" cellpadding="0" cellspacing="0">
  <tr>
    <td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td>
    <td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td>
    <td><a href="true.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
    <td><a href="unichar2char.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td>
  </tr>
</table>
<p><br clear="all"></p>
<hr>
<h1>type</h1>
<hr align="left" width="75%">
<p>The keyword is used to specify user-defined 
<a href="#type">structured types</a>, 
<a href="#subtype">subtypes</a> or 
<a href="#behavior_type">behavior types</a> (
<a href="#function_type">function type</a>, 
<a href="#altstep_type">altstep type</a> or 
<a href="#testcase_type">testcase type</a>).</p>

<hr align="left" width="50%">
<p>Related keyword:</p>
<ul>
<li><b><font face="Courier New" size="4" color="#003258"><a href="record.html">record</a></font></b></li>
<li><b><font face="Courier New" size="4" color="#003258"><a href="union.html">union</a></font></b></li>
<li><b><font face="Courier New" size="4" color="#003258"><a href="set.html">set</a></font></b></li>
<li><b><font face="Courier New" size="4" color="#003258"><a href="enumerated.html">enumerated</a></font></b></li>
<li><b><font face="Courier New" size="4" color="#003258"><a href="port.html">port</a></font></b></li>
<li><b><font face="Courier New" size="4" color="#003258"><a href="component.html">component</a></font></b></li>
<li><b><font face="Courier New" size="4" color="#003258"><a href="function.html">function</a></font></b></li>
<li><b><font face="Courier New" size="4" color="#003258"><a href="altstep.html">altstep</a></font></b></li>
<li><b><font face="Courier New" size="4" color="#003258"><a href="testcase.html">testcase</a></font></b></li>
  <li><b><font face="Courier New" size="4" color="#003258"> <a href="refers.html">refers</a></font></b></li>
  <li><b><a href="derefers.html"><font face="Courier New" size="4" color="#003258">derefers</font></a></b></li>
  <li><b><font face="Courier New" size="4" color="#003258"><a href="apply.html">apply</a></font></b></li>
</ul>

<hr align="left" width="50%">
<h2> <a name=#type>1. Structured type</a></h2>
<div align="center">
<center>
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
  <tr>
    <td width="100%">
    <h3 align="left">
		<font face="Courier New" color="#003258" size="5"><b>type </b></font> ( 
			<font face="Courier New" color="#003258" size="5"><b>record</b></font> | 
			<font face="Courier New" color="#003258" size="5"> <b>union</b></font> | 
			<font face="Courier New" color="#003258" size="5"> <b>set</b></font> |
			<font face="Courier New" color="#003258" size="5"> <b>record of</b></font> | 
			<font face="Courier New" color="#003258" size="5"> <b>set of</b></font> | 
			<font face="Courier New" color="#003258" size="5"> <b>enumerated</b></font> | 
			<font face="Courier New" color="#003258" size="5"> <b>port</b></font> | 
			<font face="Courier New" color="#003258" size="5"> <b>component</b></font> ) 
		<i>identifier&nbsp;</i> 
		<font face="Courier New" color="#003258" size="5"> <b>{</b></font>
		<i> body</i> 
		<font face="Courier New" color="#003258" size="5"> <b>};</b></font>
	</h3>
    </td>
  </tr>
</table>
</center>
</div>
<ul>
  <li>
  <p>The <font face="Courier New" color="#003258" size="4"><b>type</b></font> keyword introduces the type definition.</p>
  </li>
  <li>
  <p><a href="record.html"><font face="Courier New" color="#003258" size="4"><b>record</b></font></a> denotes an ordered structured type.</p>
  </li>
  <li>
  <p><a href="union.html"><font face="Courier New" color="#003258" size="4"><b>union</b></font></a> 
  is a structure which can take one and only one of a finite number of known types.</p>
  </li>
  <li>
  <p><a href="set.html"><font face="Courier New" color="#003258" size="4"><b>set</b></font></a> denotes an unordered structured type.</p>
  </li>
  <li>
  <p><a href="record.html"><font face="Courier New" color="#003258" size="4"><b>record of</b></font></a> 
  denotes a record the elements of which are all of the same type.</p>
  </li>
  <li>
  <p><a href="set.html"><font face="Courier New" color="#003258" size="4"><b>set of</b></font></a> 
  denotes a set the elements of which are all of the same type.</p>
  </li>
  <li>
  <p><a href="enumerated.html"><font face="Courier New" color="#003258" size="4"><b>enumerated</b></font></a> stands for a type that take only a distinct named set of values.</p>
  </li>
  <li>
  <p><a href="port.html"><font face="Courier New" color="#003258" size="4"><b>port</b></font></a> defines the messages or procedures allowed to pass the port in question.</p>
  </li>
  <li>
  <p><a href="component.html"><font face="Courier New" color="#003258" size="4"><b>component</b></font></a> defines which ports are associated with a component.</p>
  </li>
  <li>
  <p><i>identifier</i> is the&nbsp;name used to refer to the structured type. Must begin with a letter, may contain letters, numbers and underscore characters.</p>
  </li>
  <li>
  <p><i>body</i> contains the type definition itself. Its content differs from type to type.</p>
  </li>
</ul>
<hr align="left" width="75%" >
<h2> <a name=#subtype>2. Subtype</a></h2>
<p>Another use of the keyword is the subtype definition.</p>
<ul>
  <li>Subtypes define a new constrained type from an already existing parent type.</li>
  <li>When no constraint is given, it is possible to define type aliases.</li>
</ul>
<hr align="left" width="75%">
<div align="center">
<center>
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
  <tr>
    <td width="100%">
    <h3 align="left">
		<font face="Courier New" color="#003258" size="5"><b>type</b></font>
		<i>parent_identifier</i>&nbsp; ( 
		<i>identifier&nbsp;</i> | 
		<font face="Courier New" color="#003258" size="5"> <b>address</b></font>) [
			<i>array_def</i>] [ 
				<font face="Courier New" color="#003258" size="5"><b>(</b></font>
				<i>list</i>
				<font face="Courier New" color="#003258" size="5"><b>)</b></font>]
			[<i>length</i>] [
			<font face="Courier New" color="#003258" size="5"><b>;</b></font> ]
	</h3>
    </td>
  </tr>
</table>
</center>
</div>
<ul>
  <li>
  <p>The <font face="Courier New" color="#003258" size="4"><b>type</b></font> keyword introduces the type definition.</p>
  </li>
  <li>
  <p><i>parent_identifier</i> is the&nbsp;name used to refer to the parent type. Must begin with a letter, may contain letters, numbers and underscore characters.</p>
  </li>
  <li>
  <p><i>identifier</i> is the&nbsp;name used to refer to the sub-type. Must begin with a letter, may contain letters, numbers and underscore characters.</p>
  </li>
  <li>
  <p><a href="address.html"><font face="Courier New" color="#003258" size="4"><b>address</b></font></a> is a user defined type to allow addressing specific entities inside the
  System Under Test.</p>
  </li>
  <li>
  <p><i><a href="BNF.html#arraydef">array_def</a></i> restricts the indices of the parent type.</p>
  </li>
  <li>
  <p><i><a href="BNF.html#allowedvalues">list</a></i> is a comma-separated enumeration of the allowed values out of the values defined for the parent type.</p>
  </li>
  <li>
  <p><a href="length.html"> <font face="Courier New" color="#003258" size="4"><b>length</b></font></a> can be used with <font face="Courier New"><b>set of</b></font> and <font face="Courier New"><b>record
  of</b></font> types to limit the number of the elements of the structured type in question.&nbsp;<br>
  When the parent type is a&nbsp; basic string type, the keyword constraints the length of the string.</p>
  </li>
</ul>
<hr align="left" width="50%">
<p>Example 1:</p>
<p><font face="Courier New">type enumerated Example {tisdag, fredag, onsdag};</font></p>
<p>The enumerated type called Example containing three elements is defined.</p>
<p>Example 2:</p>
<p><font face="Courier New">type Ex_subt Example (tisdag, onsdag);</font></p>
<p>The sub-type, called Ex_subt, may contain only two elements of the parent type (called Example).</p>


<hr align="left" width="75%"/>
<h2> <a name=#behavior_type>3. Behavior type</a></h2>
<p>Another use of the keyword is the behavior type definition.</p>
<p>It introduces a function type, an altstep type or a testcase type.</p>
<ul>
  <li>
  <p>A function, altstep or testcase has the given type if its formal parameter list, runs on type and returned value type is the same as given in the type definition.</p>
  </li>
</ul>
<hr align="left" width="50%"/>
<h3> <a name=#function_type>3.1. Function type</a></h3>
<div align="center">
<center>
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
  <tr>
    <td width="100%">
    <h3 align="left"><font face="Courier New" color="#003258" size="5"><b>type function</b></font> <i>Function_type_name</i>&nbsp;<b>(</b><i> formal_parameter_list&nbsp;</i><b>)</b> [<font face="Courier New" color="#003258"
      size="5"> <b>runs on</b></font> <i>component_type_ref&nbsp</i>] [<font face="Courier New" color="#003258" size="5"><b>return</b></font><i>&nbsp;returned_type</i> ]<font face="Courier New" color="#003258" size="5"><b>&nbsp;</b>[;]</font></h3>
    </td>
  </tr>
</table>
</center>
</div>
<ul>
  <li>
  <p>The <font face="Courier New" color="#003258" size="4"><b>type function</b></font> keywords introduce the type definition.</p>
  </li>
  <li>
	<p><i>Function_type_name</i> is the&nbsp;name used to refer to the function type. Must begin with a letter, may contain letters, numbers and underscore characters.</p>
  </li>
  <li>
	<p><i>formal_parameter_list</i> is the&nbsp;list of the formal parameters (arguments). See the definion of <a href="function.html"><font face="Courier New" color="#003258" size="4"><b>function</b></font></a>.</p>
  </li>
  <li>
	<p><i>component_type_ref&nbsp</i> See the definion of <a href="function.html"><font face="Courier New" color="#003258" size="4"><b>function</b></font></a>.</p>
  </li>
 <li>
	<p><i>returned_type</i> See the definion of <a href="function.html"><font face="Courier New" color="#003258" size="4"><b>function</b></font></a>.</p>
  </li>
</ul>
<hr align="left" width="50%"/>
<p>Example 3:</p>
<font face="Courier New">
	<p>type function F_type(in integer pl_i) runs on CT returns charstring; // line 1</p>
	<p>function f(in integer pl_ii) runs on CT returns charstring { log(pl_ii);return "Hello" }; // line 2</p>
	<p>var F_type v_f := refers(f);   // line 3</p>
	<p>var CT v_comp := CT.create;    // line 4</p>
	<p>v_comp.start(derefers(v_f)(1));// line 5</p>
	<p>v_f.apply(2);                  // line 6</p>
</font>

<p>Line 1: Function type "F_type" is defined. Its parameter is type of integer and it is an "in" parameter. It runs on CT and its return value a charstring.</p>
<p>Line 2: The function f defined here has type of F_type. </p> 
<p>Line 3: The function reference variable v_f has a type of function (reference) type F_type and its value is defined here as a reference to function f. 
This definition is valid because v_f refers to the same type as f. </p>
<p>Line 5: The behavior function referenced by v_f is started on component v_comp.</p>
<p>Line 6: The function referenced by v_f is called. It is the same as calling f(2).</p>
<hr align="left" width="50%"/>
<h3> <a name=#altstep_type>3.2. Altstep type</a></h3>
<div align="center">
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
  <tr>
    <td width="100%">
    <h3 align="left">
		<font face="Courier New" color="#003258" size="5"><b>type altstep&nbsp;</b></font>
		<i> altstep_identifier </i> 
		<font face="Courier New" color="#003258" size="5"><b>(</b></font> 
		[<i> altstep_parameter</i> ... ] 
		<font face="Courier New" color="#003258" size="5"><b>)</b></font> 
		<font face="Courier New" color="#003258" size="5"><b>runs on</b></font>
		<i>component_type_ref</i> [
		<font face="Courier New" color="#003258" size="5"><b>;</b></font>]
	</h3>
    </td>
  </tr>
</table>
</div>
<ul>
  <li>
  <p>The <font face="Courier New" color="#003258" size="4"><b>type altstep</b></font> keywords introduce the altstep type definition.</p>
  </li>
  <li>
  <p>Details can be found in <a href="altstep.html"><font face="Courier New" color="#003258" size="4"><b>altstep</b></font></a>.</p>
  </li>
</ul>
<p>Example 4:</p>
<font face="Courier New">
<p>type component CT {} </p>
<p>type altstep As_type() runs on CT </p>
<p>altstep as_1() runs on CT {</p>
<p>	&nbsp;&nbsp;[else]  {}</p>
<p>}</p>
<p>testcase tc() runs on CT {</p>
<p>&nbsp;&nbsp;var As_type v_as := refers(as_1);</p>
<p>&nbsp;&nbsp;v_as.apply(); //same as "as_1();"
<p>};</p>

</font>
<hr align="left" width="50%">
<h3> <a name=#testcase_type>3.3. Testcase type</a></h3>
<div align="center">
<center>
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
  <tr>
    <td width="100%">
    <h3 align="left">
		<font face="Courier New" color="#003258" size="5"><b>type testcase</b></font>
		<i> testcase_identifier </i>
		<font face="Courier New" color="#003258" size="5"><b>(</b></font> [ 
			<i>testcase_parameters</i>
			<b>...</b>&nbsp; ] 
		<font face="Courier New" color="#003258" size="5"><b>)</b></font> 
		<font face="Courier New" color="#003258" size="5"><b>runs on</b></font>
		<i> component_type_ref&nbsp;</i> [ 
		<font face="Courier New" color="#003258" size="5"><b>system</b></font>
		<i> system_component_type_ref </i>] [
		<font face="Courier New" color="#003258" size="5"><b>;</b></font> ]
	  </h3>
    </td>
  </tr>
</table>
</center>
</div>
<ul>
  <li>
  <p>The <font face="Courier New" color="#003258" size="4"><b>type testcase</b></font> keywords introduce the test case type definition.</p>
  </li>
  <li>
  <p>Details can be found in <a href="testcase.html"><font face="Courier New" color="#003258" size="4"><b>testcase</b></font></a>.</p>
  </li>
</ul>
<p><a HREF="BNF.html#typedef">BNF definition</a> of <font face="Courier New"> type</font></p>
</body>
</html>