ocarina-backends-c_tree-nodes.idl 12.5 KB
Newer Older
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
/*****************************************************************************
**                                                                          **
**                           OCARINA COMPONENTS                             **
**                                                                          **
**        O C A R I N A . B A C K E N D S . C _ T R E E . N O D E S         **
**                                                                          **
**               Copyright (C) 2007-2008, GET-Telecom Paris.                **
**                                                                          **
** Ocarina  is free software;  you  can  redistribute  it and/or  modify    **
** it under terms of the GNU General Public License as published by the     **
** Free Software Foundation; either version 2, or (at your option) any      **
** later version. Ocarina is distributed  in  the  hope  that it will be    **
** useful, but WITHOUT ANY WARRANTY;  without even the implied warranty of  **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General **
** Public License for more details. You should have received  a copy of the **
** GNU General Public License distributed with Ocarina; see file COPYING.   **
** If not, write to the Free Software Foundation, 51 Franklin Street, Fifth **
** Floor, Boston, MA 02111-1301, USA.                                       **
**                                                                          **
** As a special exception,  if other files  instantiate  generics from this **
** unit, or you link  this unit with other files  to produce an executable, **
** this  unit  does not  by itself cause  the resulting  executable to be   **
** covered  by the  GNU  General  Public  License. This exception does not  **
** however invalidate  any other reasons why the executable file might be   **
** covered by the GNU Public License.                                       **
**                                                                          **
**                 Ocarina is maintained by the Ocarina team                **
**                       (ocarina-users@listes.enst.fr)                     **
**                                                                          **
*****************************************************************************/

module Ocarina::Backends::C_Tree::Nodes {

  /******************/
  /* Internal types */
  /******************/

  typedef octet   Operator_Id;
  typedef long    Name_Id;
  typedef long    Value_Id;

  /******************/
  /* Internal nodes */
  /******************/

  interface Node_Id {
    Node_Id    Next_Node;
    Node_Id    Frontend_Node;
  };

  interface Definition : Node_Id {
    Node_Id    Defining_Identifier;
  };

  interface List_Id {
    Node_Id    First_Node;
    Node_Id    Last_Node;
  };

  interface Defining_Identifier : Node_Id {
    Name_Id    Name;
    Node_Id    Corresponding_Node;
    Node_Id    Compile_Unit;
    boolean    Is_Pointer; 
  };

  interface Ifdef_Clause : Node_Id {
    Node_Id    Clause;
    List_Id    Then_Statements;
    List_Id    Else_Statements;
    boolean    Negation;
  };

  interface Include_Clause : Node_Id {
    Node_Id    Header_Name;
    boolean    Is_Local; 
  };

  interface Includes : List_Id {};

  interface Declaration_List : List_Id {};

  interface Header_List : List_Id {};

  interface Statement_List : List_Id {};

  interface Parameter_List : List_Id {};

  interface Enumeration_Literals : List_Id {};

  interface Element_List : List_Id {};

  interface Label_List : List_Id {};

  interface Alternatives_List : List_Id {};

  interface Sources : List_Id {};

  interface Headers : List_Id {};

  interface Array_Values : Node_Id {
    List_Id    Values;
  };

  interface Array_Value : Definition {
    Node_Id    Array_Item;
  };

  /* Interfaces for the PolyORB-HI module */

  interface HI_Distributed_Application : Node_Id {
    Name_Id    Name;
    List_Id    Units;
    List_Id    HI_Nodes;
  };

  interface HI_Node : Node_Id {
    Name_Id    Name;
    List_Id    Units;
    Node_Id    Distributed_Application;
  };

  interface Header_File : Definition {
    Node_Id    Distributed_Application_Unit;
    List_Id    Included_Headers;
    List_Id    Declarations;
  };

  interface Source_File : Definition {
    Node_Id    Distributed_Application_Unit;
    List_Id    Included_Headers;
    List_Id    Declarations;
  };

  /* Units that gather all the generated packages */

  interface API_Unit : Node_Id {
   /* Whatever the distributed application kind is, a main function
      is required for each node */
    List_Id    Sources;
    List_Id    Headers;
    Node_Id    Entity;
  };

  /* This is the root node of the packages generated specifically for
     an PolyORB-HI Distributed application */

  interface HI_Unit : API_Unit {
    Node_Id    Main_Source;
    Node_Id    Main_Header;
    Node_Id    Activity_Source;
    Node_Id    Activity_Header;
    Node_Id    Marshallers_Source;
    Node_Id    Marshallers_Header;
    Node_Id    Request_Source;
    Node_Id    Request_Header;
    Node_Id    Types_Header;
    Node_Id    Types_Source;
    Node_Id    Deployment_Header;
    Node_Id    Deployment_Source;
    Node_Id    Naming_Source;
    Node_Id    Naming_Header;
    Node_Id    Subprograms_Source;
    Node_Id    Subprograms_Header;
  };
  
  interface Parameter_Specification : Definition {
    Node_Id    Parameter_Type;
  };

  interface Parameter_Profile : List_Id {};

  /*
   * tf myfunc (arg1, arg2, ..., argN);
   */
  interface Function_Specification : Definition {
    List_Id    Parameters;
    Node_Id    Return_Type;
    Node_Id    Compile_Unit;
  };
  
  /*
   * int myfunc (int arg1 , char arg2)
   * {
   *    ...
   *    return (value);
   * }
   */
  interface Function_Implementation : Node_Id {
    Node_Id    Specification;
    List_Id    Declarations;
    List_Id    Statements;
    Node_Id    Compile_Unit;
  };
      
  /*
   * myfunc (arg1, arg2);
   */
  interface Call_Profile : Definition {
    List_Id    Parameters;
  };

  interface Macro_Call : Definition {
    List_Id    Parameters;
  };


  /*
   * Example : 
   *           - typedef int my_integer;
   *           - typedef struct{....} my_type;
   */
  interface Full_Type_Declaration : Definition {
    Node_Id    Type_Definition;
    Node_Id    Type_Name;
  };

  /****************/
  /* Statetements */
  /****************/

  interface Block_Statement : Definition {
    List_Id    Declarative_Part;
    List_Id    Statements;
  };

  interface If_Statement : Node_Id {
    Node_Id    Condition;
    List_Id    Statements;
    List_Id    Else_Statements;
  };

  interface Assignment_Statement : Definition {
    Node_Id    Expression;
  };

  interface Return_Statement : Node_Id {
    Node_Id    Expression;
  };

  interface For_Statement : Definition {
    Node_Id    Pre_Cond;
    Node_Id    Condition;
    Node_Id    Post_Cond;
    List_Id    Statements;
  };

  interface While_Statement : Node_Id {
    Node_Id    Condition;
    List_Id    Statements;
  };

  /*
   * Switch_Statement interface is used to generate
   * a switch instruction with all possibilities.
   * The Alternatives member should contain Switch_Alternative
   * interfaces which contain all possible alternatives
   * Generated code will look like :
   * switch (Expression)
   * {
   *     Switch_Alternative_1
   *     Switch_Alternative_2
   * }
   */
  interface Switch_Statement : Node_Id {
    Node_Id    Expression;
    List_Id    Alternatives;
  };

  /*
   * A switch alternative is used in switch statement
   * and contain possible values for the switch expression
   * Generated code will look like :
   * label1: label2: .... labelN:
   * {
   *   statement1;
   *   statement2;
   *   ...
   *   statementN;
   * }
   */
  interface Switch_Alternative : Node_Id {
    List_Id    Labels;
    List_Id    Statements;
  };

  /*
   * break statement for switch alternative
   * Only generate the "break" keyword
   */
  interface Break_Statement : Node_Id {
  };

  /*
   * As break, the Continue_Statement interface
   * only generate the "continue" keyword
   */
  interface Continue_Statement : Node_Id {
  };
  
  interface C_Comment : Definition {
    boolean     Has_Header_Spaces;
  };

305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
  interface Doxygen_C_Comment : Node_Id {
    boolean       Has_Header_Spaces;
    boolean       For_Struct;
    boolean       For_Union;
    boolean       For_Enum;
    boolean       For_Function;
    boolean       For_Variable;
    boolean       For_Define;
    boolean       For_Typedef;
    boolean       For_File;
    boolean       For_Namespace;
    boolean       For_Package;
    boolean       For_Interface;
    Node_Id       Summary;
    Node_Id       Description;
    Node_Id       Element;
  };

323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
  interface Define_Statement : Definition {
    Node_Id     Defined_Value;
  };

  /*
   * Array_Declaration is used to generate
   * code like myarray[3]
   * or myarray[mysize];
   */
  interface Array_Declaration : Definition {
    Node_Id     Array_Size;
  };

  /**************/
  /* Aggregates */
  /**************/

  /*
   * Struct_Aggregate interface is used
   * to generated code like 
   * struct struct_name {
   * member_type member1;
   * member_type member2;
   * }
   */
  interface Struct_Aggregate : Definition {
    List_Id    Struct_Members;
  };

  /*
   * Used to generate Union, generated code looks like
   * the Struct_Aggregate 
   */
  interface Union_Aggregate : Definition {
    List_Id    Union_Members;
  };

  /*
   * The list of Enum_Aggregate contains
   * Expressions or Identifier
   */
  interface Enum_Aggregate : Node_Id {
    List_Id    Enum_Members;
  };

  /* Definition is used in functions to 
   * declare variables
   * Generated code looks like :
   * used_type  variable_name;
   */
  interface Variable_Declaration : Definition {
    Node_Id    Used_Type;
  };
  
  /*
   * Member_Declaration is used in unions
   * or structures
   */
  interface Member_Declaration : Definition {
    Node_Id    Used_Type;
  };

  /*
   * Member_Designator is used to used member
   * of struct/union/enum
   * Generate code like : mystruct.member
   */
  interface Member_Designator : Definition {
    Node_Id    Aggregate_Name;
    boolean    Is_Pointer;
  };

  /****************/
  /* Object nodes */
  /****************/

  interface Macro_Declaration: Definition {
    Node_Id    Expression;
  };

  interface Literal : Node_Id {
    Value_Id   Value;
  };
 

  interface Expression : Node_Id {
    Operator_Id Operator;
    Node_Id     Left_Expression;
    Node_Id     Right_Expression;
  };

  /* Type Casting */
  interface Type_Conversion : Node_Id {
    Node_Id   Subtype_Mark;
    Node_Id   Expression;
  };

  /**************/
  /* Base types */
  /**************/

  interface Base_Type {
    Name_Id    Image;
  };

  interface Pointer_Type {
    Node_Id    Used_Type;
  };

  interface Constant_Type {
    Node_Id    Used_Type;
  };

  /*
   * Use to generate &expression
   * For example &myvariable
   *          or &(table + 4)
   */
  interface Variable_Address : Node_Id {
    Node_Id    Expression;
  };

  interface Extern_Entity_Declaration : Node_Id {
    Node_Id    Entity;
  };

  interface _Float           : Base_Type {};
  interface _Int             : Base_Type {};
  interface _Char            : Base_Type {};
  interface _Short           : Base_Type {};
  interface _Void            : Base_Type {};
  interface _Pointed_Char    : Base_Type {};

  /* Common Tree bindings */
  interface Tree_Bindings : Node_Id {
    /* Units */
    Node_Id    Main_Node;
    
    /* Entities */
    Node_Id    Type_Definition_Node;
    Node_Id    Feature_Subprogram_Node;
    Node_Id    Subprogram_Node;
  };  
  
  interface HI_Tree_Bindings : Tree_Bindings {
    /* Units */
    
    Node_Id    Internals_Node;
    Node_Id    System_Time_Node;
    Node_Id    Marshaller_Node;
    Node_Id    Unmarshaller_Node;
    Node_Id    Activity_Node;
    Node_Id    Functions_Node;
    Node_Id    Types_Node;
    Node_Id    Object_Node;
    Node_Id    Handlers_Node;
    Node_Id    Global_Port_Node;
    Node_Id    Local_Port_Node;
481
482
    Node_Id    Global_Names_Node;
    Node_Id    Global_Model_Names_Node;
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
    Node_Id    Request_Node;
    Node_Id    Deployment_Node;
    Node_Id    Entities_Node;
    Node_Id    Servers_Node;
    Node_Id    Naming_Node;
    List_Id    Processes;

    /* Entities */

    Node_Id    Request_Type_Node;
    Node_Id    Job_Node;
    Node_Id    Stub_Node;
    Node_Id    Enumerator_Node;
    Node_Id    Process_Request_Node;
    Node_Id    Marshall_Request_Node;
    Node_Id    Unmarshall_Request_Node;
    Node_Id    Default_Value_Node;
  };
};