1 |
/* |
2 |
* SWITCH List Routines |
3 |
* by Vicente Rico-Ramirez |
4 |
* Version: $Revision: 1.3 $ |
5 |
* Version control file: $RCSfile: switch.h,v $ |
6 |
* Date last modified: $Date: 1997/07/18 12:35:18 $ |
7 |
* Last modified by: $Author: mthomas $ |
8 |
* |
9 |
* This file is part of the Ascend Language Interpreter. |
10 |
* |
11 |
* Copyright (C) 1997 Carnegie Mellon University |
12 |
* |
13 |
* The Ascend Language Interpreter is free software; you can redistribute |
14 |
* it and/or modify it under the terms of the GNU General Public License as |
15 |
* published by the Free Software Foundation; either version 2 of the |
16 |
* License, or (at your option) any later version. |
17 |
* |
18 |
* The Ascend Language Interpreter is distributed in hope that it will be |
19 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
21 |
* General Public License for more details. |
22 |
* |
23 |
* You should have received a copy of the GNU General Public License along |
24 |
* with the program; if not, write to the Free Software Foundation, Inc., 675 |
25 |
* Mass Ave, Cambridge, MA 02139 USA. Check the file named COPYING. |
26 |
*/ |
27 |
|
28 |
/** @file |
29 |
* SWITCH List Routines. |
30 |
* <pre> |
31 |
* When #including switch.h, make sure these files are #included first: |
32 |
* #include "utilities/ascConfig.h" |
33 |
* #include "compiler.h" |
34 |
* #include "sets.h" |
35 |
* #include "exprs.h" |
36 |
* #include "bit.h" |
37 |
* #include "stattypes.h" |
38 |
* </pre> |
39 |
*/ |
40 |
|
41 |
#ifndef ASC_SWITCH_H |
42 |
#define ASC_SWITCH_H |
43 |
|
44 |
/** addtogroup compiler Compiler |
45 |
@{ |
46 |
*/ |
47 |
|
48 |
extern struct SwitchList *CreateSwitch(struct Set *set, struct StatementList *sl); |
49 |
/**< |
50 |
* <!-- struct SwitchList *CreateSwitch(set,sl) --> |
51 |
* <!-- struct Set *set; --> |
52 |
* <!-- struct StatementList *sl; --> |
53 |
* Create a Switch node. This will examine the set data structure which |
54 |
* must contain constant boolean expressions, symbols values or integer |
55 |
* values. If set = NULL, this indicates an OTHERWISE case. |
56 |
*/ |
57 |
|
58 |
extern struct SwitchList *ReverseSwitchCases(struct SwitchList *sw); |
59 |
/**< |
60 |
* <!-- struct SwitchList *ReverseSwitchCases(sw) --> |
61 |
* <!-- struct SwitchList *sw; --> |
62 |
* Reverse this list. |
63 |
*/ |
64 |
|
65 |
extern struct SwitchList *LinkSwitchCases(struct SwitchList *sw1, |
66 |
struct SwitchList *sw2); |
67 |
/**< |
68 |
* <!-- struct SwitchList *LinkSwitchCases(sw1,sw2) --> |
69 |
* <!-- struct SwitchList *sw1,*sw2; --> |
70 |
* Link two case lists and return the joined list. This works best when |
71 |
* sw1 is a one element list. |
72 |
*/ |
73 |
|
74 |
#ifdef NDEBUG |
75 |
#define NextSwitchCase(sw) ((sw)->next) |
76 |
#else |
77 |
#define NextSwitchCase(sw) NextSwitchCaseF(sw) |
78 |
#endif |
79 |
/**< |
80 |
* Return the next case. |
81 |
* @param sw struct SwitchList*, the list to query. |
82 |
* @return The next case as a struct SwitchList*. |
83 |
* @see NextSwitchCaseF() |
84 |
*/ |
85 |
extern struct SwitchList *NextSwitchCaseF(struct SwitchList *cs); |
86 |
/**< |
87 |
* <!-- macro NextSwitchCase(cs) --> |
88 |
* <!-- struct SwitchList *NextSwitchCaseF(cs) --> |
89 |
* <!-- struct SwitchList *cs; --> |
90 |
* <!-- Return the next case. --> |
91 |
* Implementation function for NextSwitchCase(). Do not call this |
92 |
* function directly - use NextSwitchCase() instead. |
93 |
*/ |
94 |
|
95 |
#ifdef NDEBUG |
96 |
#define SwitchSetList(sw) ((sw)->values) |
97 |
#else |
98 |
#define SwitchSetList(sw) SwitchSetListF(sw) |
99 |
#endif |
100 |
/**< |
101 |
* This will return the set list part of a SwitchList structure. When |
102 |
* the set is NULL, this indicates an OTHERWISE case. |
103 |
* @param sw struct SwitchList*, the list to query. |
104 |
* @return The list as a struct Set*. |
105 |
* @see SwitchSetListF() |
106 |
*/ |
107 |
extern struct Set *SwitchSetListF(struct SwitchList *sw); |
108 |
/**< |
109 |
* <!-- macro SwitchSetList(sw) --> |
110 |
* <!-- struct Set *SwitchSetListF(sw) --> |
111 |
* <!-- const struct SwitchList *sw; --> |
112 |
* <!-- This will return the set list part of a SwitchList structure. --> |
113 |
* <!-- When the set is NULL, this indicates an OTHERWISE case. --> |
114 |
* Implementation function for SwitchSetList(). Do not call this |
115 |
* function directly - use SwitchSetList() instead. |
116 |
*/ |
117 |
|
118 |
#ifdef NDEBUG |
119 |
#define SwitchStatementList(sw) ((sw)->slist) |
120 |
#else |
121 |
#define SwitchStatementList(sw) SwitchStatementListF(sw) |
122 |
#endif |
123 |
/**< |
124 |
* Return the statement list. |
125 |
* @param sw struct SwitchList*, the list to query. |
126 |
* @return The list as a struct StatementList*. |
127 |
* @see SwitchStatementListF() |
128 |
*/ |
129 |
extern struct StatementList *SwitchStatementListF(struct SwitchList *sw); |
130 |
/**< |
131 |
* <!-- macro SwitchStatementList(sw) --> |
132 |
* <!-- const struct StatementList *SwitchStatementListF(sw) --> |
133 |
* <!-- const struct SwitchList *sw; --> |
134 |
* <!-- Return the statement list. --> |
135 |
* Implementation function for SwitchStatementList(). Do not call this |
136 |
* function directly - use SwitchStatementList() instead. |
137 |
*/ |
138 |
|
139 |
extern void DestroySwitchList(struct SwitchList *sw); |
140 |
/**< |
141 |
* <!-- void DestroySwitchList(sw) --> |
142 |
* <!-- struct SwitchList *sw; --> |
143 |
* Destroy a whole list. |
144 |
*/ |
145 |
|
146 |
extern void DestroySwitchNode(struct SwitchList *sw); |
147 |
/**< |
148 |
* <!-- void DestroySwitchNode(sw) --> |
149 |
* <!-- struct SwitchList *sw; --> |
150 |
* Destroy just this node. |
151 |
*/ |
152 |
|
153 |
extern struct SwitchList *CopySwitchNode(struct SwitchList *sw); |
154 |
/**< |
155 |
* <!-- struct SwitchList *CopySwitchNode(sw) --> |
156 |
* <!-- struct SwitchList *sw; --> |
157 |
* Copy a case. The next attribute is initialized to NULL. |
158 |
*/ |
159 |
|
160 |
extern struct SwitchList *CopySwitchList(struct SwitchList *sw); |
161 |
/**< |
162 |
* <!-- struct SwitchList *CopySwitchList(sw) --> |
163 |
* <!-- struct SwitchList *sw; --> |
164 |
* Copy the whole list content. not a reference count change. |
165 |
*/ |
166 |
|
167 |
/* @} */ |
168 |
|
169 |
#endif /* ASC_SWITCH_H */ |
170 |
|