aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_compile.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-04 22:47:37 +1000
committerDavid Walter Seikel2012-02-04 22:47:37 +1000
commit6b097d337444a0e02efc6cebed08a860d2e435ed (patch)
treeb923c45c8f71068d3acc705d813a794a44cff030 /LuaSL/src/LuaSL_compile.c
parentSet variables to a proper value if otherwised unitialized. (diff)
downloadSledjHamr-6b097d337444a0e02efc6cebed08a860d2e435ed.zip
SledjHamr-6b097d337444a0e02efc6cebed08a860d2e435ed.tar.gz
SledjHamr-6b097d337444a0e02efc6cebed08a860d2e435ed.tar.bz2
SledjHamr-6b097d337444a0e02efc6cebed08a860d2e435ed.tar.xz
Implement typecasts when needed. Actually, doing some extras for the moment.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_compile.c13
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