diff options
Diffstat (limited to 'LuaSL/src/LuaSL_compile.c')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 13 |
1 files changed, 11 insertions, 2 deletions
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 * | |||
1217 | if (lval) | 1217 | if (lval) |
1218 | { | 1218 | { |
1219 | if (type) | 1219 | if (type) |
1220 | { | ||
1220 | lval->basicType = type->basicType; | 1221 | lval->basicType = type->basicType; |
1222 | 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? | ||
1223 | lval->value.parenthesis->flags |= MF_TYPECAST; | ||
1224 | } | ||
1221 | // Actualy, at this point, type is no longer needed. | 1225 | // Actualy, at this point, type is no longer needed. |
1222 | lval->toKen = tokens[LSL_TYPECAST_OPEN - lowestToken]; | 1226 | lval->toKen = tokens[LSL_TYPECAST_OPEN - lowestToken]; |
1223 | } | 1227 | } |
@@ -1401,7 +1405,7 @@ Explicit type casting - | |||
1401 | Leading spaces are ignored, as are any characters after the run of digits. | 1405 | Leading spaces are ignored, as are any characters after the run of digits. |
1402 | All other strings convert to 0. | 1406 | All other strings convert to 0. |
1403 | Which means "" and " " convert to 0. | 1407 | Which means "" and " " convert to 0. |
1404 | Strings in hexadecimal format will work. | 1408 | Strings in hexadecimal format will work, same in Lua (though Lua can't handle "0x", but "0x0" is fine). |
1405 | keys <-> string | 1409 | keys <-> string |
1406 | No other typecasting can be done with keys. | 1410 | No other typecasting can be done with keys. |
1407 | float -> string | 1411 | float -> string |
@@ -1770,8 +1774,13 @@ static void outputRawParenthesisToken(FILE *file, outputMode mode, LSL_Parenthes | |||
1770 | { | 1774 | { |
1771 | if ((OM_LUA == mode) && (LSL_TYPECAST_OPEN == parenthesis->type)) | 1775 | if ((OM_LUA == mode) && (LSL_TYPECAST_OPEN == parenthesis->type)) |
1772 | { | 1776 | { |
1773 | fprintf(file, " --[[(%s)]] ", typeName); | 1777 | if (MF_TYPECAST & parenthesis->flags) |
1778 | fprintf(file, " _LSL.%sTypecast(", typeName); | ||
1779 | else | ||
1780 | fprintf(file, " --[[%s]] ", typeName); | ||
1774 | outputLeaf(file, mode, parenthesis->contents); | 1781 | outputLeaf(file, mode, parenthesis->contents); |
1782 | if (MF_TYPECAST & parenthesis->flags) | ||
1783 | fprintf(file, ") "); | ||
1775 | return; | 1784 | return; |
1776 | } | 1785 | } |
1777 | 1786 | ||