Added passthroughs and small fix for malloc/free
This commit is contained in:
@@ -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>();
|
||||
}
|
||||
|
||||
@@ -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
23
stdlib/mem.krak
Normal 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);
|
||||
"""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user