diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 71 |
1 files changed, 68 insertions, 3 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 1755e6c..c2d3260 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -196,15 +196,15 @@ struct _LSL_Block | |||
196 | LSL_Block *outerBlock; | 196 | LSL_Block *outerBlock; |
197 | // Eina_Hash *statements; // Probably should be some sort of eina list. | 197 | // Eina_Hash *statements; // Probably should be some sort of eina list. |
198 | Eina_Hash *variables; // Those variables in this scope. | 198 | Eina_Hash *variables; // Those variables in this scope. |
199 | LSL_Function *function; | 199 | LSL_Function *function; // A pointer to the function if this block is a function. |
200 | }; | 200 | }; |
201 | 201 | ||
202 | struct _LSL_Function | 202 | struct _LSL_Function |
203 | { | 203 | { |
204 | const char *name; | 204 | const char *name; |
205 | LSL_Leaf *type; | 205 | LSL_Leaf *type; |
206 | LSL_Leaf *params; | 206 | LSL_Leaf *params; // Probably should be some sort of eina list. |
207 | Eina_Hash *variables; | 207 | Eina_Hash *variables; // And this actually duplicates params. |
208 | LSL_Leaf *block; | 208 | LSL_Leaf *block; |
209 | }; | 209 | }; |
210 | 210 | ||
@@ -223,6 +223,71 @@ struct _LSL_Script | |||
223 | Eina_Hash *variables; | 223 | Eina_Hash *variables; |
224 | }; | 224 | }; |
225 | 225 | ||
226 | /* Tracking variables. | ||
227 | |||
228 | There are global variables, block local variables, and function parameters. | ||
229 | |||
230 | For outputting Lua, which is the ultimate goal - | ||
231 | track order, name, and type. | ||
232 | |||
233 | For looking them up during the compile - | ||
234 | quick access from name. | ||
235 | |||
236 | For validating them during compile - | ||
237 | track type. | ||
238 | |||
239 | For outputting LSL to double check - | ||
240 | track order, name, type, and white space. | ||
241 | |||
242 | For executing directly from the AST - | ||
243 | track order, name, type, and value. | ||
244 | In this case, order is only important for functions. | ||
245 | |||
246 | We can assume that names are stringshared. This means we only have to | ||
247 | compare pointers. It also means the same name stored at diffferent | ||
248 | scopes, must be stored in separate structures, coz the pointers are the | ||
249 | same. | ||
250 | |||
251 | Order is taken care of by the AST anyway, but for somethings we want to | ||
252 | condense the AST down to something more efficient. | ||
253 | |||
254 | On the other hand, no need to micro optimise it just yet, we should be | ||
255 | able to try out other data structures at a later date, then benchmark | ||
256 | them with typical scripts. | ||
257 | |||
258 | Right now I see nothing wrong with the current use of hash for script | ||
259 | and block variables. The same for script states and functions, as wall | ||
260 | as state functions. Though in the near future, they will have similar | ||
261 | problems to functcions I think - the need to track order and white | ||
262 | space. | ||
263 | |||
264 | Function params though have gotten unwieldy. Each param ends up with | ||
265 | AST nodes for itself, it's type, it's own paramlist node, and the comma. | ||
266 | The paramlist nodes are the excessive bits, the rest are needed to track | ||
267 | the white space. | ||
268 | |||
269 | */ | ||
270 | |||
271 | /* General design. | ||
272 | |||
273 | NOTE We should be able to remove the white space tracking at compile | ||
274 | time, as it's only a debugging aid. Will be a performance and memory | ||
275 | gain for productidon use. Tracking values on the other hand will still | ||
276 | be useful for constants. | ||
277 | |||
278 | The compile process starts with turning tokens into AST nodes connected | ||
279 | in a tree. During that process the parser wants to condense nodes down | ||
280 | to more efficient data structures. This is a good idea, as we will | ||
281 | spend a fair amount of time looking up names, no matter which part of | ||
282 | the process is important at the time. | ||
283 | |||
284 | Once the parser has condensed things down, it only deals with the | ||
285 | condensed nodes. So we can get rid of some of the AST parts at this | ||
286 | time, so long as we keep the relevant information. This is what the | ||
287 | other data structures above are for. | ||
288 | |||
289 | */ | ||
290 | |||
226 | // Define the type for flex and lemon. | 291 | // Define the type for flex and lemon. |
227 | #define YYSTYPE LSL_Leaf | 292 | #define YYSTYPE LSL_Leaf |
228 | 293 | ||