checkin of 0.3.0
[pspp-builds.git] / src / do-ifP.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18    02111-1307, USA. */
19
20 #if !do_ifP_h
21 #define do_ifP_h 1
22
23 #include "var.h"
24
25 /* BREAK transformation. */
26 struct break_trns
27   {
28     struct trns_header h;
29
30     struct break_trns *next;    /* Next in chain of BREAKs associated
31                                    with a single LOOP. */
32     int loop_term;              /* t_trns[] index to jump to; backpatched
33                                    in by END LOOP. */
34   };
35
36 /* Types of control structures. */
37 enum
38   {
39     CST_LOOP,
40     CST_DO_IF
41   };
42
43 /* Control structure info. */
44 struct ctl_stmt
45   {
46     int type;                   /* One of CST_*. */
47     struct ctl_stmt *down;      /* Points toward the bottom of ctl_stack. */
48     struct trns_header *trns;   /* Associated transformation. */
49     struct break_trns *brk;     /* (LOOP only): Chain of associated BREAKs. */
50   };                            /* ctl_stmt */
51
52 /* Goto transformation. */
53 struct goto_trns
54   {
55     struct trns_header h;
56
57     int dest;                   /* t_trns[] index of destination of jump. */
58   };
59
60 /* DO IF/ELSE IF/ELSE transformation. */
61 struct do_if_trns
62   {
63     struct trns_header h;
64
65     struct ctl_stmt ctl;        /* DO IF: Control information for nesting. */
66
67     /* Keeping track of clauses. */
68     struct do_if_trns *next;    /* Points toward next ELSE IF. */
69     struct goto_trns *brk;      /* ELSE IF: jumps out of DO IF structure. */
70     int has_else;               /* DO IF: 1=there's been an ELSE. */
71
72     /* Runtime info. */
73     struct expression *cond;    /* Condition. */
74     int false_jump;             /* t_trns[] index of destination when false. */
75     int missing_jump;           /* t_trns[] index to break out of DO IF. */
76   };
77
78 /* Top of the control structure stack. */
79 extern struct ctl_stmt *ctl_stack;
80
81 void discard_ctl_stack (void);
82
83 #endif /* !do_ifP_h */