4 * (c)Copyright 1993-2014, Matthew Dillon, All Rights Reserved. See the
5 * COPYRIGHT file at the base of the distribution.
11 typedef runctx_p (*st_run_t)(runctx_p ct, struct Stmt *st);
12 typedef genctx_p (*st_gen_t)(genctx_p ct, struct Stmt *st);
15 * Compiler/Interpreter. The return value is designed to allow the
16 * interpreter to deal with break/continue, and even though we do not
17 * have exceptions we can theoretically use it to deal with those too.
19 typedef RUNE_HEAD(stmtlist, Stmt) stmtlist_t;
22 RUNE_ENTRY(Stmt) st_Node; /* node in list */
23 st_run_t st_Run; /* function vector for interpreter */
24 st_gen_t st_Gen; /* function vector for generator */
25 struct Stmt *st_Parent; /* parent statement */
26 int st_Op; /* ST_ code */
27 int st_Flags; /* flags */
28 int st_SaveOffset; /* when saving */
29 stmtlist_t st_List; /* base of list / parse tree */
31 LexRef st_LexRef; /* for error reporting */
34 struct Parse *es_Parser; /* possibly shared */
35 string_t es_AsId; /* NULL if self */
39 SemGroup *es_SemGroup; /* top-level SemGroup */
40 void *es_DLL; /* DLL */
45 /* es_Super is same as es_Decl->d_ClassDecl.ed.. */
51 * NOTE: declarations are stored in their SemGroup's
52 * linked list. The DeclStmt below points into a
53 * subset of this list.
56 Declaration *es_Decl; /* first declaration */
57 int es_DeclCount; /* number of decls */
59 int es_CallCount; /* heuristic */
60 runesize_t es_TmpOffset; /* type def init */
77 int es_Count; /* +N break, -N cont */
84 struct Stmt *es_TrueStmt;
85 struct Stmt *es_FalseStmt;
101 Exp *es_Exp; /* switch expression */
102 struct Stmt *es_Default; /* default statement or NULL */
106 genlabel_t *es_Label; /* (generator only) */
114 #define st_BlockStmt u.BlockStmt
115 #define st_ProcStmt u.DeclStmt
116 #define st_ImportStmt u.ImportStmt
117 #define st_ClassStmt u.ClassStmt
118 #define st_TypedefStmt u.TypedefStmt
119 #define st_DeclStmt u.DeclStmt
120 #define st_NopStmt u.NopStmt
121 #define st_ModuleStmt u.ModuleStmt
122 #define st_LoopStmt u.LoopStmt
123 #define st_BreakStmt u.BreakStmt
124 #define st_BadStmt u.BadStmt
125 #define st_IfStmt u.IfStmt
126 #define st_RetStmt u.RetStmt
127 #define st_ResStmt u.ResStmt
128 #define st_SwStmt u.SwStmt
129 #define st_CaseStmt u.CaseStmt
130 #define st_ExpStmt u.ExpStmt
131 #define st_ThreadSchedStmt u.ThreadSchedStmt
133 #define ST_UNKNOWN 0 /* placemarker for fwd reference */
134 #define ST_Import 0x0001 /* import statement or top-level file */
135 #define ST_Class 0x0002 /* class */
136 #define ST_Typedef 0x0003 /* typedef */
137 #define ST_Decl 0x0004 /* declaration wrapped by a statement */
138 #define ST_Block 0x0005 /* braced block */
139 #define ST_Nop 0x0006 /* empty statement (e.g. just semicolon) */
140 #define ST_Loop 0x0007 /* for/while/do/until loop */
141 #define ST_BreakCont 0x0008 /* break or continue */
142 #define ST_Bad 0x0009 /* bad/illegal statement */
143 #define ST_IfElse 0x000A /* if or if-else */
144 #define ST_Return 0x000B /* return from procedure */
145 #define ST_Result 0x000C /* return value and continue as thread */
146 #define ST_Switch 0x000D /* switch */
147 #define ST_Case 0x000E /* case/default in switch */
148 #define ST_Exp 0x000F /* expression wrapped by a statement */
149 #define ST_Else 0x0010 /* (synthesized for break/continue) */
150 #define ST_Proc 0x0011 /* procedure body block statement */
151 #define ST_ThreadSched 0x0012 /* thread schedule statement */
152 #define ST_Module 0x0013 /* A module */
155 * STF_SEMANTIC - Indicates that this is a new semantic lavel for
156 * the purposes of a semantic search.
158 * (ST_Import, ST_Class, ST_Block, ST_Proc,
159 * ST_Loop, ST_Case, ST_Module)
161 * STF_SEMTOP - ST_Import, ST_Class, ST_Proc, ST_Module
163 * STF_FORWARD - Indicates that forward references may occur
164 * at this semantic level. This flag is typically
165 * only set in certain non-executable statements.
167 * STF_NESTED - Indicates that a procedure (ST_Proc) is nested
169 #define STF_SEMANTIC 0x0001 /* a semantic rendezvous point */
170 #define STF_FORWARD 0x0002 /* forward references may occur */
171 #define STF_UNUSED04 0x0004
172 #define STF_RESOLVING 0x0008 /* resolver interlock */
173 #define STF_RESOLVED 0x0010 /* resolver interlock */
174 #define STF_MODEXIT 0x0020 /* (import) exit on return */
175 #define STF_SEMTOP 0x0040 /* top level in semantic group terms */
176 #define STF_SELFCONTAINED 0x0080 /* (import) self contained */
177 #define STF_SHARED 0x0100 /* (import) shared import */
178 #define STF_NESTED 0x0200 /* (proc) nested procedure */
180 #define dassert_stmt(stmt, cond) if (!(cond)) StmtFatalError((stmt), 0)
182 #define StmtFatalError(stmt, type) \
184 StmtPrintError(stmt, type); \