Debian Codegraph @

help/info/type.html

raw symbols SCIP
1 <!--
2 Copyright (c) 2000-2021 Ericsson Telecom AB
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Eclipse Public License v2.0
5 which accompanies this distribution, and is available at
6 https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
7
8 Contributors:
9 Baji, Laszlo
10 Balasko, Jeno
11 Farkas, Laszlo
12 Forstner, Matyas
13 Szabados, Kristof
14 -->
15 <html>
16 <head>
17 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
18 <meta http-equiv="Content-Language" content="en-us">
19 <title>type</title>
20 </head>
21 <body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258">
22 <table align="left" border="0" cellspacing="0" cellpadding="0" valign=top>
23 <tr>
24 <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>
25 </tr>
26 </table>
27 <table border="0" align="right" cellpadding="0" cellspacing="0">
28 <tr>
29 <td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td>
30 <td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td>
31 <td><a href="true.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
32 <td><a href="unichar2char.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td>
33 </tr>
34 </table>
35 <p><br clear="all"></p>
36 <hr>
37 <h1>type</h1>
38 <hr align="left" width="75%">
39 <p>The keyword is used to specify user-defined
40 <a href="#type">structured types</a>,
41 <a href="#subtype">subtypes</a> or
42 <a href="#behavior_type">behavior types</a> (
43 <a href="#function_type">function type</a>,
44 <a href="#altstep_type">altstep type</a> or
45 <a href="#testcase_type">testcase type</a>).</p>
46
47 <hr align="left" width="50%">
48 <p>Related keyword:</p>
49 <ul>
50 <li><b><font face="Courier New" size="4" color="#003258"><a href="record.html">record</a></font></b></li>
51 <li><b><font face="Courier New" size="4" color="#003258"><a href="union.html">union</a></font></b></li>
52 <li><b><font face="Courier New" size="4" color="#003258"><a href="set.html">set</a></font></b></li>
53 <li><b><font face="Courier New" size="4" color="#003258"><a href="enumerated.html">enumerated</a></font></b></li>
54 <li><b><font face="Courier New" size="4" color="#003258"><a href="port.html">port</a></font></b></li>
55 <li><b><font face="Courier New" size="4" color="#003258"><a href="component.html">component</a></font></b></li>
56 <li><b><font face="Courier New" size="4" color="#003258"><a href="function.html">function</a></font></b></li>
57 <li><b><font face="Courier New" size="4" color="#003258"><a href="altstep.html">altstep</a></font></b></li>
58 <li><b><font face="Courier New" size="4" color="#003258"><a href="testcase.html">testcase</a></font></b></li>
59 <li><b><font face="Courier New" size="4" color="#003258"> <a href="refers.html">refers</a></font></b></li>
60 <li><b><a href="derefers.html"><font face="Courier New" size="4" color="#003258">derefers</font></a></b></li>
61 <li><b><font face="Courier New" size="4" color="#003258"><a href="apply.html">apply</a></font></b></li>
62 </ul>
63
64 <hr align="left" width="50%">
65 <h2> <a name=#type>1. Structured type</a></h2>
66 <div align="center">
67 <center>
68 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
69 <tr>
70 <td width="100%">
71 <h3 align="left">
72 <font face="Courier New" color="#003258" size="5"><b>type </b></font> (
73 <font face="Courier New" color="#003258" size="5"><b>record</b></font> |
74 <font face="Courier New" color="#003258" size="5"> <b>union</b></font> |
75 <font face="Courier New" color="#003258" size="5"> <b>set</b></font> |
76 <font face="Courier New" color="#003258" size="5"> <b>record of</b></font> |
77 <font face="Courier New" color="#003258" size="5"> <b>set of</b></font> |
78 <font face="Courier New" color="#003258" size="5"> <b>enumerated</b></font> |
79 <font face="Courier New" color="#003258" size="5"> <b>port</b></font> |
80 <font face="Courier New" color="#003258" size="5"> <b>component</b></font> )
81 <i>identifier&nbsp;</i>
82 <font face="Courier New" color="#003258" size="5"> <b>{</b></font>
83 <i> body</i>
84 <font face="Courier New" color="#003258" size="5"> <b>};</b></font>
85 </h3>
86 </td>
87 </tr>
88 </table>
89 </center>
90 </div>
91 <ul>
92 <li>
93 <p>The <font face="Courier New" color="#003258" size="4"><b>type</b></font> keyword introduces the type definition.</p>
94 </li>
95 <li>
96 <p><a href="record.html"><font face="Courier New" color="#003258" size="4"><b>record</b></font></a> denotes an ordered structured type.</p>
97 </li>
98 <li>
99 <p><a href="union.html"><font face="Courier New" color="#003258" size="4"><b>union</b></font></a>
100 is a structure which can take one and only one of a finite number of known types.</p>
101 </li>
102 <li>
103 <p><a href="set.html"><font face="Courier New" color="#003258" size="4"><b>set</b></font></a> denotes an unordered structured type.</p>
104 </li>
105 <li>
106 <p><a href="record.html"><font face="Courier New" color="#003258" size="4"><b>record of</b></font></a>
107 denotes a record the elements of which are all of the same type.</p>
108 </li>
109 <li>
110 <p><a href="set.html"><font face="Courier New" color="#003258" size="4"><b>set of</b></font></a>
111 denotes a set the elements of which are all of the same type.</p>
112 </li>
113 <li>
114 <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>
115 </li>
116 <li>
117 <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>
118 </li>
119 <li>
120 <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>
121 </li>
122 <li>
123 <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>
124 </li>
125 <li>
126 <p><i>body</i> contains the type definition itself. Its content differs from type to type.</p>
127 </li>
128 </ul>
129 <hr align="left" width="75%" >
130 <h2> <a name=#subtype>2. Subtype</a></h2>
131 <p>Another use of the keyword is the subtype definition.</p>
132 <ul>
133 <li>Subtypes define a new constrained type from an already existing parent type.</li>
134 <li>When no constraint is given, it is possible to define type aliases.</li>
135 </ul>
136 <hr align="left" width="75%">
137 <div align="center">
138 <center>
139 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
140 <tr>
141 <td width="100%">
142 <h3 align="left">
143 <font face="Courier New" color="#003258" size="5"><b>type</b></font>
144 <i>parent_identifier</i>&nbsp; (
145 <i>identifier&nbsp;</i> |
146 <font face="Courier New" color="#003258" size="5"> <b>address</b></font>) [
147 <i>array_def</i>] [
148 <font face="Courier New" color="#003258" size="5"><b>(</b></font>
149 <i>list</i>
150 <font face="Courier New" color="#003258" size="5"><b>)</b></font>]
151 [<i>length</i>] [
152 <font face="Courier New" color="#003258" size="5"><b>;</b></font> ]
153 </h3>
154 </td>
155 </tr>
156 </table>
157 </center>
158 </div>
159 <ul>
160 <li>
161 <p>The <font face="Courier New" color="#003258" size="4"><b>type</b></font> keyword introduces the type definition.</p>
162 </li>
163 <li>
164 <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>
165 </li>
166 <li>
167 <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>
168 </li>
169 <li>
170 <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
171 System Under Test.</p>
172 </li>
173 <li>
174 <p><i><a href="BNF.html#arraydef">array_def</a></i> restricts the indices of the parent type.</p>
175 </li>
176 <li>
177 <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>
178 </li>
179 <li>
180 <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
181 of</b></font> types to limit the number of the elements of the structured type in question.&nbsp;<br>
182 When the parent type is a&nbsp; basic string type, the keyword constraints the length of the string.</p>
183 </li>
184 </ul>
185 <hr align="left" width="50%">
186 <p>Example 1:</p>
187 <p><font face="Courier New">type enumerated Example {tisdag, fredag, onsdag};</font></p>
188 <p>The enumerated type called Example containing three elements is defined.</p>
189 <p>Example 2:</p>
190 <p><font face="Courier New">type Ex_subt Example (tisdag, onsdag);</font></p>
191 <p>The sub-type, called Ex_subt, may contain only two elements of the parent type (called Example).</p>
192
193
194 <hr align="left" width="75%"/>
195 <h2> <a name=#behavior_type>3. Behavior type</a></h2>
196 <p>Another use of the keyword is the behavior type definition.</p>
197 <p>It introduces a function type, an altstep type or a testcase type.</p>
198 <ul>
199 <li>
200 <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>
201 </li>
202 </ul>
203 <hr align="left" width="50%"/>
204 <h3> <a name=#function_type>3.1. Function type</a></h3>
205 <div align="center">
206 <center>
207 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
208 <tr>
209 <td width="100%">
210 <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"
211 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>
212 </td>
213 </tr>
214 </table>
215 </center>
216 </div>
217 <ul>
218 <li>
219 <p>The <font face="Courier New" color="#003258" size="4"><b>type function</b></font> keywords introduce the type definition.</p>
220 </li>
221 <li>
222 <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>
223 </li>
224 <li>
225 <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>
226 </li>
227 <li>
228 <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>
229 </li>
230 <li>
231 <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>
232 </li>
233 </ul>
234 <hr align="left" width="50%"/>
235 <p>Example 3:</p>
236 <font face="Courier New">
237 <p>type function F_type(in integer pl_i) runs on CT returns charstring; // line 1</p>
238 <p>function f(in integer pl_ii) runs on CT returns charstring { log(pl_ii);return "Hello" }; // line 2</p>
239 <p>var F_type v_f := refers(f); // line 3</p>
240 <p>var CT v_comp := CT.create; // line 4</p>
241 <p>v_comp.start(derefers(v_f)(1));// line 5</p>
242 <p>v_f.apply(2); // line 6</p>
243 </font>
244
245 <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>
246 <p>Line 2: The function f defined here has type of F_type. </p>
247 <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.
248 This definition is valid because v_f refers to the same type as f. </p>
249 <p>Line 5: The behavior function referenced by v_f is started on component v_comp.</p>
250 <p>Line 6: The function referenced by v_f is called. It is the same as calling f(2).</p>
251 <hr align="left" width="50%"/>
252 <h3> <a name=#altstep_type>3.2. Altstep type</a></h3>
253 <div align="center">
254 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
255 <tr>
256 <td width="100%">
257 <h3 align="left">
258 <font face="Courier New" color="#003258" size="5"><b>type altstep&nbsp;</b></font>
259 <i> altstep_identifier </i>
260 <font face="Courier New" color="#003258" size="5"><b>(</b></font>
261 [<i> altstep_parameter</i> ... ]
262 <font face="Courier New" color="#003258" size="5"><b>)</b></font>
263 <font face="Courier New" color="#003258" size="5"><b>runs on</b></font>
264 <i>component_type_ref</i> [
265 <font face="Courier New" color="#003258" size="5"><b>;</b></font>]
266 </h3>
267 </td>
268 </tr>
269 </table>
270 </div>
271 <ul>
272 <li>
273 <p>The <font face="Courier New" color="#003258" size="4"><b>type altstep</b></font> keywords introduce the altstep type definition.</p>
274 </li>
275 <li>
276 <p>Details can be found in <a href="altstep.html"><font face="Courier New" color="#003258" size="4"><b>altstep</b></font></a>.</p>
277 </li>
278 </ul>
279 <p>Example 4:</p>
280 <font face="Courier New">
281 <p>type component CT {} </p>
282 <p>type altstep As_type() runs on CT </p>
283 <p>altstep as_1() runs on CT {</p>
284 <p> &nbsp;&nbsp;[else] {}</p>
285 <p>}</p>
286 <p>testcase tc() runs on CT {</p>
287 <p>&nbsp;&nbsp;var As_type v_as := refers(as_1);</p>
288 <p>&nbsp;&nbsp;v_as.apply(); //same as "as_1();"
289 <p>};</p>
290
291 </font>
292 <hr align="left" width="50%">
293 <h3> <a name=#testcase_type>3.3. Testcase type</a></h3>
294 <div align="center">
295 <center>
296 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
297 <tr>
298 <td width="100%">
299 <h3 align="left">
300 <font face="Courier New" color="#003258" size="5"><b>type testcase</b></font>
301 <i> testcase_identifier </i>
302 <font face="Courier New" color="#003258" size="5"><b>(</b></font> [
303 <i>testcase_parameters</i>
304 <b>...</b>&nbsp; ]
305 <font face="Courier New" color="#003258" size="5"><b>)</b></font>
306 <font face="Courier New" color="#003258" size="5"><b>runs on</b></font>
307 <i> component_type_ref&nbsp;</i> [
308 <font face="Courier New" color="#003258" size="5"><b>system</b></font>
309 <i> system_component_type_ref </i>] [
310 <font face="Courier New" color="#003258" size="5"><b>;</b></font> ]
311 </h3>
312 </td>
313 </tr>
314 </table>
315 </center>
316 </div>
317 <ul>
318 <li>
319 <p>The <font face="Courier New" color="#003258" size="4"><b>type testcase</b></font> keywords introduce the test case type definition.</p>
320 </li>
321 <li>
322 <p>Details can be found in <a href="testcase.html"><font face="Courier New" color="#003258" size="4"><b>testcase</b></font></a>.</p>
323 </li>
324 </ul>
325 <p><a HREF="BNF.html#typedef">BNF definition</a> of <font face="Courier New"> type</font></p>
326 </body>
327 </html>