* sh.c (prepare_move_operand): Check if operand 0 is an invalid
[official-gcc.git] / gcc / f / std.c
blobd225d1c97243ea4b05708b1e71c804586d277bd7
1 /* std.c -- Implementation File (module.c template V1.0)
2 Copyright (C) 1995, 1996, 2000, 2002, 2003 Free Software Foundation, Inc.
3 Contributed by James Craig Burley.
5 This file is part of GNU Fortran.
7 GNU Fortran is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU Fortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Fortran; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.
22 Related Modules:
23 st.c
25 Description:
26 Implements the various statements and such like.
28 Modifications:
29 21-Nov-91 JCB 2.0
30 Split out actual code generation to ffeste.
33 /* Include files. */
35 #include "proj.h"
36 #include "std.h"
37 #include "bld.h"
38 #include "com.h"
39 #include "lab.h"
40 #include "lex.h"
41 #include "malloc.h"
42 #include "sta.h"
43 #include "ste.h"
44 #include "stp.h"
45 #include "str.h"
46 #include "sts.h"
47 #include "stt.h"
48 #include "stv.h"
49 #include "stw.h"
50 #include "symbol.h"
51 #include "target.h"
53 /* Externals defined here. */
56 /* Simple definitions and enumerations. */
58 #define FFESTD_COPY_EASY_ 1 /* 1 for only one _subr_copy_xyz_ fn. */
60 #define FFESTD_IS_END_OPTIMIZED_ 1 /* 0=always gen STOP/RETURN before
61 END. */
63 typedef enum
65 FFESTD_stateletSIMPLE_, /* Expecting simple/start. */
66 FFESTD_stateletATTRIB_, /* Expecting attrib/item/itemstart. */
67 FFESTD_stateletITEM_, /* Expecting item/itemstart/finish. */
68 FFESTD_stateletITEMVALS_, /* Expecting itemvalue/itemendvals. */
69 FFESTD_
70 } ffestdStatelet_;
72 typedef enum
74 FFESTD_stmtidENDDOLOOP_,
75 FFESTD_stmtidENDLOGIF_,
76 FFESTD_stmtidEXECLABEL_,
77 FFESTD_stmtidFORMATLABEL_,
78 FFESTD_stmtidR737A_, /* let */
79 FFESTD_stmtidR803_, /* IF-block */
80 FFESTD_stmtidR804_, /* ELSE IF */
81 FFESTD_stmtidR805_, /* ELSE */
82 FFESTD_stmtidR806_, /* END IF */
83 FFESTD_stmtidR807_, /* IF-logical */
84 FFESTD_stmtidR809_, /* SELECT CASE */
85 FFESTD_stmtidR810_, /* CASE */
86 FFESTD_stmtidR811_, /* END SELECT */
87 FFESTD_stmtidR819A_, /* DO-iterative */
88 FFESTD_stmtidR819B_, /* DO WHILE */
89 FFESTD_stmtidR825_, /* END DO */
90 FFESTD_stmtidR834_, /* CYCLE */
91 FFESTD_stmtidR835_, /* EXIT */
92 FFESTD_stmtidR836_, /* GOTO */
93 FFESTD_stmtidR837_, /* GOTO-computed */
94 FFESTD_stmtidR838_, /* ASSIGN */
95 FFESTD_stmtidR839_, /* GOTO-assigned */
96 FFESTD_stmtidR840_, /* IF-arithmetic */
97 FFESTD_stmtidR841_, /* CONTINUE */
98 FFESTD_stmtidR842_, /* STOP */
99 FFESTD_stmtidR843_, /* PAUSE */
100 FFESTD_stmtidR904_, /* OPEN */
101 FFESTD_stmtidR907_, /* CLOSE */
102 FFESTD_stmtidR909_, /* READ */
103 FFESTD_stmtidR910_, /* WRITE */
104 FFESTD_stmtidR911_, /* PRINT */
105 FFESTD_stmtidR919_, /* BACKSPACE */
106 FFESTD_stmtidR920_, /* ENDFILE */
107 FFESTD_stmtidR921_, /* REWIND */
108 FFESTD_stmtidR923A_, /* INQUIRE */
109 FFESTD_stmtidR923B_, /* INQUIRE-iolength */
110 FFESTD_stmtidR1001_, /* FORMAT */
111 FFESTD_stmtidR1103_, /* END_PROGRAM */
112 FFESTD_stmtidR1112_, /* END_BLOCK_DATA */
113 FFESTD_stmtidR1212_, /* CALL */
114 FFESTD_stmtidR1221_, /* END_FUNCTION */
115 FFESTD_stmtidR1225_, /* END_SUBROUTINE */
116 FFESTD_stmtidR1226_, /* ENTRY */
117 FFESTD_stmtidR1227_, /* RETURN */
118 FFESTD_stmtidV020_, /* TYPE */
119 FFESTD_stmtid_,
120 } ffestdStmtId_;
122 /* Internal typedefs. */
124 typedef struct _ffestd_expr_item_ *ffestdExprItem_;
125 typedef struct _ffestd_stmt_ *ffestdStmt_;
127 /* Private include files. */
130 /* Internal structure definitions. */
132 struct _ffestd_expr_item_
134 ffestdExprItem_ next;
135 ffebld expr;
136 ffelexToken token;
139 struct _ffestd_stmt_
141 ffestdStmt_ next;
142 ffestdStmt_ previous;
143 ffestdStmtId_ id;
144 char *filename;
145 int filelinenum;
146 union
148 struct
150 ffestw block;
152 enddoloop;
153 struct
155 ffelab label;
157 execlabel;
158 struct
160 ffelab label;
162 formatlabel;
163 struct
165 mallocPool pool;
166 ffebld dest;
167 ffebld source;
169 R737A;
170 struct
172 mallocPool pool;
173 ffestw block;
174 ffebld expr;
176 R803;
177 struct
179 mallocPool pool;
180 ffestw block;
181 ffebld expr;
183 R804;
184 struct
186 ffestw block;
188 R805;
189 struct
191 ffestw block;
193 R806;
194 struct
196 mallocPool pool;
197 ffebld expr;
199 R807;
200 struct
202 mallocPool pool;
203 ffestw block;
204 ffebld expr;
206 R809;
207 struct
209 mallocPool pool;
210 ffestw block;
211 unsigned long casenum;
213 R810;
214 struct
216 ffestw block;
218 R811;
219 struct
221 mallocPool pool;
222 ffestw block;
223 ffelab label;
224 ffebld var;
225 ffebld start;
226 ffelexToken start_token;
227 ffebld end;
228 ffelexToken end_token;
229 ffebld incr;
230 ffelexToken incr_token;
232 R819A;
233 struct
235 mallocPool pool;
236 ffestw block;
237 ffelab label;
238 ffebld expr;
240 R819B;
241 struct
243 ffestw block;
245 R834;
246 struct
248 ffestw block;
250 R835;
251 struct
253 ffelab label;
255 R836;
256 struct
258 mallocPool pool;
259 ffelab *labels;
260 int count;
261 ffebld expr;
263 R837;
264 struct
266 mallocPool pool;
267 ffelab label;
268 ffebld target;
270 R838;
271 struct
273 mallocPool pool;
274 ffebld target;
276 R839;
277 struct
279 mallocPool pool;
280 ffebld expr;
281 ffelab neg;
282 ffelab zero;
283 ffelab pos;
285 R840;
286 struct
288 mallocPool pool;
289 ffebld expr;
291 R842;
292 struct
294 mallocPool pool;
295 ffebld expr;
297 R843;
298 struct
300 mallocPool pool;
301 ffestpOpenStmt *params;
303 R904;
304 struct
306 mallocPool pool;
307 ffestpCloseStmt *params;
309 R907;
310 struct
312 mallocPool pool;
313 ffestpReadStmt *params;
314 bool only_format;
315 ffestvUnit unit;
316 ffestvFormat format;
317 bool rec;
318 bool key;
319 ffestdExprItem_ list;
321 R909;
322 struct
324 mallocPool pool;
325 ffestpWriteStmt *params;
326 ffestvUnit unit;
327 ffestvFormat format;
328 bool rec;
329 ffestdExprItem_ list;
331 R910;
332 struct
334 mallocPool pool;
335 ffestpPrintStmt *params;
336 ffestvFormat format;
337 ffestdExprItem_ list;
339 R911;
340 struct
342 mallocPool pool;
343 ffestpBeruStmt *params;
345 R919;
346 struct
348 mallocPool pool;
349 ffestpBeruStmt *params;
351 R920;
352 struct
354 mallocPool pool;
355 ffestpBeruStmt *params;
357 R921;
358 struct
360 mallocPool pool;
361 ffestpInquireStmt *params;
362 bool by_file;
364 R923A;
365 struct
367 mallocPool pool;
368 ffestpInquireStmt *params;
369 ffestdExprItem_ list;
371 R923B;
372 struct
374 ffestsHolder str;
376 R1001;
377 struct
379 mallocPool pool;
380 ffebld expr;
382 R1212;
383 struct
385 ffesymbol entry;
386 int entrynum;
388 R1226;
389 struct
391 mallocPool pool;
392 ffestw block;
393 ffebld expr;
395 R1227;
396 struct
398 mallocPool pool;
399 ffestpTypeStmt *params;
400 ffestvFormat format;
401 ffestdExprItem_ list;
403 V020;
408 /* Static objects accessed by functions in this module. */
410 static ffestdStatelet_ ffestd_statelet_ = FFESTD_stateletSIMPLE_;
411 static int ffestd_block_level_ = 0; /* Block level for reachableness. */
412 static bool ffestd_is_reachable_; /* Is the current stmt reachable? */
413 static ffelab ffestd_label_formatdef_ = NULL;
414 static ffestdExprItem_ *ffestd_expr_list_;
415 static struct
417 ffestdStmt_ first;
418 ffestdStmt_ last;
420 ffestd_stmt_list_ =
422 NULL, NULL
426 /* # ENTRY statements pending. */
427 static int ffestd_2pass_entrypoints_ = 0;
429 /* Static functions (internal). */
431 static void ffestd_stmt_append_ (ffestdStmt_ stmt);
432 static ffestdStmt_ ffestd_stmt_new_ (ffestdStmtId_ id);
433 static void ffestd_stmt_pass_ (void);
434 #if FFESTD_COPY_EASY_
435 static ffestpInquireStmt *ffestd_subr_copy_easy_ (ffestpInquireIx max);
436 #endif
437 static void ffestd_subr_vxt_ (void);
438 static void ffestd_subr_labels_ (bool unexpected);
439 static void ffestd_R1001dump_ (ffests s, ffesttFormatList list);
440 static void ffestd_R1001dump_1005_1_ (ffests s, ffesttFormatList f,
441 const char *string);
442 static void ffestd_R1001dump_1005_2_ (ffests s, ffesttFormatList f,
443 const char *string);
444 static void ffestd_R1001dump_1005_3_ (ffests s, ffesttFormatList f,
445 const char *string);
446 static void ffestd_R1001dump_1005_4_ (ffests s, ffesttFormatList f,
447 const char *string);
448 static void ffestd_R1001dump_1005_5_ (ffests s, ffesttFormatList f,
449 const char *string);
450 static void ffestd_R1001dump_1010_1_ (ffests s, ffesttFormatList f,
451 const char *string);
452 static void ffestd_R1001dump_1010_2_ (ffests s, ffesttFormatList f,
453 const char *string);
454 static void ffestd_R1001dump_1010_4_ (ffests s, ffesttFormatList f,
455 const char *string);
456 static void ffestd_R1001dump_1010_5_ (ffests s, ffesttFormatList f,
457 const char *string);
458 static void ffestd_R1001error_ (ffesttFormatList f);
459 static void ffestd_R1001rtexpr_ (ffests s, ffesttFormatList f, ffebld expr);
461 /* Internal macros. */
463 #define ffestd_subr_line_now_() \
464 ffeste_set_line (ffelex_token_where_filename (ffesta_tokens[0]), \
465 ffelex_token_where_filelinenum (ffesta_tokens[0]))
466 #define ffestd_subr_line_restore_(s) \
467 ffeste_set_line ((s)->filename, (s)->filelinenum)
468 #define ffestd_subr_line_save_(s) \
469 ((s)->filename = ffelex_token_where_filename (ffesta_tokens[0]), \
470 (s)->filelinenum = ffelex_token_where_filelinenum (ffesta_tokens[0]))
471 #define ffestd_check_simple_() \
472 assert(ffestd_statelet_ == FFESTD_stateletSIMPLE_)
473 #define ffestd_check_start_() \
474 assert(ffestd_statelet_ == FFESTD_stateletSIMPLE_); \
475 ffestd_statelet_ = FFESTD_stateletATTRIB_
476 #define ffestd_check_attrib_() \
477 assert(ffestd_statelet_ == FFESTD_stateletATTRIB_)
478 #define ffestd_check_item_() \
479 assert(ffestd_statelet_ == FFESTD_stateletATTRIB_ \
480 || ffestd_statelet_ == FFESTD_stateletITEM_); \
481 ffestd_statelet_ = FFESTD_stateletITEM_
482 #define ffestd_check_item_startvals_() \
483 assert(ffestd_statelet_ == FFESTD_stateletATTRIB_ \
484 || ffestd_statelet_ == FFESTD_stateletITEM_); \
485 ffestd_statelet_ = FFESTD_stateletITEMVALS_
486 #define ffestd_check_item_value_() \
487 assert(ffestd_statelet_ == FFESTD_stateletITEMVALS_)
488 #define ffestd_check_item_endvals_() \
489 assert(ffestd_statelet_ == FFESTD_stateletITEMVALS_); \
490 ffestd_statelet_ = FFESTD_stateletITEM_
491 #define ffestd_check_finish_() \
492 assert(ffestd_statelet_ == FFESTD_stateletATTRIB_ \
493 || ffestd_statelet_ == FFESTD_stateletITEM_); \
494 ffestd_statelet_ = FFESTD_stateletSIMPLE_
496 #if FFESTD_COPY_EASY_
497 #define ffestd_subr_copy_accept_() (ffestpAcceptStmt *) \
498 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_acceptix)
499 #define ffestd_subr_copy_beru_() (ffestpBeruStmt *) \
500 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_beruix)
501 #define ffestd_subr_copy_close_() (ffestpCloseStmt *) \
502 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_closeix)
503 #define ffestd_subr_copy_delete_() (ffestpDeleteStmt *) \
504 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_deleteix)
505 #define ffestd_subr_copy_find_() (ffestpFindStmt *) \
506 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_findix)
507 #define ffestd_subr_copy_inquire_() (ffestpInquireStmt *) \
508 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_inquireix)
509 #define ffestd_subr_copy_open_() (ffestpOpenStmt *) \
510 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_openix)
511 #define ffestd_subr_copy_print_() (ffestpPrintStmt *) \
512 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_printix)
513 #define ffestd_subr_copy_read_() (ffestpReadStmt *) \
514 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_readix)
515 #define ffestd_subr_copy_rewrite_() (ffestpRewriteStmt *) \
516 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_rewriteix)
517 #define ffestd_subr_copy_type_() (ffestpTypeStmt *) \
518 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_typeix)
519 #define ffestd_subr_copy_vxtcode_() (ffestpVxtcodeStmt *) \
520 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_vxtcodeix)
521 #define ffestd_subr_copy_write_() (ffestpWriteStmt *) \
522 ffestd_subr_copy_easy_((ffestpInquireIx) FFESTP_writeix)
523 #endif
525 /* ffestd_stmt_append_ -- Append statement to end of stmt list
527 ffestd_stmt_append_(ffestd_stmt_new_(FFESTD_stmtidR737A_)); */
529 static void
530 ffestd_stmt_append_ (ffestdStmt_ stmt)
532 stmt->next = (ffestdStmt_) &ffestd_stmt_list_.first;
533 stmt->previous = ffestd_stmt_list_.last;
534 stmt->next->previous = stmt;
535 stmt->previous->next = stmt;
538 /* ffestd_stmt_new_ -- Make new statement with given id
540 ffestdStmt_ stmt;
541 stmt = ffestd_stmt_new_(FFESTD_stmtidR737A_); */
543 static ffestdStmt_
544 ffestd_stmt_new_ (ffestdStmtId_ id)
546 ffestdStmt_ stmt;
548 stmt = malloc_new_kp (ffe_pool_any_unit (), "ffestdStmt_", sizeof (*stmt));
549 stmt->id = id;
550 return stmt;
553 /* ffestd_stmt_pass_ -- Pass all statements on list to ffeste
555 ffestd_stmt_pass_(); */
557 static void
558 ffestd_stmt_pass_ ()
560 ffestdStmt_ stmt;
561 ffestdExprItem_ expr; /* For traversing lists. */
562 bool okay = (TREE_CODE (current_function_decl) != ERROR_MARK);
564 if ((ffestd_2pass_entrypoints_ != 0) && okay)
566 tree which = ffecom_which_entrypoint_decl ();
567 tree value;
568 tree label;
569 int pushok;
570 int ents = ffestd_2pass_entrypoints_;
571 tree duplicate;
573 expand_start_case (0, which, TREE_TYPE (which), "entrypoint dispatch");
575 stmt = ffestd_stmt_list_.first;
578 while (stmt->id != FFESTD_stmtidR1226_)
579 stmt = stmt->next;
581 if (stmt->u.R1226.entry != NULL)
583 value = build_int_2 (stmt->u.R1226.entrynum, 0);
584 /* Yes, we really want to build a null LABEL_DECL here and not
585 put it on any list. That's what pushcase wants, so that's
586 what it gets! */
587 label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
589 pushok = pushcase (value, convert, label, &duplicate);
590 assert (pushok == 0);
592 label = ffecom_temp_label ();
593 TREE_USED (label) = 1;
594 expand_goto (label);
596 ffesymbol_hook (stmt->u.R1226.entry).length_tree = label;
598 stmt = stmt->next;
600 while (--ents != 0);
602 expand_end_case (which);
605 for (stmt = ffestd_stmt_list_.first;
606 stmt != (ffestdStmt_) &ffestd_stmt_list_.first;
607 stmt = stmt->next)
609 switch (stmt->id)
611 case FFESTD_stmtidENDDOLOOP_:
612 ffestd_subr_line_restore_ (stmt);
613 if (okay)
614 ffeste_do (stmt->u.enddoloop.block);
615 ffestw_kill (stmt->u.enddoloop.block);
616 break;
618 case FFESTD_stmtidENDLOGIF_:
619 ffestd_subr_line_restore_ (stmt);
620 if (okay)
621 ffeste_end_R807 ();
622 break;
624 case FFESTD_stmtidEXECLABEL_:
625 if (okay)
626 ffeste_labeldef_branch (stmt->u.execlabel.label);
627 break;
629 case FFESTD_stmtidFORMATLABEL_:
630 if (okay)
631 ffeste_labeldef_format (stmt->u.formatlabel.label);
632 break;
634 case FFESTD_stmtidR737A_:
635 ffestd_subr_line_restore_ (stmt);
636 if (okay)
637 ffeste_R737A (stmt->u.R737A.dest, stmt->u.R737A.source);
638 malloc_pool_kill (stmt->u.R737A.pool);
639 break;
641 case FFESTD_stmtidR803_:
642 ffestd_subr_line_restore_ (stmt);
643 if (okay)
644 ffeste_R803 (stmt->u.R803.block, stmt->u.R803.expr);
645 malloc_pool_kill (stmt->u.R803.pool);
646 break;
648 case FFESTD_stmtidR804_:
649 ffestd_subr_line_restore_ (stmt);
650 if (okay)
651 ffeste_R804 (stmt->u.R803.block, stmt->u.R804.expr);
652 malloc_pool_kill (stmt->u.R804.pool);
653 break;
655 case FFESTD_stmtidR805_:
656 ffestd_subr_line_restore_ (stmt);
657 if (okay)
658 ffeste_R805 (stmt->u.R803.block);
659 break;
661 case FFESTD_stmtidR806_:
662 ffestd_subr_line_restore_ (stmt);
663 if (okay)
664 ffeste_R806 (stmt->u.R806.block);
665 ffestw_kill (stmt->u.R806.block);
666 break;
668 case FFESTD_stmtidR807_:
669 ffestd_subr_line_restore_ (stmt);
670 if (okay)
671 ffeste_R807 (stmt->u.R807.expr);
672 malloc_pool_kill (stmt->u.R807.pool);
673 break;
675 case FFESTD_stmtidR809_:
676 ffestd_subr_line_restore_ (stmt);
677 if (okay)
678 ffeste_R809 (stmt->u.R809.block, stmt->u.R809.expr);
679 malloc_pool_kill (stmt->u.R809.pool);
680 break;
682 case FFESTD_stmtidR810_:
683 ffestd_subr_line_restore_ (stmt);
684 if (okay)
685 ffeste_R810 (stmt->u.R810.block, stmt->u.R810.casenum);
686 malloc_pool_kill (stmt->u.R810.pool);
687 break;
689 case FFESTD_stmtidR811_:
690 ffestd_subr_line_restore_ (stmt);
691 if (okay)
692 ffeste_R811 (stmt->u.R811.block);
693 malloc_pool_kill (ffestw_select (stmt->u.R811.block)->pool);
694 ffestw_kill (stmt->u.R811.block);
695 break;
697 case FFESTD_stmtidR819A_:
698 ffestd_subr_line_restore_ (stmt);
699 if (okay)
700 ffeste_R819A (stmt->u.R819A.block, stmt->u.R819A.label,
701 stmt->u.R819A.var,
702 stmt->u.R819A.start, stmt->u.R819A.start_token,
703 stmt->u.R819A.end, stmt->u.R819A.end_token,
704 stmt->u.R819A.incr, stmt->u.R819A.incr_token);
705 ffelex_token_kill (stmt->u.R819A.start_token);
706 ffelex_token_kill (stmt->u.R819A.end_token);
707 if (stmt->u.R819A.incr_token != NULL)
708 ffelex_token_kill (stmt->u.R819A.incr_token);
709 malloc_pool_kill (stmt->u.R819A.pool);
710 break;
712 case FFESTD_stmtidR819B_:
713 ffestd_subr_line_restore_ (stmt);
714 if (okay)
715 ffeste_R819B (stmt->u.R819B.block, stmt->u.R819B.label,
716 stmt->u.R819B.expr);
717 malloc_pool_kill (stmt->u.R819B.pool);
718 break;
720 case FFESTD_stmtidR825_:
721 ffestd_subr_line_restore_ (stmt);
722 if (okay)
723 ffeste_R825 ();
724 break;
726 case FFESTD_stmtidR834_:
727 ffestd_subr_line_restore_ (stmt);
728 if (okay)
729 ffeste_R834 (stmt->u.R834.block);
730 break;
732 case FFESTD_stmtidR835_:
733 ffestd_subr_line_restore_ (stmt);
734 if (okay)
735 ffeste_R835 (stmt->u.R835.block);
736 break;
738 case FFESTD_stmtidR836_:
739 ffestd_subr_line_restore_ (stmt);
740 if (okay)
741 ffeste_R836 (stmt->u.R836.label);
742 break;
744 case FFESTD_stmtidR837_:
745 ffestd_subr_line_restore_ (stmt);
746 if (okay)
747 ffeste_R837 (stmt->u.R837.labels, stmt->u.R837.count,
748 stmt->u.R837.expr);
749 malloc_pool_kill (stmt->u.R837.pool);
750 break;
752 case FFESTD_stmtidR838_:
753 ffestd_subr_line_restore_ (stmt);
754 if (okay)
755 ffeste_R838 (stmt->u.R838.label, stmt->u.R838.target);
756 malloc_pool_kill (stmt->u.R838.pool);
757 break;
759 case FFESTD_stmtidR839_:
760 ffestd_subr_line_restore_ (stmt);
761 if (okay)
762 ffeste_R839 (stmt->u.R839.target);
763 malloc_pool_kill (stmt->u.R839.pool);
764 break;
766 case FFESTD_stmtidR840_:
767 ffestd_subr_line_restore_ (stmt);
768 if (okay)
769 ffeste_R840 (stmt->u.R840.expr, stmt->u.R840.neg, stmt->u.R840.zero,
770 stmt->u.R840.pos);
771 malloc_pool_kill (stmt->u.R840.pool);
772 break;
774 case FFESTD_stmtidR841_:
775 ffestd_subr_line_restore_ (stmt);
776 if (okay)
777 ffeste_R841 ();
778 break;
780 case FFESTD_stmtidR842_:
781 ffestd_subr_line_restore_ (stmt);
782 if (okay)
783 ffeste_R842 (stmt->u.R842.expr);
784 if (stmt->u.R842.pool != NULL)
785 malloc_pool_kill (stmt->u.R842.pool);
786 break;
788 case FFESTD_stmtidR843_:
789 ffestd_subr_line_restore_ (stmt);
790 if (okay)
791 ffeste_R843 (stmt->u.R843.expr);
792 malloc_pool_kill (stmt->u.R843.pool);
793 break;
795 case FFESTD_stmtidR904_:
796 ffestd_subr_line_restore_ (stmt);
797 if (okay)
798 ffeste_R904 (stmt->u.R904.params);
799 malloc_pool_kill (stmt->u.R904.pool);
800 break;
802 case FFESTD_stmtidR907_:
803 ffestd_subr_line_restore_ (stmt);
804 if (okay)
805 ffeste_R907 (stmt->u.R907.params);
806 malloc_pool_kill (stmt->u.R907.pool);
807 break;
809 case FFESTD_stmtidR909_:
810 ffestd_subr_line_restore_ (stmt);
811 if (okay)
812 ffeste_R909_start (stmt->u.R909.params, stmt->u.R909.only_format,
813 stmt->u.R909.unit, stmt->u.R909.format,
814 stmt->u.R909.rec, stmt->u.R909.key);
815 for (expr = stmt->u.R909.list; expr != NULL; expr = expr->next)
817 if (okay)
818 ffeste_R909_item (expr->expr, expr->token);
819 ffelex_token_kill (expr->token);
821 if (okay)
822 ffeste_R909_finish ();
823 malloc_pool_kill (stmt->u.R909.pool);
824 break;
826 case FFESTD_stmtidR910_:
827 ffestd_subr_line_restore_ (stmt);
828 if (okay)
829 ffeste_R910_start (stmt->u.R910.params, stmt->u.R910.unit,
830 stmt->u.R910.format, stmt->u.R910.rec);
831 for (expr = stmt->u.R910.list; expr != NULL; expr = expr->next)
833 if (okay)
834 ffeste_R910_item (expr->expr, expr->token);
835 ffelex_token_kill (expr->token);
837 if (okay)
838 ffeste_R910_finish ();
839 malloc_pool_kill (stmt->u.R910.pool);
840 break;
842 case FFESTD_stmtidR911_:
843 ffestd_subr_line_restore_ (stmt);
844 if (okay)
845 ffeste_R911_start (stmt->u.R911.params, stmt->u.R911.format);
846 for (expr = stmt->u.R911.list; expr != NULL; expr = expr->next)
848 if (okay)
849 ffeste_R911_item (expr->expr, expr->token);
850 ffelex_token_kill (expr->token);
852 if (okay)
853 ffeste_R911_finish ();
854 malloc_pool_kill (stmt->u.R911.pool);
855 break;
857 case FFESTD_stmtidR919_:
858 ffestd_subr_line_restore_ (stmt);
859 if (okay)
860 ffeste_R919 (stmt->u.R919.params);
861 malloc_pool_kill (stmt->u.R919.pool);
862 break;
864 case FFESTD_stmtidR920_:
865 ffestd_subr_line_restore_ (stmt);
866 if (okay)
867 ffeste_R920 (stmt->u.R920.params);
868 malloc_pool_kill (stmt->u.R920.pool);
869 break;
871 case FFESTD_stmtidR921_:
872 ffestd_subr_line_restore_ (stmt);
873 if (okay)
874 ffeste_R921 (stmt->u.R921.params);
875 malloc_pool_kill (stmt->u.R921.pool);
876 break;
878 case FFESTD_stmtidR923A_:
879 ffestd_subr_line_restore_ (stmt);
880 if (okay)
881 ffeste_R923A (stmt->u.R923A.params, stmt->u.R923A.by_file);
882 malloc_pool_kill (stmt->u.R923A.pool);
883 break;
885 case FFESTD_stmtidR923B_:
886 ffestd_subr_line_restore_ (stmt);
887 if (okay)
888 ffeste_R923B_start (stmt->u.R923B.params);
889 for (expr = stmt->u.R923B.list; expr != NULL; expr = expr->next)
891 if (okay)
892 ffeste_R923B_item (expr->expr);
894 if (okay)
895 ffeste_R923B_finish ();
896 malloc_pool_kill (stmt->u.R923B.pool);
897 break;
899 case FFESTD_stmtidR1001_:
900 if (okay)
901 ffeste_R1001 (&stmt->u.R1001.str);
902 ffests_kill (&stmt->u.R1001.str);
903 break;
905 case FFESTD_stmtidR1103_:
906 if (okay)
907 ffeste_R1103 ();
908 break;
910 case FFESTD_stmtidR1112_:
911 if (okay)
912 ffeste_R1112 ();
913 break;
915 case FFESTD_stmtidR1212_:
916 ffestd_subr_line_restore_ (stmt);
917 if (okay)
918 ffeste_R1212 (stmt->u.R1212.expr);
919 malloc_pool_kill (stmt->u.R1212.pool);
920 break;
922 case FFESTD_stmtidR1221_:
923 if (okay)
924 ffeste_R1221 ();
925 break;
927 case FFESTD_stmtidR1225_:
928 if (okay)
929 ffeste_R1225 ();
930 break;
932 case FFESTD_stmtidR1226_:
933 ffestd_subr_line_restore_ (stmt);
934 if (stmt->u.R1226.entry != NULL)
936 if (okay)
937 ffeste_R1226 (stmt->u.R1226.entry);
939 break;
941 case FFESTD_stmtidR1227_:
942 ffestd_subr_line_restore_ (stmt);
943 if (okay)
944 ffeste_R1227 (stmt->u.R1227.block, stmt->u.R1227.expr);
945 malloc_pool_kill (stmt->u.R1227.pool);
946 break;
948 case FFESTD_stmtidV020_:
949 ffestd_subr_line_restore_ (stmt);
950 if (okay)
951 ffeste_V020_start (stmt->u.V020.params, stmt->u.V020.format);
952 for (expr = stmt->u.V020.list; expr != NULL; expr = expr->next)
954 if (okay)
955 ffeste_V020_item (expr->expr);
957 if (okay)
958 ffeste_V020_finish ();
959 malloc_pool_kill (stmt->u.V020.pool);
960 break;
962 default:
963 assert ("bad stmt->id" == NULL);
964 break;
969 /* ffestd_subr_copy_easy_ -- Copy I/O statement data structure
971 ffestd_subr_copy_easy_();
973 Copies all data except tokens in the I/O data structure into a new
974 structure that lasts as long as the output pool for the current
975 statement. Assumes that they are
976 overlaid with each other (union) in stp.h and the typing
977 and structure references assume (though not necessarily dangerous if
978 FALSE) that INQUIRE has the most file elements. */
980 #if FFESTD_COPY_EASY_
981 static ffestpInquireStmt *
982 ffestd_subr_copy_easy_ (ffestpInquireIx max)
984 ffestpInquireStmt *stmt;
985 ffestpInquireIx ix;
987 stmt = (ffestpInquireStmt *) malloc_new_kp (ffesta_output_pool,
988 "FFESTD easy", sizeof (ffestpFile) * max);
990 for (ix = 0; ix < max; ++ix)
992 if ((stmt->inquire_spec[ix].kw_or_val_present
993 = ffestp_file.inquire.inquire_spec[ix].kw_or_val_present)
994 && (stmt->inquire_spec[ix].value_present
995 = ffestp_file.inquire.inquire_spec[ix].value_present))
997 if ((stmt->inquire_spec[ix].value_is_label
998 = ffestp_file.inquire.inquire_spec[ix].value_is_label))
999 stmt->inquire_spec[ix].u.label
1000 = ffestp_file.inquire.inquire_spec[ix].u.label;
1001 else
1002 stmt->inquire_spec[ix].u.expr
1003 = ffestp_file.inquire.inquire_spec[ix].u.expr;
1007 return stmt;
1010 #endif
1011 /* ffestd_subr_labels_ -- Handle any undefined labels
1013 ffestd_subr_labels_(FALSE);
1015 For every undefined label, generate an error message and either define
1016 label as a FORMAT() statement (for FORMAT labels) or as a STOP statement
1017 (for all other labels). */
1019 static void
1020 ffestd_subr_labels_ (bool unexpected)
1022 ffelab l;
1023 ffelabHandle h;
1024 ffelabNumber undef;
1025 ffesttFormatList f;
1027 undef = ffelab_number () - ffestv_num_label_defines_;
1029 for (h = ffelab_handle_first (); h != NULL; h = ffelab_handle_next (h))
1031 l = ffelab_handle_target (h);
1032 if (ffewhere_line_is_unknown (ffelab_definition_line (l)))
1033 { /* Undefined label. */
1034 assert (!unexpected);
1035 assert (undef > 0);
1036 undef--;
1037 ffebad_start (FFEBAD_UNDEF_LABEL);
1038 if (ffelab_type (l) == FFELAB_typeLOOPEND)
1039 ffebad_here (0, ffelab_doref_line (l), ffelab_doref_column (l));
1040 else if (ffelab_type (l) != FFELAB_typeANY)
1041 ffebad_here (0, ffelab_firstref_line (l), ffelab_firstref_column (l));
1042 else if (!ffewhere_line_is_unknown (ffelab_firstref_line (l)))
1043 ffebad_here (0, ffelab_firstref_line (l), ffelab_firstref_column (l));
1044 else if (!ffewhere_line_is_unknown (ffelab_doref_line (l)))
1045 ffebad_here (0, ffelab_doref_line (l), ffelab_doref_column (l));
1046 else
1047 ffebad_here (0, ffelab_definition_line (l), ffelab_definition_column (l));
1048 ffebad_finish ();
1050 switch (ffelab_type (l))
1052 case FFELAB_typeFORMAT:
1053 ffelab_set_definition_line (l,
1054 ffewhere_line_use (ffelab_firstref_line (l)));
1055 ffelab_set_definition_column (l,
1056 ffewhere_column_use (ffelab_firstref_column (l)));
1057 ffestv_num_label_defines_++;
1058 f = ffestt_formatlist_create (NULL, NULL);
1059 ffestd_labeldef_format (l);
1060 ffestd_R1001 (f);
1061 ffestt_formatlist_kill (f);
1062 break;
1064 case FFELAB_typeASSIGNABLE:
1065 ffelab_set_definition_line (l,
1066 ffewhere_line_use (ffelab_firstref_line (l)));
1067 ffelab_set_definition_column (l,
1068 ffewhere_column_use (ffelab_firstref_column (l)));
1069 ffestv_num_label_defines_++;
1070 ffelab_set_type (l, FFELAB_typeNOTLOOP);
1071 ffelab_set_blocknum (l, ffestw_blocknum (ffestw_stack_top ()));
1072 ffestd_labeldef_notloop (l);
1073 ffestd_R842 (NULL);
1074 break;
1076 case FFELAB_typeNOTLOOP:
1077 ffelab_set_definition_line (l,
1078 ffewhere_line_use (ffelab_firstref_line (l)));
1079 ffelab_set_definition_column (l,
1080 ffewhere_column_use (ffelab_firstref_column (l)));
1081 ffestv_num_label_defines_++;
1082 ffelab_set_blocknum (l, ffestw_blocknum (ffestw_stack_top ()));
1083 ffestd_labeldef_notloop (l);
1084 ffestd_R842 (NULL);
1085 break;
1087 default:
1088 assert ("bad label type" == NULL);
1089 /* Fall through. */
1090 case FFELAB_typeUNKNOWN:
1091 case FFELAB_typeANY:
1092 break;
1096 ffelab_handle_done (h);
1097 assert (undef == 0);
1100 /* ffestd_subr_vxt_ -- Report error about lack of full VXT support
1102 ffestd_subr_vxt_(); */
1104 static void
1105 ffestd_subr_vxt_ ()
1107 ffebad_start (FFEBAD_VXT_UNSUPPORTED);
1108 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
1109 ffelex_token_where_column (ffesta_tokens[0]));
1110 ffebad_finish ();
1113 /* ffestd_begin_uses -- Start a bunch of USE statements
1115 ffestd_begin_uses();
1117 Invoked before handling the first USE statement in a block of one or
1118 more USE statements. _end_uses_(bool ok) is invoked before handling
1119 the first statement after the block (there are no BEGIN USE and END USE
1120 statements, but the semantics of USE statements effectively requires
1121 handling them as a single block rather than one statement at a time). */
1123 void
1124 ffestd_begin_uses ()
1128 /* ffestd_do -- End of statement following DO-term-stmt etc
1130 ffestd_do(TRUE);
1132 Also invoked by _labeldef_branch_finish_ (or, in cases
1133 of errors, other _labeldef_ functions) when the label definition is
1134 for a DO-target (LOOPEND) label, once per matching/outstanding DO
1135 block on the stack. These cases invoke this function with ok==TRUE, so
1136 only forced stack popping (via ffestd_eof_()) invokes it with ok==FALSE. */
1138 void
1139 ffestd_do (bool ok UNUSED)
1141 ffestdStmt_ stmt;
1143 stmt = ffestd_stmt_new_ (FFESTD_stmtidENDDOLOOP_);
1144 ffestd_stmt_append_ (stmt);
1145 ffestd_subr_line_save_ (stmt);
1146 stmt->u.enddoloop.block = ffestw_stack_top ();
1148 --ffestd_block_level_;
1149 assert (ffestd_block_level_ >= 0);
1152 /* ffestd_end_R807 -- End of statement following logical IF
1154 ffestd_end_R807(TRUE);
1156 Applies ONLY to logical IF, not to IF-THEN. For example, does not
1157 ffelex_token_kill the construct name for an IF-THEN block (the name
1158 field is invalid for logical IF). ok==TRUE iff statement following
1159 logical IF (substatement) is valid; else, statement is invalid or
1160 stack forcibly popped due to ffestd_eof_(). */
1162 void
1163 ffestd_end_R807 (bool ok UNUSED)
1165 ffestdStmt_ stmt;
1167 stmt = ffestd_stmt_new_ (FFESTD_stmtidENDLOGIF_);
1168 ffestd_stmt_append_ (stmt);
1169 ffestd_subr_line_save_ (stmt);
1171 --ffestd_block_level_;
1172 assert (ffestd_block_level_ >= 0);
1175 /* ffestd_exec_begin -- Executable statements can start coming in now
1177 ffestd_exec_begin(); */
1179 void
1180 ffestd_exec_begin ()
1182 ffecom_exec_transition ();
1184 if (ffestd_2pass_entrypoints_ != 0)
1185 { /* Process pending ENTRY statements now that
1186 info filled in. */
1187 ffestdStmt_ stmt;
1188 int ents = ffestd_2pass_entrypoints_;
1190 stmt = ffestd_stmt_list_.first;
1193 while (stmt->id != FFESTD_stmtidR1226_)
1194 stmt = stmt->next;
1196 if (!ffecom_2pass_advise_entrypoint (stmt->u.R1226.entry))
1198 stmt->u.R1226.entry = NULL;
1199 --ffestd_2pass_entrypoints_;
1201 stmt = stmt->next;
1203 while (--ents != 0);
1207 /* ffestd_exec_end -- Executable statements can no longer come in now
1209 ffestd_exec_end(); */
1211 void
1212 ffestd_exec_end ()
1214 location_t old_loc = input_location;
1216 ffecom_end_transition ();
1218 ffestd_stmt_pass_ ();
1220 ffecom_finish_progunit ();
1222 if (ffestd_2pass_entrypoints_ != 0)
1224 int ents = ffestd_2pass_entrypoints_;
1225 ffestdStmt_ stmt = ffestd_stmt_list_.first;
1229 while (stmt->id != FFESTD_stmtidR1226_)
1230 stmt = stmt->next;
1232 if (stmt->u.R1226.entry != NULL)
1234 ffestd_subr_line_restore_ (stmt);
1235 ffecom_2pass_do_entrypoint (stmt->u.R1226.entry);
1237 stmt = stmt->next;
1239 while (--ents != 0);
1242 ffestd_stmt_list_.first = NULL;
1243 ffestd_stmt_list_.last = NULL;
1244 ffestd_2pass_entrypoints_ = 0;
1246 input_location = old_loc;
1249 /* ffestd_init_3 -- Initialize for any program unit
1251 ffestd_init_3(); */
1253 void
1254 ffestd_init_3 ()
1256 ffestd_stmt_list_.first = (ffestdStmt_) &ffestd_stmt_list_.first;
1257 ffestd_stmt_list_.last = (ffestdStmt_) &ffestd_stmt_list_.first;
1260 /* Generate "code" for "any" label def. */
1262 void
1263 ffestd_labeldef_any (ffelab label UNUSED)
1267 /* ffestd_labeldef_branch -- Generate "code" for branch label def
1269 ffestd_labeldef_branch(label); */
1271 void
1272 ffestd_labeldef_branch (ffelab label)
1274 ffestdStmt_ stmt;
1276 stmt = ffestd_stmt_new_ (FFESTD_stmtidEXECLABEL_);
1277 ffestd_stmt_append_ (stmt);
1278 stmt->u.execlabel.label = label;
1280 ffestd_is_reachable_ = TRUE;
1283 /* ffestd_labeldef_format -- Generate "code" for FORMAT label def
1285 ffestd_labeldef_format(label); */
1287 void
1288 ffestd_labeldef_format (ffelab label)
1290 ffestdStmt_ stmt;
1292 ffestd_label_formatdef_ = label;
1294 stmt = ffestd_stmt_new_ (FFESTD_stmtidFORMATLABEL_);
1295 ffestd_stmt_append_ (stmt);
1296 stmt->u.formatlabel.label = label;
1299 /* ffestd_labeldef_useless -- Generate "code" for useless label def
1301 ffestd_labeldef_useless(label); */
1303 void
1304 ffestd_labeldef_useless (ffelab label UNUSED)
1308 /* ffestd_R522 -- SAVE statement with no list
1310 ffestd_R522();
1312 Verify that SAVE is valid here, and flag everything as SAVEd. */
1314 void
1315 ffestd_R522 ()
1317 ffestd_check_simple_ ();
1320 /* ffestd_R522start -- SAVE statement list begin
1322 ffestd_R522start();
1324 Verify that SAVE is valid here, and begin accepting items in the list. */
1326 void
1327 ffestd_R522start ()
1329 ffestd_check_start_ ();
1332 /* ffestd_R522item_object -- SAVE statement for object-name
1334 ffestd_R522item_object(name_token);
1336 Make sure name_token identifies a valid object to be SAVEd. */
1338 void
1339 ffestd_R522item_object (ffelexToken name UNUSED)
1341 ffestd_check_item_ ();
1344 /* ffestd_R522item_cblock -- SAVE statement for common-block-name
1346 ffestd_R522item_cblock(name_token);
1348 Make sure name_token identifies a valid common block to be SAVEd. */
1350 void
1351 ffestd_R522item_cblock (ffelexToken name UNUSED)
1353 ffestd_check_item_ ();
1356 /* ffestd_R522finish -- SAVE statement list complete
1358 ffestd_R522finish();
1360 Just wrap up any local activities. */
1362 void
1363 ffestd_R522finish ()
1365 ffestd_check_finish_ ();
1368 /* ffestd_R524_start -- DIMENSION statement list begin
1370 ffestd_R524_start(bool virtual);
1372 Verify that DIMENSION is valid here, and begin accepting items in the list. */
1374 void
1375 ffestd_R524_start (bool virtual UNUSED)
1377 ffestd_check_start_ ();
1380 /* ffestd_R524_item -- DIMENSION statement for object-name
1382 ffestd_R524_item(name_token,dim_list);
1384 Make sure name_token identifies a valid object to be DIMENSIONd. */
1386 void
1387 ffestd_R524_item (ffelexToken name UNUSED, ffesttDimList dims UNUSED)
1389 ffestd_check_item_ ();
1392 /* ffestd_R524_finish -- DIMENSION statement list complete
1394 ffestd_R524_finish();
1396 Just wrap up any local activities. */
1398 void
1399 ffestd_R524_finish ()
1401 ffestd_check_finish_ ();
1404 /* ffestd_R537_start -- PARAMETER statement list begin
1406 ffestd_R537_start();
1408 Verify that PARAMETER is valid here, and begin accepting items in the list. */
1410 void
1411 ffestd_R537_start ()
1413 ffestd_check_start_ ();
1416 /* ffestd_R537_item -- PARAMETER statement assignment
1418 ffestd_R537_item(dest,dest_token,source,source_token);
1420 Make sure the source is a valid source for the destination; make the
1421 assignment. */
1423 void
1424 ffestd_R537_item (ffebld dest UNUSED, ffebld source UNUSED)
1426 ffestd_check_item_ ();
1429 /* ffestd_R537_finish -- PARAMETER statement list complete
1431 ffestd_R537_finish();
1433 Just wrap up any local activities. */
1435 void
1436 ffestd_R537_finish ()
1438 ffestd_check_finish_ ();
1441 /* ffestd_R539 -- IMPLICIT NONE statement
1443 ffestd_R539();
1445 Verify that the IMPLICIT NONE statement is ok here and implement. */
1447 void
1448 ffestd_R539 ()
1450 ffestd_check_simple_ ();
1453 /* ffestd_R539start -- IMPLICIT statement
1455 ffestd_R539start();
1457 Verify that the IMPLICIT statement is ok here and implement. */
1459 void
1460 ffestd_R539start ()
1462 ffestd_check_start_ ();
1465 /* ffestd_R539item -- IMPLICIT statement specification (R540)
1467 ffestd_R539item(...);
1469 Verify that the type and letter list are all ok and implement. */
1471 void
1472 ffestd_R539item (ffestpType type UNUSED, ffebld kind UNUSED,
1473 ffelexToken kindt UNUSED, ffebld len UNUSED,
1474 ffelexToken lent UNUSED, ffesttImpList letters UNUSED)
1476 ffestd_check_item_ ();
1479 /* ffestd_R539finish -- IMPLICIT statement
1481 ffestd_R539finish();
1483 Finish up any local activities. */
1485 void
1486 ffestd_R539finish ()
1488 ffestd_check_finish_ ();
1491 /* ffestd_R542_start -- NAMELIST statement list begin
1493 ffestd_R542_start();
1495 Verify that NAMELIST is valid here, and begin accepting items in the list. */
1497 void
1498 ffestd_R542_start ()
1500 ffestd_check_start_ ();
1503 /* ffestd_R542_item_nlist -- NAMELIST statement for group-name
1505 ffestd_R542_item_nlist(groupname_token);
1507 Make sure name_token identifies a valid object to be NAMELISTd. */
1509 void
1510 ffestd_R542_item_nlist (ffelexToken name UNUSED)
1512 ffestd_check_item_ ();
1515 /* ffestd_R542_item_nitem -- NAMELIST statement for variable-name
1517 ffestd_R542_item_nitem(name_token);
1519 Make sure name_token identifies a valid object to be NAMELISTd. */
1521 void
1522 ffestd_R542_item_nitem (ffelexToken name UNUSED)
1524 ffestd_check_item_ ();
1527 /* ffestd_R542_finish -- NAMELIST statement list complete
1529 ffestd_R542_finish();
1531 Just wrap up any local activities. */
1533 void
1534 ffestd_R542_finish ()
1536 ffestd_check_finish_ ();
1539 /* ffestd_R547_start -- COMMON statement list begin
1541 ffestd_R547_start();
1543 Verify that COMMON is valid here, and begin accepting items in the list. */
1545 void
1546 ffestd_R547_start ()
1548 ffestd_check_start_ ();
1551 /* ffestd_R547_item_object -- COMMON statement for object-name
1553 ffestd_R547_item_object(name_token,dim_list);
1555 Make sure name_token identifies a valid object to be COMMONd. */
1557 void
1558 ffestd_R547_item_object (ffelexToken name UNUSED,
1559 ffesttDimList dims UNUSED)
1561 ffestd_check_item_ ();
1564 /* ffestd_R547_item_cblock -- COMMON statement for common-block-name
1566 ffestd_R547_item_cblock(name_token);
1568 Make sure name_token identifies a valid common block to be COMMONd. */
1570 void
1571 ffestd_R547_item_cblock (ffelexToken name UNUSED)
1573 ffestd_check_item_ ();
1576 /* ffestd_R547_finish -- COMMON statement list complete
1578 ffestd_R547_finish();
1580 Just wrap up any local activities. */
1582 void
1583 ffestd_R547_finish ()
1585 ffestd_check_finish_ ();
1588 /* ffestd_R737A -- Assignment statement outside of WHERE
1590 ffestd_R737A(dest_expr,source_expr); */
1592 void
1593 ffestd_R737A (ffebld dest, ffebld source)
1595 ffestdStmt_ stmt;
1597 ffestd_check_simple_ ();
1599 stmt = ffestd_stmt_new_ (FFESTD_stmtidR737A_);
1600 ffestd_stmt_append_ (stmt);
1601 ffestd_subr_line_save_ (stmt);
1602 stmt->u.R737A.pool = ffesta_output_pool;
1603 stmt->u.R737A.dest = dest;
1604 stmt->u.R737A.source = source;
1605 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
1609 /* Block IF (IF-THEN) statement. */
1611 void
1612 ffestd_R803 (ffelexToken construct_name UNUSED, ffebld expr)
1614 ffestdStmt_ stmt;
1616 ffestd_check_simple_ ();
1618 stmt = ffestd_stmt_new_ (FFESTD_stmtidR803_);
1619 ffestd_stmt_append_ (stmt);
1620 ffestd_subr_line_save_ (stmt);
1621 stmt->u.R803.pool = ffesta_output_pool;
1622 stmt->u.R803.block = ffestw_use (ffestw_stack_top ());
1623 stmt->u.R803.expr = expr;
1624 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
1626 ++ffestd_block_level_;
1627 assert (ffestd_block_level_ > 0);
1630 /* ELSE IF statement. */
1632 void
1633 ffestd_R804 (ffebld expr, ffelexToken name UNUSED)
1635 ffestdStmt_ stmt;
1637 ffestd_check_simple_ ();
1639 stmt = ffestd_stmt_new_ (FFESTD_stmtidR804_);
1640 ffestd_stmt_append_ (stmt);
1641 ffestd_subr_line_save_ (stmt);
1642 stmt->u.R804.pool = ffesta_output_pool;
1643 stmt->u.R804.block = ffestw_use (ffestw_stack_top ());
1644 stmt->u.R804.expr = expr;
1645 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
1648 /* ELSE statement. */
1650 void
1651 ffestd_R805 (ffelexToken name UNUSED)
1653 ffestdStmt_ stmt;
1655 ffestd_check_simple_ ();
1657 stmt = ffestd_stmt_new_ (FFESTD_stmtidR805_);
1658 ffestd_stmt_append_ (stmt);
1659 ffestd_subr_line_save_ (stmt);
1660 stmt->u.R805.block = ffestw_use (ffestw_stack_top ());
1663 /* END IF statement. */
1665 void
1666 ffestd_R806 (bool ok UNUSED)
1668 ffestdStmt_ stmt;
1670 stmt = ffestd_stmt_new_ (FFESTD_stmtidR806_);
1671 ffestd_stmt_append_ (stmt);
1672 ffestd_subr_line_save_ (stmt);
1673 stmt->u.R806.block = ffestw_use (ffestw_stack_top ());
1675 --ffestd_block_level_;
1676 assert (ffestd_block_level_ >= 0);
1679 /* ffestd_R807 -- Logical IF statement
1681 ffestd_R807(expr,expr_token);
1683 Make sure statement is valid here; implement. */
1685 void
1686 ffestd_R807 (ffebld expr)
1688 ffestdStmt_ stmt;
1690 ffestd_check_simple_ ();
1692 stmt = ffestd_stmt_new_ (FFESTD_stmtidR807_);
1693 ffestd_stmt_append_ (stmt);
1694 ffestd_subr_line_save_ (stmt);
1695 stmt->u.R807.pool = ffesta_output_pool;
1696 stmt->u.R807.expr = expr;
1697 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
1699 ++ffestd_block_level_;
1700 assert (ffestd_block_level_ > 0);
1703 /* ffestd_R809 -- SELECT CASE statement
1705 ffestd_R809(construct_name,expr,expr_token);
1707 Make sure statement is valid here; implement. */
1709 void
1710 ffestd_R809 (ffelexToken construct_name UNUSED, ffebld expr)
1712 ffestdStmt_ stmt;
1714 ffestd_check_simple_ ();
1716 stmt = ffestd_stmt_new_ (FFESTD_stmtidR809_);
1717 ffestd_stmt_append_ (stmt);
1718 ffestd_subr_line_save_ (stmt);
1719 stmt->u.R809.pool = ffesta_output_pool;
1720 stmt->u.R809.block = ffestw_use (ffestw_stack_top ());
1721 stmt->u.R809.expr = expr;
1722 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
1723 malloc_pool_use (ffestw_select (ffestw_stack_top ())->pool);
1725 ++ffestd_block_level_;
1726 assert (ffestd_block_level_ > 0);
1729 /* ffestd_R810 -- CASE statement
1731 ffestd_R810(case_value_range_list,name);
1733 If casenum is 0, it's CASE DEFAULT. Else it's the case ranges at
1734 the start of the first_stmt list in the select object at the top of
1735 the stack that match casenum. */
1737 void
1738 ffestd_R810 (unsigned long casenum)
1740 ffestdStmt_ stmt;
1742 ffestd_check_simple_ ();
1744 stmt = ffestd_stmt_new_ (FFESTD_stmtidR810_);
1745 ffestd_stmt_append_ (stmt);
1746 ffestd_subr_line_save_ (stmt);
1747 stmt->u.R810.pool = ffesta_output_pool;
1748 stmt->u.R810.block = ffestw_stack_top ();
1749 stmt->u.R810.casenum = casenum;
1750 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
1753 /* ffestd_R811 -- End a SELECT
1755 ffestd_R811(TRUE); */
1757 void
1758 ffestd_R811 (bool ok UNUSED)
1760 ffestdStmt_ stmt;
1762 stmt = ffestd_stmt_new_ (FFESTD_stmtidR811_);
1763 ffestd_stmt_append_ (stmt);
1764 ffestd_subr_line_save_ (stmt);
1765 stmt->u.R811.block = ffestw_stack_top ();
1767 --ffestd_block_level_;
1768 assert (ffestd_block_level_ >= 0);
1771 /* ffestd_R819A -- Iterative DO statement
1773 ffestd_R819A(construct_name,label_token,expr,expr_token);
1775 Make sure statement is valid here; implement. */
1777 void
1778 ffestd_R819A (ffelexToken construct_name UNUSED, ffelab label,
1779 ffebld var, ffebld start, ffelexToken start_token,
1780 ffebld end, ffelexToken end_token,
1781 ffebld incr, ffelexToken incr_token)
1783 ffestdStmt_ stmt;
1785 ffestd_check_simple_ ();
1787 stmt = ffestd_stmt_new_ (FFESTD_stmtidR819A_);
1788 ffestd_stmt_append_ (stmt);
1789 ffestd_subr_line_save_ (stmt);
1790 stmt->u.R819A.pool = ffesta_output_pool;
1791 stmt->u.R819A.block = ffestw_use (ffestw_stack_top ());
1792 stmt->u.R819A.label = label;
1793 stmt->u.R819A.var = var;
1794 stmt->u.R819A.start = start;
1795 stmt->u.R819A.start_token = ffelex_token_use (start_token);
1796 stmt->u.R819A.end = end;
1797 stmt->u.R819A.end_token = ffelex_token_use (end_token);
1798 stmt->u.R819A.incr = incr;
1799 stmt->u.R819A.incr_token = (incr_token == NULL) ? NULL
1800 : ffelex_token_use (incr_token);
1801 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
1803 ++ffestd_block_level_;
1804 assert (ffestd_block_level_ > 0);
1807 /* ffestd_R819B -- DO WHILE statement
1809 ffestd_R819B(construct_name,label_token,expr,expr_token);
1811 Make sure statement is valid here; implement. */
1813 void
1814 ffestd_R819B (ffelexToken construct_name UNUSED, ffelab label,
1815 ffebld expr)
1817 ffestdStmt_ stmt;
1819 ffestd_check_simple_ ();
1821 stmt = ffestd_stmt_new_ (FFESTD_stmtidR819B_);
1822 ffestd_stmt_append_ (stmt);
1823 ffestd_subr_line_save_ (stmt);
1824 stmt->u.R819B.pool = ffesta_output_pool;
1825 stmt->u.R819B.block = ffestw_use (ffestw_stack_top ());
1826 stmt->u.R819B.label = label;
1827 stmt->u.R819B.expr = expr;
1828 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
1830 ++ffestd_block_level_;
1831 assert (ffestd_block_level_ > 0);
1834 /* ffestd_R825 -- END DO statement
1836 ffestd_R825(name_token);
1838 Make sure ffestd_kind_ identifies a DO block. If not
1839 NULL, make sure name_token gives the correct name. Do whatever
1840 is specific to seeing END DO with a DO-target label definition on it,
1841 where the END DO is really treated as a CONTINUE (i.e. generate th
1842 same code you would for CONTINUE). ffestd_do handles the actual
1843 generation of end-loop code. */
1845 void
1846 ffestd_R825 (ffelexToken name UNUSED)
1848 ffestdStmt_ stmt;
1850 ffestd_check_simple_ ();
1852 stmt = ffestd_stmt_new_ (FFESTD_stmtidR825_);
1853 ffestd_stmt_append_ (stmt);
1854 ffestd_subr_line_save_ (stmt);
1857 /* ffestd_R834 -- CYCLE statement
1859 ffestd_R834(name_token);
1861 Handle a CYCLE within a loop. */
1863 void
1864 ffestd_R834 (ffestw block)
1866 ffestdStmt_ stmt;
1868 ffestd_check_simple_ ();
1870 stmt = ffestd_stmt_new_ (FFESTD_stmtidR834_);
1871 ffestd_stmt_append_ (stmt);
1872 ffestd_subr_line_save_ (stmt);
1873 stmt->u.R834.block = block;
1876 /* ffestd_R835 -- EXIT statement
1878 ffestd_R835(name_token);
1880 Handle a EXIT within a loop. */
1882 void
1883 ffestd_R835 (ffestw block)
1885 ffestdStmt_ stmt;
1887 ffestd_check_simple_ ();
1889 stmt = ffestd_stmt_new_ (FFESTD_stmtidR835_);
1890 ffestd_stmt_append_ (stmt);
1891 ffestd_subr_line_save_ (stmt);
1892 stmt->u.R835.block = block;
1895 /* ffestd_R836 -- GOTO statement
1897 ffestd_R836(label);
1899 Make sure label_token identifies a valid label for a GOTO. Update
1900 that label's info to indicate it is the target of a GOTO. */
1902 void
1903 ffestd_R836 (ffelab label)
1905 ffestdStmt_ stmt;
1907 ffestd_check_simple_ ();
1909 stmt = ffestd_stmt_new_ (FFESTD_stmtidR836_);
1910 ffestd_stmt_append_ (stmt);
1911 ffestd_subr_line_save_ (stmt);
1912 stmt->u.R836.label = label;
1914 if (ffestd_block_level_ == 0)
1915 ffestd_is_reachable_ = FALSE;
1918 /* ffestd_R837 -- Computed GOTO statement
1920 ffestd_R837(labels,expr);
1922 Make sure label_list identifies valid labels for a GOTO. Update
1923 each label's info to indicate it is the target of a GOTO. */
1925 void
1926 ffestd_R837 (ffelab *labels, int count, ffebld expr)
1928 ffestdStmt_ stmt;
1930 ffestd_check_simple_ ();
1932 stmt = ffestd_stmt_new_ (FFESTD_stmtidR837_);
1933 ffestd_stmt_append_ (stmt);
1934 ffestd_subr_line_save_ (stmt);
1935 stmt->u.R837.pool = ffesta_output_pool;
1936 stmt->u.R837.labels = labels;
1937 stmt->u.R837.count = count;
1938 stmt->u.R837.expr = expr;
1939 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
1942 /* ffestd_R838 -- ASSIGN statement
1944 ffestd_R838(label_token,target_variable,target_token);
1946 Make sure label_token identifies a valid label for an assignment. Update
1947 that label's info to indicate it is the source of an assignment. Update
1948 target_variable's info to indicate it is the target the assignment of that
1949 label. */
1951 void
1952 ffestd_R838 (ffelab label, ffebld target)
1954 ffestdStmt_ stmt;
1956 ffestd_check_simple_ ();
1958 stmt = ffestd_stmt_new_ (FFESTD_stmtidR838_);
1959 ffestd_stmt_append_ (stmt);
1960 ffestd_subr_line_save_ (stmt);
1961 stmt->u.R838.pool = ffesta_output_pool;
1962 stmt->u.R838.label = label;
1963 stmt->u.R838.target = target;
1964 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
1967 /* ffestd_R839 -- Assigned GOTO statement
1969 ffestd_R839(target,labels);
1971 Make sure label_list identifies valid labels for a GOTO. Update
1972 each label's info to indicate it is the target of a GOTO. */
1974 void
1975 ffestd_R839 (ffebld target, ffelab *labels UNUSED, int count UNUSED)
1977 ffestdStmt_ stmt;
1979 ffestd_check_simple_ ();
1981 stmt = ffestd_stmt_new_ (FFESTD_stmtidR839_);
1982 ffestd_stmt_append_ (stmt);
1983 ffestd_subr_line_save_ (stmt);
1984 stmt->u.R839.pool = ffesta_output_pool;
1985 stmt->u.R839.target = target;
1986 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
1988 if (ffestd_block_level_ == 0)
1989 ffestd_is_reachable_ = FALSE;
1992 /* ffestd_R840 -- Arithmetic IF statement
1994 ffestd_R840(expr,expr_token,neg,zero,pos);
1996 Make sure the labels are valid; implement. */
1998 void
1999 ffestd_R840 (ffebld expr, ffelab neg, ffelab zero, ffelab pos)
2001 ffestdStmt_ stmt;
2003 ffestd_check_simple_ ();
2005 stmt = ffestd_stmt_new_ (FFESTD_stmtidR840_);
2006 ffestd_stmt_append_ (stmt);
2007 ffestd_subr_line_save_ (stmt);
2008 stmt->u.R840.pool = ffesta_output_pool;
2009 stmt->u.R840.expr = expr;
2010 stmt->u.R840.neg = neg;
2011 stmt->u.R840.zero = zero;
2012 stmt->u.R840.pos = pos;
2013 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2015 if (ffestd_block_level_ == 0)
2016 ffestd_is_reachable_ = FALSE;
2019 /* ffestd_R841 -- CONTINUE statement
2021 ffestd_R841(); */
2023 void
2024 ffestd_R841 (bool in_where UNUSED)
2026 ffestdStmt_ stmt;
2028 ffestd_check_simple_ ();
2030 stmt = ffestd_stmt_new_ (FFESTD_stmtidR841_);
2031 ffestd_stmt_append_ (stmt);
2032 ffestd_subr_line_save_ (stmt);
2035 /* ffestd_R842 -- STOP statement
2037 ffestd_R842(expr); */
2039 void
2040 ffestd_R842 (ffebld expr)
2042 ffestdStmt_ stmt;
2044 ffestd_check_simple_ ();
2046 stmt = ffestd_stmt_new_ (FFESTD_stmtidR842_);
2047 ffestd_stmt_append_ (stmt);
2048 ffestd_subr_line_save_ (stmt);
2049 if (ffesta_outpooldisp () == FFESTA_pooldispPRESERVE)
2051 /* This is a "spurious" (automatically-generated) STOP
2052 that follows a previous STOP or other statement.
2053 Make sure we don't have an expression in the pool,
2054 and then mark that the pool has already been killed. */
2055 assert (expr == NULL);
2056 stmt->u.R842.pool = NULL;
2057 stmt->u.R842.expr = NULL;
2059 else
2061 stmt->u.R842.pool = ffesta_output_pool;
2062 stmt->u.R842.expr = expr;
2063 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2066 if (ffestd_block_level_ == 0)
2067 ffestd_is_reachable_ = FALSE;
2070 /* ffestd_R843 -- PAUSE statement
2072 ffestd_R843(expr,expr_token);
2074 Make sure statement is valid here; implement. expr and expr_token are
2075 both NULL if there was no expression. */
2077 void
2078 ffestd_R843 (ffebld expr)
2080 ffestdStmt_ stmt;
2082 ffestd_check_simple_ ();
2084 stmt = ffestd_stmt_new_ (FFESTD_stmtidR843_);
2085 ffestd_stmt_append_ (stmt);
2086 ffestd_subr_line_save_ (stmt);
2087 stmt->u.R843.pool = ffesta_output_pool;
2088 stmt->u.R843.expr = expr;
2089 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2092 /* ffestd_R904 -- OPEN statement
2094 ffestd_R904();
2096 Make sure an OPEN is valid in the current context, and implement it. */
2098 void
2099 ffestd_R904 ()
2101 ffestdStmt_ stmt;
2103 ffestd_check_simple_ ();
2105 #define specified(something) \
2106 (ffestp_file.open.open_spec[something].kw_or_val_present)
2108 /* Warn if there are any thing we don't handle via f2c libraries. */
2110 if (specified (FFESTP_openixACTION)
2111 || specified (FFESTP_openixASSOCIATEVARIABLE)
2112 || specified (FFESTP_openixBLOCKSIZE)
2113 || specified (FFESTP_openixBUFFERCOUNT)
2114 || specified (FFESTP_openixCARRIAGECONTROL)
2115 || specified (FFESTP_openixDEFAULTFILE)
2116 || specified (FFESTP_openixDELIM)
2117 || specified (FFESTP_openixDISPOSE)
2118 || specified (FFESTP_openixEXTENDSIZE)
2119 || specified (FFESTP_openixINITIALSIZE)
2120 || specified (FFESTP_openixKEY)
2121 || specified (FFESTP_openixMAXREC)
2122 || specified (FFESTP_openixNOSPANBLOCKS)
2123 || specified (FFESTP_openixORGANIZATION)
2124 || specified (FFESTP_openixPAD)
2125 || specified (FFESTP_openixPOSITION)
2126 || specified (FFESTP_openixREADONLY)
2127 || specified (FFESTP_openixRECORDTYPE)
2128 || specified (FFESTP_openixSHARED)
2129 || specified (FFESTP_openixUSEROPEN))
2131 ffebad_start (FFEBAD_OPEN_UNSUPPORTED);
2132 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
2133 ffelex_token_where_column (ffesta_tokens[0]));
2134 ffebad_finish ();
2137 #undef specified
2139 stmt = ffestd_stmt_new_ (FFESTD_stmtidR904_);
2140 ffestd_stmt_append_ (stmt);
2141 ffestd_subr_line_save_ (stmt);
2142 stmt->u.R904.pool = ffesta_output_pool;
2143 stmt->u.R904.params = ffestd_subr_copy_open_ ();
2144 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2147 /* ffestd_R907 -- CLOSE statement
2149 ffestd_R907();
2151 Make sure a CLOSE is valid in the current context, and implement it. */
2153 void
2154 ffestd_R907 ()
2156 ffestdStmt_ stmt;
2158 ffestd_check_simple_ ();
2160 stmt = ffestd_stmt_new_ (FFESTD_stmtidR907_);
2161 ffestd_stmt_append_ (stmt);
2162 ffestd_subr_line_save_ (stmt);
2163 stmt->u.R907.pool = ffesta_output_pool;
2164 stmt->u.R907.params = ffestd_subr_copy_close_ ();
2165 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2168 /* ffestd_R909_start -- READ(...) statement list begin
2170 ffestd_R909_start(FALSE);
2172 Verify that READ is valid here, and begin accepting items in the
2173 list. */
2175 void
2176 ffestd_R909_start (bool only_format, ffestvUnit unit,
2177 ffestvFormat format, bool rec, bool key)
2179 ffestdStmt_ stmt;
2181 ffestd_check_start_ ();
2183 #define specified(something) \
2184 (ffestp_file.read.read_spec[something].kw_or_val_present)
2186 /* Warn if there are any thing we don't handle via f2c libraries. */
2187 if (specified (FFESTP_readixADVANCE)
2188 || specified (FFESTP_readixEOR)
2189 || specified (FFESTP_readixKEYEQ)
2190 || specified (FFESTP_readixKEYGE)
2191 || specified (FFESTP_readixKEYGT)
2192 || specified (FFESTP_readixKEYID)
2193 || specified (FFESTP_readixNULLS)
2194 || specified (FFESTP_readixSIZE))
2196 ffebad_start (FFEBAD_READ_UNSUPPORTED);
2197 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
2198 ffelex_token_where_column (ffesta_tokens[0]));
2199 ffebad_finish ();
2202 #undef specified
2204 stmt = ffestd_stmt_new_ (FFESTD_stmtidR909_);
2205 ffestd_stmt_append_ (stmt);
2206 ffestd_subr_line_save_ (stmt);
2207 stmt->u.R909.pool = ffesta_output_pool;
2208 stmt->u.R909.params = ffestd_subr_copy_read_ ();
2209 stmt->u.R909.only_format = only_format;
2210 stmt->u.R909.unit = unit;
2211 stmt->u.R909.format = format;
2212 stmt->u.R909.rec = rec;
2213 stmt->u.R909.key = key;
2214 stmt->u.R909.list = NULL;
2215 ffestd_expr_list_ = &stmt->u.R909.list;
2216 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2219 /* ffestd_R909_item -- READ statement i/o item
2221 ffestd_R909_item(expr,expr_token);
2223 Implement output-list expression. */
2225 void
2226 ffestd_R909_item (ffebld expr, ffelexToken expr_token)
2228 ffestdExprItem_ item;
2230 ffestd_check_item_ ();
2232 item = (ffestdExprItem_) malloc_new_kp (ffesta_output_pool,
2233 "ffestdExprItem_", sizeof (*item));
2235 item->next = NULL;
2236 item->expr = expr;
2237 item->token = ffelex_token_use (expr_token);
2238 *ffestd_expr_list_ = item;
2239 ffestd_expr_list_ = &item->next;
2242 /* ffestd_R909_finish -- READ statement list complete
2244 ffestd_R909_finish();
2246 Just wrap up any local activities. */
2248 void
2249 ffestd_R909_finish ()
2251 ffestd_check_finish_ ();
2254 /* ffestd_R910_start -- WRITE(...) statement list begin
2256 ffestd_R910_start();
2258 Verify that WRITE is valid here, and begin accepting items in the
2259 list. */
2261 void
2262 ffestd_R910_start (ffestvUnit unit, ffestvFormat format, bool rec)
2264 ffestdStmt_ stmt;
2266 ffestd_check_start_ ();
2268 #define specified(something) \
2269 (ffestp_file.write.write_spec[something].kw_or_val_present)
2271 /* Warn if there are any thing we don't handle via f2c libraries. */
2272 if (specified (FFESTP_writeixADVANCE)
2273 || specified (FFESTP_writeixEOR))
2275 ffebad_start (FFEBAD_WRITE_UNSUPPORTED);
2276 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
2277 ffelex_token_where_column (ffesta_tokens[0]));
2278 ffebad_finish ();
2281 #undef specified
2283 stmt = ffestd_stmt_new_ (FFESTD_stmtidR910_);
2284 ffestd_stmt_append_ (stmt);
2285 ffestd_subr_line_save_ (stmt);
2286 stmt->u.R910.pool = ffesta_output_pool;
2287 stmt->u.R910.params = ffestd_subr_copy_write_ ();
2288 stmt->u.R910.unit = unit;
2289 stmt->u.R910.format = format;
2290 stmt->u.R910.rec = rec;
2291 stmt->u.R910.list = NULL;
2292 ffestd_expr_list_ = &stmt->u.R910.list;
2293 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2296 /* ffestd_R910_item -- WRITE statement i/o item
2298 ffestd_R910_item(expr,expr_token);
2300 Implement output-list expression. */
2302 void
2303 ffestd_R910_item (ffebld expr, ffelexToken expr_token)
2305 ffestdExprItem_ item;
2307 ffestd_check_item_ ();
2309 item = (ffestdExprItem_) malloc_new_kp (ffesta_output_pool,
2310 "ffestdExprItem_", sizeof (*item));
2312 item->next = NULL;
2313 item->expr = expr;
2314 item->token = ffelex_token_use (expr_token);
2315 *ffestd_expr_list_ = item;
2316 ffestd_expr_list_ = &item->next;
2319 /* ffestd_R910_finish -- WRITE statement list complete
2321 ffestd_R910_finish();
2323 Just wrap up any local activities. */
2325 void
2326 ffestd_R910_finish ()
2328 ffestd_check_finish_ ();
2331 /* ffestd_R911_start -- PRINT statement list begin
2333 ffestd_R911_start();
2335 Verify that PRINT is valid here, and begin accepting items in the
2336 list. */
2338 void
2339 ffestd_R911_start (ffestvFormat format)
2341 ffestdStmt_ stmt;
2343 ffestd_check_start_ ();
2345 stmt = ffestd_stmt_new_ (FFESTD_stmtidR911_);
2346 ffestd_stmt_append_ (stmt);
2347 ffestd_subr_line_save_ (stmt);
2348 stmt->u.R911.pool = ffesta_output_pool;
2349 stmt->u.R911.params = ffestd_subr_copy_print_ ();
2350 stmt->u.R911.format = format;
2351 stmt->u.R911.list = NULL;
2352 ffestd_expr_list_ = &stmt->u.R911.list;
2353 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2356 /* ffestd_R911_item -- PRINT statement i/o item
2358 ffestd_R911_item(expr,expr_token);
2360 Implement output-list expression. */
2362 void
2363 ffestd_R911_item (ffebld expr, ffelexToken expr_token)
2365 ffestdExprItem_ item;
2367 ffestd_check_item_ ();
2369 item = (ffestdExprItem_) malloc_new_kp (ffesta_output_pool,
2370 "ffestdExprItem_", sizeof (*item));
2372 item->next = NULL;
2373 item->expr = expr;
2374 item->token = ffelex_token_use (expr_token);
2375 *ffestd_expr_list_ = item;
2376 ffestd_expr_list_ = &item->next;
2379 /* ffestd_R911_finish -- PRINT statement list complete
2381 ffestd_R911_finish();
2383 Just wrap up any local activities. */
2385 void
2386 ffestd_R911_finish ()
2388 ffestd_check_finish_ ();
2391 /* ffestd_R919 -- BACKSPACE statement
2393 ffestd_R919();
2395 Make sure a BACKSPACE is valid in the current context, and implement it. */
2397 void
2398 ffestd_R919 ()
2400 ffestdStmt_ stmt;
2402 ffestd_check_simple_ ();
2404 stmt = ffestd_stmt_new_ (FFESTD_stmtidR919_);
2405 ffestd_stmt_append_ (stmt);
2406 ffestd_subr_line_save_ (stmt);
2407 stmt->u.R919.pool = ffesta_output_pool;
2408 stmt->u.R919.params = ffestd_subr_copy_beru_ ();
2409 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2412 /* ffestd_R920 -- ENDFILE statement
2414 ffestd_R920();
2416 Make sure a ENDFILE is valid in the current context, and implement it. */
2418 void
2419 ffestd_R920 ()
2421 ffestdStmt_ stmt;
2423 ffestd_check_simple_ ();
2425 stmt = ffestd_stmt_new_ (FFESTD_stmtidR920_);
2426 ffestd_stmt_append_ (stmt);
2427 ffestd_subr_line_save_ (stmt);
2428 stmt->u.R920.pool = ffesta_output_pool;
2429 stmt->u.R920.params = ffestd_subr_copy_beru_ ();
2430 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2433 /* ffestd_R921 -- REWIND statement
2435 ffestd_R921();
2437 Make sure a REWIND is valid in the current context, and implement it. */
2439 void
2440 ffestd_R921 ()
2442 ffestdStmt_ stmt;
2444 ffestd_check_simple_ ();
2446 stmt = ffestd_stmt_new_ (FFESTD_stmtidR921_);
2447 ffestd_stmt_append_ (stmt);
2448 ffestd_subr_line_save_ (stmt);
2449 stmt->u.R921.pool = ffesta_output_pool;
2450 stmt->u.R921.params = ffestd_subr_copy_beru_ ();
2451 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2454 /* ffestd_R923A -- INQUIRE statement (non-IOLENGTH version)
2456 ffestd_R923A(bool by_file);
2458 Make sure an INQUIRE is valid in the current context, and implement it. */
2460 void
2461 ffestd_R923A (bool by_file)
2463 ffestdStmt_ stmt;
2465 ffestd_check_simple_ ();
2467 #define specified(something) \
2468 (ffestp_file.inquire.inquire_spec[something].kw_or_val_present)
2470 /* Warn if there are any thing we don't handle via f2c libraries. */
2471 if (specified (FFESTP_inquireixACTION)
2472 || specified (FFESTP_inquireixCARRIAGECONTROL)
2473 || specified (FFESTP_inquireixDEFAULTFILE)
2474 || specified (FFESTP_inquireixDELIM)
2475 || specified (FFESTP_inquireixKEYED)
2476 || specified (FFESTP_inquireixORGANIZATION)
2477 || specified (FFESTP_inquireixPAD)
2478 || specified (FFESTP_inquireixPOSITION)
2479 || specified (FFESTP_inquireixREAD)
2480 || specified (FFESTP_inquireixREADWRITE)
2481 || specified (FFESTP_inquireixRECORDTYPE)
2482 || specified (FFESTP_inquireixWRITE))
2484 ffebad_start (FFEBAD_INQUIRE_UNSUPPORTED);
2485 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
2486 ffelex_token_where_column (ffesta_tokens[0]));
2487 ffebad_finish ();
2490 #undef specified
2492 stmt = ffestd_stmt_new_ (FFESTD_stmtidR923A_);
2493 ffestd_stmt_append_ (stmt);
2494 ffestd_subr_line_save_ (stmt);
2495 stmt->u.R923A.pool = ffesta_output_pool;
2496 stmt->u.R923A.params = ffestd_subr_copy_inquire_ ();
2497 stmt->u.R923A.by_file = by_file;
2498 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2501 /* ffestd_R923B_start -- INQUIRE(IOLENGTH=expr) statement list begin
2503 ffestd_R923B_start();
2505 Verify that INQUIRE is valid here, and begin accepting items in the
2506 list. */
2508 void
2509 ffestd_R923B_start ()
2511 ffestdStmt_ stmt;
2513 ffestd_check_start_ ();
2515 stmt = ffestd_stmt_new_ (FFESTD_stmtidR923B_);
2516 ffestd_stmt_append_ (stmt);
2517 ffestd_subr_line_save_ (stmt);
2518 stmt->u.R923B.pool = ffesta_output_pool;
2519 stmt->u.R923B.params = ffestd_subr_copy_inquire_ ();
2520 stmt->u.R923B.list = NULL;
2521 ffestd_expr_list_ = &stmt->u.R923B.list;
2522 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
2525 /* ffestd_R923B_item -- INQUIRE statement i/o item
2527 ffestd_R923B_item(expr,expr_token);
2529 Implement output-list expression. */
2531 void
2532 ffestd_R923B_item (ffebld expr)
2534 ffestdExprItem_ item;
2536 ffestd_check_item_ ();
2538 item = (ffestdExprItem_) malloc_new_kp (ffesta_output_pool,
2539 "ffestdExprItem_", sizeof (*item));
2541 item->next = NULL;
2542 item->expr = expr;
2543 *ffestd_expr_list_ = item;
2544 ffestd_expr_list_ = &item->next;
2547 /* ffestd_R923B_finish -- INQUIRE statement list complete
2549 ffestd_R923B_finish();
2551 Just wrap up any local activities. */
2553 void
2554 ffestd_R923B_finish ()
2556 ffestd_check_finish_ ();
2559 /* ffestd_R1001 -- FORMAT statement
2561 ffestd_R1001(format_list); */
2563 void
2564 ffestd_R1001 (ffesttFormatList f)
2566 ffestsHolder str;
2567 ffests s = &str;
2568 ffestdStmt_ stmt;
2570 ffestd_check_simple_ ();
2572 if (ffestd_label_formatdef_ == NULL)
2573 return; /* Nothing to hook it up to (no label def). */
2575 ffests_new (s, malloc_pool_image (), 80);
2576 ffests_putc (s, '(');
2577 ffestd_R1001dump_ (s, f); /* Build the string in s. */
2578 ffests_putc (s, ')');
2580 stmt = ffestd_stmt_new_ (FFESTD_stmtidR1001_);
2581 ffestd_stmt_append_ (stmt);
2582 stmt->u.R1001.str = str;
2584 ffestd_label_formatdef_ = NULL;
2587 /* ffestd_R1001dump_ -- Dump list of formats
2589 ffesttFormatList list;
2590 ffestd_R1001dump_(list,0);
2592 The formats in the list are dumped. */
2594 static void
2595 ffestd_R1001dump_ (ffests s, ffesttFormatList list)
2597 ffesttFormatList next;
2599 for (next = list->next; next != list; next = next->next)
2601 if (next != list->next)
2602 ffests_putc (s, ',');
2603 switch (next->type)
2605 case FFESTP_formattypeI:
2606 ffestd_R1001dump_1005_3_ (s, next, "I");
2607 break;
2609 case FFESTP_formattypeB:
2610 ffestd_R1001error_ (next);
2611 break;
2613 case FFESTP_formattypeO:
2614 ffestd_R1001dump_1005_3_ (s, next, "O");
2615 break;
2617 case FFESTP_formattypeZ:
2618 ffestd_R1001dump_1005_3_ (s, next, "Z");
2619 break;
2621 case FFESTP_formattypeF:
2622 ffestd_R1001dump_1005_4_ (s, next, "F");
2623 break;
2625 case FFESTP_formattypeE:
2626 ffestd_R1001dump_1005_5_ (s, next, "E");
2627 break;
2629 case FFESTP_formattypeEN:
2630 ffestd_R1001error_ (next);
2631 break;
2633 case FFESTP_formattypeG:
2634 ffestd_R1001dump_1005_5_ (s, next, "G");
2635 break;
2637 case FFESTP_formattypeL:
2638 ffestd_R1001dump_1005_2_ (s, next, "L");
2639 break;
2641 case FFESTP_formattypeA:
2642 ffestd_R1001dump_1005_1_ (s, next, "A");
2643 break;
2645 case FFESTP_formattypeD:
2646 ffestd_R1001dump_1005_4_ (s, next, "D");
2647 break;
2649 case FFESTP_formattypeQ:
2650 ffestd_R1001error_ (next);
2651 break;
2653 case FFESTP_formattypeDOLLAR:
2654 ffestd_R1001dump_1010_1_ (s, next, "$");
2655 break;
2657 case FFESTP_formattypeP:
2658 ffestd_R1001dump_1010_4_ (s, next, "P");
2659 break;
2661 case FFESTP_formattypeT:
2662 ffestd_R1001dump_1010_5_ (s, next, "T");
2663 break;
2665 case FFESTP_formattypeTL:
2666 ffestd_R1001dump_1010_5_ (s, next, "TL");
2667 break;
2669 case FFESTP_formattypeTR:
2670 ffestd_R1001dump_1010_5_ (s, next, "TR");
2671 break;
2673 case FFESTP_formattypeX:
2674 ffestd_R1001dump_1010_2_ (s, next, "X");
2675 break;
2677 case FFESTP_formattypeS:
2678 ffestd_R1001dump_1010_1_ (s, next, "S");
2679 break;
2681 case FFESTP_formattypeSP:
2682 ffestd_R1001dump_1010_1_ (s, next, "SP");
2683 break;
2685 case FFESTP_formattypeSS:
2686 ffestd_R1001dump_1010_1_ (s, next, "SS");
2687 break;
2689 case FFESTP_formattypeBN:
2690 ffestd_R1001dump_1010_1_ (s, next, "BN");
2691 break;
2693 case FFESTP_formattypeBZ:
2694 ffestd_R1001dump_1010_1_ (s, next, "BZ");
2695 break;
2697 case FFESTP_formattypeSLASH:
2698 ffestd_R1001dump_1010_2_ (s, next, "/");
2699 break;
2701 case FFESTP_formattypeCOLON:
2702 ffestd_R1001dump_1010_1_ (s, next, ":");
2703 break;
2705 case FFESTP_formattypeR1016:
2706 switch (ffelex_token_type (next->t))
2708 case FFELEX_typeCHARACTER:
2710 char *p = ffelex_token_text (next->t);
2711 ffeTokenLength i = ffelex_token_length (next->t);
2713 ffests_putc (s, '\002');
2714 while (i-- != 0)
2716 if (*p == '\002')
2717 ffests_putc (s, '\002');
2718 ffests_putc (s, *p);
2719 ++p;
2721 ffests_putc (s, '\002');
2723 break;
2725 case FFELEX_typeHOLLERITH:
2727 char *p = ffelex_token_text (next->t);
2728 ffeTokenLength i = ffelex_token_length (next->t);
2730 ffests_printf (s, "%" ffeTokenLength_f "uH", i);
2731 while (i-- != 0)
2733 ffests_putc (s, *p);
2734 ++p;
2737 break;
2739 default:
2740 assert (FALSE);
2742 break;
2744 case FFESTP_formattypeFORMAT:
2745 if (next->u.R1003D.R1004.present)
2747 if (next->u.R1003D.R1004.rtexpr)
2748 ffestd_R1001rtexpr_ (s, next, next->u.R1003D.R1004.u.expr);
2749 else
2750 ffests_printf (s, "%lu", next->u.R1003D.R1004.u.unsigned_val);
2753 ffests_putc (s, '(');
2754 ffestd_R1001dump_ (s, next->u.R1003D.format);
2755 ffests_putc (s, ')');
2756 break;
2758 default:
2759 assert (FALSE);
2764 /* ffestd_R1001dump_1005_1_ -- Dump a particular format
2766 ffesttFormatList f;
2767 ffestd_R1001dump_1005_1_(f,"I");
2769 The format is dumped with form [r]X[w]. */
2771 static void
2772 ffestd_R1001dump_1005_1_ (ffests s, ffesttFormatList f, const char *string)
2774 assert (!f->u.R1005.R1007_or_R1008.present);
2775 assert (!f->u.R1005.R1009.present);
2777 if (f->u.R1005.R1004.present)
2779 if (f->u.R1005.R1004.rtexpr)
2780 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1004.u.expr);
2781 else
2782 ffests_printf (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
2785 ffests_puts (s, string);
2787 if (f->u.R1005.R1006.present)
2789 if (f->u.R1005.R1006.rtexpr)
2790 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1006.u.expr);
2791 else
2792 ffests_printf (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
2796 /* ffestd_R1001dump_1005_2_ -- Dump a particular format
2798 ffesttFormatList f;
2799 ffestd_R1001dump_1005_2_(f,"I");
2801 The format is dumped with form [r]Xw. */
2803 static void
2804 ffestd_R1001dump_1005_2_ (ffests s, ffesttFormatList f, const char *string)
2806 assert (!f->u.R1005.R1007_or_R1008.present);
2807 assert (!f->u.R1005.R1009.present);
2808 assert (f->u.R1005.R1006.present);
2810 if (f->u.R1005.R1004.present)
2812 if (f->u.R1005.R1004.rtexpr)
2813 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1004.u.expr);
2814 else
2815 ffests_printf (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
2818 ffests_puts (s, string);
2820 if (f->u.R1005.R1006.rtexpr)
2821 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1006.u.expr);
2822 else
2823 ffests_printf (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
2826 /* ffestd_R1001dump_1005_3_ -- Dump a particular format
2828 ffesttFormatList f;
2829 ffestd_R1001dump_1005_3_(f,"I");
2831 The format is dumped with form [r]Xw[.m]. */
2833 static void
2834 ffestd_R1001dump_1005_3_ (ffests s, ffesttFormatList f, const char *string)
2836 assert (!f->u.R1005.R1009.present);
2837 assert (f->u.R1005.R1006.present);
2839 if (f->u.R1005.R1004.present)
2841 if (f->u.R1005.R1004.rtexpr)
2842 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1004.u.expr);
2843 else
2844 ffests_printf (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
2847 ffests_puts (s, string);
2849 if (f->u.R1005.R1006.rtexpr)
2850 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1006.u.expr);
2851 else
2852 ffests_printf (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
2854 if (f->u.R1005.R1007_or_R1008.present)
2856 ffests_putc (s, '.');
2857 if (f->u.R1005.R1007_or_R1008.rtexpr)
2858 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1007_or_R1008.u.expr);
2859 else
2860 ffests_printf (s, "%lu", f->u.R1005.R1007_or_R1008.u.unsigned_val);
2864 /* ffestd_R1001dump_1005_4_ -- Dump a particular format
2866 ffesttFormatList f;
2867 ffestd_R1001dump_1005_4_(f,"I");
2869 The format is dumped with form [r]Xw.d. */
2871 static void
2872 ffestd_R1001dump_1005_4_ (ffests s, ffesttFormatList f, const char *string)
2874 assert (!f->u.R1005.R1009.present);
2875 assert (f->u.R1005.R1007_or_R1008.present);
2876 assert (f->u.R1005.R1006.present);
2878 if (f->u.R1005.R1004.present)
2880 if (f->u.R1005.R1004.rtexpr)
2881 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1004.u.expr);
2882 else
2883 ffests_printf (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
2886 ffests_puts (s, string);
2888 if (f->u.R1005.R1006.rtexpr)
2889 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1006.u.expr);
2890 else
2891 ffests_printf (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
2893 ffests_putc (s, '.');
2894 if (f->u.R1005.R1007_or_R1008.rtexpr)
2895 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1007_or_R1008.u.expr);
2896 else
2897 ffests_printf (s, "%lu", f->u.R1005.R1007_or_R1008.u.unsigned_val);
2900 /* ffestd_R1001dump_1005_5_ -- Dump a particular format
2902 ffesttFormatList f;
2903 ffestd_R1001dump_1005_5_(f,"I");
2905 The format is dumped with form [r]Xw.d[Ee]. */
2907 static void
2908 ffestd_R1001dump_1005_5_ (ffests s, ffesttFormatList f, const char *string)
2910 assert (f->u.R1005.R1007_or_R1008.present);
2911 assert (f->u.R1005.R1006.present);
2913 if (f->u.R1005.R1004.present)
2915 if (f->u.R1005.R1004.rtexpr)
2916 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1004.u.expr);
2917 else
2918 ffests_printf (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
2921 ffests_puts (s, string);
2923 if (f->u.R1005.R1006.rtexpr)
2924 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1006.u.expr);
2925 else
2926 ffests_printf (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
2928 ffests_putc (s, '.');
2929 if (f->u.R1005.R1007_or_R1008.rtexpr)
2930 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1007_or_R1008.u.expr);
2931 else
2932 ffests_printf (s, "%lu", f->u.R1005.R1007_or_R1008.u.unsigned_val);
2934 if (f->u.R1005.R1009.present)
2936 ffests_putc (s, 'E');
2937 if (f->u.R1005.R1009.rtexpr)
2938 ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1009.u.expr);
2939 else
2940 ffests_printf (s, "%lu", f->u.R1005.R1009.u.unsigned_val);
2944 /* ffestd_R1001dump_1010_1_ -- Dump a particular format
2946 ffesttFormatList f;
2947 ffestd_R1001dump_1010_1_(f,"I");
2949 The format is dumped with form X. */
2951 static void
2952 ffestd_R1001dump_1010_1_ (ffests s, ffesttFormatList f, const char *string)
2954 assert (!f->u.R1010.val.present);
2956 ffests_puts (s, string);
2959 /* ffestd_R1001dump_1010_2_ -- Dump a particular format
2961 ffesttFormatList f;
2962 ffestd_R1001dump_1010_2_(f,"I");
2964 The format is dumped with form [r]X. */
2966 static void
2967 ffestd_R1001dump_1010_2_ (ffests s, ffesttFormatList f, const char *string)
2969 if (f->u.R1010.val.present)
2971 if (f->u.R1010.val.rtexpr)
2972 ffestd_R1001rtexpr_ (s, f, f->u.R1010.val.u.expr);
2973 else
2974 ffests_printf (s, "%lu", f->u.R1010.val.u.unsigned_val);
2977 ffests_puts (s, string);
2980 /* ffestd_R1001dump_1010_4_ -- Dump a particular format
2982 ffesttFormatList f;
2983 ffestd_R1001dump_1010_4_(f,"I");
2985 The format is dumped with form kX. Note that k is signed. */
2987 static void
2988 ffestd_R1001dump_1010_4_ (ffests s, ffesttFormatList f, const char *string)
2990 assert (f->u.R1010.val.present);
2992 if (f->u.R1010.val.rtexpr)
2993 ffestd_R1001rtexpr_ (s, f, f->u.R1010.val.u.expr);
2994 else
2995 ffests_printf (s, "%ld", f->u.R1010.val.u.signed_val);
2997 ffests_puts (s, string);
3000 /* ffestd_R1001dump_1010_5_ -- Dump a particular format
3002 ffesttFormatList f;
3003 ffestd_R1001dump_1010_5_(f,"I");
3005 The format is dumped with form Xn. */
3007 static void
3008 ffestd_R1001dump_1010_5_ (ffests s, ffesttFormatList f, const char *string)
3010 assert (f->u.R1010.val.present);
3012 ffests_puts (s, string);
3014 if (f->u.R1010.val.rtexpr)
3015 ffestd_R1001rtexpr_ (s, f, f->u.R1010.val.u.expr);
3016 else
3017 ffests_printf (s, "%lu", f->u.R1010.val.u.unsigned_val);
3020 /* ffestd_R1001error_ -- Complain about FORMAT specification not supported
3022 ffesttFormatList f;
3023 ffestd_R1001error_(f);
3025 An error message is produced. */
3027 static void
3028 ffestd_R1001error_ (ffesttFormatList f)
3030 ffebad_start (FFEBAD_FORMAT_UNSUPPORTED);
3031 ffebad_here (0, ffelex_token_where_line (f->t), ffelex_token_where_column (f->t));
3032 ffebad_finish ();
3035 static void
3036 ffestd_R1001rtexpr_ (ffests s, ffesttFormatList f, ffebld expr)
3038 if ((expr == NULL)
3039 || (ffebld_op (expr) != FFEBLD_opCONTER)
3040 || (ffeinfo_basictype (ffebld_info (expr)) != FFEINFO_basictypeINTEGER)
3041 || (ffeinfo_kindtype (ffebld_info (expr)) == FFEINFO_kindtypeINTEGER4))
3043 ffebad_start (FFEBAD_FORMAT_VARIABLE);
3044 ffebad_here (0, ffelex_token_where_line (f->t), ffelex_token_where_column (f->t));
3045 ffebad_finish ();
3047 else
3049 int val;
3051 switch (ffeinfo_kindtype (ffebld_info (expr)))
3053 #if FFETARGET_okINTEGER1
3054 case FFEINFO_kindtypeINTEGER1:
3055 val = ffebld_constant_integer1 (ffebld_conter (expr));
3056 break;
3057 #endif
3059 #if FFETARGET_okINTEGER2
3060 case FFEINFO_kindtypeINTEGER2:
3061 val = ffebld_constant_integer2 (ffebld_conter (expr));
3062 break;
3063 #endif
3065 #if FFETARGET_okINTEGER3
3066 case FFEINFO_kindtypeINTEGER3:
3067 val = ffebld_constant_integer3 (ffebld_conter (expr));
3068 break;
3069 #endif
3071 default:
3072 assert ("bad INTEGER constant kind type" == NULL);
3073 /* Fall through. */
3074 case FFEINFO_kindtypeANY:
3075 return;
3077 ffests_printf (s, "%ld", (long) val);
3081 /* ffestd_R1102 -- PROGRAM statement
3083 ffestd_R1102(name_token);
3085 Make sure ffestd_kind_ identifies an empty block. Make sure name_token
3086 gives a valid name. Implement the beginning of a main program. */
3088 void
3089 ffestd_R1102 (ffesymbol s, ffelexToken name UNUSED)
3091 ffestd_check_simple_ ();
3093 assert (ffestd_block_level_ == 0);
3094 ffestd_is_reachable_ = TRUE;
3096 ffecom_notify_primary_entry (s);
3097 ffe_set_is_mainprog (TRUE); /* Is a main program. */
3098 ffe_set_is_saveall (TRUE); /* Main program always has implicit SAVE. */
3100 ffestw_set_sym (ffestw_stack_top (), s);
3103 /* ffestd_R1103 -- End a PROGRAM
3105 ffestd_R1103(); */
3107 void
3108 ffestd_R1103 (bool ok UNUSED)
3110 ffestdStmt_ stmt;
3112 assert (ffestd_block_level_ == 0);
3114 if (FFESTD_IS_END_OPTIMIZED_ && ffestd_is_reachable_)
3115 ffestd_R842 (NULL); /* Generate STOP. */
3117 if (ffestw_state (ffestw_stack_top ()) != FFESTV_statePROGRAM5)
3118 ffestd_subr_labels_ (FALSE);/* Handle any undefined labels. */
3120 stmt = ffestd_stmt_new_ (FFESTD_stmtidR1103_);
3121 ffestd_stmt_append_ (stmt);
3124 /* ffestd_R1111 -- BLOCK DATA statement
3126 ffestd_R1111(name_token);
3128 Make sure ffestd_kind_ identifies no current program unit. If not
3129 NULL, make sure name_token gives a valid name. Implement the beginning
3130 of a block data program unit. */
3132 void
3133 ffestd_R1111 (ffesymbol s, ffelexToken name UNUSED)
3135 assert (ffestd_block_level_ == 0);
3136 ffestd_is_reachable_ = TRUE;
3138 ffestd_check_simple_ ();
3140 ffecom_notify_primary_entry (s);
3141 ffestw_set_sym (ffestw_stack_top (), s);
3144 /* ffestd_R1112 -- End a BLOCK DATA
3146 ffestd_R1112(TRUE); */
3148 void
3149 ffestd_R1112 (bool ok UNUSED)
3151 ffestdStmt_ stmt;
3153 assert (ffestd_block_level_ == 0);
3155 /* Generate any return-like code here (not likely for BLOCK DATA!). */
3157 if (ffestw_state (ffestw_stack_top ()) != FFESTV_stateBLOCKDATA5)
3158 ffestd_subr_labels_ (TRUE); /* Handle any undefined labels. */
3160 stmt = ffestd_stmt_new_ (FFESTD_stmtidR1112_);
3161 ffestd_stmt_append_ (stmt);
3164 /* ffestd_R1207_start -- EXTERNAL statement list begin
3166 ffestd_R1207_start();
3168 Verify that EXTERNAL is valid here, and begin accepting items in the list. */
3170 void
3171 ffestd_R1207_start ()
3173 ffestd_check_start_ ();
3176 /* ffestd_R1207_item -- EXTERNAL statement for name
3178 ffestd_R1207_item(name_token);
3180 Make sure name_token identifies a valid object to be EXTERNALd. */
3182 void
3183 ffestd_R1207_item (ffelexToken name)
3185 ffestd_check_item_ ();
3186 assert (name != NULL);
3189 /* ffestd_R1207_finish -- EXTERNAL statement list complete
3191 ffestd_R1207_finish();
3193 Just wrap up any local activities. */
3195 void
3196 ffestd_R1207_finish ()
3198 ffestd_check_finish_ ();
3201 /* ffestd_R1208_start -- INTRINSIC statement list begin
3203 ffestd_R1208_start();
3205 Verify that INTRINSIC is valid here, and begin accepting items in the list. */
3207 void
3208 ffestd_R1208_start ()
3210 ffestd_check_start_ ();
3213 /* ffestd_R1208_item -- INTRINSIC statement for name
3215 ffestd_R1208_item(name_token);
3217 Make sure name_token identifies a valid object to be INTRINSICd. */
3219 void
3220 ffestd_R1208_item (ffelexToken name)
3222 ffestd_check_item_ ();
3223 assert (name != NULL);
3226 /* ffestd_R1208_finish -- INTRINSIC statement list complete
3228 ffestd_R1208_finish();
3230 Just wrap up any local activities. */
3232 void
3233 ffestd_R1208_finish ()
3235 ffestd_check_finish_ ();
3238 /* ffestd_R1212 -- CALL statement
3240 ffestd_R1212(expr,expr_token);
3242 Make sure statement is valid here; implement. */
3244 void
3245 ffestd_R1212 (ffebld expr)
3247 ffestdStmt_ stmt;
3249 ffestd_check_simple_ ();
3251 stmt = ffestd_stmt_new_ (FFESTD_stmtidR1212_);
3252 ffestd_stmt_append_ (stmt);
3253 ffestd_subr_line_save_ (stmt);
3254 stmt->u.R1212.pool = ffesta_output_pool;
3255 stmt->u.R1212.expr = expr;
3256 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
3259 /* ffestd_R1219 -- FUNCTION statement
3261 ffestd_R1219(funcname,arglist,ending_token,kind,kindt,len,lent,
3262 recursive);
3264 Make sure statement is valid here, register arguments for the
3265 function name, and so on.
3267 06-Jun-90 JCB 2.0
3268 Added the kind, len, and recursive arguments. */
3270 void
3271 ffestd_R1219 (ffesymbol s, ffelexToken funcname UNUSED,
3272 ffesttTokenList args UNUSED, ffestpType type UNUSED,
3273 ffebld kind UNUSED, ffelexToken kindt UNUSED,
3274 ffebld len UNUSED, ffelexToken lent UNUSED,
3275 bool recursive UNUSED, ffelexToken result UNUSED,
3276 bool separate_result UNUSED)
3278 assert (ffestd_block_level_ == 0);
3279 ffestd_is_reachable_ = TRUE;
3281 ffestd_check_simple_ ();
3283 ffecom_notify_primary_entry (s);
3284 ffestw_set_sym (ffestw_stack_top (), s);
3287 /* ffestd_R1221 -- End a FUNCTION
3289 ffestd_R1221(TRUE); */
3291 void
3292 ffestd_R1221 (bool ok UNUSED)
3294 ffestdStmt_ stmt;
3296 assert (ffestd_block_level_ == 0);
3298 if (FFESTD_IS_END_OPTIMIZED_ && ffestd_is_reachable_)
3299 ffestd_R1227 (NULL); /* Generate RETURN. */
3301 if (ffestw_state (ffestw_stack_top ()) != FFESTV_stateFUNCTION5)
3302 ffestd_subr_labels_ (FALSE);/* Handle any undefined labels. */
3304 stmt = ffestd_stmt_new_ (FFESTD_stmtidR1221_);
3305 ffestd_stmt_append_ (stmt);
3308 /* ffestd_R1223 -- SUBROUTINE statement
3310 ffestd_R1223(subrname,arglist,ending_token,recursive_token);
3312 Make sure statement is valid here, register arguments for the
3313 subroutine name, and so on.
3315 06-Jun-90 JCB 2.0
3316 Added the recursive argument. */
3318 void
3319 ffestd_R1223 (ffesymbol s, ffelexToken subrname UNUSED,
3320 ffesttTokenList args UNUSED, ffelexToken final UNUSED,
3321 bool recursive UNUSED)
3323 assert (ffestd_block_level_ == 0);
3324 ffestd_is_reachable_ = TRUE;
3326 ffestd_check_simple_ ();
3328 ffecom_notify_primary_entry (s);
3329 ffestw_set_sym (ffestw_stack_top (), s);
3332 /* ffestd_R1225 -- End a SUBROUTINE
3334 ffestd_R1225(TRUE); */
3336 void
3337 ffestd_R1225 (bool ok UNUSED)
3339 ffestdStmt_ stmt;
3341 assert (ffestd_block_level_ == 0);
3343 if (FFESTD_IS_END_OPTIMIZED_ && ffestd_is_reachable_)
3344 ffestd_R1227 (NULL); /* Generate RETURN. */
3346 if (ffestw_state (ffestw_stack_top ()) != FFESTV_stateSUBROUTINE5)
3347 ffestd_subr_labels_ (FALSE);/* Handle any undefined labels. */
3349 stmt = ffestd_stmt_new_ (FFESTD_stmtidR1225_);
3350 ffestd_stmt_append_ (stmt);
3353 /* ffestd_R1226 -- ENTRY statement
3355 ffestd_R1226(entryname,arglist,ending_token);
3357 Make sure we're in a SUBROUTINE or FUNCTION, register arguments for the
3358 entry point name, and so on. */
3360 void
3361 ffestd_R1226 (ffesymbol entry)
3363 ffestd_check_simple_ ();
3365 if (!ffesta_seen_first_exec || ffecom_2pass_advise_entrypoint (entry))
3367 ffestdStmt_ stmt;
3369 stmt = ffestd_stmt_new_ (FFESTD_stmtidR1226_);
3370 ffestd_stmt_append_ (stmt);
3371 ffestd_subr_line_save_ (stmt);
3372 stmt->u.R1226.entry = entry;
3373 stmt->u.R1226.entrynum = ++ffestd_2pass_entrypoints_;
3376 ffestd_is_reachable_ = TRUE;
3379 /* ffestd_R1227 -- RETURN statement
3381 ffestd_R1227(expr);
3383 Make sure statement is valid here; implement. expr and expr_token are
3384 both NULL if there was no expression. */
3386 void
3387 ffestd_R1227 (ffebld expr)
3389 ffestdStmt_ stmt;
3391 ffestd_check_simple_ ();
3393 stmt = ffestd_stmt_new_ (FFESTD_stmtidR1227_);
3394 ffestd_stmt_append_ (stmt);
3395 ffestd_subr_line_save_ (stmt);
3396 stmt->u.R1227.pool = ffesta_output_pool;
3397 stmt->u.R1227.block = ffestw_stack_top ();
3398 stmt->u.R1227.expr = expr;
3399 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
3401 if (ffestd_block_level_ == 0)
3402 ffestd_is_reachable_ = FALSE;
3405 /* ffestd_R1229_start -- STMTFUNCTION statement begin
3407 ffestd_R1229_start(func_name,func_arg_list,close_paren);
3409 This function does not really need to do anything, since _finish_
3410 gets all the info needed, and ffestc_R1229_start has already
3411 done all the stuff that makes a two-phase operation (start and
3412 finish) for handling statement functions necessary.
3414 03-Jan-91 JCB 2.0
3415 Do nothing, now that _finish_ does everything. */
3417 void
3418 ffestd_R1229_start (ffelexToken name UNUSED, ffesttTokenList args UNUSED)
3420 ffestd_check_start_ ();
3423 /* ffestd_R1229_finish -- STMTFUNCTION statement list complete
3425 ffestd_R1229_finish(s);
3427 The statement function's symbol is passed. Its list of dummy args is
3428 accessed via ffesymbol_dummyargs and its expansion expression (expr)
3429 is accessed via ffesymbol_sfexpr.
3431 If sfexpr is NULL, an error occurred parsing the expansion expression, so
3432 just cancel the effects of ffestd_R1229_start and pretend nothing
3433 happened. Otherwise, install the expression as the expansion for the
3434 statement function, then clean up.
3436 03-Jan-91 JCB 2.0
3437 Takes sfunc sym instead of just the expansion expression as an
3438 argument, so this function can do all the work, and _start_ is just
3439 a nicety than can do nothing in a back end. */
3441 void
3442 ffestd_R1229_finish (ffesymbol s)
3444 ffebld expr = ffesymbol_sfexpr (s);
3446 ffestd_check_finish_ ();
3448 if (expr == NULL)
3449 return; /* Nothing to do, definition didn't work. */
3451 /* With gcc, cannot do anything here, because the backend hasn't even
3452 (necessarily) been notified that we're compiling a program unit! */
3453 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
3456 /* ffestd_S3P4 -- INCLUDE line
3458 ffestd_S3P4(filename,filename_token);
3460 Make sure INCLUDE not preceded by any semicolons or a label def; implement. */
3462 void
3463 ffestd_S3P4 (ffebld filename)
3465 FILE *fi;
3466 ffetargetCharacterDefault buildname;
3467 ffewhereFile wf;
3469 ffestd_check_simple_ ();
3471 assert (filename != NULL);
3472 if (ffebld_op (filename) != FFEBLD_opANY)
3474 assert (ffebld_op (filename) == FFEBLD_opCONTER);
3475 assert (ffeinfo_basictype (ffebld_info (filename))
3476 == FFEINFO_basictypeCHARACTER);
3477 assert (ffeinfo_kindtype (ffebld_info (filename))
3478 == FFEINFO_kindtypeCHARACTERDEFAULT);
3479 buildname = ffebld_constant_characterdefault (ffebld_conter (filename));
3480 wf = ffewhere_file_new (ffetarget_text_characterdefault (buildname),
3481 ffetarget_length_characterdefault (buildname));
3482 fi = ffecom_open_include (ffewhere_file_name (wf),
3483 ffelex_token_where_line (ffesta_tokens[0]),
3484 ffelex_token_where_column (ffesta_tokens[0]));
3485 if (fi != NULL)
3486 ffelex_set_include (wf, (ffelex_token_type (ffesta_tokens[0])
3487 == FFELEX_typeNAME), fi);
3491 /* ffestd_V014_start -- VOLATILE statement list begin
3493 ffestd_V014_start();
3495 Verify that VOLATILE is valid here, and begin accepting items in the list. */
3497 void
3498 ffestd_V014_start ()
3500 ffestd_check_start_ ();
3503 /* ffestd_V014_item_object -- VOLATILE statement for object-name
3505 ffestd_V014_item_object(name_token);
3507 Make sure name_token identifies a valid object to be VOLATILEd. */
3509 void
3510 ffestd_V014_item_object (ffelexToken name UNUSED)
3512 ffestd_check_item_ ();
3515 /* ffestd_V014_item_cblock -- VOLATILE statement for common-block-name
3517 ffestd_V014_item_cblock(name_token);
3519 Make sure name_token identifies a valid common block to be VOLATILEd. */
3521 void
3522 ffestd_V014_item_cblock (ffelexToken name UNUSED)
3524 ffestd_check_item_ ();
3527 /* ffestd_V014_finish -- VOLATILE statement list complete
3529 ffestd_V014_finish();
3531 Just wrap up any local activities. */
3533 void
3534 ffestd_V014_finish ()
3536 ffestd_check_finish_ ();
3539 /* ffestd_V020_start -- TYPE statement list begin
3541 ffestd_V020_start();
3543 Verify that TYPE is valid here, and begin accepting items in the
3544 list. */
3546 void
3547 ffestd_V020_start (ffestvFormat format UNUSED)
3549 ffestd_check_start_ ();
3550 ffestd_subr_vxt_ ();
3553 /* ffestd_V020_item -- TYPE statement i/o item
3555 ffestd_V020_item(expr,expr_token);
3557 Implement output-list expression. */
3559 void
3560 ffestd_V020_item (ffebld expr UNUSED)
3562 ffestd_check_item_ ();
3565 /* ffestd_V020_finish -- TYPE statement list complete
3567 ffestd_V020_finish();
3569 Just wrap up any local activities. */
3571 void
3572 ffestd_V020_finish ()
3574 ffestd_check_finish_ ();
3577 /* ffestd_V027_start -- VXT PARAMETER statement list begin
3579 ffestd_V027_start();
3581 Verify that PARAMETER is valid here, and begin accepting items in the list. */
3583 void
3584 ffestd_V027_start ()
3586 ffestd_check_start_ ();
3587 ffestd_subr_vxt_ ();
3590 /* ffestd_V027_item -- VXT PARAMETER statement assignment
3592 ffestd_V027_item(dest,dest_token,source,source_token);
3594 Make sure the source is a valid source for the destination; make the
3595 assignment. */
3597 void
3598 ffestd_V027_item (ffelexToken dest_token UNUSED, ffebld source UNUSED)
3600 ffestd_check_item_ ();
3603 /* ffestd_V027_finish -- VXT PARAMETER statement list complete
3605 ffestd_V027_finish();
3607 Just wrap up any local activities. */
3609 void
3610 ffestd_V027_finish ()
3612 ffestd_check_finish_ ();
3615 /* Any executable statement. */
3617 void
3618 ffestd_any ()
3620 ffestdStmt_ stmt;
3622 ffestd_check_simple_ ();
3624 stmt = ffestd_stmt_new_ (FFESTD_stmtidR841_);
3625 ffestd_stmt_append_ (stmt);
3626 ffestd_subr_line_save_ (stmt);