From 6a6eaf26345f7e12648aa25a9390e5d92c50a11b Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Fri, 3 Feb 2012 13:32:27 +1000 Subject: Take care of declerations without asignments. --- LuaSL/src/LuaSL_LSL_tree.h | 3 ++- LuaSL/src/LuaSL_compile.c | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'LuaSL/src') diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 3e80f50..9f1aaee 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h @@ -149,7 +149,8 @@ typedef enum typedef enum { MF_NONE = 0, - MF_LOCAL = 1 + MF_LOCAL = 1, + MF_NOASSIGN = 2 } miscFlags; struct _allowedTypes diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 2ae8dca..c06afc4 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c @@ -1092,6 +1092,8 @@ LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi identifier->right = assignment; if (assignment) assignment->right = expr; + else + identifier->flags |= MF_NOASSIGN; if (type) { if (compiler->currentBlock) @@ -2025,6 +2027,12 @@ static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content fprintf(file, ".%s", content->value.identifierValue->sub); } else + if ((LSL_VARIABLE == content->toKen->type) && (MF_NOASSIGN & content->flags)) + { + outputText(file, &(content->value.identifierValue->name), !(LSL_NOIGNORE & content->toKen->flags)); + fprintf(file, " = nil"); + } + else outputText(file, &(content->value.identifierValue->name), !(LSL_NOIGNORE & content->toKen->flags)); } } -- cgit v1.1