WOW. NodeTree deletes duplicate nodes. So x+x didn't work....
This commit is contained in:
@@ -130,7 +130,7 @@ template<class T>
|
||||
void NodeTree<T>::addChild(NodeTree<T>* child) {
|
||||
if (!child)
|
||||
throw "Help, NULL child";
|
||||
if (findChild(child) == -1)
|
||||
//if (findChild(child) == -1)
|
||||
children.push_back(child);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ template<class T>
|
||||
void NodeTree<T>::insertChild(int i, NodeTree<T>* child) {
|
||||
if (!child)
|
||||
throw "Help, NULL child";
|
||||
if (findChild(child) == -1)
|
||||
//if (findChild(child) == -1)
|
||||
children.insert(children.begin()+i,child);
|
||||
}
|
||||
|
||||
|
||||
@@ -775,16 +775,23 @@ NodeTree<ASTData>* ASTTransformation::doFunction(NodeTree<ASTData>* scope, std::
|
||||
|
||||
newNode = new NodeTree<ASTData>(lookup, ASTData(function_call, Symbol(lookup, true)));
|
||||
NodeTree<ASTData>* function = functionLookup(scope, lookup, mapNodesToTypes(nodes));
|
||||
std::cout << "Num of newNode children " << newNode->getChildren().size() << std::endl;
|
||||
newNode->addChild(function);
|
||||
std::cout << "Num of newNode children " << newNode->getChildren().size() << std::endl;
|
||||
newNode->addChildren(nodes);
|
||||
std::cout << "Num of newNode children " << newNode->getChildren().size() << std::endl;
|
||||
std::cout << "nodes " << nodes.size() << std::endl;
|
||||
|
||||
//Specially handle dereference and address of to assign the correct type
|
||||
//We need some significant other type corrections here, maybe to the point of being their own function. (int + float, etc.)
|
||||
std::cout << "the passed in nodes" << std::endl;
|
||||
for (auto i : nodes)
|
||||
std::cout << i->getDataRef()->toString() << " ";
|
||||
std::cout<<std::endl;
|
||||
|
||||
|
||||
std::vector<Type> oldTypes = mapNodesToTypes(nodes);
|
||||
std::cout << "the oldtypes size" << oldTypes.size() << std::endl;
|
||||
if ((nodes.size() != 2 && lookup == "*") || lookup == "&" || lookup == "[]") {
|
||||
Type* newType = oldTypes[0].clone();
|
||||
if (lookup == "*" || lookup == "[]")
|
||||
@@ -796,6 +803,7 @@ NodeTree<ASTData>* ASTTransformation::doFunction(NodeTree<ASTData>* scope, std::
|
||||
} else {
|
||||
newNode->getDataRef()->valueType = function->getDataRef()->valueType, std::cout << "Some other ||" << lookup << "||" << std::endl;
|
||||
}
|
||||
std::cout << "Num of newNode children " << newNode->getChildren().size() << std::endl;
|
||||
return newNode;
|
||||
}
|
||||
|
||||
|
||||
6
tests/test_badMath.expected_results
Normal file
6
tests/test_badMath.expected_results
Normal file
@@ -0,0 +1,6 @@
|
||||
Spam
|
||||
12
|
||||
14
|
||||
28
|
||||
We'll find out.
|
||||
34
|
||||
18
tests/test_badMath.krak
Normal file
18
tests/test_badMath.krak
Normal file
@@ -0,0 +1,18 @@
|
||||
import io;
|
||||
|int| main() {
|
||||
io::println("Spam");
|
||||
|int| x = 4;
|
||||
x += 3;
|
||||
x++;
|
||||
|int| y = 6;
|
||||
|int| z = x + y;
|
||||
|int| q = z+z;
|
||||
|int| q2 = z*3;
|
||||
|int| q3 = y + y;
|
||||
io::println(q3);
|
||||
io::println(z);
|
||||
io::println(q);
|
||||
for (|int| i = 0; i < 20; i++;) z++;
|
||||
if (z > 20) io::println("We'll find out.");
|
||||
io::println(z);
|
||||
}
|
||||
Reference in New Issue
Block a user