aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-20 16:30:39 +1000
committerDavid Walter Seikel2012-01-20 16:30:39 +1000
commit9081cfb9c357563bd9da2a3542ba47b5477a9e79 (patch)
treee672271cb793b96d5cd5f209a46748c469c9122d
parentMore quirk comments. (diff)
downloadSledjHamr-9081cfb9c357563bd9da2a3542ba47b5477a9e79.zip
SledjHamr-9081cfb9c357563bd9da2a3542ba47b5477a9e79.tar.gz
SledjHamr-9081cfb9c357563bd9da2a3542ba47b5477a9e79.tar.bz2
SledjHamr-9081cfb9c357563bd9da2a3542ba47b5477a9e79.tar.xz
More commentry.
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h71
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
202struct _LSL_Function 202struct _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
228There are global variables, block local variables, and function parameters.
229
230For outputting Lua, which is the ultimate goal -
231 track order, name, and type.
232
233For looking them up during the compile -
234 quick access from name.
235
236For validating them during compile -
237 track type.
238
239For outputting LSL to double check -
240 track order, name, type, and white space.
241
242For executing directly from the AST -
243 track order, name, type, and value.
244 In this case, order is only important for functions.
245
246We can assume that names are stringshared. This means we only have to
247compare pointers. It also means the same name stored at diffferent
248scopes, must be stored in separate structures, coz the pointers are the
249same.
250
251Order is taken care of by the AST anyway, but for somethings we want to
252condense the AST down to something more efficient.
253
254On the other hand, no need to micro optimise it just yet, we should be
255able to try out other data structures at a later date, then benchmark
256them with typical scripts.
257
258Right now I see nothing wrong with the current use of hash for script
259and block variables. The same for script states and functions, as wall
260as state functions. Though in the near future, they will have similar
261problems to functcions I think - the need to track order and white
262space.
263
264Function params though have gotten unwieldy. Each param ends up with
265AST nodes for itself, it's type, it's own paramlist node, and the comma.
266The paramlist nodes are the excessive bits, the rest are needed to track
267the white space.
268
269*/
270
271/* General design.
272
273NOTE We should be able to remove the white space tracking at compile
274time, as it's only a debugging aid. Will be a performance and memory
275gain for productidon use. Tracking values on the other hand will still
276be useful for constants.
277
278The compile process starts with turning tokens into AST nodes connected
279in a tree. During that process the parser wants to condense nodes down
280to more efficient data structures. This is a good idea, as we will
281spend a fair amount of time looking up names, no matter which part of
282the process is important at the time.
283
284Once the parser has condensed things down, it only deals with the
285condensed nodes. So we can get rid of some of the AST parts at this
286time, so long as we keep the relevant information. This is what the
287other 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