Added passthroughs and small fix for malloc/free

This commit is contained in:
Nathan Braswell
2014-05-03 20:46:10 -04:00
parent 6a75832b59
commit 9a4507a0f5
3 changed files with 28 additions and 1 deletions

View File

@@ -305,10 +305,12 @@ NodeTree<ASTData>* ASTTransformation::transform(NodeTree<Symbol>* from, NodeTree
newNode = new NodeTree<ASTData>(name, ASTData(value, Symbol(concatSymbolTree(from), true), new Type(floating)));
} else if (name == "double") {
newNode = new NodeTree<ASTData>(name, ASTData(value, Symbol(concatSymbolTree(from), true), new Type(double_percision)));
} else if (name == "char") {
} else if (name == "char") { //Is this correct? This might be a useless old thing
newNode = new NodeTree<ASTData>(name, ASTData(value, Symbol(concatSymbolTree(children[0]), true), new Type(character, 1))); //Indirection of 1 for array
} else if (name == "string" || name == "triple_quoted_string") {
newNode = new NodeTree<ASTData>(name, ASTData(value, Symbol(concatSymbolTree(children[0]), true), new Type(character, 1))); //Indirection of 1 for array
}else if (name == "character") {
newNode = new NodeTree<ASTData>(name, ASTData(value, Symbol(concatSymbolTree(children[0]), true), new Type(character, 0))); //Indirection of 0 for character
} else {
return new NodeTree<ASTData>();
}

View File

@@ -52,6 +52,8 @@ NodeTree<ASTData>* Importer::import(std::string fileName) {
programInFile.open(i+fileName);
if (programInFile.is_open())
break;
else
std::cout << i+fileName << " is no good" << std::endl;
}
if (!programInFile.is_open()) {
std::cout << "Problem opening programInFile " << fileName << "\n";

23
stdlib/mem.krak Normal file
View File

@@ -0,0 +1,23 @@
__if_comp__ __C__ __simple_passthrough__ """
#include <stdlib.h>
"""
char* nullPtr = 0;
char* malloc(int size) {
char* memPtr = nullPtr;
__if_comp__ __C__ {
__simple_passthrough__ """
memPtr = malloc(size);
"""
}
return memPtr;
}
void free(char* memPtr) {
__if_comp__ __C__ {
__simple_passthrough__ """
free(memPtr);
"""
}
}