diff options
author | David Walter Seikel | 2012-02-02 01:55:44 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-02-02 01:55:44 +1000 |
commit | 809530889811445b7fca3a57ce38efee196d1c22 (patch) | |
tree | 179cc1515705f051268b4c37215a440de4b85089 /LuaSL/src/LuaSL_compile.c | |
parent | Fix up single statement "blocks". (diff) | |
download | SledjHamr-809530889811445b7fca3a57ce38efee196d1c22.zip SledjHamr-809530889811445b7fca3a57ce38efee196d1c22.tar.gz SledjHamr-809530889811445b7fca3a57ce38efee196d1c22.tar.bz2 SledjHamr-809530889811445b7fca3a57ce38efee196d1c22.tar.xz |
Parse dot subbies.
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 0b56845..5fb3946 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -300,13 +300,19 @@ static LSL_Leaf *findVariable(LuaSL_compiler *compiler, const char *name) | |||
300 | return var; | 300 | return var; |
301 | } | 301 | } |
302 | 302 | ||
303 | LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier) | 303 | LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *dot, LSL_Leaf *sub) |
304 | { | 304 | { |
305 | gameGlobals *game = compiler->game; | 305 | gameGlobals *game = compiler->game; |
306 | const char *search; | ||
307 | |||
308 | if (dot) | ||
309 | search = identifier->value.identifierValue->name.text; | ||
310 | else | ||
311 | search = identifier->value.stringValue; | ||
306 | 312 | ||
307 | if (identifier) | 313 | if (identifier) |
308 | { | 314 | { |
309 | LSL_Leaf *var = findVariable(compiler, identifier->value.stringValue); | 315 | LSL_Leaf *var = findVariable(compiler, search); |
310 | 316 | ||
311 | if (var) | 317 | if (var) |
312 | { | 318 | { |
@@ -314,6 +320,26 @@ LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier) | |||
314 | PI("Found %s!", identifier->value.stringValue); | 320 | PI("Found %s!", identifier->value.stringValue); |
315 | identifier->value.identifierValue = var->value.identifierValue; | 321 | identifier->value.identifierValue = var->value.identifierValue; |
316 | identifier->basicType = var->basicType; | 322 | identifier->basicType = var->basicType; |
323 | if ((dot) && (sub)) | ||
324 | { | ||
325 | LSL_Identifier *id = calloc(1, sizeof(LSL_Identifier)); | ||
326 | |||
327 | if (id) | ||
328 | { | ||
329 | memcpy(id, var->value.identifierValue, sizeof(LSL_Identifier)); | ||
330 | identifier->value.identifierValue = id; | ||
331 | if (LSL_ROTATION == var->toKen->type) | ||
332 | { | ||
333 | // TODO - check if it's one of x, y, z, or s. | ||
334 | } | ||
335 | if (LSL_VECTOR == var->toKen->type) | ||
336 | { | ||
337 | // TODO - check if it's one of x, y, or z. | ||
338 | } | ||
339 | identifier->value.identifierValue->sub = sub->value.stringValue; | ||
340 | identifier->basicType = OT_float; | ||
341 | } | ||
342 | } | ||
317 | } | 343 | } |
318 | else | 344 | else |
319 | PE("NOT found %s @ line %d, column %d!", identifier->value.stringValue, identifier->line, identifier->column); | 345 | PE("NOT found %s @ line %d, column %d!", identifier->value.stringValue, identifier->line, identifier->column); |
@@ -1520,6 +1546,8 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1520 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | 1546 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); |
1521 | #endif | 1547 | #endif |
1522 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); | 1548 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); |
1549 | if (statement->identifier) | ||
1550 | outputText(file, &(statement->identifier->name), FALSE); | ||
1523 | break; | 1551 | break; |
1524 | } | 1552 | } |
1525 | case LSL_STATEMENT : | 1553 | case LSL_STATEMENT : |
@@ -1708,7 +1736,11 @@ static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content | |||
1708 | if (content) | 1736 | if (content) |
1709 | { | 1737 | { |
1710 | if (LSL_IDENTIFIER == content->toKen->type) | 1738 | if (LSL_IDENTIFIER == content->toKen->type) |
1739 | { | ||
1711 | outputText(file, &(content->value.identifierValue->name), FALSE); | 1740 | outputText(file, &(content->value.identifierValue->name), FALSE); |
1741 | if (content->value.identifierValue->sub) | ||
1742 | fprintf(file, ".%s", content->value.identifierValue->sub); | ||
1743 | } | ||
1712 | else | 1744 | else |
1713 | outputText(file, &(content->value.identifierValue->name), !(LSL_NOIGNORE & content->toKen->flags)); | 1745 | outputText(file, &(content->value.identifierValue->name), !(LSL_NOIGNORE & content->toKen->flags)); |
1714 | } | 1746 | } |