From 6b097d337444a0e02efc6cebed08a860d2e435ed Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sat, 4 Feb 2012 22:47:37 +1000 Subject: Implement typecasts when needed. Actually, doing some extras for the moment. --- LuaSL/src/LuaSL_compile.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'LuaSL/src/LuaSL_compile.c') diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index f3fddef..cd8494a 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c @@ -1217,7 +1217,11 @@ LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf * if (lval) { if (type) + { lval->basicType = type->basicType; + if ((expr) && (OT_integer == type->basicType)) // TODO - Should be from string, but I guess I'm not propagating basic types up from function calls and parenthesis? + lval->value.parenthesis->flags |= MF_TYPECAST; + } // Actualy, at this point, type is no longer needed. lval->toKen = tokens[LSL_TYPECAST_OPEN - lowestToken]; } @@ -1401,7 +1405,7 @@ Explicit type casting - Leading spaces are ignored, as are any characters after the run of digits. All other strings convert to 0. Which means "" and " " convert to 0. - Strings in hexadecimal format will work. + Strings in hexadecimal format will work, same in Lua (though Lua can't handle "0x", but "0x0" is fine). keys <-> string No other typecasting can be done with keys. float -> string @@ -1770,8 +1774,13 @@ static void outputRawParenthesisToken(FILE *file, outputMode mode, LSL_Parenthes { if ((OM_LUA == mode) && (LSL_TYPECAST_OPEN == parenthesis->type)) { - fprintf(file, " --[[(%s)]] ", typeName); + if (MF_TYPECAST & parenthesis->flags) + fprintf(file, " _LSL.%sTypecast(", typeName); + else + fprintf(file, " --[[%s]] ", typeName); outputLeaf(file, mode, parenthesis->contents); + if (MF_TYPECAST & parenthesis->flags) + fprintf(file, ") "); return; } -- cgit v1.1