forked from solstice/solstice
Function calling fix
This commit is contained in:
@@ -655,7 +655,7 @@ namespace Solstice {
|
|||||||
if (isTemp(children[1].outputId)) codeBlock.toBeDropped.push_back(children[1].outputId);
|
if (isTemp(children[1].outputId)) codeBlock.toBeDropped.push_back(children[1].outputId);
|
||||||
code.push_back(codeBlock);
|
code.push_back(codeBlock);
|
||||||
// Make sure we know what the variable type is
|
// Make sure we know what the variable type is
|
||||||
variables[children[0].outputId] = children[1].data.getTypeString();
|
variables[children[0].outputId] = checkNodeReturnType(children[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SolNodeType::FunctionCall: {
|
case SolNodeType::FunctionCall: {
|
||||||
@@ -1268,7 +1268,7 @@ namespace Solstice {
|
|||||||
}
|
}
|
||||||
case SolNodeType::BracketStart: {
|
case SolNodeType::BracketStart: {
|
||||||
// function call
|
// function call
|
||||||
if (rootNode.children.back().nodeType == SolNodeType::Identifier) {
|
if (!rootNode.children.empty() && rootNode.children.back().nodeType == SolNodeType::Identifier) {
|
||||||
SolNode fnCallNode(SolNodeType::FunctionCall);
|
SolNode fnCallNode(SolNodeType::FunctionCall);
|
||||||
fnCallNode.line = tokenObj.line;
|
fnCallNode.line = tokenObj.line;
|
||||||
fnCallNode.lineContent = tokenObj.lineContent;
|
fnCallNode.lineContent = tokenObj.lineContent;
|
||||||
@@ -1317,8 +1317,9 @@ namespace Solstice {
|
|||||||
tokens.push_back(tokenopt.value());
|
tokens.push_back(tokenopt.value());
|
||||||
}
|
}
|
||||||
auto node = Parser(tokens).parse();
|
auto node = Parser(tokens).parse();
|
||||||
node.nodeType = SolNodeType::Expression;
|
if (!node.children.empty()) {
|
||||||
rootNode.addNode(node);
|
rootNode.addNode(node.children.back());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
std::string n2t = checkNodeReturnType(node2); \
|
std::string n2t = checkNodeReturnType(node2); \
|
||||||
if (n1t != n2t) { \
|
if (n1t != n2t) { \
|
||||||
if (!(n1t == "int" && n2t == "double" || n1t == "double" && n2t == "int")) { \
|
if (!(n1t == "int" && n2t == "double" || n1t == "double" && n2t == "int")) { \
|
||||||
Error::typingError("Expected types to be the same for " + std::string(op), node1.line, node1.lineContent); \
|
Error::typingError("Expected types to be the same for " + std::string(op) + " (got types '" + n1t + "' and '" + n2t + "')", node1.line, node1.lineContent); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user