aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_compile.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-02 03:16:00 +1000
committerDavid Walter Seikel2012-02-02 03:16:00 +1000
commit64ba572fbac74b39c4d74d2a5b24289e803c6acb (patch)
tree7429d32d3a9c77744ff6f0291c59573b6f1dc7e4 /LuaSL/src/LuaSL_compile.c
parentTweak the space around crements, still not perfect though. (diff)
downloadSledjHamr-64ba572fbac74b39c4d74d2a5b24289e803c6acb.zip
SledjHamr-64ba572fbac74b39c4d74d2a5b24289e803c6acb.tar.gz
SledjHamr-64ba572fbac74b39c4d74d2a5b24289e803c6acb.tar.bz2
SledjHamr-64ba572fbac74b39c4d74d2a5b24289e803c6acb.tar.xz
Numby magic.
Diffstat (limited to 'LuaSL/src/LuaSL_compile.c')
-rw-r--r--LuaSL/src/LuaSL_compile.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index de23b78..73b43dd 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -710,6 +710,40 @@ LSL_Leaf *addList(LSL_Leaf *left, LSL_Leaf *list, LSL_Leaf *right)
710 return left; 710 return left;
711} 711}
712 712
713LSL_Leaf *addNumby(LSL_Leaf *numby)
714{
715 LSL_Numby *num = calloc(1, sizeof(LSL_Numby));
716
717 if ((numby) && (num))
718 {
719 num->text.text = numby->value.stringValue;
720#if LUASL_DIFF_CHECK
721 num->text.ignorable = numby->ignorable;
722 numby->ignorable = NULL;
723#endif
724 switch (numby->toKen->type)
725 {
726 case LSL_FLOAT :
727 {
728 num->value.floatValue = atof(num->text.text);
729 numby->basicType = OT_float;
730 break;
731 }
732 case LSL_INTEGER :
733 {
734 num->value.integerValue = atoi(num->text.text);
735 numby->basicType = OT_integer;
736 break;
737 }
738 default:
739 break;
740 }
741 numby->value.numbyValue = num;
742 num->type = numby->basicType;
743 }
744 return numby;
745}
746
713LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval) 747LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval)
714{ 748{
715 LSL_Parenthesis *parens = calloc(1, sizeof(LSL_Parenthesis)); 749 LSL_Parenthesis *parens = calloc(1, sizeof(LSL_Parenthesis));
@@ -1103,10 +1137,11 @@ static LSL_Leaf *evaluateFloatToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf
1103 1137
1104 if (content && result) 1138 if (content && result)
1105 { 1139 {
1106 if (LUASL_DEBUG)
1107 printf(" <%g> ", content->value.floatValue);
1108 memcpy(result, content, sizeof(LSL_Leaf)); 1140 memcpy(result, content, sizeof(LSL_Leaf));
1141 result->value.floatValue = content->value.numbyValue->value.floatValue;
1109 result->basicType = OT_float; 1142 result->basicType = OT_float;
1143 if (LUASL_DEBUG)
1144 printf(" <%g> ", content->value.floatValue);
1110 } 1145 }
1111 return result; 1146 return result;
1112} 1147}
@@ -1117,10 +1152,11 @@ static LSL_Leaf *evaluateIntegerToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Lea
1117 1152
1118 if (content && result) 1153 if (content && result)
1119 { 1154 {
1120 if (LUASL_DEBUG)
1121 printf(" <%d> ", content->value.integerValue);
1122 memcpy(result, content, sizeof(LSL_Leaf)); 1155 memcpy(result, content, sizeof(LSL_Leaf));
1156 result->value.integerValue = content->value.numbyValue->value.integerValue;
1123 result->basicType = OT_integer; 1157 result->basicType = OT_integer;
1158 if (LUASL_DEBUG)
1159 printf(" <%d> ", result->value.integerValue);
1124 } 1160 }
1125 return result; 1161 return result;
1126} 1162}
@@ -1681,7 +1717,7 @@ static void outputCrementsToken(FILE *file, outputMode mode, LSL_Leaf *content)
1681static void outputFloatToken(FILE *file, outputMode mode, LSL_Leaf *content) 1717static void outputFloatToken(FILE *file, outputMode mode, LSL_Leaf *content)
1682{ 1718{
1683 if (content) 1719 if (content)
1684 fprintf(file, "%g", content->value.floatValue); 1720 outputText(file, &(content->value.numbyValue->text), !(LSL_NOIGNORE & content->toKen->flags));
1685} 1721}
1686 1722
1687static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content) 1723static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content)
@@ -1734,7 +1770,7 @@ static void outputFunctionCallToken(FILE *file, outputMode mode, LSL_Leaf *conte
1734static void outputIntegerToken(FILE *file, outputMode mode, LSL_Leaf *content) 1770static void outputIntegerToken(FILE *file, outputMode mode, LSL_Leaf *content)
1735{ 1771{
1736 if (content) 1772 if (content)
1737 fprintf(file, "%d", content->value.integerValue); 1773 outputText(file, &(content->value.numbyValue->text), !(LSL_NOIGNORE & content->toKen->flags));
1738} 1774}
1739 1775
1740static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content) 1776static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content)