-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocglobal.cpp
More file actions
executable file
·1681 lines (1636 loc) · 59.6 KB
/
Copy pathprocglobal.cpp
File metadata and controls
executable file
·1681 lines (1636 loc) · 59.6 KB
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
/*
* File: procglobal.cpp
* Procedure Division related items. Separated in order to
* reduce the compilation.
*/
/*
* File: procglobal.cpp
* Created Date: Wednesday August 27th 2014
* Author: Deepak Purandare
* -----
* Last Modified: Wednesday August 27th 2014 7:08:40 pm
* Modified By: Deepak Purandare - <deepak_purandare@hotmail.com>
* -----
* Copyright (c) 2019 Purndare Consulting
* This software is made available under GNU General Public License Version 3
* Visit http://www.gnu.org/licenses/gpl-3.0.html for terms of usage.
*/
#include <list>
#include "procglobal.h"
#include "global.h"
#include "procinc.h"
#include "ast/CobProcedureDivision.h"
#include "proc/CobSectionDeclaration.h"
#include "proc/CobParagraphDeclaration.h"
#include "proc/CobSentence.h"
#include "proc/CobStmtInitiate.h"
using namespace std;
/***********************************
* Globals *
***********************************/
CobSectionDeclaration * gCurrentSectionDeclaration;
CobParagraphDeclaration * gCurrentParagraphDeclaration;
extern "C" {
/***********************************
* Function declarations *
***********************************/
void * start_generic_list(void * pitem){
list <void *> * retLst = new list <void *>;
retLst->clear();
if(pitem != NULL) retLst->push_back(pitem);
return retLst;
}
void * addto_generic_list(void * plst, void * pitem){
list <void *> * retLst = (list <void *> *)plst;
if(pitem != NULL) retLst->push_back(pitem);
return retLst;
}
// list of identifiers or literal values
void * startXvalList(struct xvaldata * pxval){
list <struct xvaldata *> * listptr = new list <struct xvaldata *>;
listptr->push_back(pxval);
return (void *) listptr;
}
void * addXvalListItem(void * plist, struct xvaldata * pxval){
list <struct xvaldata *> * ret = (list <struct xvaldata *> *) plist;
ret->push_back(pxval);
return (void *) ret;
}
void delete_xvallist(void * plst){
if(plst == NULL) return;
list <struct xvaldata *> * xvallist = (list <struct xvaldata *> *) plst;
list <struct xvaldata *>::iterator i;
for(i = xvallist->begin(); i != xvallist->end(); ++i ){
struct xvaldata * item = (struct xvaldata *)(*i);
if(item != NULL) delete_xval(item);
}
delete xvallist;
}
void * startGnameList(struct valueType * pgname){
list <struct valueType *> * ret = new list <struct valueType *>;
ret->push_back(pgname);
return (void *) ret;
}
void * addGnameListItem( void * plist, struct valueType * pgname){
list <struct valueType *> * ret = (list <struct valueType *> *) plist;
ret->push_back(pgname);
return (void *) ret;
}
void delete_gnamelist(void * pgnamelst){
list <struct valueType *> * tlst = (list <struct valueType *> *)pgnamelst;
if(tlst == NULL) return;
list<struct valueType *>::iterator i;
for(i = tlst->begin(); i != tlst->end(); ++i ){
struct valueType * item = (struct valueType *)(*i);
if(item != NULL) delete_value(item);
}
delete tlst;
}
// Add statement
void * construct_add_stmt( enum add_type_enum ptype, void * pfromlst, void * ptolst,
void * pgivinglst, void * ponsize_error ){
void * ret;
ret = (void *) new CobStmtAdd(ptype, pfromlst, ptolst, pgivinglst, ponsize_error);
return ret;
}
void * construct_on_error_data( void * ponerror, void * pnotonerror){
struct on_size_error_data * ret = new struct on_size_error_data;
ret->on_error = ponerror;
ret->not_on_error = pnotonerror;
return (void *) ret;
}
void delete_on_error_data(void * ponerrordata){
struct on_size_error_data * item = (struct on_size_error_data *)ponerrordata;
if(item->on_error != NULL) delete (CobProcDivItem *)item->on_error;
if(item->not_on_error != NULL) delete (CobProcDivItem *)item->not_on_error;
delete item;
}
// Subtract statement
void * construct_subtract_stmt(enum add_type_enum ptype, void * plstfirst, void * pfromlst,
void * pgiving, void * ponsize_error, int prounded ){
void * ret = (void *) new CobStmtSubtract(ptype, plstfirst, pfromlst,
pgiving, ponsize_error, prounded);
return ret;
}
// Multiply statement
void * construct_multiply_stmt(enum add_type_enum ptype, void * ptarget, void * pby, void * pgivinglst,
void * ponsize_error) {
void * ret = (void *) new CobStmtMultiply(ptype, ptarget, pby, pgivinglst,
ponsize_error);
return ret;
}
// Divide statement
void * construct_divide_stmt(enum divide_type_enum ptype, void * ptarget, void * pby_into, void * pgivinglst,
void * premainder, void * ponsize_error){
void * ret = new CobStmtDivide(ptype, ptarget, pby_into, pgivinglst,
premainder, ponsize_error);
return ret;
}
void * construct_perform_stmt(struct _proc_names * pnames, void * poptlist, void * pprocstmt){
void * ret;
ret = (void *)new CobStmtPerform(pnames, poptlist, pprocstmt);
return ret;
}
struct _proc_names * construct_pnames(int throughflag, char * pfirst, char * psecond){
struct _proc_names * ret = new struct _proc_names;
ret->thruflag = throughflag;
ret->target = pfirst;
ret->to = psecond;
return ret;
}
void * start_perform_options_list(struct _perform_option * popt){
return start_generic_list((void *) popt);
}
void * addto_perform_options_list(void * plst, struct _perform_option * popt){
return addto_generic_list(plst, (void*) popt);
}
struct _perform_option * construct_perf_opt(int ptype, int pforever,
struct idvalStru * pid, int ptest, struct _condition * pcond,
void * pvaryinglist) {
struct _perform_option * ret = new struct _perform_option;
ret->type = ptype;
ret->times = pforever;
ret->id = pid;
ret->with_test_specified = ptest;
ret->condition = pcond;
ret->perform_varying_list = pvaryinglist;
return ret;
}
void * start_perf_opt_varying_list( struct _perform_varying * pitem){
return start_generic_list((void *) pitem);
}
void * addto_perf_opt_varying_list( void * plst, struct _perform_varying * pitem){
return addto_generic_list(plst, (void *) pitem);
}
struct _perform_varying * construct_perf_varying_item( struct valueType * ptarget,
struct valueType * pfrom, struct valueType * pto, struct _condition * pcond){
struct _perform_varying * ret = new struct _perform_varying;
ret->target = ptarget;
ret->from = pfrom;
ret->to = pto;
ret->condition = pcond;
return ret;
}
void delete_perform_option_list(void * plst){
if(plst == NULL) return;
list <void *> * lst = (list <void *> *)plst;
list<void *>::iterator i;
for(i = lst->begin(); i != lst->end(); ++i ){
struct _perform_option * item = (struct _perform_option *)(*i);
if(item != NULL){
if(item->id != NULL) delete_id(item->id);
if(item->condition != NULL) delete_condition(item->condition);
if(item->perform_varying_list)
delete_perform_varying_list(item->perform_varying_list);
delete item;
}
}
delete lst;
}
void delete_perform_varying_list(void * plst){
if(plst == NULL) return;
list <void *> * lst = (list <void *> *)plst;
list<void *>::iterator i;
for(i = lst->begin(); i != lst->end(); ++i ){
struct _perform_varying * item = (struct _perform_varying *)(*i);
if(item != NULL){
if(item->target != NULL) delete_value(item->target);
if(item->from != NULL) delete_value(item->from);
if(item->to != NULL) delete_value(item->to);
if(item->condition != NULL) delete_condition(item->condition);
delete item;
}
}
delete lst;
}
// Move statement
void * construct_move_stmt( int pcorr, struct valueType * pgname, void * plist){
void * ret;
ret = (void *)new CobStmtMove(pcorr, pgname, plist);
return ret;
}
// IfElse statement
void * construct_ifelse_stmt( struct _condition * pcond, struct _statements * pthen,
struct _statements * pelse){
void * ret;
ret = (void *) new CobStmtIfElse(pcond, pthen, pelse);
return ret;
}
struct _statements * construct_stmts_list( void * plist, int next_sentence ){
struct _statements * ret = new struct _statements;
ret->list = plist;
ret->type = next_sentence;
return ret;
}
void delete_statement_list(struct _statements * plst){
if(plst == NULL) return;
// list<void *> * lst = (list<void *> *) plst;
// list<void *>::iterator i;
//
// for(i = lst->begin(); i != lst->end(); ++i ){
// delete (CobProcDivItem *)(*i);
// }
if(plst != NULL){
// check if this is correct.
// if(plst->list != NULL) delete (CobSentence *)plst;
delete (CobSentence *) plst;
}
}
// Accept statement
struct _esc_excep_action * construct_esc_excp_item(
int pesc_excp, void * pproc){
struct _esc_excep_action * ret = new struct _esc_excep_action;
ret->esc_excep = pesc_excp;
ret->proc_statement = pproc;
return ret;
}
struct _esc_excep_action * update_esc_excp_item(int pesc_excp,
struct idvalStru * popt_id, void * pproc,
struct _esc_excep_action * pnot_on){
struct _esc_excep_action * ret = pnot_on;
ret->esc_excep = pesc_excp;
ret->opt_id = popt_id;
ret->proc_statement = pproc;
return ret;
}
void delete_esc_excp_item(struct _esc_excep_action * pitem){
if(pitem == NULL) return;
if(pitem->opt_id != NULL) delete_id(pitem->opt_id);
if(pitem->proc_statement != NULL) delete (CobSentence *)pitem->proc_statement;
if(pitem->not_on_item != NULL) delete_esc_excp_item(pitem->not_on_item);
delete pitem;
}
struct _position_clause * construct_pos(int pwhere, struct valueType * pval){
struct _position_clause * ret = new struct _position_clause;
if(pwhere == 1) {
ret->col = pval;
} else {
ret->position = pval;
}
return ret;
}
struct _position_clause * update_pos(struct _position_clause * ppos, struct valueType * pval){
struct _position_clause * ret = ppos;
ret->line = pval;
return ret;
}
struct _with_clause_2 * construct_with_clause2(int penum, struct _position_clause * ppos,struct valueType * pval){
struct _with_clause_2 * ret = new struct _with_clause_2;
ret->withenum = penum;
ret->pos = ppos;
ret->val = pval;
return ret;
}
void * create_with2_list(struct _with_clause_2 * pitem){
return start_generic_list((void *) pitem);
}
void * addto_with2_list(void * plist, struct _with_clause_2 * pitem){
return addto_generic_list(plist, (void *) pitem);
}
struct xvaldata * getXval(int ptype, struct idvalStru * pid, struct valueType * pval){
struct xvaldata * ret = new struct xvaldata;
ret->type = ptype;
ret->identifier = pid;
ret->litval = pval;
return ret;
}
struct _accept_item * construct_accept_item(struct xvaldata * pval,
struct _with_clause_2 * pwith2val){
struct _accept_item * ret = new struct _accept_item;
ret->val = pval;
ret->with2val = pwith2val;
return ret;
}
void * create_accept_item_list( struct _accept_item * pitem ){
return start_generic_list((void *) pitem);
}
void * addto_accept_item_list( void * plist, struct _accept_item * pitem ){
return addto_generic_list(plist, (void *) pitem);
}
struct _at_clause_accept * construct_at_clause_acc(struct valueType * pline, struct valueType * pcol){
/*struct _at_clause_accept * construct_at_clause_acc(int plc, struct xvaldata * pval) { */
struct _at_clause_accept * ret = new struct _at_clause_accept;
ret->line = pline;
ret->col = pcol;
return ret;
}
// remember while implementing this. This is used at two places.
struct xvaldata * get_from_clause(int ptype, struct idvalStru * pid, int pimplcit){
struct xvaldata * ret = new struct xvaldata;
ret->type = ptype;
ret->usetype = 0;
ret->identifier = pid;
ret->imp = pimplcit;
return ret;
}
struct xvaldata * getXval2(int ptype, struct idvalStru * pid, int pival){
struct xvaldata * ret = new struct xvaldata;
ret->identifier = pid;
ret->usetype = ptype;
ret->type = ptype;
return ret;
}
void * construct_accept_stmt(int ptype,
struct idvalStru * pid,
struct xvaldata * pfrom,
void * paccept_item_list,
struct _esc_excep_action * pesc,
int pmsg_count,
struct _at_clause_accept * pat){
void * ret;
ret = (void *)new CobStmtAccept(ptype, pid, pfrom, paccept_item_list, pesc,
pmsg_count, pat);
return ret;
}
// Display statement
void * construct_display_stmt_sysname(void * psysnamelst,
struct xvaldata * pupon,
int padvancing){
void * ret;
ret = (void *) new CobStmtDisplay(psysnamelst, pupon, padvancing);
return ret;
}
void * construct_display_stmt_term(void * pdisp_itemlst){
void * ret;
ret = (void *) new CobStmtDisplay(CobStmtDisplay::CB_TERM, pdisp_itemlst);
return ret;
}
void * construct_display_stmt_screen(void * pdisp_screen_lst){
void * ret;
ret = (void *) new CobStmtDisplay(CobStmtDisplay::CB_SCREEN, pdisp_screen_lst);
return ret;
}
void * start_disp_item_list(struct _disp_item * pitem){
return start_generic_list((void *) pitem);
}
void * addto_disp_item_list(void * plst, struct _disp_item * pitem){
return addto_generic_list(plst, (void *) pitem);
}
void delete_disp_item_list(void * plst){
list <void *> * lst = (list <void *> *)plst;
if(lst == NULL) return;
list<void *>::iterator i;
for(i = lst->begin(); i != lst->end(); ++i ){
struct _disp_item * item = (struct _disp_item *)(*i);
if(item != NULL) {
delete_xval(item->id_clause);
//item->with_clause_list;
delete_with_clause_list(item->with_clause_list);
}
}
delete lst;
}
struct _disp_item * construct_disp_item (struct xvaldata * pid_clause, void * pwith_list){
struct _disp_item * ret = new struct _disp_item;
ret->id_clause = pid_clause;
ret->with_clause_list = pwith_list;
return ret;
}
struct _with_clause * construct_with_clause(int pwithenum, struct xvaldata * pval){
struct _with_clause * ret = new struct _with_clause;
ret->withenum = pwithenum;
ret->addinfo = pval;
return ret;
}
void * start_with_cl_item_list(struct _with_clause * pitem){
return start_generic_list((void *) pitem);
}
void * addto_with_cl_item_list(void * plst, struct _with_clause * pitem){
return addto_generic_list(plst, (void *) pitem);
}
void delete_with_clause_list(void * plst){
list <void *> * lst = (list <void *> *)plst;
if(lst == NULL) return;
list<void *>::iterator i;
for(i = lst->begin(); i != lst->end(); ++i ){
struct _with_clause * item = (struct _with_clause *)(*i);
if(item != NULL){
delete_xval(item->addinfo);
delete item;
}
}
delete lst;
}
struct _disp_screen_item * construct_disp_screen_item(
struct idvalStru * pid, struct _at_clause_accept * pat){
struct _disp_screen_item * ret = new struct _disp_screen_item;
ret->id = pid;
ret->at_clause = pat;
return ret;
}
void * create_create_screen_item_lst(struct _disp_screen_item * pitem){
return start_generic_list((void *) pitem);
}
void * addto_create_screen_item_lst(void * plst, struct _disp_screen_item * pitem){
return addto_generic_list(plst, (void *) pitem);
}
void delete_screen_item_list(void * plst){
list <void *> * lst = (list <void *> *)plst;
if(lst == NULL) return;
list<void *>::iterator i;
for(i = lst->begin(); i != lst->end(); ++i ){
struct _disp_screen_item * item = (struct _disp_screen_item *)(*i);
if(item != NULL) {
if(item->id != NULL) delete_id(item->id);
if(item->at_clause != NULL) {
if(item->at_clause->col != NULL)
delete_value(item->at_clause->col);
if(item->at_clause->line != NULL)
delete_value(item->at_clause->line);
delete item->at_clause;
}
delete item;
}
}
delete lst;
}
// Open statement
void * create_int_list(int pval){
list <int> * ret = new list <int>;
ret->push_back(pval);
return ret;
}
void * addto_int_list(void * plst, int pval){
list <int> * ret = (list <int> *) plst;
ret->push_back(pval);
return ret;
}
void * create_file_name_list(struct _file_name_item * pitem){
return start_generic_list((void *) pitem);
}
void * addto_file_name_list(void * plst, struct _file_name_item * pitem){
return addto_generic_list(plst, (void *) pitem);
}
struct _file_name_item * construct_file_name(struct idvalStru * pfile_name, void * popen_items){
struct _file_name_item * ret = new struct _file_name_item;
ret->file_name = pfile_name;
ret->open_items = popen_items;
return ret;
}
struct _open_file_type * construct_open_file_type(int pfile_type, void * popen_file_list){
struct _open_file_type * ret = new struct _open_file_type;
ret->file_type = pfile_type;
ret->open_file_list = popen_file_list;
return ret;
}
void * create_open_file_list(struct _open_file_type * pitem){
return start_generic_list((void *) pitem);
}
void * addto_open_file_list(void * plst, struct _open_file_type * pitem){
return addto_generic_list(plst, (void *) pitem);
}
void delete_open_file_list(void * plst){ //// struct _open_file_type
list <void *> * lst = (list <void *> *)plst;
list<void *>::iterator i;
for(i = lst->begin(); i != lst->end(); ++i ){
struct _open_file_type * item = (struct _open_file_type *)(*i);
if(item != NULL){
if(item->open_file_list != NULL) {
delete_file_name_item_list(item->open_file_list);
}
}
}
delete lst;
}
void delete_file_name_item_list(void * plst){ //struct _file_name_item
list <void *> * lst = (list <void *> *)plst;
list<void *>::iterator i;
for(i = lst->begin(); i != lst->end(); ++i ){
struct _file_name_item * item = (struct _file_name_item *)(*i);
if(item != NULL){
if(item->file_name != NULL) delete_id(item->file_name);
if(item->open_items != NULL) delete (list <void *> *) (item->open_items);
delete item;
}
}
delete lst;
}
void * construct_open_stmt(int pexclusive, void * popen_file_type_list){
void * ret;
ret = (void *) new CobStmtOpen(pexclusive, popen_file_type_list);
return ret;
}
// Close Statement
struct _close_file_item * construct_close_file_item(struct idvalStru * pfile_name, int pclose_file_option){
struct _close_file_item * ret = new struct _close_file_item;
ret->file_name = pfile_name;
ret->close_file_option = pclose_file_option;
return ret;
}
void * start_close_file_list(struct _close_file_item * pitem){
return start_generic_list((void *) pitem);
}
void * addto_close_file_list(void * plst, struct _close_file_item * pitem){
return addto_generic_list(plst, (void *) pitem);
}
void delete_close_file_list(void * plst){
if(plst == NULL) return;
list <void *> * cilst = (list <void *> *)plst;
list <void *>::iterator i;
for(i = cilst->begin(); i != cilst->end(); ++i ){
struct _close_file_item * cfitem = (struct _close_file_item *)(*i);
if(cfitem != NULL) {
if(cfitem->file_name != NULL)delete_id(cfitem->file_name);
delete cfitem;
}
}
delete cilst;
}
void * construct_close_stmt(void * plst){
void * ret;
ret = (void *) new CobStmtClose(plst);
return ret;
}
// Read statement
struct _at_end_action * construct_at_end_clause(void * pend_proc, void * pnotend_proc){
struct _at_end_action * ret = new struct _at_end_action;
ret->at_end_action = pend_proc;
ret->not_at_end_action = pnotend_proc;
return ret;
}
void delete_at_end_clause(struct _at_end_action * pitem){
if(pitem->at_end_action != NULL) {
delete (CobProcDivItem *)pitem->at_end_action;
}
if(pitem->not_at_end_action != NULL) {
delete (CobProcDivItem *)pitem->not_at_end_action;
}
delete pitem;
}
struct _invalid_key_action * construct_invalid_key_clause(void * pyes, void * pno){
struct _invalid_key_action * ret = new struct _invalid_key_action;
ret->invalid_key_proc = pyes;
ret->not_invalid_key_proc = pno;
return ret;
}
void delete_invalid_key_action(void * pinvkeyaction){
if(pinvkeyaction == NULL) return;
struct _invalid_key_action * item = (struct _invalid_key_action *)pinvkeyaction;
if(item->invalid_key_proc != NULL) {
delete (CobProcDivItem *)item->invalid_key_proc;
}
if(item->not_invalid_key_proc != NULL) {
delete (CobProcDivItem *)item->not_invalid_key_proc;
}
delete item;
}
void * construct_read_seq_stmt( struct idvalStru * pfile_name,
int pnext_prev,
int precord_clause,
struct idvalStru * popt_id,
struct _at_end_action * pend_action
){
void * ret;
ret = (void *) new CobStmtRead(pfile_name, pnext_prev, precord_clause,
popt_id, pend_action);
return ret;
}
void * construct_read_random_stmt( struct idvalStru * pfile_name,
int next_prev,
int precord_clause,
struct idvalStru * popt_id,
struct idvalStru * popt_key,
struct _invalid_key_action * pinvalid_key
){
void * ret;
ret = (void *) new CobStmtRead(pfile_name, next_prev, precord_clause,
popt_id, popt_key, pinvalid_key);
return ret;
}
// Write statement
void * construct_action_pair(void * yesaction, void * noaction){
struct _action_pair * ret = new struct _action_pair;
ret->yes_action = yesaction;
ret->no_action = noaction;
return (void *) ret;
}
void delete_action_pair(void * pactinpair){
if(pactinpair == NULL) return;
struct _action_pair * actpair = (struct _action_pair *)pactinpair;
if(actpair->yes_action != NULL) {
CobSentence * stmt = (CobSentence *)(actpair->yes_action);
delete (CobProcDivItem *)(actpair->yes_action);
actpair->yes_action = NULL;
}
if(actpair->no_action != NULL) {
delete (CobSentence *)actpair->no_action;
actpair->no_action = NULL;
}
delete actpair;
}
struct _advaicing_clause * construct_advancing_clause( int pbefore_after,
int popt_advancing, struct xvaldata * padvancing_clause){
struct _advaicing_clause * ret = new struct _advaicing_clause;
ret->before_after = pbefore_after;
ret->opt_advanc = popt_advancing;
ret->advancing = padvancing_clause;
return ret;
}
struct _advaicing_clause * conemp_advancing_clause(){
struct _advaicing_clause * ret = new struct _advaicing_clause;
ret->before_after = -1;
ret->opt_advanc = -1;
ret->advancing = NULL;
return ret;
}
struct _id_gname * gen_id_gname(struct idvalStru * pid, struct valueType * pval){
struct _id_gname * ret = new struct _id_gname;
ret->ident = pid;
ret->value = pval;
return ret;
}
void * construct_write_stmt(struct _id_gname * pidgname,
struct _advaicing_clause * padv){
void * ret;
ret = (void *) new CobStmtWrite(pidgname, padv);
return ret;
}
void * construct_write_stmt2(struct _id_gname * pidgname,
struct _invalid_key_action * keyvalidation){
void * ret;
ret = (void *) new CobStmtWrite(pidgname, keyvalidation);
return ret;
}
void * construct_compute_stmt(void * plvallist,
int popt_rounded,
struct _arithmetic_expression * pexp,
int popt_not,
void * popt_on_error){
void * ret;
ret = (void *) new CobStmtCompute(plvallist, popt_rounded, pexp,popt_not,
popt_on_error);;
return ret;
}
void * construct_rewrite_stmt(struct idvalStru * pid,
struct valueType * pfrom_clause,
void * pkeyvalidation){
void * ret;
ret = (void *) new CobStmtRewrite(pid, pfrom_clause, pkeyvalidation);
return ret;
}
void * construct_goback_stmt(){
void * ret;
ret = (void *) new CobStmtGoback();
return ret;
}
void * construct_purge_stmt( struct idvalStru * pid){
void * ret;
ret = (void *) new CobStmtPurge(pid);
return ret;
}
void * construct_release_stmt(struct idvalStru * pid, struct xvaldata * pval){
void * ret;
ret = (void *) new CobStmtRelease(pid, pval);
return ret;
}
void * construct_unlock_stmt(struct idvalStru * pid){
void * ret;
ret = (void *) new CobStmtUnlock(pid);
return ret;
}
void * construct_cancel_stmt(void * pitem_list){ /* (struct xvaldata * pval */
void * ret;
ret = (void *) new CobStmtCancel(pitem_list);
return ret;
}
void * construct_continue_stmt(){
void * ret;
ret = (void *) new CobStmtContinue();
return ret;
}
void * construct_goto_stmt1(char * pprocname){
void * ret;
ret = (void *) new CobStmtGoto(pprocname);
return ret;
}
void * construct_goto_stmt2(void * lprocnamelst, struct idvalStru * pid){
void * ret;
ret = (void *) new CobStmtGoto(lprocnamelst, pid);
return ret;
}
void * construct_strpair(char * str1, char * str2){
struct _strpair * ret = new struct _strpair;
ret->first = str1;
ret->second = str2;
return ret;
}
void * construct_alter_stmt(void * plst){
void * ret;
ret = (void *) new CobStmtAlter(plst);
return ret;
}
void * construct_return_stmt(struct idvalStru * pfilename,
int popt_record,
struct xvaldata * pinto_identifier,
void * pend_action ){
void * ret;
ret = (void *) new CobStmtReturn(pfilename,popt_record,
pinto_identifier, pend_action);
return ret;
}
struct _delete_simple * construct_del_simple(struct idvalStru * pfilename, int popt_record, void * ponkey_action){
struct _delete_simple * ret = new struct _delete_simple;
ret->filename = pfilename;
ret->opt_record = popt_record;
ret->key_validation_action = ponkey_action;
return ret;
}
void delete_del_simple(struct _delete_simple * pitem){
if(pitem == NULL) return;
if(pitem->filename != NULL) delete_id(pitem->filename);
if(pitem->key_validation_action != NULL)
delete_invalid_key_action(pitem->key_validation_action);
delete pitem;
}
void * construct_delete_stmt(struct _delete_simple * pitem){
void * ret;
ret = (void *) new CobStmtDelete(pitem);
return ret;
}
void * construct_delete_multi_stmt(void * pfilelst){
void * ret;
ret = (void *) new CobStmtDelete(pfilelst);
return ret;
}
struct _str_argument * construct_str_argument(void * pitemlst, struct xvaldata * pmoditemlst){
struct _str_argument * ret = new struct _str_argument;
ret->pgnamelst = pitemlst;
ret->moditem = pmoditemlst;
return ret;
}
void * construct_string_stmt(void * pstr_args, struct idvalStru * pid,
struct idvalStru * pptropt,
struct _action_pair * pon_overflow){
void * ret;
ret = (void *) new CobStmtString(pstr_args, pid, pptropt, pon_overflow);
return ret;
}
void * construct_stop_stmt(enum _stop_option_enum ptype, struct xvaldata * pval){
void * ret;
ret = (void *) new CobStmtStop(ptype, pval);
return ret;
}
void * construct_exit_stmt(enum _exit_enum ptype, int pcycle){
void * ret;
ret = (void *) new CobStmtExit(ptype, pcycle);
return ret;
}
/*
struct _address_item * construct_address_item(int ptype, struct idvalStru * pid){
struct _address_item * ret = new struct _address_item;
ret->type = ptype;
ret->id = pid;
return ret;
}
void delete_address_item(struct _address_item * pitem){
if(pitem == NULL) return;
if(pitem->id != NULL) delete_id(pitem->id);
delete pitem;
}
void delete_address_item_list(void * plst){
if(plst == NULL) return;
list <void *> * lst = (list <void *> *)plst;
list<void *>::iterator i;
for(i = lst->begin(); i != lst->end(); ++i ){
struct _address_item * item = (struct _address_item *)(*i);
delete_address_item(item);
}
delete lst;
}
struct _up_down_item * construct_up_down_item(void * plst, int pupdown,
struct xvaldata * pval){
struct _up_down_item * ret = new struct _up_down_item;
ret->itemlst = plst;
ret->updown = pupdown;
ret->val = pval;
return ret;
}
struct _condition_item * construct_condition_item(struct idvalStru * pid, int ptrue_false){
struct _condition_item * ret = new struct _condition_item;
ret->id = pid;
ret->true_false = ptrue_false;
return ret;
}
struct _set_address_item * construct_set_address_item(void * paddr_item_list,
struct _address_item * ptoitem){
struct _set_address_item * ret = new struct _set_address_item;
ret->addr_item_list = paddr_item_list;
ret->toitem = ptoitem;
return ret;
}
struct _set_pointer_item * construct_set_pointer_item(void * pitemlst, int pupdown,
struct idvalStru * pid){
struct _set_pointer_item * ret = new struct _set_pointer_item;
ret->itemlst = pitemlst;
ret->updown = pupdown;
ret->id = pid;
return ret;
}
struct _mnemonic_item * construct_mnemonic_item(void * plst, int ponoff){
struct _mnemonic_item * ret = new struct _mnemonic_item;
ret->item_list = plst;
ret->onoff = ponoff;
return ret;
}
struct _set_index_item * construct_set_index_item(void * plst,
struct xvaldata * pval){
struct _set_index_item * ret = new struct _set_index_item;
ret->lst = plst;
ret->val = pval;
return ret;
}
void * construct_set_stmt(enum _set_stmt_type_enum ptype, void * plst){
void * ret;
ret = (void *) new CobStmtSet(ptype, plst);
return ret;
}
*/
////////// SET statement : modified
struct _set_item * cons_set_item(enum _set_info_type ptype, struct xvaldata * pval){
struct _set_item * ret = new struct _set_item;
ret->type = ptype;
ret->xval = pval;
return ret;
}
void delete_set_item_list(void * plst){
if(plst == NULL) return;
list <void *> * lst = (list <void *> *)plst;
list<void *>::iterator i;
for(i = lst->begin(); i != lst->end(); ++i ){
struct _set_item * item = (struct _set_item *)(*i);
if(item != NULL) {
if(item->xval != NULL) {
delete_xval(item->xval);
}
delete item;
}
}
delete lst;
}
struct _set_clause * cons_set_clause(void * plst, enum _set_direction pdir,
struct _set_item * pitem){
struct _set_clause * ret = new struct _set_clause;
ret->set_item_list = plst;
ret->direction = pdir;
ret->ritem = pitem;
return ret;
}
void delete_set_clause_list(void * plst){
if(plst == NULL) return;
list <void *> * lst = (list <void *> *)plst;
list<void *>::iterator i;
for(i = lst->begin(); i != lst->end(); ++i ){
struct _set_clause * item = (struct _set_clause *)(*i);
if(item != NULL){
if(item->set_item_list != NULL)
delete_set_item_list(item->set_item_list);
if(item->ritem != NULL){
if(item->ritem->xval != NULL)
delete_xval(item->ritem->xval);
delete item->ritem;
}
delete item;
}
}
delete lst;
}
void * cons_set_stmt(void * pset_clause_list){
void * ret;
ret = (void *) new CobStmtSet(pset_clause_list);
return ret;
}
////////////////////////////////////////////////
struct _on_key_clause * construct_on_key_clause(int pdir, void * plst){
struct _on_key_clause * ret = new struct _on_key_clause;
ret->direction = pdir;
ret->itemlist = plst;
return ret;
}
void delete_on_key_clause_list(void * plst){
if(plst == NULL) return;
list<void *> * lst = (list<void *> *) plst;
list<void *>::iterator i;
for(i = lst->begin(); i != lst->end(); ++i ){
struct _on_key_clause * item = (struct _on_key_clause *)(*i);
if(item != NULL) {
if(item->itemlist != NULL)
delete_xvallist(item->itemlist);
delete item;
}
}
delete lst;
}
struct _file_io_clause * construct_file_io_clause(enum filetypeenum ptype,
char * pprocname, char * pthru_procname, void * pfname_lst){
struct _file_io_clause * ret = new struct _file_io_clause;
ret->type = ptype;
ret->proc_name = pprocname;
ret->thru_proc_name = pthru_procname;
ret->using_fname_list = pfname_lst;
return ret;
}
void delete_file_io_clause(struct _file_io_clause * pitem){
if(pitem == NULL) return;
if(pitem->proc_name != NULL) delete pitem->proc_name;
if(pitem->thru_proc_name != NULL) delete pitem->thru_proc_name;
if(pitem->using_fname_list != NULL) delete_xvallist(pitem->using_fname_list);
delete pitem;
}
void * construct_sort_stmt( struct idvalStru * pid,
void * ponkeylst,
int popt_duplicate,
struct idvalStru * pcollating_seq,
struct _file_io_clause * pinput,
struct _file_io_clause * poutput){
void * ret;
ret = (void *) new CobStmtSort(pid, ponkeylst, popt_duplicate, pcollating_seq,
pinput, poutput);
return ret;
}
void * construct_merge_stmt(struct idvalStru * pfile_name,
void * ponkey_lst, struct idvalStru * pcollating_seq,
void * pusingfile, struct _file_io_clause * poutput){
void * ret;
ret = (void *) new CobStmtMerge(pfile_name, ponkey_lst, pcollating_seq,
pusingfile, poutput);
return ret;
}
struct _eval_item * construct_eval_item(enum _eval_enum ptype, void * pfirst, void * psecond){
struct _eval_item * ret = new struct _eval_item;
ret->type = ptype;
switch(ptype) {
case CB_EI_ANY: break;
case CB_EI_COND:
ret->cond = (struct _condition *) pfirst;
break;
case CB_EI_TRUE: break;
case CB_EI_FALSE: break;
case CB_EI_EVAL:
ret->from_item = (struct _eval_item *) pfirst;
break;
case CB_EI_EVAL_ITEMS:
ret->from_item = (struct _eval_item *) pfirst;
ret->thru_item = (struct _eval_item *) psecond;
break;
case CB_EI_IDENTIFIER:
ret->id = (struct idvalStru *) pfirst;
break;