-
Notifications
You must be signed in to change notification settings - Fork 133
/
statement.C
3858 lines (3255 loc) · 287 KB
/
statement.C
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
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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "grammar.h"
#include "ROSETTA_macros.h"
#include "terminal.h"
#if 0
#ifdef TEMPLATE_DECLARATIONS_DERIVED_FROM_NON_TEMPLATE_DECLARATIONS
#error "TEMPLATE_DECLARATIONS_DERIVED_FROM_NON_TEMPLATE_DECLARATIONS IS defined and should NOT BE..."
#else
#error "TEMPLATE_DECLARATIONS_DERIVED_FROM_NON_TEMPLATE_DECLARATIONS is NOT defined and SHOULD BE..."
#endif
#endif
/*
DQ (3/2/2004): After March 1st meeting with Bjarne, it seems clear we should
support a few more IR nodes specific to templates.
The idea here is to simplfy analysis and manipulation of templates.
It is not clear if this does not favor the relationship of a templated
class to template rather than to a class declaration. We can only put the
IR node at one location in the hierarchy, but any choise is a compromise.
Fundamentally, is a template class declaration more of a template or a
class declaration? Or should we go down the road of multiple inheritance
as a way to describe the template relationship the non-template IR nodes?
Possible Design of Template IR nodes:
// parameters to template declaration
TemplateParameters // new IR node to SAGE
// arguments to template instantiations (not clear how to handle partial specialization)
TemplateArguments // new IR node
// Support for class templates
TemplateDeclaration
TemplateClassDeclaration
TemplateClassInstantiationDeclaration
TemplateClassSpecializationDeclaration // new IR node to SAGE
TemplateClassSpecializationInstantiationDeclaration // new IR node to SAGE
TemplateClassInstantiationDefinition
// Support for function templates
TemplateFunctionDeclaration
TemplateSpecializationFunctionDeclaration // new IR node to SAGE
TemplateSpecializationInstantiationFunctionDeclaration // new IR node to SAGE
TemplateInstantiationFunctionDeclaration
TemplateMemberFunctionDeclaration
TemplateSpecializationMemberFunctionDeclaration // new IR node to SAGE
TemplateSpecializationInstantiationMemberFunctionDeclaration // new IR node to SAGE
TemplateInstantiationMemberFunctionDeclaration
// TemplateTemplateDeclaration
// TemplateStaticDataMemberDeclaration
NOTE: Current Design has TemplateClassInstantiationDeclaration derived from SgClassDeclaration
This allows instiated templates to be treated as classes (which they are!).
*/
void
Grammar::setUpStatements ()
{
// This function sets up the type system for the grammar. In this case it implements the
// C++ grammar, but this will be modified to permit all grammars to contain elements of the
// C++ grammar. Modified grammars will add and subtract elements from this default C++ grammar.
NEW_TERMINAL_MACRO (ForStatement, "ForStatement", "FOR_STMT");
NEW_TERMINAL_MACRO (ForInitStatement, "ForInitStatement", "FOR_INIT_STMT" );
NEW_TERMINAL_MACRO (CatchStatementSeq, "CatchStatementSeq", "CATCH_STATEMENT_SEQ" );
NEW_TERMINAL_MACRO (FunctionParameterList, "FunctionParameterList", "FUNCTION_PARAMETER_LIST" );
NEW_TERMINAL_MACRO (CtorInitializerList, "CtorInitializerList", "CTOR_INITIALIZER_LIST" );
NEW_TERMINAL_MACRO (BasicBlock, "BasicBlock", "BASIC_BLOCK_STMT");
NEW_TERMINAL_MACRO (Global, "Global", "GLOBAL_STMT" );
NEW_TERMINAL_MACRO (IfStmt, "IfStmt", "IF_STMT" );
// NEW_TERMINAL_MACRO (FunctionDefinition, "FunctionDefinition", "FUNC_DEFN_STMT" );
NEW_TERMINAL_MACRO (WhileStmt, "WhileStmt", "WHILE_STMT" );
NEW_TERMINAL_MACRO (DoWhileStmt, "DoWhileStmt", "DO_WHILE_STMT" );
NEW_TERMINAL_MACRO (SwitchStatement, "SwitchStatement", "SWITCH_STMT" );
NEW_TERMINAL_MACRO (CatchOptionStmt, "CatchOptionStmt", "CATCH_STMT" );
NEW_TERMINAL_MACRO (VariableDefinition, "VariableDefinition", "VAR_DEFN_STMT" );
// NEW_TERMINAL_MACRO (ClassDeclaration, "ClassDeclaration", "CLASS_DECL_STMT" );
// NEW_TERMINAL_MACRO (ClassDefinition, "ClassDefinition", "CLASS_DEFN_STMT" );
NEW_TERMINAL_MACRO (StmtDeclarationStatement, "StmtDeclarationStatement", "STMT_DECL_STMT" );
NEW_TERMINAL_MACRO (EnumDeclaration, "EnumDeclaration", "ENUM_DECL_STMT" );
NEW_TERMINAL_MACRO (AsmStmt, "AsmStmt", "ASM_STMT" );
NEW_TERMINAL_MACRO (TypedefDeclaration, "TypedefDeclaration", "TYPEDEF_STMT" );
NEW_TERMINAL_MACRO (FunctionTypeTable, "FunctionTypeTable", "FUNC_TBL_STMT" );
NEW_TERMINAL_MACRO (ExprStatement, "ExprStatement", "EXPR_STMT" );
NEW_TERMINAL_MACRO (LabelStatement, "LabelStatement", "LABEL_STMT" );
NEW_TERMINAL_MACRO (CaseOptionStmt, "CaseOptionStmt", "CASE_STMT" );
NEW_TERMINAL_MACRO (TryStmt, "TryStmt", "TRY_STMT" );
NEW_TERMINAL_MACRO (DefaultOptionStmt, "DefaultOptionStmt", "DEFAULT_STMT" );
NEW_TERMINAL_MACRO (BreakStmt, "BreakStmt", "BREAK_STMT" );
NEW_TERMINAL_MACRO (ContinueStmt, "ContinueStmt", "CONTINUE_STMT" );
NEW_TERMINAL_MACRO (ReturnStmt, "ReturnStmt", "RETURN_STMT" );
NEW_TERMINAL_MACRO (GotoStatement, "GotoStatement", "GOTO_STMT" );
NEW_TERMINAL_MACRO (SpawnStmt, "SpawnStmt", "SPAWN_STMT" );
// DQ (12/13/2005): Added support for empty statement (and empty expression).
NEW_TERMINAL_MACRO (NullStatement, "NullStatement", "NULL_STMT" );
// DQ (12/13/2005): Added variant statement to support future patterns
// specifications (contains RegEx string specifier for SgStatement IR node).
NEW_TERMINAL_MACRO (VariantStatement, "VariantStatement", "VARIANT_STMT" );
// Addition to SAGE3 (not present in SAGE2) this permits the representation of unbound pragmas in SAGE3
// NEW_TERMINAL_MACRO (PragmaStatement, "PragmaStatement", "PRAGMA_STMT" );
NEW_TERMINAL_MACRO (PragmaDeclaration, "PragmaDeclaration", "PRAGMA_DECL" );
// Added template support
// Note: TemplateInstantiationDecl should have been called TemplateClassInstantiationDecl
// to better match TemplateInstantiationFunctionDecl (suggested name change).
// DQ (6/10/2011): Added more IR nodes specific to template declarations. Note that later we want
// TemplateDeclaration to not be allowed so that we can force the derived IR nodes to be used instead.
// NEW_TERMINAL_MACRO (TemplateDeclaration, "TemplateDeclaration", "TEMPLATE_DECL_STMT" );
NEW_TERMINAL_MACRO (TemplateClassDeclaration, "TemplateClassDeclaration", "TEMPLATE_CLASS_DECL_STMT" );
// NEW_TERMINAL_MACRO (TemplateFunctionDeclaration, "TemplateFunctionDeclaration", "TEMPLATE_FUNCTION_DECL_STMT" );
NEW_TERMINAL_MACRO (TemplateMemberFunctionDeclaration, "TemplateMemberFunctionDeclaration", "TEMPLATE_MEMBER_FUNCTION_DECL_STMT" );
#ifdef TEMPLATE_DECLARATIONS_DERIVED_FROM_NON_TEMPLATE_DECLARATIONS
NEW_TERMINAL_MACRO (TemplateFunctionDeclaration, "TemplateFunctionDeclaration", "TEMPLATE_FUNCTION_DECL_STMT" );
#else
NEW_NONTERMINAL_MACRO (TemplateFunctionDeclaration, TemplateMemberFunctionDeclaration, "TemplateFunctionDeclaration", "TEMPLATE_FUNCTION_DECL_STMT", true );
#endif
// DQ (12/6/2011): Adding support for template variables (static data members).
NEW_TERMINAL_MACRO (TemplateVariableDeclaration, "TemplateVariableDeclaration", "TEMPLATE_VARIABLE_DECL_STMT" );
#ifdef TEMPLATE_DECLARATIONS_DERIVED_FROM_NON_TEMPLATE_DECLARATIONS
// DQ (12/21/2011): This is the newer design, we want template declaration to act just like functions and classes since they are used as such in the AST
// representation of the template declaration. In this case a template function declaration is more like a function declaration than a template declaration.
NEW_TERMINAL_MACRO (TemplateDeclaration, "TemplateDeclaration", "TEMPLATE_DECL_STMT");
#else
// DQ (12/21/2011): This was the first design, but it is problematic for the representation of template function and template class declarations in the AST.
// In this case a template function declaration is more like a template declaration than a function declaration.
NEW_NONTERMINAL_MACRO (TemplateDeclaration,
TemplateClassDeclaration | TemplateFunctionDeclaration | TemplateVariableDeclaration, "TemplateDeclaration", "TEMPLATE_DECL_STMT", true);
#endif
#ifdef TEMPLATE_DECLARATIONS_DERIVED_FROM_NON_TEMPLATE_DECLARATIONS
// DQ (12/21/2011): Newer version of code.
NEW_NONTERMINAL_MACRO (VariableDeclaration, TemplateVariableDeclaration, "VariableDeclaration", "VAR_DECL_STMT", true );
#else
// DQ (12/21/2011): Older version of code.
NEW_TERMINAL_MACRO (VariableDeclaration, "VariableDeclaration", "VAR_DECL_STMT" );
#endif
// DQ (9/12/2004): Adding new IR node to support instantiation directives (C++ template language construct)
// NEW_TERMINAL_MACRO (TemplateInstantiationDirective, "TemplateInstantiationDirective", "TEMPLATE_INST_DIRECTIVE_STMT" );
// NEW_TERMINAL_MACRO (TemplateSpecializationDeclaration, "TemplateSpecializationDeclaration", "TEMPLATE_SPECIALIZATION_DECL_STMT" );
NEW_TERMINAL_MACRO (TemplateInstantiationDecl, "TemplateInstantiationDecl", "TEMPLATE_INST_DECL_STMT" );
NEW_TERMINAL_MACRO (TemplateInstantiationDefn, "TemplateInstantiationDefn", "TEMPLATE_INST_DEFN_STMT" );
NEW_TERMINAL_MACRO (TemplateInstantiationFunctionDecl,
"TemplateInstantiationFunctionDecl", "TEMPLATE_INST_FUNCTION_DECL_STMT" );
NEW_TERMINAL_MACRO (TemplateInstantiationMemberFunctionDecl,
"TemplateInstantiationMemberFunctionDecl", "TEMPLATE_INST_MEMBER_FUNCTION_DECL_STMT" );
// driscoll6 (6/27/11): Support for Python
NEW_TERMINAL_MACRO (WithStatement, "WithStatement", "WITH_STATEMENT" );
NEW_TERMINAL_MACRO (PythonGlobalStmt, "PythonGlobalStmt", "PYTHON_GLOBAL_STMT" );
NEW_TERMINAL_MACRO (PythonPrintStmt, "PythonPrintStmt", "PYTHON_PRINT_STMT" );
NEW_TERMINAL_MACRO (PassStatement, "PassStatement", "PASS_STATEMENT" );
NEW_TERMINAL_MACRO (AssertStmt, "AssertStmt", "ASSERT_STMT" );
NEW_TERMINAL_MACRO (ExecStatement, "ExecStatement", "EXEC_STMT" );
#if USE_FORTRAN_IR_NODES
// Fortran language constructs that map directly to C/C++ IR nodes:
// Fortran: cycle --> C: continue
// Fortran: exit --> C: break
// Fortran: select case --> C: switch
// Fortran: case --> C: case option
// Fortran: case default --> C: default
// Fortran: type --> C: struct
// Fortran: sequence --> C: ???
// Fortran: --> C:
// DQ (2/2/2006): Support for Fortran IR nodes
NEW_TERMINAL_MACRO (ProgramHeaderStatement, "ProgramHeaderStatement", "PROGRAM_HEADER_STMT" );
NEW_TERMINAL_MACRO (ProcedureHeaderStatement, "ProcedureHeaderStatement", "PROCEDURE_HEADER_STMT" );
NEW_TERMINAL_MACRO (EntryStatement, "EntryStatement", "ENTRY_STMT" );
// DQ (3/22/2007): Added Fortran non-blocked do statement
// NEW_TERMINAL_MACRO (FortranDo, "FortranDo", "FORTRAN_DO" );
NEW_TERMINAL_MACRO (FortranNonblockedDo, "FortranNonblockedDo", "FORTRAN_NONBLOCKED_DO" );
NEW_TERMINAL_MACRO (InterfaceStatement, "InterfaceStatement", "INTERFACE_STATEMENT" );
NEW_TERMINAL_MACRO (ParameterStatement, "ParameterStatement", "PARAMETER_STATEMENT" );
NEW_TERMINAL_MACRO (CommonBlock, "CommonBlock", "COMMON_BLOCK" );
NEW_TERMINAL_MACRO (ModuleStatement, "ModuleStatement", "MODULE_STATEMENT" );
NEW_TERMINAL_MACRO (UseStatement, "UseStatement", "USE_STATEMENT" );
NEW_TERMINAL_MACRO (StopOrPauseStatement, "StopOrPauseStatement", "STOP_OR_PAUSE_STATEMENT" );
// DQ (11/25/2007): Make this the base class of all the IR nodes for Frotran I/O
// NEW_TERMINAL_MACRO (IOStatement, "IOStatement", "IO_STATEMENT" );
// NEW_TERMINAL_MACRO (InputOutputStatement, "InputOutputStatement", "INPUT_OUTPUT_STATEMENT" );
NEW_TERMINAL_MACRO (PrintStatement, "PrintStatement", "PRINT_STATEMENT" );
NEW_TERMINAL_MACRO (ReadStatement, "ReadStatement", "READ_STATEMENT" );
NEW_TERMINAL_MACRO (WriteStatement, "WriteStatement", "WRITE_STATEMENT" );
NEW_TERMINAL_MACRO (OpenStatement, "OpenStatement", "OPEN_STATEMENT" );
NEW_TERMINAL_MACRO (CloseStatement, "CloseStatement", "CLOSE_STATEMENT" );
NEW_TERMINAL_MACRO (InquireStatement, "InquireStatement", "INQUIRE_STATEMENT" );
NEW_TERMINAL_MACRO (FlushStatement, "FlushStatement", "FLUSH_STATEMENT" );
NEW_TERMINAL_MACRO (BackspaceStatement, "BackspaceStatement", "BACKSPACE_STATEMENT" );
NEW_TERMINAL_MACRO (RewindStatement, "RewindStatement", "REWIND_STATEMENT" );
NEW_TERMINAL_MACRO (EndfileStatement, "EndfileStatement", "ENDFILE_STATEMENT" );
NEW_TERMINAL_MACRO (WaitStatement, "WaitStatement", "WAIT_STATEMENT" );
// FMZ (2/3/2009): Added co-array "withteam" stmt
// NEW_TERMINAL_MACRO (WithTeamStatement, "WithTeamStatement", "WITHTEAM_DECL_STMT" );
// FMZ (2/17/2009): We re-defined "withteam" stmt
NEW_TERMINAL_MACRO (CAFWithTeamStatement, "CAFWithTeamStatement", "WITHTEAM_STMT" );
// DQ (12/18/2007): Added support for Fortran Format statement
NEW_TERMINAL_MACRO (FormatStatement, "FormatStatement", "FORMAT_STATEMENT" );
// DQ (11/24/2007): Not sure how this maps to Fortran.
// NEW_TERMINAL_MACRO (IOFileControlStmt, "IOFileControlStmt", "IO_FILE_CONTROL_STMT" );
// These each have only unit, iostat and err (so they are just a flag in the SgIOControlStatement IR node
// NEW_TERMINAL_MACRO (EndFileStatement, "EndFileStatement", "END_FILE_STATEMENT" );
// NEW_TERMINAL_MACRO (BackspaceStatement, "BackspaceStatement", "BACKSPACE_STATEMENT" );
// NEW_TERMINAL_MACRO (RewindStatement, "RewindStatement", "REWIND_STATEMENT" );
// DQ (3/22/2007): Added Fortran non-blocked do statement (derived from FortranDo)
NEW_NONTERMINAL_MACRO (FortranDo, FortranNonblockedDo, "FortranDo", "FORTRAN_DO", true);
NEW_TERMINAL_MACRO (ForAllStatement, "ForAllStatement", "FOR_ALL_STMT");
NEW_NONTERMINAL_MACRO (IOStatement,
// InputOutputStatement | OpenStatement | CloseStatement | InquireStatement | IOFileControlStmt,
PrintStatement | ReadStatement | WriteStatement | OpenStatement | CloseStatement |
InquireStatement | FlushStatement | BackspaceStatement | RewindStatement | EndfileStatement |
WaitStatement,
"IOStatement", "IO_STATEMENT", false);
#endif
#if USE_UPC_IR_NODES
// DQ and Liao (6/10/2008): Added new IR nodes specific to UPC.
NEW_TERMINAL_MACRO (UpcNotifyStatement, "UpcNotifyStatement", "UPC_NOTIFY_STMT" );
NEW_TERMINAL_MACRO (UpcWaitStatement, "UpcWaitStatement", "UPC_WAIT_STMT" );
NEW_TERMINAL_MACRO (UpcBarrierStatement, "UpcBarrierStatement", "UPC_BARRIER_STMT" );
NEW_TERMINAL_MACRO (UpcFenceStatement, "UpcFenceStatement", "UPC_FENCE_STMT" );
NEW_TERMINAL_MACRO (UpcForAllStatement, "UpcForAllStatement", "UPC_FORALL_STMT" );
#endif
// Common OpenMP nodes for both C/C++ and Fortran, Liao, 5/29/2009
#if USE_OMP_IR_NODES
// define terminals and non-terminals and their hierarchy
//------------------------------------------------------------
// +body+ clauses
NEW_TERMINAL_MACRO (OmpParallelStatement, "OmpParallelStatement", "OMP_PARALLEL_STMT" );
NEW_TERMINAL_MACRO (OmpSingleStatement, "OmpSingleStatement", "OMP_SINGLE_STMT" );
NEW_TERMINAL_MACRO (OmpTaskStatement, "OmpTaskStatement", "OMP_TASK_STMT" );
NEW_TERMINAL_MACRO (OmpForStatement, "OmpForStatement", "OMP_FOR_STMT" );
NEW_TERMINAL_MACRO (OmpDoStatement, "OmpDoStatement", "OMP_DO_STMT" );
NEW_TERMINAL_MACRO (OmpSectionsStatement, "OmpSectionsStatement", "OMP_SECTIONS_STMT" );
// experimental omp target directive, Liao 1/22/2012
// use for testing OpenMP accelerator model
NEW_TERMINAL_MACRO (OmpTargetStatement, "OmpTargetStatement", "OMP_TARGET_STMT" );
NEW_TERMINAL_MACRO (OmpTargetDataStatement, "OmpTargetDataStatement", "OMP_TARGET_DATA_STMT" );
NEW_TERMINAL_MACRO (OmpSimdStatement, "OmpSimdStatement", "OMP_SIMD_STMT" );
// A base class for the most commonly formed directives with both clauses and a structured body
// We treat OmpSectionsStatement separatedly by move the body to a list of SgOmpSectionStatement
// sensitive to
NEW_NONTERMINAL_MACRO (OmpClauseBodyStatement, OmpParallelStatement | OmpSingleStatement |
OmpTaskStatement| OmpForStatement| OmpDoStatement | OmpSectionsStatement | OmpTargetStatement| OmpTargetDataStatement |
OmpSimdStatement,
"OmpClauseBodyStatement", "OMP_CLAUSEBODY_STMT", false );
// + a statement / block
NEW_TERMINAL_MACRO (OmpAtomicStatement, "OmpAtomicStatement", "OMP_ATOMIC_STMT" );
NEW_TERMINAL_MACRO (OmpMasterStatement, "OmpMasterStatement", "OMP_MASTER_STMT" );
NEW_TERMINAL_MACRO (OmpSectionStatement, "OmpSectionStatement", "OMP_SECTION_STMT" ); // need this?
NEW_TERMINAL_MACRO (OmpOrderedStatement, "OmpOrderedStatement", "OMP_ORDERED_STMT" );
NEW_TERMINAL_MACRO (OmpWorkshareStatement, "OmpWorkshareStatement", "OMP_WORKSHARE_STMT" );
// + stmt/block + name
NEW_TERMINAL_MACRO (OmpCriticalStatement, "OmpCriticalStatement", "OMP_CRITICAL_STMT" );
// A base class for all directives with a body/statement
NEW_NONTERMINAL_MACRO (OmpBodyStatement, OmpAtomicStatement | OmpMasterStatement | OmpOrderedStatement
| OmpCriticalStatement | OmpSectionStatement | OmpWorkshareStatement | OmpClauseBodyStatement ,
"OmpBodyStatement", "OMP_BODY_STMT", false );
#endif
#include "java/terminals.cpp"
// DQ (8/21/2007): More IR nodes required for Fortran support
NEW_TERMINAL_MACRO (BlockDataStatement, "BlockDataStatement", "TEMP_Block_Data_Statement" );
NEW_TERMINAL_MACRO (ImplicitStatement, "ImplicitStatement", "TEMP_Implicit_Statement" );
NEW_TERMINAL_MACRO (StatementFunctionStatement,"StatementFunctionStatement", "TEMP_Statement_Function_Statement" );
NEW_TERMINAL_MACRO (WhereStatement, "WhereStatement", "TEMP_Where_Statement" );
NEW_TERMINAL_MACRO (NullifyStatement, "NullifyStatement", "TEMP_Nullify_Statement" );
NEW_TERMINAL_MACRO (EquivalenceStatement, "EquivalenceStatement", "TEMP_Equivalence_Statement" );
NEW_TERMINAL_MACRO (DerivedTypeStatement, "DerivedTypeStatement", "TEMP_Derived_Type_Statement" );
// DQ (9/4/2007): Added DIMENSION statement (for array declaration support)
// These are the type attributes: ALLOCATABLE, DIMENSION, EXTERNAL, INTENT, INTRINSIC, OPTIONAL, PARAMETER, POINTER, SAVE, TARGET
// These are the ones that have associated statements: ALLOCATE, DIMENSION, EXTERNAL, INTRINSIC, OPTIONAL, PARAMETER, POINTER, SAVE, TARGET
// Attributes that are not an associated statement: INTENT
// Paired statements: ALLOCATE, DEALLOCATE
// Additional statements that I expect we will require: AccessStatement, AllocatableStatement, AllocateStatement,
// AsynchronousStatement, BindStatement, DataStatement, DeallocateStatement, DimensionStatement, ContainsStatement,
// ValueStatement, VolatileStatement, ExternalStatement, IntentStatement, IntrinsicStatement, OptionalStatement,
// PointerStatement, ProtectedStatement, SaveStatement, SequenceStatement, TargetStatement
// Alternatively we could defined an AttributeSpecificationStatement to be:
// AccessStatement, AllocatableStatement, AsynchronousStatement, BindStatement, DataStatement, DimensionStatement,
// IntentStatement, IntrinsicStatement, OptionalStatement, ParameterStatement, PointerStatement, ProtectedStatement, SaveStatement,
// TargetStatement, ValueStatement, VolatileStatement
// And then define separate statements for: AllocateStatement, DeallocateStatement, ContainsStatement, SequenceStatement
NEW_TERMINAL_MACRO (AttributeSpecificationStatement, "AttributeSpecificationStatement", "TEMP_Attribute_Specification_Statement" );
NEW_TERMINAL_MACRO (AllocateStatement, "AllocateStatement", "TEMP_Allocate_Statement" );
NEW_TERMINAL_MACRO (DeallocateStatement, "DeallocateStatement", "TEMP_Deallocate_Statement" );
NEW_TERMINAL_MACRO (ContainsStatement, "ContainsStatement", "TEMP_Contains_Statement" );
NEW_TERMINAL_MACRO (SequenceStatement, "SequenceStatement", "TEMP_Sequence_Statement" );
// DQ (9/23/2007): Added elsewhere IR node to handle cascading elsewhere in where statement
NEW_TERMINAL_MACRO (ElseWhereStatement, "ElseWhereStatement", "TEMP_Else_Where_Statement" );
// Required for F77 support (but depricated in F90)
NEW_TERMINAL_MACRO (ArithmeticIfStatement, "ArithmeticIfStatement", "TEMP_Arithmetic_If_Statement" );
NEW_TERMINAL_MACRO (AssignStatement, "AssignStatement", "TEMP_Assign_Statement" );
NEW_TERMINAL_MACRO (ComputedGotoStatement, "ComputedGotoStatement", "TEMP_Computed_Goto_Statement" );
NEW_TERMINAL_MACRO (AssignedGotoStatement, "AssignedGotoStatement", "TEMP_Assigned_Goto_Statement" );
NEW_TERMINAL_MACRO (NamelistStatement, "NamelistStatement", "TEMP_Namelist_Statement" );
NEW_TERMINAL_MACRO (ImportStatement, "ImportStatement", "TEMP_Import_Statement" );
// DQ (11/30/2007): Added new IR node to support "associate" statement (F2003)
NEW_TERMINAL_MACRO (AssociateStatement, "AssociateStatement", "TEMP_Associate_Statement" );
// DQ (2/18/2008): Added support for language specific Fortran include line (not a statement in Fortran,
// but a declaration statement in ROSE similar to the CPP IncludeDirectiveStatement).
NEW_TERMINAL_MACRO (FortranIncludeLine, "FortranIncludeLine", "TEMP_Fortran_Include_Line" );
// NEW_TERMINAL_MACRO (ClinkageStartStatement, "ClinkageStartStatement", "C_LINKAGE_START_STMT" );
// DQ (4/19/2004): Support for namespaces: NamespaceDeclarationStatement,
// NamespaceAliasDeclarationStatement, UsingDeclarationStatement
NEW_TERMINAL_MACRO (NamespaceDeclarationStatement,"NamespaceDeclarationStatement","NAMESPACE_DECLARATION_STMT" );
NEW_TERMINAL_MACRO (NamespaceAliasDeclarationStatement,
"NamespaceAliasDeclarationStatement",
"NAMESPACE_ALIAS_DECLARATION_STMT");
NEW_TERMINAL_MACRO (NamespaceDefinitionStatement,"NamespaceDefinitionStatement","NAMESPACE_DEFINITION_STMT" );
NEW_TERMINAL_MACRO (UsingDeclarationStatement, "UsingDeclarationStatement", "USING_DECLARATION_STMT" );
NEW_TERMINAL_MACRO (UsingDirectiveStatement, "UsingDirectiveStatement", "USING_DIRECTIVE_STMT" );
// DQ (4/16/2005): Added specific support in the IR for explicit template instantiation directives (to fix linking issues)
NEW_TERMINAL_MACRO (TemplateInstantiationDirectiveStatement, "TemplateInstantiationDirectiveStatement", "TEMPLATE_INST_DIRECTIVE_STMT" );
// DQ (6/10/2011): Added template specific definitions.
NEW_TERMINAL_MACRO (TemplateClassDefinition, "TemplateClassDefinition", "TEMPLATE_CLASS_DEF_STMT" );
NEW_TERMINAL_MACRO (TemplateFunctionDefinition, "TemplateFunctionDefinition", "TEMPLATE_FUNCTION_DEF_STMT" );
#ifdef TEMPLATE_DECLARATIONS_DERIVED_FROM_NON_TEMPLATE_DECLARATIONS
// DQ (12/21/2011): New design...
NEW_NONTERMINAL_MACRO (ClassDeclaration, TemplateClassDeclaration | TemplateInstantiationDecl | DerivedTypeStatement | ModuleStatement | JavaPackageDeclaration, "ClassDeclaration", "CLASS_DECL_STMT", true );
#else
NEW_NONTERMINAL_MACRO (ClassDeclaration, TemplateInstantiationDecl | DerivedTypeStatement | ModuleStatement | JavaPackageDeclaration, "ClassDeclaration", "CLASS_DECL_STMT", true );
#endif
// NEW_NONTERMINAL_MACRO (ClassDefinition, TemplateInstantiationDefn, "ClassDefinition", "CLASS_DEFN_STMT", true );
NEW_NONTERMINAL_MACRO (ClassDefinition, TemplateInstantiationDefn | TemplateClassDefinition, "ClassDefinition", "CLASS_DEFN_STMT", true );
// DQ (6/10/2011): Changed this to be a non-terminal and added TemplateFunctionDefinition
NEW_NONTERMINAL_MACRO (FunctionDefinition, TemplateFunctionDefinition, "FunctionDefinition", "FUNC_DEFN_STMT", true );
// Note that the associate statement is really a scope, with its own declarations of variables declared by reference to
// other variables or expressions. They are only l-values if and only if the rhs is a l-value (I think).
NEW_NONTERMINAL_MACRO (ScopeStatement,
Global | BasicBlock | IfStmt | ForStatement | FunctionDefinition |
ClassDefinition | WhileStmt | DoWhileStmt | SwitchStatement | CatchOptionStmt |
NamespaceDefinitionStatement | BlockDataStatement | AssociateStatement | FortranDo | ForAllStatement |
UpcForAllStatement | CAFWithTeamStatement | JavaForEachStatement | JavaLabelStatement
/* | TemplateInstantiationDefn */,
"ScopeStatement","SCOPE_STMT", false);
// DQ (3/22/2004): Added to support template member functions (removed MemberFunctionDeclaration as terminal)
#ifdef TEMPLATE_DECLARATIONS_DERIVED_FROM_NON_TEMPLATE_DECLARATIONS
// DQ (12/21/2011): New design...
NEW_NONTERMINAL_MACRO (MemberFunctionDeclaration, TemplateMemberFunctionDeclaration | TemplateInstantiationMemberFunctionDecl,"MemberFunctionDeclaration","MFUNC_DECL_STMT", true);
#else
NEW_NONTERMINAL_MACRO (MemberFunctionDeclaration,TemplateInstantiationMemberFunctionDecl,"MemberFunctionDeclaration","MFUNC_DECL_STMT", true);
#endif
// DQ (3/20/2007): ProgramHeaderStatement and ProcedureHeaderStatement are derived from FunctionDeclaration
#ifdef TEMPLATE_DECLARATIONS_DERIVED_FROM_NON_TEMPLATE_DECLARATIONS
// DQ (12/21/2011): New design...
NEW_NONTERMINAL_MACRO (FunctionDeclaration,
TemplateFunctionDeclaration | MemberFunctionDeclaration | TemplateInstantiationFunctionDecl | ProgramHeaderStatement | ProcedureHeaderStatement | EntryStatement,
"FunctionDeclaration","FUNC_DECL_STMT", true);
#else
NEW_NONTERMINAL_MACRO (FunctionDeclaration,
MemberFunctionDeclaration | TemplateInstantiationFunctionDecl | ProgramHeaderStatement | ProcedureHeaderStatement | EntryStatement,
"FunctionDeclaration","FUNC_DECL_STMT", true);
#endif
#if 0
// DQ (11/23/2008): Note that we could have F77 and F90 stype comments here, but we are not separating out comments as IR nodes.
NEW_TERMINAL_MACRO (C_StyleCommentStatement, "C_StyleCommentStatement", "C_STYLE_COMMENT_STMT" );
NEW_TERMINAL_MACRO (CxxStyleCommentStatement, "CxxStyleCommentStatement", "CXX_STYLE_COMMENT_STMT" );
NEW_NONTERMINAL_MACRO (CommentStatement,
C_StyleCommentStatement | CxxStyleCommentStatement ,
"CommentStatement", "COMMENT_STMT" );
#endif
// DQ (8/17/2007): Added CPP directives back into the IR to better support analysis and transformations.
NEW_TERMINAL_MACRO (IncludeDirectiveStatement, "IncludeDirectiveStatement", "INCLUDE_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (DefineDirectiveStatement, "DefineDirectiveStatement", "DEFINE_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (UndefDirectiveStatement, "UndefDirectiveStatement", "UNDEF_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (IfdefDirectiveStatement, "IfdefDirectiveStatement", "IFDEF_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (IfndefDirectiveStatement, "IfndefDirectiveStatement", "IFNDEF_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (IfDirectiveStatement, "IfDirectiveStatement", "IF_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (DeadIfDirectiveStatement, "DeadIfDirectiveStatement", "DEAD_IF_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (ElseDirectiveStatement, "ElseDirectiveStatement", "ELSE_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (ElseifDirectiveStatement, "ElseifDirectiveStatement", "ELSEIF_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (EndifDirectiveStatement, "EndifDirectiveStatement", "ENDIF_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (LineDirectiveStatement, "LineDirectiveStatement", "LINE_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (WarningDirectiveStatement, "WarningDirectiveStatement", "WARNING_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (ErrorDirectiveStatement, "ErrorDirectiveStatement", "ERROR_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (EmptyDirectiveStatement, "EmptyDirectiveStatement", "EMPTY_DIRECTIVE_STMT" );
// DQ (11/28/2008): Added new IR nodes.
NEW_TERMINAL_MACRO (IncludeNextDirectiveStatement, "IncludeNextDirectiveStatement", "INCLUDE_NEXT_DIRECTIVE_STMT" );
NEW_TERMINAL_MACRO (IdentDirectiveStatement, "IdentDirectiveStatement", "IDENT_DIRECTIVE_STMT" );
// Note that this IR nodes is critical to Fortran support for CPP processed generated code.
NEW_TERMINAL_MACRO (LinemarkerDirectiveStatement, "LinemarkerDirectiveStatement", "LINEMARKER_DIRECTIVE_STMT" );
NEW_NONTERMINAL_MACRO (C_PreprocessorDirectiveStatement,
IncludeDirectiveStatement | DefineDirectiveStatement | UndefDirectiveStatement |
IfdefDirectiveStatement | IfndefDirectiveStatement | IfDirectiveStatement | DeadIfDirectiveStatement |
ElseDirectiveStatement | ElseifDirectiveStatement | EndifDirectiveStatement |
LineDirectiveStatement | WarningDirectiveStatement | ErrorDirectiveStatement | EmptyDirectiveStatement |
IncludeNextDirectiveStatement | IdentDirectiveStatement | LinemarkerDirectiveStatement,
"C_PreprocessorDirectiveStatement", "CPP_DIRECTIVE_STMT", false );
NEW_TERMINAL_MACRO (ClinkageStartStatement,"ClinkageStartStatement","C_LINKAGE_START_STMT" );
NEW_TERMINAL_MACRO (ClinkageEndStatement,"ClinkageEndStatement","C_LINKAGE_END_STMT" );
NEW_NONTERMINAL_MACRO (ClinkageDeclarationStatement,
ClinkageStartStatement | ClinkageEndStatement,
"ClinkageDeclarationStatement", "C_LINKAGE_DECLARATION_STMT", false );
// + variable list
NEW_TERMINAL_MACRO (OmpFlushStatement, "OmpFlushStatement", "OMP_FLUSH_STMT" );
// simplest directives, just one line
NEW_TERMINAL_MACRO (OmpBarrierStatement, "OmpBarrierStatement", "OMP_BARRIER_STMT" );
NEW_TERMINAL_MACRO (OmpTaskwaitStatement, "OmpTaskwaitStatement", "OMP_TASKWAIT_STMT" );
// + variable list
NEW_TERMINAL_MACRO (OmpThreadprivateStatement, "OmpThreadprivateStatement", "OMP_THREADPRIVATE_STMT" );
// DQ (2/2/2006): Support for Fortran IR nodes (contributed by Rice)
NEW_NONTERMINAL_MACRO (DeclarationStatement,
FunctionParameterList | VariableDeclaration | VariableDefinition |
ClinkageDeclarationStatement | EnumDeclaration | AsmStmt |
AttributeSpecificationStatement | FormatStatement | TemplateDeclaration |
TemplateInstantiationDirectiveStatement | UseStatement | ParameterStatement |
NamespaceDeclarationStatement | EquivalenceStatement | InterfaceStatement |
NamespaceAliasDeclarationStatement | CommonBlock | TypedefDeclaration |
StatementFunctionStatement | CtorInitializerList | PragmaDeclaration |
UsingDirectiveStatement | ClassDeclaration | ImplicitStatement |
UsingDeclarationStatement | NamelistStatement | ImportStatement |
FunctionDeclaration /* | ModuleStatement */ | ContainsStatement |
C_PreprocessorDirectiveStatement | OmpThreadprivateStatement | FortranIncludeLine |
JavaImportStatement | JavaPackageStatement | StmtDeclarationStatement,
"DeclarationStatement","DECL_STMT", false);
// DQ (2/2/2006): Support for Fortran IR nodes (contributed by Rice)
NEW_NONTERMINAL_MACRO (Statement,
ScopeStatement | FunctionTypeTable | DeclarationStatement | ExprStatement |
LabelStatement | CaseOptionStmt | TryStmt | DefaultOptionStmt |
BreakStmt | ContinueStmt | ReturnStmt | GotoStatement |
SpawnStmt | NullStatement | VariantStatement | ForInitStatement |
CatchStatementSeq | StopOrPauseStatement | IOStatement |
WhereStatement | ElseWhereStatement | NullifyStatement | ArithmeticIfStatement |
AssignStatement | ComputedGotoStatement | AssignedGotoStatement |
/* FortranDo | */ AllocateStatement | DeallocateStatement | UpcNotifyStatement |
UpcWaitStatement | UpcBarrierStatement | UpcFenceStatement |
OmpBarrierStatement | OmpTaskwaitStatement | OmpFlushStatement | OmpBodyStatement |
SequenceStatement | WithStatement | PythonPrintStmt | PassStatement |
AssertStmt | ExecStatement | PythonGlobalStmt | JavaThrowStatement |
JavaSynchronizedStatement /* | JavaPackageDeclaration */,
"Statement","StatementTag", false);
// DQ (11/24/2007): These have been moved to be declarations, so they can appear where only declaration statements are allowed
// InterfaceStatement | ModuleStatement | UseStatement | ContainsStatement |
// DQ (11/24/2007): These are derived from IOControlStatement and are not directly derived from SgStatement
// InputOutputStatement | OpenStatement | CloseStatement | InquireStatement | IOFileControlStmt |
// ***********************************************************************
// ***********************************************************************
// Header Code Declaration
// ***********************************************************************
// ***********************************************************************
// Statement.setSubTreeFunctionPrototype ( "HEADER", "../Grammar/sageCommon.code" );
// Statement.excludeFunctionPrototype ( "HEADER", "../Grammar/sageCommon.code" );
Statement.setFunctionPrototype ("HEADER", "../Grammar/Statement.code" );
// DQ (12/30/2009): Added post declaration support for the template function StatementReplace
// which was previously buried into the generated source code and which work only when
// all the references were in the same file. Now with the new support to build smaller
// ROSETTA generated files this template function must be put into the header file where
// all the different source code files can see it defined.
Statement.setPostdeclarationString ("HEADER_STATEMENT_POSTDECLARATION", "../Grammar/Statement.code");
// MK: the following two function calls could be wrapped into a single one:
Statement.setFunctionPrototype("HEADER_POST_CONSTRUCTION_INITIALIZATION", "../Grammar/Statement.code");
Statement.setSubTreeFunctionPrototype("HEADER_POST_CONSTRUCTION_INITIALIZATION", "../Grammar/Statement.code" );
// DQ (12/4/2004): Now we automate the generation of the destructors
// Statement.setAutomaticGenerationOfDestructor(false);
// Statement.excludeFunctionPrototype ( "HEADER_POST_CONSTRUCTION_INITIALIZATION",
// "../Grammar/Statement.code" );
// Statement.setDataPrototype ( "SgStatement*","parent","= NULL");
// Statement.excludeDataPrototype( "SgStatement*","parent","= NULL");
// The functions we want to generate for setting the parent data are special
// Statement.setAutomaticGenerationOfDataAccessFunctions(false);
// DQ (3/21/2007): Added numeric label to support Fortran (any statement can have a label)
// A value of -1 indicates that no label is explicit in the source code.
// Statement.setDataPrototype("int", "numeric_label", "= -1",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
Statement.setDataPrototype("SgLabelRefExp*", "numeric_label", "= NULL",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (10/1/2009): Adding support for source sequence numbers as part of name qualification support
// which would include a test for if statements containing references to declarations appear before
// or after the defining declaration they are associated with. More subtle rules also apply and are
// critical for correct name qualification in the generated code (unparser).
Statement.setDataPrototype("int", "source_sequence_value", "= -1",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
ScopeStatement.setFunctionPrototype( "HEADER_SCOPE_STATEMENT", "../Grammar/Statement.code" );
ScopeStatement.setAutomaticGenerationOfConstructor(false);
// Switch between inlcuding the SgSymbolTable as a pointer or as a data member
// ScopeStatement.setDataPrototype ( "SgSymbolTable*","symbol_table","= NULL",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, DEF_DELETE, NO_COPY_DATA);
ScopeStatement.setDataPrototype ( "SgSymbolTable*","symbol_table","= NULL",
NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, DEF_DELETE, NO_COPY_DATA);
// DQ (7/23/2010): Build a local type table because during construction of the AST we can't yet build the global type table.
// After construction of the AST it might be that we can build a global type table and then perhaps not use this local one at each scope.
ScopeStatement.setDataPrototype ( "SgTypeTable*","type_table","= NULL",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, DEF_DELETE, NO_COPY_DATA);
// DQ (5/11/2011): This should be depricated since we now have a newer name qualification implementation going into place.
// DQ (6/5/2007): Specify no access functions so that we can build special ones that return by reference.
// DQ (5/8/2007): Added type elaboration list. If a symbol is in this list then it requires type elaboration ("typically "class" keyword).
ScopeStatement.setDataPrototype ( "std::set<SgSymbol*>","type_elaboration_list","",
NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE, NO_COPY_DATA);
// DQ (6/5/2007): Specify no access functions so that we can build special ones that return by reference.
// DQ (5/8/2007): Added hidden type list. If a symbol is in this list then it requires name qualification ("typically "::" keyword).
ScopeStatement.setDataPrototype ( "std::set<SgSymbol*>","hidden_type_list","",
NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE, NO_COPY_DATA);
// DQ (6/5/2007): Specify no access functions so that we can build special ones that return by reference.
// DQ (5/8/2007): Added hidden declaration list. If a symbol is in this list then it requires name qualification ("typically "::" keyword).
ScopeStatement.setDataPrototype ( "std::set<SgSymbol*>","hidden_declaration_list","",
NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE, NO_COPY_DATA);
FunctionTypeTable.setFunctionPrototype( "HEADER_FUNCTION_TYPE_TABLE", "../Grammar/Statement.code" );
FunctionTypeTable.setDataPrototype ( "SgSymbolTable*","function_type_table","= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, DEF_DELETE);
FunctionTypeTable.setAutomaticGenerationOfConstructor(false);
Global.setFunctionPrototype( "HEADER_GLOBAL", "../Grammar/Statement.code" );
Global.editSubstitute ( "HEADER_LIST_DECLARATIONS", "HEADER_LIST_DECLARATIONS", "../Grammar/Statement.code" );
// Global.setFunctionPrototype( "HEADER_LIST_DECLARATIONS", "../Grammar/Statement.code" );
Global.editSubstitute ( "LIST_DATA_TYPE", "SgDeclarationStatementPtrList" );
Global.editSubstitute ( "LIST_NAME", "declarations" );
Global.editSubstitute ( "LIST_FUNCTION_RETURN_TYPE", "void" );
Global.editSubstitute ( "LIST_FUNCTION_NAME", "declaration" );
Global.editSubstitute ( "LIST_ELEMENT_DATA_TYPE", "SgDeclarationStatement*" );
Global.setDataPrototype ( "SgDeclarationStatementPtrList", "declarations", "",
NO_CONSTRUCTOR_PARAMETER, BUILD_LIST_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
// We need a custom destructor until we have automated support for deletion of list elements.
// DQ (12/4/2004): Now we automate the generation of the destructors
// Global.setAutomaticGenerationOfDestructor(false);
// DQ (6/26/2007): Moved to SgNode to support AST merge
// DQ (10/6/2006): Support for caching of mangle names unique to global scope; this is a performance improvement.
// Global.setDataPrototype ( "std::map<SgNode*,std::string>", "mangledNameCache", "",
// NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// Global.setDataPrototype ( "std::map<std::string, int>", "shortMangledNameCache", "",
// NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
DeclarationStatement.setFunctionPrototype( "HEADER_DECLARATION_STATEMENT", "../Grammar/Statement.code" );
// DQ (3/9/2012): Moved this function to be declared after the SgDeclarationStatement was declared.
// It used to be a part of the BASIC_BLOCK_POSTDECLARATION (see that part of the code below for more details).
DeclarationStatement.setPostdeclarationString ("HEADER_DECLARATION_STATEMENT_POSTDECLARATION", "../Grammar/Statement.code");
// DQ (4/22/2004): Remove these later when the new modifiers are working
DeclarationStatement.setDataPrototype ( "unsigned int","decl_attributes","= 0",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DeclarationStatement.setDataPrototype ( "char*","linkage","= NULL",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, DEF_DELETE);
// DQ (11/23/2007): This string is used to hold the Fortran binding language as well.
// DQ (11/16/2007): Added "" as initializer for linkage string. Because we have this
// string explicit, we are not using the SgLinkageModifier (which might be a better idea).
DeclarationStatement.setDataPrototype ( "std::string","linkage","= \"\"",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (4/22/2004): Adding new modifier support (might not need/want to use the
// SgDeclarationModifier node??? When might this not be enough???)
#if 0
DeclarationStatement.setDataPrototype("SgAccessModifier", "accessModifier", "",
NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
DeclarationStatement.setDataPrototype("SgStorageModifier", "storageModifier", "",
NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
DeclarationStatement.setDataPrototype("SgLinkageModifier", "linkageModifier", "",
NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
#else
DeclarationStatement.setDataPrototype ("SgDeclarationModifier", "declarationModifier", "",
NO_CONSTRUCTOR_PARAMETER, BUILD_LIST_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
DeclarationStatement.setDataPrototype ("bool","nameOnly","= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
DeclarationStatement.setDataPrototype ("bool","forward","= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
DeclarationStatement.setDataPrototype ("bool","externBrace","= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
DeclarationStatement.setDataPrototype ("bool","skipElaborateType","= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
#endif
// DQ (10/10/2006): Use the SgQualifiedNamePtrList instead of a boolean value, and remove this data member.
// DQ (9/7/2004): Moved to declaration from variable declarations
// DQ (9/4/2004): Added support for qualification of type names in variable declarations
// DeclarationStatement.setDataPrototype("bool", "need_name_qualifier", "= false",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (9/23/2004): Removed this since it is better to compute the qualified name dynamically than to have it
// statically specified in the AST and possibly set incorrectly after a possible transformation. This also
// simplifies the transformations since they don't have to worry about setting this correctly.
// DQ (9/7/2004): Moved to declaration from variable declarations
// DQ (9/6/2004): Instead of storing the name store a symbol (either a SgClassSymbol or SgNamespaceSymbol), since
// this can be a cascading set of names (as in A::B::C::x) we need to store a list of these name qualifiers.
// As long as the traversal does not traverse the list then we can put it into the current IR node. This would have
// to be moved to its own IR node if we later want to traverse it! Until we have an example of this implemented
// we will use a list of SgSymbols and later move it to a new IR node where it can be used more generally in
// variable declarations, initializers, base class specifiers, global and member functions and tose in namespaces, etc.
// VariableDeclaration.setDataPrototype("string", "name_qualifier", "",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DeclarationStatement.setDataPrototype("SgSymbolPtrList", "name_qualifier_list", "",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (9/23/2004): Added support for references to the defining declaration (all others are forward or non-defining)
// as in the following declaration of a typedef of a function pointer:
// typedef struct foobar *(*foobarFunctionPointer)();
// where the "struct foobar" is not not really a forward declaration in a typical sense (it is the base type of a pointer
// which is a function return type), but not a defining declaration either!
// Having a concept of a "defining declaration" allows us to simplify the unparser and more accurately know when to output
// a definition. The idea is not specific to class declarations and perhaps should be in the SgDeclaration object.
// DeclarationStatement.setDataPrototype ("SgDeclarationStatement*", "definingDeclaration", "= NULL",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
DeclarationStatement.setDataPrototype ("SgDeclarationStatement*", "definingDeclaration", "= NULL",
NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (9/23/2004): Keep track of the first non-defining declaration (so it can be reused to avoid redundant
// declarations (explicitly or implicitly forward declarations).
// DeclarationStatement.setDataPrototype ("SgDeclarationStatement*", "firstNondefiningDeclaration", "= NULL",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
DeclarationStatement.setDataPrototype ("SgDeclarationStatement*", "firstNondefiningDeclaration", "= NULL",
NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (10/10/2006): Not all declarations make sense with qualified names, but enough do that I have placed
// this here for now! I have removed these lists from the SgNamedType IR nodes since SgTypes are shared and
// name qualification is require non-uniformally within the AST (making share IR nodes holding name
// qualification list a problem).
// DeclarationStatement.setDataPrototype ("static SgQualifiedNamePtrList", "defaultQualifiedNamePtrList", "",
// NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DeclarationStatement.setDataPrototype ("SgQualifiedNamePtrList", "qualifiedNameList", "= p_defaultQualifiedNamePtrList",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
DeclarationStatement.setDataPrototype ("SgQualifiedNamePtrList", "qualifiedNameList", "",
NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (11/23/2007): In Fortran, we now support the bind attribute (fixed to be handled on the DeclarationStatement
// instead of separately on SgFunctionDeclaration, SgVariableDeclaration, and SgClassDeclaration IR nodes).
// Use the "linkage" string already stored in the SgDeclarationStatement (above).
// DeclarationStatement.setDataPrototype ("std::string", "bind_language", "=\"\"",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
DeclarationStatement.setDataPrototype ("std::string", "binding_label", "=\"\"",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
BasicBlock.setFunctionPrototype ( "HEADER_BASIC_BLOCK", "../Grammar/Statement.code" );
// DQ (12/30/2009): As part of building separate smaller files using ROSETTA, we have to
// declare this template function in the headers instead of the source file AND it can
// only appear after the declaration of SgBasicBlock.
BasicBlock.setPostdeclarationString ("HEADER_BASIC_BLOCK_POSTDECLARATION", "../Grammar/Statement.code");
BasicBlock.setAutomaticGenerationOfConstructor(false);
BasicBlock.editSubstitute ( "HEADER_LIST_DECLARATIONS", "HEADER_LIST_DECLARATIONS", "../Grammar/Statement.code" );
BasicBlock.editSubstitute ( "LIST_DATA_TYPE", "SgStatementPtrList" );
BasicBlock.editSubstitute ( "LIST_NAME", "statements" );
BasicBlock.editSubstitute ( "LIST_FUNCTION_RETURN_TYPE", "void" );
BasicBlock.editSubstitute ( "LIST_FUNCTION_NAME", "statement" );
BasicBlock.editSubstitute ( "LIST_ELEMENT_DATA_TYPE", "SgStatement*" );
BasicBlock.setDataPrototype ( "SgStatementPtrList", "statements", "",
NO_CONSTRUCTOR_PARAMETER, BUILD_LIST_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
// DQ (12/4/2004): Now we automate the generation of the destructors
// BasicBlock.setAutomaticGenerationOfDestructor(false);
// DQ (3/4/2010): Added support for asm functions in ROSE. This is support is required for
// handling embedded code. When used the SgBasicBlock can only appear in a SgFunctionDefinition
// and can contain any string (only meaningful if they are assembly instructions).
BasicBlock.setDataPrototype ( "std::string", "asm_function_body", "= \"\"",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
IfStmt.setFunctionPrototype ( "HEADER_IF_STATEMENT", "../Grammar/Statement.code" );
IfStmt.setDataPrototype ( "SgStatement*", "conditional", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
IfStmt.setDataPrototype ( "SgStatement*", "true_body", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
IfStmt.setDataPrototype ( "SgStatement*", "false_body", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
// DQ (12/4/2004): Now we automate the generation of the destructors
// IfStmt.setAutomaticGenerationOfDestructor(false);
// DQ (12/16/2007): The else part of the if can have its own label (fortran only)!
// IfStmt.setDataPrototype ( "int", "else_numeric_label", "= -1",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
IfStmt.setDataPrototype ( "SgLabelRefExp*", "else_numeric_label", "= NULL",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (11/16/2007): Added support for string labels (for Fortran).
IfStmt.setDataPrototype ( "std::string", "string_label", "= \"\"",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (8/24/2007): Added to support Fortran specific use of WhileStmt
// IfStmt.setDataPrototype ( "int", "end_numeric_label", "= -1",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
IfStmt.setDataPrototype ( "SgLabelRefExp*", "end_numeric_label", "= NULL",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (12/26/2007): Fortran specific, has associated endif statement
IfStmt.setDataPrototype ( "bool", "has_end_statement", "= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (12/7/2010): Fortran specific, has associated then keyword.
IfStmt.setDataPrototype ( "bool", "use_then_keyword", "= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (12/7/2010): Fortran specific, has associated else keyword before if (is an else-if statement).
IfStmt.setDataPrototype ( "bool", "is_else_if_statement", "= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
ForStatement.setFunctionPrototype ( "HEADER_FOR_STATEMENT", "../Grammar/Statement.code" );
ForStatement.editSubstitute ( "HEADER_LIST_DECLARATIONS", "HEADER_LIST_DECLARATIONS", "../Grammar/Statement.code" );
ForStatement.editSubstitute ( "LIST_DATA_TYPE", "SgStatementPtrList" );
ForStatement.editSubstitute ( "LIST_NAME", "init_stmt" );
ForStatement.editSubstitute ( "LIST_FUNCTION_RETURN_TYPE", "void" );
ForStatement.editSubstitute ( "LIST_FUNCTION_NAME", "init_stmt" );
ForStatement.editSubstitute ( "LIST_ELEMENT_DATA_TYPE", "SgStatement*" );
// DQ (10/24/2007): Copy the SgForInitStatement
// ForStatement.setDataPrototype ( "SgForInitStatement*", "for_init_stmt", "= NULL",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
ForStatement.setDataPrototype ( "SgForInitStatement*", "for_init_stmt", "= NULL",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE, CLONE_PTR);
// DQ (11/23/2005): This replaces the SgExpressionRoot with a SgStatement
// so that declarations can be used (required for C and C++).
ForStatement.setDataPrototype ( "SgStatement*", "test", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
// DQ (10/24/2007): Copy the SgForInitStatement
// DQ (11/7/2006): Trying to remove the WRAP mechanism since it is overly complex and not required
// ForStatement.setDataPrototype ( "SgExpression*", "increment", "= NULL",
// CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
ForStatement.setDataPrototype ( "SgExpression*", "increment", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE, CLONE_PTR);
ForStatement.setDataPrototype ( "SgStatement*", "loop_body", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
ForStatement.setDataPrototype ( "SgStatement*", "else_body", "= NULL",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
// DQ (11/16/2007): Added support for string labels (for Fortran).
ForStatement.setDataPrototype ( "std::string", "string_label", "= \"\"",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (12/4/2004): Now we automate the generation of the destructors
// ForStatement.setAutomaticGenerationOfDestructor(false);
ForInitStatement.setFunctionPrototype ( "HEADER_FOR_INIT_STATEMENT", "../Grammar/Statement.code" );
ForInitStatement.editSubstitute ( "HEADER_LIST_DECLARATIONS", "HEADER_LIST_DECLARATIONS", "../Grammar/Statement.code" );
ForInitStatement.editSubstitute ( "LIST_DATA_TYPE", "SgStatementPtrList" );
ForInitStatement.editSubstitute ( "LIST_NAME", "init_stmt" );
ForInitStatement.editSubstitute ( "LIST_FUNCTION_RETURN_TYPE", "void" );
ForInitStatement.editSubstitute ( "LIST_FUNCTION_NAME", "init_stmt" );
ForInitStatement.editSubstitute ( "LIST_ELEMENT_DATA_TYPE", "SgStatement*" );
ForInitStatement.setDataPrototype ( "SgStatementPtrList", "init_stmt", "",
NO_CONSTRUCTOR_PARAMETER, BUILD_LIST_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
// DQ (12/4/2004): Now we automate the generation of the destructors
// ForInitStatement.setAutomaticGenerationOfDestructor(false);
// DQ and Liao (6/11/2008): Added support for UPC forall IR node.
UpcForAllStatement.setFunctionPrototype ( "HEADER_UPC_FORALL_STATEMENT", "../Grammar/Statement.code" );
UpcForAllStatement.editSubstitute ( "HEADER_LIST_DECLARATIONS", "HEADER_LIST_DECLARATIONS", "../Grammar/Statement.code" );
UpcForAllStatement.editSubstitute ( "LIST_DATA_TYPE", "SgStatementPtrList" );
UpcForAllStatement.editSubstitute ( "LIST_NAME", "init_stmt" );
UpcForAllStatement.editSubstitute ( "LIST_FUNCTION_RETURN_TYPE", "void" );
UpcForAllStatement.editSubstitute ( "LIST_FUNCTION_NAME", "init_stmt" );
UpcForAllStatement.editSubstitute ( "LIST_ELEMENT_DATA_TYPE", "SgStatement*" );
UpcForAllStatement.setDataPrototype ( "SgForInitStatement*", "for_init_stmt", "= NULL",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE, CLONE_PTR);
UpcForAllStatement.setDataPrototype ( "SgStatement*", "test", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
UpcForAllStatement.setDataPrototype ( "SgExpression*", "increment", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE, CLONE_PTR);
UpcForAllStatement.setDataPrototype ( "SgExpression*", "affinity", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE, CLONE_PTR);
UpcForAllStatement.setDataPrototype ( "SgStatement*", "loop_body", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
FunctionDeclaration.setFunctionPrototype ( "HEADER_FUNCTION_DECLARATION_STATEMENT", "../Grammar/Statement.code" );
FunctionDeclaration.setFunctionPrototype ( "HEADER_TEMPLATE_SPECIALIZATION_SUPPORT", "../Grammar/Statement.code" );
FunctionDeclaration.editSubstitute ( "HEADER_LIST_DECLARATIONS", "HEADER_LIST_DECLARATIONS", "../Grammar/Statement.code" );
FunctionDeclaration.editSubstitute ( "LIST_DATA_TYPE", "SgInitializedNamePtrList" );
FunctionDeclaration.editSubstitute ( "LIST_NAME", "args" );
FunctionDeclaration.editSubstitute ( "LIST_FUNCTION_RETURN_TYPE", "SgInitializedNamePtrList::iterator" );
FunctionDeclaration.editSubstitute ( "LIST_FUNCTION_NAME", "arg" );
// DQ (6/1/2004): Changed list to contain pointers to SgInitializedName elements
// FunctionDeclaration.editSubstitute ( "LIST_ELEMENT_DATA_TYPE", "const SgInitializedName &" );
FunctionDeclaration.editSubstitute ( "LIST_ELEMENT_DATA_TYPE", "SgInitializedName*" );
#if 1
// DQ (10/20/2004): Since constructor names don't require their template arguments this has a far simpler solution!
// for example: "template <typename T> class X { X(); }; X<int>::X() {}"
// DQ (10/20/2004): Changed to disallow ROSETTA to generate the get_name() function. This function is now
// modified to handle the special case of a constructor and destructor (to output the class name in these cases).
// It is left as a constructor parameter, but ignored interanlly in the case of a member function constructor
// of destructor.
FunctionDeclaration.setDataPrototype ( "SgName", "name", "= \"\"",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
#else
FunctionDeclaration.setDataPrototype ( "SgName", "name", "= \"\"",
CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
#endif
// DQ (3/4/2007): We want to force the copy mechanism to skip building a new SgFunctionParameterList
// when making a copy (use NO_COPY_DATA to do this). The p_parameterList is handled internally
// in SageIII.
// DQ (3/10/2007) But now were we make a copy of a function we will get the parameter list wrong!
// This is a problem in building template function forward declarations!
// FunctionDeclaration.setDataPrototype ( "SgFunctionParameterList*", "parameterList", "=NULL",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
// FunctionDeclaration.setDataPrototype ( "SgFunctionParameterList*", "parameterList", "= NULL",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE, NO_COPY_DATA);
FunctionDeclaration.setDataPrototype ( "SgFunctionParameterList*", "parameterList", "= NULL",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE, CLONE_PTR);
// DQ (4/25/2004): Add modifier FunctionModifier and SpecialFunctionModifier
FunctionDeclaration.setDataPrototype ( "SgFunctionModifier", "functionModifier", "",
NO_CONSTRUCTOR_PARAMETER, BUILD_LIST_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
FunctionDeclaration.setDataPrototype ( "SgSpecialFunctionModifier", "specialFunctionModifier", "",
NO_CONSTRUCTOR_PARAMETER, BUILD_LIST_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (6/27/2006): Support for function declaration exception specifications
FunctionDeclaration.setDataPrototype ( "SgTypePtrList", "exceptionSpecification", "",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
#if 1
// DQ (9/3/2007): In Fortran, the function name has been used in the end statement.
FunctionDeclaration.setDataPrototype ( "bool", "named_in_end_statement", "= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
#endif
// DQ (1/25/2009): Added support for asm names for functions (see test2009_10.C)
FunctionDeclaration.setDataPrototype ( "std::string", "asm_name", "= \"\"",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
#if 0
// DQ (11/21/2007): In Fortran, we now support the bind attribute.
FunctionDeclaration.setDataPrototype ( "std::string", "bind_language", "=\"\"",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
FunctionDeclaration.setDataPrototype ( "std::string", "binding_label", "=\"\"",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
#endif
/* driscoll6 (7/14/11) support for python decorators */
FunctionDeclaration.setDataPrototype ( "SgExprListExp*", "decoratorList", "= NULL",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
FunctionParameterList.setFunctionPrototype ( "HEADER_FUNCTION_PARAMETER_LIST", "../Grammar/Statement.code" );
FunctionParameterList.editSubstitute ( "HEADER_LIST_DECLARATIONS", "HEADER_LIST_DECLARATIONS", "../Grammar/Statement.code" );
FunctionParameterList.editSubstitute ( "LIST_DATA_TYPE", "SgInitializedNamePtrList" );
FunctionParameterList.editSubstitute ( "LIST_NAME", "args" );
FunctionParameterList.editSubstitute ( "LIST_FUNCTION_RETURN_TYPE", "SgInitializedNamePtrList::iterator" );
FunctionParameterList.editSubstitute ( "LIST_FUNCTION_NAME", "arg" );
// DQ (6/1/2004): Changed list to contain pointers to SgInitializedName elements
// FunctionParameterList.editSubstitute ( "LIST_ELEMENT_DATA_TYPE", "const SgInitializedName &" );
FunctionParameterList.editSubstitute ( "LIST_ELEMENT_DATA_TYPE", "SgInitializedName*" );
FunctionParameterList.setDataPrototype ( "SgInitializedNamePtrList", "args", "",
NO_CONSTRUCTOR_PARAMETER, BUILD_LIST_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
// DQ (12/4/2004): Now we automate the generation of the destructors
// FunctionParameterList.setAutomaticGenerationOfDestructor(false);
// We would like to have a class include data members which are terminals/nonterminals within the grammar.
// In the case where these are X terminals/nonterminals the data members should be X versions of these.
// It is difficult for it to be either the X or non_X version since these are different types.
// There are three cases to consider:
// 1) Data member is an X version (matching Xness of the outer terminal)
// Implementation proceedure: build X version
// 2) Data member is a non X version (not matching the Xness of the outer terminal)
// Implementation proceedure: build non X version
// 3) Data member can be the X OR non X version (independent of the Xness of the outer terminal)
// Implementation proceedure: build X and non X versions?
// In this case we want the Xness of the data member to match that of the outer terminal
FunctionDeclaration.setDataPrototype ( "SgFunctionType*", "type", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL || DEF2TYPE_TRAVERSAL, NO_DELETE);
// DQ (4/18/2005): Removed this data member since it is redundent with the firstNondefiningDeclaration in the base class (SgDeclarationStatement)
// QY: need forward definition so that we can set definition pointer as NULL for forward decls
// FunctionDeclaration.setDataPrototype ( "SgFunctionDefinition*", "forwardDefinition", "= NULL",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
FunctionDeclaration.setDataPrototype ( "SgFunctionDefinition*", "definition", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
// DQ (4/18/2005): Removed this data member since it is redundent with the definingDeclaration->get_definition()
// referenced from the base class (SgDeclarationStatement).
// FunctionDeclaration.setDataPrototype ( "SgFunctionDefinition*", "definition_ref", "= NULL",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// QY:11/2/04 isn't p_mangled_name always obtained from p_type? should go through p_type then
// We can't use the generated versions of the data access functions here!
// FunctionDeclaration.setDataPrototype ( "SgName", "mangled_name", "= SgdefaultName",
// NO_CONSTRUCTOR_PARAMETER, NO_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
#if 0
// QY:11/2/04 isn't p_orig_return_type already stored in p_type? should go through p_type then
// FunctionDeclaration.setDataPrototype ( "SgType*", "orig_return_type", "= NULL",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL | DEF2TYPE_TRAVERSAL, NO_DELETE);
FunctionDeclaration.setDataPrototype ( "int", "from_template", "= 0",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
#endif
// DQ (2/15/2004): Add support for old-style C function definitions (K&R style)
FunctionDeclaration.setDataPrototype ( "bool","oldStyleDefinition", "= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (11/15/2004): class declarations for nested classes can appear outside the scope of the class to which
// they belong, thus the parent information is not sufficent to define the relationship of nested classes
// (and typedefs within the classes, as well, which is the current bug in Kull). So we need an additional
// data member to explicitly represent the scope of a class (consistant with the design of the member
// function declaration).
FunctionDeclaration.setDataPrototype ( "SgScopeStatement*", "scope", "= NULL",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (5/9/2005): Adding special template support. These data members help control the instantiation of
// templates and there representation in the unparsed code (code generated by ROSE).
// Note that the File_Info object is where IR nodes are marked as compiler generated (also relavant here).
FunctionDeclaration.setDataPrototype ( "SgDeclarationStatement::template_specialization_enum", "specialization", "= SgDeclarationStatement::e_no_specialization",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (8/20/2006): Record if global name qualification is required on the type.
// See test2003_01.C for an example of where this is required.
FunctionDeclaration.setDataPrototype("bool", "requiresNameQualificationOnReturnType", "= false",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
// DQ (8/22/2007): Added this data member to the SgFunctionDeclaration since it is used for functions and subroutines in Fortran.
// FunctionDeclaration.setDataPrototype ( "int", "end_numeric_label", "= -1",
// NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);