From ef0f7b7843110c329a2ff0906729d3e616d86b75 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Fri, 3 Feb 2012 13:20:48 +1000 Subject: Lua locals. --- LuaSL/src/LuaSL_LSL_tree.h | 7 +++++++ LuaSL/src/LuaSL_compile.c | 6 ++++++ 2 files changed, 13 insertions(+) (limited to 'LuaSL/src') diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 6273d60..3e80f50 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h @@ -146,6 +146,12 @@ typedef enum ST_MODULO = 8192 // % %= } opSubType; +typedef enum +{ + MF_NONE = 0, + MF_LOCAL = 1 +} miscFlags; + struct _allowedTypes { opType result; @@ -181,6 +187,7 @@ struct _LSL_Leaf #endif int line, column, len; opType basicType; + miscFlags flags; union { float floatValue; diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 7457f0c..2ae8dca 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c @@ -1094,6 +1094,8 @@ LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi assignment->right = expr; if (type) { + if (compiler->currentBlock) + type->flags |= MF_LOCAL; identifier->basicType = type->basicType; result->value.basicType = type->basicType; result->value.toKen = type->toKen; // This is the LSL_TYPE_* toKen instead of the LSL_* toKen. Not sure if that's a problem. @@ -1523,7 +1525,11 @@ static void outputLeaf(FILE *file, outputMode mode, LSL_Leaf *leaf) if (OM_LUA == mode) { if (LSL_TYPE & leaf->toKen->flags) + { + if (MF_LOCAL & leaf->flags) + fprintf(file, " local "); fprintf(file, " --[[%s]] ", leaf->toKen->toKen); + } else if (LSL_CONCATENATE == leaf->toKen->type) fprintf(file, " .. "); else -- cgit v1.1