- Migrated all build-related code to new logging mechanism
This commit is contained in:
Tristan B. Velloza Kildaire 2024-04-12 00:10:40 +02:00
parent 8f5faf58f0
commit ae7b13a1d0
12 changed files with 321 additions and 324 deletions

View File

@ -133,7 +133,7 @@ public final class DCodeEmitter : CodeEmitter
// return "KAK TODO";
}
gprintln("Type transform unimplemented for type '"~to!(string)(typeIn)~"'", DebugType.ERROR);
ERROR("Type transform unimplemented for type '"~to!(string)(typeIn)~"'");
assert(false);
// return stringRepr;
}
@ -142,7 +142,7 @@ public final class DCodeEmitter : CodeEmitter
public override string transform(const Instruction instruction)
{
writeln("\n");
gprintln("transform(): "~to!(string)(instruction));
DEBUG("transform(): "~to!(string)(instruction));
transformDepth++;
// The data to emit
@ -157,21 +157,21 @@ public final class DCodeEmitter : CodeEmitter
/* VariableAssignmentInstr */
if(cast(VariableAssignmentInstr)instruction)
{
gprintln("type: VariableAssignmentInstr");
DEBUG("type: VariableAssignmentInstr");
VariableAssignmentInstr varAs = cast(VariableAssignmentInstr)instruction;
Context context = varAs.getContext();
gprintln("Is ContextNull?: "~to!(string)(context is null));
gprintln("Wazza contect: "~to!(string)(context.container));
DEBUG("Is ContextNull?: "~to!(string)(context is null));
DEBUG("Wazza contect: "~to!(string)(context.container));
auto typedEntityVariable = typeChecker.getResolver().resolveBest(context.getContainer(), varAs.varName); //TODO: Remove `auto`
gprintln("Hi"~to!(string)(varAs));
gprintln("Hi"~to!(string)(varAs.data));
gprintln("Hi"~to!(string)(varAs.data.getInstrType()));
DEBUG("Hi"~to!(string)(varAs));
DEBUG("Hi"~to!(string)(varAs.data));
DEBUG("Hi"~to!(string)(varAs.data.getInstrType()));
// NOTE: For tetsing issue #94 coercion (remove when done)
string typeName = (cast(Type)varAs.data.getInstrType()).getName();
gprintln("VariableAssignmentInstr: The data to assign's type is: "~typeName);
DEBUG("VariableAssignmentInstr: The data to assign's type is: "~typeName);
/* If it is not external */
@ -191,7 +191,7 @@ public final class DCodeEmitter : CodeEmitter
/* VariableDeclaration */
else if(cast(VariableDeclaration)instruction)
{
gprintln("type: VariableDeclaration");
DEBUG("type: VariableDeclaration");
VariableDeclaration varDecInstr = cast(VariableDeclaration)instruction;
Context context = varDecInstr.getContext();
@ -224,7 +224,7 @@ public final class DCodeEmitter : CodeEmitter
if(typedEntityVariable.getAssignment())
{
Value varAssInstr = varDecInstr.getAssignmentInstr();
gprintln("VarDec(with assignment): My assignment type is: "~varAssInstr.getInstrType().getName());
DEBUG("VarDec(with assignment): My assignment type is: "~varAssInstr.getInstrType().getName());
// Generate the code to emit
emmmmit = typeTransform(cast(Type)varDecInstr.varType)~" "~renamedSymbol~" = "~transform(varAssInstr)~";";
@ -243,7 +243,7 @@ public final class DCodeEmitter : CodeEmitter
/* LiteralValue */
else if(cast(LiteralValue)instruction)
{
gprintln("type: LiteralValue");
DEBUG("type: LiteralValue");
LiteralValue literalValueInstr = cast(LiteralValue)instruction;
@ -252,7 +252,7 @@ public final class DCodeEmitter : CodeEmitter
/* FetchValueVar */
else if(cast(FetchValueVar)instruction)
{
gprintln("type: FetchValueVar");
DEBUG("type: FetchValueVar");
FetchValueVar fetchValueVarInstr = cast(FetchValueVar)instruction;
Context context = fetchValueVarInstr.getContext();
@ -279,7 +279,7 @@ public final class DCodeEmitter : CodeEmitter
/* BinOpInstr */
else if(cast(BinOpInstr)instruction)
{
gprintln("type: BinOpInstr");
DEBUG("type: BinOpInstr");
BinOpInstr binOpInstr = cast(BinOpInstr)instruction;
@ -314,7 +314,7 @@ public final class DCodeEmitter : CodeEmitter
CastedValueInstruction cvInstr = cast(CastedValueInstruction)binOpInstr.rhs;
assert(cvInstr);
gprintln("CastedValueInstruction relax setting: Da funk RIGHT ");
DEBUG("CastedValueInstruction relax setting: Da funk RIGHT ");
// Relax the CV-instr to prevent it from emitting explicit cast code
cvInstr.setRelax(true);
@ -325,7 +325,7 @@ public final class DCodeEmitter : CodeEmitter
CastedValueInstruction cvInstr = cast(CastedValueInstruction)binOpInstr.lhs;
assert(cvInstr);
gprintln("CastedValueInstruction relax setting: Da funk LEFT ");
DEBUG("CastedValueInstruction relax setting: Da funk LEFT ");
// Relax the CV-instr to prevent it from emitting explicit cast code
cvInstr.setRelax(true);
@ -336,7 +336,7 @@ public final class DCodeEmitter : CodeEmitter
/* FuncCallInstr */
else if(cast(FuncCallInstr)instruction)
{
gprintln("type: FuncCallInstr");
DEBUG("type: FuncCallInstr");
FuncCallInstr funcCallInstr = cast(FuncCallInstr)instruction;
Context context = funcCallInstr.getContext();
@ -386,7 +386,7 @@ public final class DCodeEmitter : CodeEmitter
/* ReturnInstruction */
else if(cast(ReturnInstruction)instruction)
{
gprintln("type: ReturnInstruction");
DEBUG("type: ReturnInstruction");
ReturnInstruction returnInstruction = cast(ReturnInstruction)instruction;
Context context = returnInstruction.getContext();
@ -405,7 +405,7 @@ public final class DCodeEmitter : CodeEmitter
IfStatementInstruction ifStatementInstruction = cast(IfStatementInstruction)instruction;
BranchInstruction[] branchInstructions = ifStatementInstruction.getBranchInstructions();
gprintln("Holla"~to!(string)(branchInstructions));
DEBUG("Holla"~to!(string)(branchInstructions));
string emit;
@ -619,7 +619,7 @@ public final class DCodeEmitter : CodeEmitter
else
{
// TODO: Implement this
gprintln("Non-primitive type casting not yet implemented", DebugType.ERROR);
ERROR("Non-primitive type casting not yet implemented");
assert(false);
}
}
@ -636,10 +636,10 @@ public final class DCodeEmitter : CodeEmitter
{
ArrayIndexInstruction arrAssInstr = cast(ArrayIndexInstruction)instruction;
gprintln("TODO: Implement Pointer-array index emit", DebugType.ERROR);
ERROR("TODO: Implement Pointer-array index emit");
gprintln("ArrayInstr: "~arrAssInstr.getIndexedToInstr().toString());
gprintln("ArrayIndexInstr: "~to!(string)(arrAssInstr.getIndexInstr()));
DEBUG("ArrayInstr: "~arrAssInstr.getIndexedToInstr().toString());
DEBUG("ArrayIndexInstr: "~to!(string)(arrAssInstr.getIndexInstr()));
/* Obtain the entity being indexed */
@ -745,7 +745,7 @@ public final class DCodeEmitter : CodeEmitter
emit ~= "]";
gprintln("TODO: Implement Stack-array index emit", DebugType.ERROR);
ERROR("TODO: Implement Stack-array index emit");
@ -825,11 +825,11 @@ public final class DCodeEmitter : CodeEmitter
import tlang.compiler.symbols.containers : Module;
Program program = this.typeChecker.getProgram();
Module[] programsModules = program.getModules();
gprintln("emit() has found modules '"~to!(string)(programsModules)~"'", DebugType.INFO);
DEBUG("emit() has found modules '"~to!(string)(programsModules)~"'");
foreach(Module curMod; programsModules)
{
gprintln("Begin emit process for module '"~to!(string)(curMod)~"'...");
DEBUG("Begin emit process for module '"~to!(string)(curMod)~"'...");
File modOut;
modOut.open(format("%s.c", curMod.getName()), "w");
@ -855,7 +855,7 @@ public final class DCodeEmitter : CodeEmitter
// Close (and flush anything not yet written)
modOut.close();
gprintln("Emit for '"~to!(string)(curMod)~"'");
DEBUG("Emit for '"~to!(string)(curMod)~"'");
}
// If enabled (default: yes) then emit entry point (TODO: change later)
@ -882,7 +882,7 @@ public final class DCodeEmitter : CodeEmitter
// is the one we care about
if(config.getConfig("dgen:emit_entrypoint_test").getBoolean())
{
gprintln("Generating a testcase entrypoint for this program", DebugType.WARNING);
WARN("Generating a testcase entrypoint for this program");
Module firstMod = programsModules[0];
File firstModOut;
@ -895,7 +895,7 @@ public final class DCodeEmitter : CodeEmitter
}
else
{
gprintln("Could not find an entry point module and function. Missing a main() maybe?", DebugType.ERROR);
ERROR("Could not find an entry point module and function. Missing a main() maybe?");
}
}
}
@ -1002,7 +1002,7 @@ public final class DCodeEmitter : CodeEmitter
private ModuleExternSet generateExternsForModule(Module mod)
{
gprintln(format("Generating extern statements for module '%s'", mod.getName()));
DEBUG(format("Generating extern statements for module '%s'", mod.getName()));
Entity[] allPubFunc;
Entity[] allPubVar;
@ -1021,7 +1021,7 @@ public final class DCodeEmitter : CodeEmitter
Entity[] entities;
resolver.resolveWithin(mod, &allPubFuncsAndVars, entities);
gprintln(format("Got %d many entities needing extern statements emitted", entities.length));
DEBUG(format("Got %d many entities needing extern statements emitted", entities.length));
import niknaks.arrays : filter;
import niknaks.functional : predicateOf;
@ -1081,7 +1081,7 @@ public final class DCodeEmitter : CodeEmitter
*/
foreach(ModuleExternSet mos; externSets)
{
gprintln(format("Emitting extern(...) statements for module %s...", mos.mod()));
DEBUG(format("Emitting extern(...) statements for module %s...", mos.mod()));
// Emit public functions
foreach(Function func; mos.funcs())
@ -1095,7 +1095,7 @@ public final class DCodeEmitter : CodeEmitter
// Generate the emit
string externEmit = format("%s%s;", externPart, signature);
gprintln(format("FuncExternEmit: '%s'", externEmit));
DEBUG(format("FuncExternEmit: '%s'", externEmit));
modOut.writeln(externEmit);
}
@ -1111,7 +1111,7 @@ public final class DCodeEmitter : CodeEmitter
// Generate the emit
string externEmit = format("%s%s;", externPart, signature);
gprintln(format("VarExternEmit: '%s'", externEmit));
DEBUG(format("VarExternEmit: '%s'", externEmit));
modOut.writeln(externEmit);
}
}
@ -1129,7 +1129,7 @@ public final class DCodeEmitter : CodeEmitter
// Select the static initializations code queue for
// the given module
selectQueue(mod, QueueType.ALLOC_QUEUE);
gprintln("Static allocations needed: "~to!(string)(getQueueLength()));
DEBUG("Static allocations needed: "~to!(string)(getQueueLength()));
modOut.writeln();
}
@ -1143,13 +1143,13 @@ public final class DCodeEmitter : CodeEmitter
*/
private void emitFunctionPrototypes(File modOut, Module mod)
{
gprintln("Function definitions needed: "~to!(string)(getFunctionDefinitionsCount(mod)));
DEBUG("Function definitions needed: "~to!(string)(getFunctionDefinitionsCount(mod)));
// Get complete map (should we bypass anything in CodeEmitter for this? Guess it is fair?)
Instruction[][string] functionBodyInstrs = typeChecker.getFunctionBodyCodeQueues(mod);
string[] functionNames = getFunctionDefinitionNames(mod);
gprintln("WOAH: "~to!(string)(functionNames));
DEBUG("WOAH: "~to!(string)(functionNames));
foreach(string currentFunctioName; functionNames)
{
@ -1167,14 +1167,14 @@ public final class DCodeEmitter : CodeEmitter
*/
private void emitFunctionDefinitions(File modOut, Module mod)
{
gprintln("Function definitions needed: "~to!(string)(getFunctionDefinitionsCount(mod)));
DEBUG("Function definitions needed: "~to!(string)(getFunctionDefinitionsCount(mod)));
// Get the function definitions of the current module
Instruction[][string] functionBodyInstrs = typeChecker.getFunctionBodyCodeQueues(mod);
string[] functionNames = getFunctionDefinitionNames(mod);
gprintln("WOAH: "~to!(string)(functionNames));
DEBUG("WOAH: "~to!(string)(functionNames));
foreach(string currentFunctioName; functionNames)
{
@ -1301,7 +1301,7 @@ public final class DCodeEmitter : CodeEmitter
// TODO: Is this needed for protptype def? I think not (REMOVE PLEASE)
selectQueue(mod, QueueType.FUNCTION_DEF_QUEUE, functionName);
gprintln("emotFunctionDefinition(): Function: "~functionName~", with "~to!(string)(getSelectedQueueLength())~" many instructions");
DEBUG("emotFunctionDefinition(): Function: "~functionName~", with "~to!(string)(getSelectedQueueLength())~" many instructions");
//TODO: Look at nested definitions or nah? (Context!!)
//TODO: And what about methods defined in classes? Those should technically be here too
@ -1325,7 +1325,7 @@ public final class DCodeEmitter : CodeEmitter
// Select the function definition code queue by module and function name
selectQueue(mod, QueueType.FUNCTION_DEF_QUEUE, functionName);
gprintln("emotFunctionDefinition(): Function: "~functionName~", with "~to!(string)(getSelectedQueueLength())~" many instructions");
DEBUG("emotFunctionDefinition(): Function: "~functionName~", with "~to!(string)(getSelectedQueueLength())~" many instructions");
//TODO: Look at nested definitions or nah? (Context!!)
//TODO: And what about methods defined in classes? Those should technically be here too
@ -1346,7 +1346,7 @@ public final class DCodeEmitter : CodeEmitter
Instruction curFuncBodyInstr = getCurrentInstruction();
string emit = transform(curFuncBodyInstr);
gprintln("emitFunctionDefinition("~functionName~"): Emit: "~emit);
DEBUG("emitFunctionDefinition("~functionName~"): Emit: "~emit);
modOut.writeln("\t"~emit);
nextInstruction();
@ -1373,7 +1373,7 @@ public final class DCodeEmitter : CodeEmitter
{
// Select the global code queue of the current module
selectQueue(mod, QueueType.GLOBALS_QUEUE);
gprintln("Code emittings needed: "~to!(string)(getQueueLength()));
DEBUG("Code emittings needed: "~to!(string)(getQueueLength()));
while(hasInstructions())
{
@ -1401,11 +1401,11 @@ public final class DCodeEmitter : CodeEmitter
private void emitEntrypoint(File modOut, Module mod)
{
gprintln("IMPLEMENT ME", DebugType.ERROR);
gprintln("IMPLEMENT ME", DebugType.ERROR);
gprintln("IMPLEMENT ME", DebugType.ERROR);
gprintln("IMPLEMENT ME", DebugType.ERROR);
gprintln("We have NOT YET implemented the init method", DebugType.ERROR);
ERROR("IMPLEMENT ME");
ERROR("IMPLEMENT ME");
ERROR("IMPLEMENT ME");
ERROR("IMPLEMENT ME");
ERROR("We have NOT YET implemented the init method");
// modOut.writeln("fok");
@ -1669,13 +1669,13 @@ int main()
{
foreach(string srcFile; srcFiles)
{
gprintln("Cleaning up source file '"~srcFile~"'...");
DEBUG("Cleaning up source file '"~srcFile~"'...");
import std.stdio : remove;
remove(srcFile.ptr);
if(!remove(srcFile.ptr))
{
gprintln("There was an error cleaning up source file '"~srcFile~"'"); // TODO: Add error code
ERROR("There was an error cleaning up source file '"~srcFile~"'"); // TODO: Add error code
}
}
}
@ -1685,13 +1685,13 @@ int main()
{
foreach(string objFile; objectFiles)
{
gprintln("Cleaning up object file '"~objFile~"'...");
DEBUG("Cleaning up object file '"~objFile~"'...");
import std.stdio : remove;
remove(objFile.ptr);
if(!remove(objFile.ptr))
{
gprintln("There was an error cleaning up object file '"~objFile~"'"); // TODO: Add error code
ERROR("There was an error cleaning up object file '"~objFile~"'"); // TODO: Add error code
}
}
}
@ -1700,18 +1700,18 @@ int main()
try
{
string systemCompiler = config.getConfig("dgen:compiler").getText();
gprintln("Using system C compiler '"~systemCompiler~"' for compilation");
INFO("Using system C compiler '"~systemCompiler~"' for compilation");
// Check for object files to be linked in
string[] objectFilesLink;
if(config.hasConfig("linker:link_files"))
{
objectFilesLink = config.getConfig("linker:link_files").getArray();
gprintln("Object files to be linked in: "~to!(string)(objectFilesLink));
INFO("Object files to be linked in: "~to!(string)(objectFilesLink));
}
else
{
gprintln("No files to link in");
INFO("No files to link in");
}
// Total compilation time
@ -1726,7 +1726,7 @@ int main()
string[] args = [systemCompiler, "-c", modFileSrcPath, "-o", modFileObjPath];
gprintln("Compiling now with arguments: "~to!(string)(args));
INFO("Compiling now with arguments: "~to!(string)(args));
StopWatch watch = StopWatch(AutoStart.yes);
Pid ccPID = spawnProcess(args);
@ -1738,7 +1738,7 @@ int main()
}
Duration compTime = watch.peek();
gprintln(format("Compiled %s in %sms", curMod.getName(), compTime.total!("msecs")()));
INFO(format("Compiled %s in %sms", curMod.getName(), compTime.total!("msecs")()));
total = dur!("msecs")(total.total!("msecs")()+compTime.total!("msecs")());
// Only add it to the list of files if it was generated
@ -1747,7 +1747,7 @@ int main()
objectFiles ~= modFileObjPath;
}
gprintln(format("Total compilation time took %s", total));
INFO(format("Total compilation time took %s", total));
// Now determine the entry point module
// Module entryModule;
@ -1784,7 +1784,7 @@ int main()
}
catch(ProcessException e)
{
gprintln("NOTE: Case where it exited and Pid now inavlid (if it happens it would throw processexception surely)?", DebugType.ERROR);
ERROR("NOTE: Case where it exited and Pid now inavlid (if it happens it would throw processexception surely)?");
assert(false);
}
}

View File

@ -348,13 +348,13 @@ public string gibFileData(string sourceFile)
void beginCompilation(string[] sourceFiles)
{
/* TODO: Begin compilation process, take in data here */
gprintln("Compiling files "~to!(string)(sourceFiles)~" ...");
DEBUG("Compiling files "~to!(string)(sourceFiles)~" ...");
foreach(string sourceFile; sourceFiles)
{
/* Read in the source code */
// TODO: THis below code is used so many times, for heavens-sake please make a helper function for it
gprintln("Reading source file '"~sourceFile~"' ...");
DEBUG("Reading source file '"~sourceFile~"' ...");
File sourceFileFile;
sourceFileFile.open(sourceFile); /* TODO: Error handling with ANY file I/O */
ulong fileSize = sourceFileFile.size();

View File

@ -333,7 +333,7 @@ public final class BasicLexer : LexerInterface
}
//else if (currentChar == LS.UNDERSCORE || ((!isSplitter(currentChar) && !isDigit(currentChar)) && currentChar != LS.DOUBLE_QUOTE && currentChar != LS.SINGLE_QUOTE && currentChar != LS.BACKSLASH)) {
else if (currentChar == LS.UNDERSCORE || isAlpha(currentChar)) {
gprintln("path ident String");
DEBUG("path ident String");
if (!doIdentOrPath()) {
break;
} else {

View File

@ -266,13 +266,13 @@ public final class ModuleManager
// The path must be valid
if(!exists(directory))
{
gprintln(format("Skipping directory '%s' as it does not exist", directory), DebugType.WARNING);
WARN(format("Skipping directory '%s' as it does not exist", directory));
return null;
}
// The path must refer to a directory
else if(!isDir(directory))
{
gprintln(format("Skipping directory '%s' it is a valid path but NOT a directory", directory), DebugType.WARNING);
WARN(format("Skipping directory '%s' it is a valid path but NOT a directory", directory));
return null;
}
@ -327,7 +327,7 @@ public final class ModuleManager
*/
private bool find(string[] directories, string modName, ref ModuleEntry found, bool isDirect = true)
{
gprintln("Request to find module '"~modName~"' in directories: "~to!(string)(directories));
DEBUG("Request to find module '"~modName~"' in directories: "~to!(string)(directories));
// Discover all files ending in .t in all search paths
// (Doing shallow)
@ -340,7 +340,7 @@ public final class ModuleManager
version(DBG_MODMAN)
{
import niknaks.debugging : dumpArray;
gprintln("Files ending in `.t`:\n\n"~dumpArray!(tFiles)(0, tFiles.length, 1));
DEBUG("Files ending in `.t`:\n\n"~dumpArray!(tFiles)(0, tFiles.length, 1));
}
@ -363,8 +363,8 @@ public final class ModuleManager
return true;
}
gprintln("Original path: "~tFile);
gprintln("Module name potetial: '"~modNamePot~"'");
DEBUG("Original path: "~tFile);
DEBUG("Module name potetial: '"~modNamePot~"'");
}
// Only if not tried already (else recursion)
@ -384,7 +384,7 @@ public final class ModuleManager
*/
if(!isPresent(modName, '.'))
{
gprintln
DEBUG
(
format
(
@ -396,7 +396,7 @@ public final class ModuleManager
}
string newModName = tailEndGet(modName);
gprintln("New module name "~newModName);
DEBUG("New module name "~newModName);
/**
* Now before giving up we must consider
@ -428,11 +428,11 @@ public final class ModuleManager
{
relativeDir ~= element ~"/";
}
gprintln("Relative dir (generated): "~relativeDir);
DEBUG("Relative dir (generated): "~relativeDir);
// Construct the directory to search
string newSearchPath = directory~"/"~relativeDir;
gprintln("New search path (consideration): "~newSearchPath);
DEBUG("New search path (consideration): "~newSearchPath);
newPaths ~= newSearchPath;
}

View File

@ -54,7 +54,7 @@ public final class Parser
*/
public void expect(string message)
{
gprintln(message, DebugType.ERROR);
ERROR(message);
throw new ParserException(this, ParserException.ParserErrorType.GENERAL_ERROR, message);
}
@ -138,7 +138,7 @@ public final class Parser
*/
private IfStatement parseIf()
{
gprintln("parseIf(): Enter", DebugType.WARNING);
WARN("parseIf(): Enter");
IfStatement ifStmt;
Branch[] branches;
@ -239,7 +239,7 @@ public final class Parser
}
}
gprintln("parseIf(): Leave", DebugType.WARNING);
WARN("parseIf(): Leave");
/* Create the if statement with the branches */
ifStmt = new IfStatement(branches);
@ -252,7 +252,7 @@ public final class Parser
private WhileLoop parseWhile()
{
gprintln("parseWhile(): Enter", DebugType.WARNING);
WARN("parseWhile(): Enter");
Expression branchCondition;
Statement[] branchBody;
@ -290,14 +290,14 @@ public final class Parser
/* Parent the branch to the WhileLoop */
parentToContainer(whileLoop, [branch]);
gprintln("parseWhile(): Leave", DebugType.WARNING);
WARN("parseWhile(): Leave");
return whileLoop;
}
private WhileLoop parseDoWhile()
{
gprintln("parseDoWhile(): Enter", DebugType.WARNING);
WARN("parseDoWhile(): Enter");
Expression branchCondition;
Statement[] branchBody;
@ -342,7 +342,7 @@ public final class Parser
/* Parent the branch to the WhileLoop */
parentToContainer(whileLoop, [branch]);
gprintln("parseDoWhile(): Leave", DebugType.WARNING);
WARN("parseDoWhile(): Leave");
return whileLoop;
}
@ -352,7 +352,7 @@ public final class Parser
// TODO: We ASSUME there is always pre-run, condition and post-iteration
public ForLoop parseFor()
{
gprintln("parseFor(): Enter", DebugType.WARNING);
WARN("parseFor(): Enter");
Expression branchCondition;
Statement[] branchBody;
@ -388,7 +388,7 @@ public final class Parser
expect(SymbolType.CCURLY, lexer.getCurrentToken());
lexer.nextToken();
gprintln("Yo: "~lexer.getCurrentToken().toString());
DEBUG("Yo: "~lexer.getCurrentToken().toString());
/* Create the Branch coupling the body statements (+post iteration statement) and condition */
Branch forBranch = new Branch(branchCondition, branchBody~postIterationStatement);
@ -407,7 +407,7 @@ public final class Parser
/* Parent the Branch to its for loop */
parentToContainer(forLoop, [forBranch]);
gprintln("parseFor(): Leave", DebugType.WARNING);
WARN("parseFor(): Leave");
return forLoop;
}
@ -421,7 +421,7 @@ public final class Parser
string identifier = lexer.getCurrentToken().getToken();
lexer.nextToken();
lexer.nextToken();
gprintln(lexer.getCurrentToken());
DEBUG(lexer.getCurrentToken());
/* Expression */
Expression assignmentExpression = parseExpression();
@ -447,7 +447,7 @@ public final class Parser
/* Save the name or type */
string nameTYpe = lexer.getCurrentToken().getToken();
gprintln("parseName(): Current token: "~lexer.getCurrentToken().toString());
DEBUG("parseName(): Current token: "~lexer.getCurrentToken().toString());
/* TODO: The problem here is I don't want to progress the token */
@ -516,7 +516,7 @@ public final class Parser
/* Any other case */
else
{
gprintln(lexer.getCurrentToken());
DEBUG(lexer.getCurrentToken());
expect("Error expected ( for var/func def");
}
@ -529,7 +529,7 @@ public final class Parser
/* TODO: Implement me, and call me */
private Struct parseStruct()
{
gprintln("parseStruct(): Enter", DebugType.WARNING);
WARN("parseStruct(): Enter");
Struct generatedStruct;
Statement[] statements;
@ -650,7 +650,7 @@ public final class Parser
lexer.nextToken();
gprintln("parseStruct(): Leave", DebugType.WARNING);
WARN("parseStruct(): Leave");
return generatedStruct;
}
@ -677,7 +677,7 @@ public final class Parser
Expression returnExpression = parseExpression();
/* Expect a semi-colon as the terminator */
gprintln(lexer.getCurrentToken());
WARN(lexer.getCurrentToken());
expect(SymbolType.SEMICOLON, lexer.getCurrentToken());
/* Create the ReturnStmt */
@ -692,7 +692,7 @@ public final class Parser
private Statement[] parseBody()
{
gprintln("parseBody(): Enter", DebugType.WARNING);
WARN("parseBody(): Enter");
/* TODO: Implement body parsing */
Statement[] statements;
@ -714,13 +714,13 @@ public final class Parser
Token tok = lexer.getCurrentToken();
SymbolType symbol = getSymbolType(tok);
gprintln("parseBody(): SymbolType=" ~ to!(string)(symbol));
DEBUG("parseBody(): SymbolType=" ~ to!(string)(symbol));
/* If it is a class definition */
if(symbol == SymbolType.CLASS)
{
/* Parse the class and add its statements */
/* Parsgprintlne the class and add its statements */
statements ~= parseClass();
}
/* If it is a struct definition */
@ -732,7 +732,7 @@ public final class Parser
/* If it is closing the body `}` */
else if(symbol == SymbolType.CCURLY)
{
gprintln("parseBody(): Exiting body by }", DebugType.WARNING);
WARN("parseBody(): Exiting body by }");
closedBeforeExit = true;
break;
@ -749,7 +749,7 @@ public final class Parser
expect("Expected closing } but ran out of tokens");
}
gprintln("parseBody(): Leave", DebugType.WARNING);
WARN("parseBody(): Leave");
return statements;
}
@ -833,7 +833,7 @@ public final class Parser
{
/* TODO: Set accessor on returned thing */
entity = parseStruct();
gprintln("Poes"~to!(string)(entity));
DEBUG("Poes"~to!(string)(entity));
}
/* If typed-definition (function or variable) */
else if(symbolType == SymbolType.IDENT_TYPE)
@ -883,7 +883,7 @@ public final class Parser
{
/* TODO: Set accessor on returned thing */
entity = parseStruct();
gprintln("Poes"~to!(string)(entity));
DEBUG("Poes"~to!(string)(entity));
}
/* If typed-definition (function or variable) */
else if(symbolType == SymbolType.IDENT_TYPE)
@ -926,7 +926,7 @@ public final class Parser
private funcDefPair parseFuncDef(bool wantsBody = true)
{
gprintln("parseFuncDef(): Enter", DebugType.WARNING);
WARN("parseFuncDef(): Enter");
Statement[] statements;
VariableParameter[] parameterList;
@ -1032,8 +1032,8 @@ public final class Parser
expect(SymbolType.SEMICOLON, lexer.getCurrentToken());
}
gprintln("ParseFuncDef: Parameter count: " ~ to!(string)(parameterCount));
gprintln("parseFuncDef(): Leave", DebugType.WARNING);
DEBUG("ParseFuncDef: Parameter count: " ~ to!(string)(parameterCount));
WARN("parseFuncDef(): Leave");
bruh.bodyStatements = statements;
bruh.params = parameterList;
@ -1131,7 +1131,7 @@ public final class Parser
*/
private Expression parseExpression()
{
gprintln("parseExpression(): Enter", DebugType.WARNING);
WARN("parseExpression(): Enter");
/**
@ -1173,7 +1173,7 @@ public final class Parser
/* If we don't have 1 on the stack */
if(retExpression.length != 1)
{
gprintln(retExpression);
DEBUG(retExpression);
expect("Expression parsing failed as we had remaining items on the expression parser stack or zero");
}
}
@ -1195,7 +1195,7 @@ public final class Parser
{
SymbolType symbol = getSymbolType(lexer.getCurrentToken());
gprintln(retExpression);
DEBUG(retExpression);
/* If it is a number literal */
if (symbol == SymbolType.NUMBER_LITERAL)
@ -1330,7 +1330,7 @@ public final class Parser
{
/* Expression can only be a `VariableExpression` which accounts for Function Handles and Variable Identifiers */
Expression rhs = parseExpression();
gprintln("hhshhshshsh");
DEBUG("hhshhshshsh");
if(cast(VariableExpression)rhs)
{
/* Create UnaryExpression comprised of the operator and the right-hand side expression */
@ -1378,13 +1378,13 @@ public final class Parser
{
// Pop off an expression which will be `indexTo`
Expression indexTo = removeExp();
gprintln("indexTo: "~indexTo.toString());
DEBUG("indexTo: "~indexTo.toString());
/* Get the index expression */
lexer.nextToken();
Expression index = parseExpression();
lexer.nextToken();
gprintln("IndexExpr: "~index.toString());
DEBUG("IndexExpr: "~index.toString());
// gprintln(lexer.getCurrentToken());
ArrayIndex arrayIndexExpr = new ArrayIndex(indexTo, index);
@ -1504,8 +1504,8 @@ public final class Parser
}
gprintln(retExpression);
gprintln("parseExpression(): Leave", DebugType.WARNING);
DEBUG(retExpression);
WARN("parseExpression(): Leave");
/* TODO: DO check here for retExp.length = 1 */
expressionStackSanityCheck();
@ -1518,7 +1518,7 @@ public final class Parser
// TODO: Update to `Statement` as this can return an ArrayAssignment now
private Statement parseTypedDeclaration(bool wantsBody = true, bool allowVarDec = true, bool allowFuncDef = true, bool onlyType = false)
{
gprintln("parseTypedDeclaration(): Enter", DebugType.WARNING);
WARN("parseTypedDeclaration(): Enter");
/* Generated object */
@ -1576,13 +1576,13 @@ public final class Parser
// If the expression is an integer (which it should be)
if(stackArraySize)
{
gprintln("StackArraySize: "~stackArraySize.toString());
DEBUG("StackArraySize: "~stackArraySize.toString());
potentialStackSize = stackArraySize.getNumber();
}
// If not, then error
else
{
gprintln("Expected an integer as stack-array size but got iets ander", DebugType.ERROR);
ERROR("Expected an integer as stack-array size but got iets ander");
// TODO: Rather throw a parsing error
assert(false);
}
@ -1634,7 +1634,7 @@ public final class Parser
identifier = lexer.getCurrentToken().getToken();
lexer.nextToken();
gprintln("ParseTypedDec: DecisionBtwn FuncDef/VarDef: " ~ lexer.getCurrentToken().getToken());
DEBUG("ParseTypedDec: DecisionBtwn FuncDef/VarDef: " ~ lexer.getCurrentToken().getToken());
}
/* Anything else is an error */
else
@ -1647,7 +1647,7 @@ public final class Parser
/* Check if it is `(` (func dec) */
SymbolType symbolType = getSymbolType(lexer.getCurrentToken());
gprintln("ParseTypedDec: SymbolType=" ~ to!(string)(symbolType));
DEBUG("ParseTypedDec: SymbolType=" ~ to!(string)(symbolType));
if (symbolType == SymbolType.LBRACE)
{
// Only continue is function definitions are allowed
@ -1697,10 +1697,9 @@ public final class Parser
// Only continue if variable declarations are allowed
if(allowVarDec)
{
gprintln("Semi: "~to!(string)(lexer.getCurrentToken()));
gprintln("Semi: "~to!(string)(lexer.getCurrentToken()));
gprintln("ParseTypedDec: VariableDeclaration: (Type: " ~ type ~ ", Identifier: " ~ identifier ~ ")",
DebugType.WARNING);
DEBUG("Semi: "~to!(string)(lexer.getCurrentToken()));
DEBUG("Semi: "~to!(string)(lexer.getCurrentToken()));
WARN("ParseTypedDec: VariableDeclaration: (Type: " ~ type ~ ", Identifier: " ~ identifier ~ ")");
generated = new Variable(type, identifier);
}
@ -1726,8 +1725,8 @@ public final class Parser
VariableAssignment varAssign = new VariableAssignment(expression);
gprintln("ParseTypedDec: VariableDeclarationWithAssingment: (Type: "
~ type ~ ", Identifier: " ~ identifier ~ ")", DebugType.WARNING);
WARN("ParseTypedDec: VariableDeclarationWithAssingment: (Type: "
~ type ~ ", Identifier: " ~ identifier ~ ")");
Variable variable = new Variable(type, identifier);
variable.addAssignment(varAssign);
@ -1751,10 +1750,10 @@ public final class Parser
{
// Set the token pointer back to the beginning
lexer.setCursor(arrayAssignTokenBeginPos);
gprintln("Looking at: "~to!(string)(lexer.getCurrentToken()));
DEBUG("Looking at: "~to!(string)(lexer.getCurrentToken()));
// TODO: Move all below code to the branch below that handles this case
gprintln("We have an array assignment, here is the indexers: "~to!(string)(arrayIndexExprs), DebugType.WARNING);
WARN("We have an array assignment, here is the indexers: "~to!(string)(arrayIndexExprs));
// Our identifier will be some weird malformed-looking `mrArray[][1]` (because os atck array size declarations no-number literal)
// ... expressions don't make it in (we have arrayIndexExprs for that). Therefore what we must do is actually
@ -1763,16 +1762,16 @@ public final class Parser
long firstBracket = indexOf(type, "[");
assert(firstBracket > -1);
identifier = type[0..firstBracket];
gprintln("Then identifier is type actually: "~identifier);
DEBUG("Then identifier is type actually: "~identifier);
gprintln("We are still implenenting array assignments", DebugType.ERROR);
ERROR("We are still implenenting array assignments");
ArrayIndex muhIndex = cast(ArrayIndex)parseExpression();
gprintln("Expback: "~muhIndex.toString());
DEBUG("Expback: "~muhIndex.toString());
/* Expect a `=` and consume it */
gprintln(lexer.getCurrentToken());
DEBUG(lexer.getCurrentToken());
expect(SymbolType.ASSIGN, lexer.getCurrentToken());
lexer.nextToken();
@ -1782,7 +1781,7 @@ public final class Parser
// TODO: Get the expression after the `=`
ArrayAssignment arrayAssignment = new ArrayAssignment(muhIndex, expressionBeingAssigned);
gprintln("Created array assignment: "~arrayAssignment.toString());
DEBUG("Created array assignment: "~arrayAssignment.toString());
// assert(false);
generated = arrayAssignment;
@ -1792,7 +1791,7 @@ public final class Parser
expect("Expected one of the following: (, ; or =");
}
gprintln("parseTypedDeclaration(): Leave", DebugType.WARNING);
WARN("parseTypedDeclaration(): Leave");
return generated;
}
@ -1805,7 +1804,7 @@ public final class Parser
*/
private Clazz parseClass()
{
gprintln("parseClass(): Enter", DebugType.WARNING);
WARN("parseClass(): Enter");
Clazz generated;
@ -1819,7 +1818,7 @@ public final class Parser
expect("Class name in declaration cannot be path");
}
string className = lexer.getCurrentToken().getToken();
gprintln("parseClass(): Class name found '" ~ className ~ "'");
DEBUG("parseClass(): Class name found '" ~ className ~ "'");
lexer.nextToken();
generated = new Clazz(className);
@ -1973,7 +1972,7 @@ public final class Parser
/* Pop off the ending `}` */
lexer.nextToken();
gprintln("parseClass(): Leave", DebugType.WARNING);
WARN("parseClass(): Leave");
return generated;
}
@ -2144,7 +2143,7 @@ public final class Parser
private Statement parseDerefAssignment()
{
gprintln("parseDerefAssignment(): Enter", DebugType.WARNING);
WARN("parseDerefAssignment(): Enter");
Statement statement;
@ -2176,7 +2175,7 @@ public final class Parser
// FIXME: We should make a LHSPiinterAssignmentThing
statement = new PointerDereferenceAssignment(pointerExpression, assigmentExpression, derefCnt);
gprintln("parseDerefAssignment(): Leave", DebugType.WARNING);
WARN("parseDerefAssignment(): Leave");
return statement;
}
@ -2207,17 +2206,17 @@ public final class Parser
private void parseComment()
{
gprintln("parseComment(): Enter", DebugType.WARNING);
WARN("parseComment(): Enter");
Token curCommentToken = lexer.getCurrentToken();
pushComment(curCommentToken);
// TODO: Do something here like placing it on some kind of stack
gprintln("Comment is: '"~curCommentToken.getToken()~"'");
DEBUG("Comment is: '"~curCommentToken.getToken()~"'");
lexer.nextToken(); // Move off comment
gprintln("parseComment(): Leave", DebugType.WARNING);
WARN("parseComment(): Leave");
}
/**
@ -2315,13 +2314,13 @@ public final class Parser
// TODO: This ic currently dead code and ought to be used/implemented
private Statement parseStatement(SymbolType terminatingSymbol = SymbolType.SEMICOLON)
{
gprintln("parseStatement(): Enter", DebugType.WARNING);
WARN("parseStatement(): Enter");
/* Get the token */
Token tok = lexer.getCurrentToken();
SymbolType symbol = getSymbolType(tok);
gprintln("parseStatement(): SymbolType=" ~ to!(string)(symbol));
DEBUG("parseStatement(): SymbolType=" ~ to!(string)(symbol));
Statement statement;
@ -2388,7 +2387,7 @@ public final class Parser
/* If it is a kind-of comment */
else if(symbol == SymbolType.SINGLE_LINE_COMMENT || symbol == SymbolType.MULTI_LINE_COMMENT)
{
gprintln("COMMENTS NOT YET PROPERLY SUPOORTED", DebugType.ERROR);
ERROR("COMMENTS NOT YET PROPERLY SUPOORTED");
parseComment();
}
/* Error out */
@ -2397,14 +2396,14 @@ public final class Parser
expect("parseStatement(): Unknown symbol: " ~ lexer.getCurrentToken().getToken());
}
gprintln("parseStatement(): Leave", DebugType.WARNING);
WARN("parseStatement(): Leave");
return statement;
}
private FunctionCall parseFuncCall()
{
gprintln("parseFuncCall(): Enter", DebugType.WARNING);
WARN("parseFuncCall(): Enter");
/* TODO: Save name */
string functionName = lexer.getCurrentToken().getToken();
@ -2455,7 +2454,7 @@ public final class Parser
lexer.nextToken();
gprintln("parseFuncCall(): Leave", DebugType.WARNING);
WARN("parseFuncCall(): Leave");
return new FunctionCall(functionName, arguments);
}
@ -2524,11 +2523,11 @@ public final class Parser
*/
private void doImport(string[] modules)
{
gprintln(format("modules[]: %s", modules));
DEBUG(format("modules[]: %s", modules));
// Print out some information about the current program
Program prog = this.compiler.getProgram();
gprintln(format("Program currently: '%s'", prog));
DEBUG(format("Program currently: '%s'", prog));
// Get the module manager
ModuleManager modMan = compiler.getModMan();
@ -2537,11 +2536,11 @@ public final class Parser
ModuleEntry[] foundEnts;
foreach(string mod; modules)
{
gprintln(format("Module wanting to be imported: %s", mod));
DEBUG(format("Module wanting to be imported: %s", mod));
// Search for the module entry
ModuleEntry foundEnt = modMan.find(mod);
gprintln("Found module entry: "~to!(string)(foundEnt));
DEBUG("Found module entry: "~to!(string)(foundEnt));
foundEnts ~= foundEnt;
}
@ -2554,7 +2553,7 @@ public final class Parser
// then skip
if(prog.isEntryPresent(modEnt))
{
gprintln(format("Not parsing module '%s' as already marked as visited", modEnt));
DEBUG(format("Not parsing module '%s' as already marked as visited", modEnt));
continue;
}
@ -2563,7 +2562,7 @@ public final class Parser
// Read in the module's contents
string moduleSource = modMan.readModuleData_throwable(modEnt);
gprintln("Module has "~to!(string)(moduleSource.length)~" many bytes");
DEBUG("Module has "~to!(string)(moduleSource.length)~" many bytes");
// Parse the module
import tlang.compiler.lexer.kinds.basic : BasicLexer;
@ -2582,7 +2581,7 @@ public final class Parser
*/
private void parseImport()
{
gprintln("parseImport(): Enter", DebugType.WARNING);
WARN("parseImport(): Enter");
/* Consume the `import` keyword */
lexer.nextToken();
@ -2619,7 +2618,7 @@ public final class Parser
/* Perform the actual import */
doImport(collectedModuleNames);
gprintln("parseImport(): Leave", DebugType.WARNING);
WARN("parseImport(): Leave");
}
/* Almost like parseBody but has more */
@ -2631,7 +2630,7 @@ public final class Parser
/* TODO: Variables should be allowed to have letters in them and underscores */
public Module parse(string moduleFilePath, bool isEntrypoint = false)
{
gprintln("parse(): Enter", DebugType.WARNING);
WARN("parse(): Enter");
Module modulle;
@ -2683,7 +2682,7 @@ public final class Parser
*/
if(isEntrypoint)
{
gprintln
DEBUG
(
format
(
@ -2709,7 +2708,7 @@ public final class Parser
Token tok = lexer.getCurrentToken();
SymbolType symbol = getSymbolType(tok);
gprintln("parse(): Token: " ~ tok.getToken());
DEBUG("parse(): Token: " ~ tok.getToken());
/* If it is a type */
if (symbol == SymbolType.IDENT_TYPE)
@ -2777,7 +2776,7 @@ public final class Parser
/* If it is a kind-of comment */
else if(symbol == SymbolType.SINGLE_LINE_COMMENT || symbol == SymbolType.MULTI_LINE_COMMENT)
{
gprintln("COMMENTS NOT YET PROPERLY SUPOORTED", DebugType.ERROR);
ERROR("COMMENTS NOT YET PROPERLY SUPOORTED");
parseComment();
}
else
@ -2786,13 +2785,13 @@ public final class Parser
}
}
gprintln("parse(): Leave", DebugType.WARNING);
WARN("parse(): Leave");
/* Parent each Statement to the container (the module) */
parentToContainer(modulle, modulle.getStatements());
gprintln("Done parsing module '"~modulle.getName()~"' from file '"~modulle.getFilePath()~"'");
DEBUG("Done parsing module '"~modulle.getName()~"' from file '"~modulle.getFilePath()~"'");
return modulle;
}

View File

@ -951,7 +951,7 @@ public string getCharacter(SymbolType symbolIn)
}
else
{
gprintln("getCharacter: No back-mapping for "~to!(string)(symbolIn), DebugType.ERROR);
ERROR("getCharacter: No back-mapping for "~to!(string)(symbolIn));
assert(false);
}
}

View File

@ -167,7 +167,7 @@ public final class Program : Container
// TODO: Make this part of debug option
public void debugDump()
{
gprintln("Dumping modules imported into program:");
DEBUG("Dumping modules imported into program:");
import niknaks.debugging : dumpArray;
import std.stdio : writeln;
Module[] modulesImported = this.modules;

View File

@ -32,7 +32,7 @@ import tlang.compiler.symbols.data : Container;
*/
public Type getBuiltInType(TypeChecker tc, Container container, string typeString)
{
gprintln("getBuiltInType("~typeString~")");
DEBUG("getBuiltInType("~typeString~")");
/* `int`, signed (2-complement) */
if(cmp(typeString, "int") == 0)
@ -109,19 +109,19 @@ public Type getBuiltInType(TypeChecker tc, Container container, string typeStrin
// Find the component type (everything before `lastOBracketPos`)
string componentTypeString = typeString[0..lastOBracketPos];
gprintln("StackArray (component type): "~componentTypeString);
DEBUG("StackArray (component type): "~componentTypeString);
// Determine the size of the array (from `pos('[')+1` to typeString.length-2)
string arraySizeString = typeString[lastOBracketPos+1..$-1];
ulong arraySize = to!(ulong)(arraySizeString);
gprintln("StackArray (stack size): "~to!(string)(arraySize));
DEBUG("StackArray (stack size): "~to!(string)(arraySize));
gprintln("typeString: "~typeString);
DEBUG("typeString: "~typeString);
stackArray = new StackArray(tc.getType(container, componentTypeString), arraySize);
gprintln("Stack-based array types are still being implemented", DebugType.ERROR);
ERROR("Stack-based array types are still being implemented");
// assert(false);
return stackArray;
}
@ -147,8 +147,8 @@ public Type getBuiltInType(TypeChecker tc, Container container, string typeStrin
long ptrTypePos = rightmostTypePos;
string ptrType = typeString[0..(ptrTypePos)];
gprintln("TypeStr: "~typeString);
gprintln("Pointer to '"~ptrType~"'", DebugType.ERROR);
DEBUG("TypeStr: "~typeString);
ERROR("Pointer to '"~ptrType~"'");
return new Pointer(tc.getType(container, ptrType));
}
@ -161,7 +161,7 @@ public Type getBuiltInType(TypeChecker tc, Container container, string typeStrin
{
gprintln("getBuiltInType("~typeString~"): Failed to map to a built-in type", DebugType.ERROR);
ERROR("getBuiltInType("~typeString~"): Failed to map to a built-in type");
return null;
}

View File

@ -157,14 +157,14 @@ public final class TypeChecker
{
Module mod = cast(Module)modDep.getEntity();
assert(mod);
gprintln(format("Dependency node entry point mod: %s", modDep));
DEBUG(format("Dependency node entry point mod: %s", modDep));
// Linearize this module's dependencies
modDep.performLinearization();
// Print the dep tree
string modTree = modDep.getTree();
gprintln(format("\n%s", modTree));
DEBUG(format("\n%s", modTree));
// Get the linerization
DNode[] modActions = modDep.getLinearizedNodes();
@ -191,7 +191,7 @@ public final class TypeChecker
* for them
*/
FunctionData[string] modFuncDefs = funcDefStore.grabFunctionDefs(mod);
gprintln(format("Defined functions for module '%s': %s", mod, modFuncDefs));
DEBUG(format("Defined functions for module '%s': %s", mod, modFuncDefs));
foreach(FunctionData curFD; modFuncDefs.values)
{
assert(codeQueue.empty() == true);
@ -207,7 +207,7 @@ public final class TypeChecker
//TODO: Would this not mess with our queues?
doTypeCheck(actionListFunc);
gprintln(funcNode.getTree());
DEBUG(funcNode.getTree());
// The current code queue would be the function's body instructions
// a.k.a. the `codeQueue`
@ -260,13 +260,13 @@ public final class TypeChecker
if(this.config.hasConfig("typecheck:warnUnusedVars") & this.config.getConfig("typecheck:warnUnusedVars").getBoolean())
{
Variable[] unusedVariables = getUnusedVariables();
gprintln("There are "~to!(string)(unusedVariables.length)~" unused variables");
WARN("There are "~to!(string)(unusedVariables.length)~" unused variables");
if(unusedVariables.length)
{
foreach(Variable unusedVariable; unusedVariables)
{
// TODO: Get a nicer name, full path-based
gprintln("Variable '"~to!(string)(unusedVariable.getName())~"' is declared but never used");
INFO("Variable '"~to!(string)(unusedVariable.getName())~"' is declared but never used");
}
}
}
@ -384,7 +384,7 @@ public final class TypeChecker
foreach(Instruction instr; this.codeQueue)
{
copyQueue ~= instr;
gprintln(format("FuncDef (%s): Adding body instruction: %s", fd.getName(), instr));
DEBUG(format("FuncDef (%s): Adding body instruction: %s", fd.getName(), instr));
}
// Clear the scratchpad `codeQueue`
@ -485,7 +485,7 @@ public final class TypeChecker
ulong i = 0;
foreach(Instruction instruction; initQueue)
{
gprintln("InitQueue: "~to!(string)(i+1)~"/"~to!(string)(walkLength(initQueue[]))~": "~instruction.toString());
DEBUG("InitQueue: "~to!(string)(i+1)~"/"~to!(string)(walkLength(initQueue[]))~": "~instruction.toString());
i++;
}
}
@ -547,7 +547,7 @@ public final class TypeChecker
ulong i = 0;
foreach(Instruction instruction; codeQueue)
{
gprintln(to!(string)(i+1)~"/"~to!(string)(walkLength(codeQueue[]))~": "~instruction.toString());
DEBUG(to!(string)(i+1)~"/"~to!(string)(walkLength(codeQueue[]))~": "~instruction.toString());
i++;
}
}
@ -812,10 +812,10 @@ public final class TypeChecker
{
/* Debugging */
string dbgHeader = "typeEnforce(t1="~t1.toString()~", v2="~v2.toString()~", attemptCoerce="~to!(string)(allowCoercion)~"): ";
gprintln(dbgHeader~"Entering");
DEBUG(dbgHeader~"Entering");
scope(exit)
{
gprintln(dbgHeader~"Leaving");
DEBUG(dbgHeader~"Leaving");
}
/* Extract the original types of `v2` */
@ -892,7 +892,7 @@ public final class TypeChecker
return true;
}
gprintln("isSameType("~to!(string)(type1)~","~to!(string)(type2)~"): "~to!(string)(same), DebugType.ERROR);
ERROR("isSameType("~to!(string)(type1)~","~to!(string)(type2)~"): "~to!(string)(same));
return same;
}
@ -1052,7 +1052,7 @@ public final class TypeChecker
// Then the actual literal will be `-<value>`
string negativeLiteral = "-"~theLiteral.getLiteralValue();
gprintln("Negated literal: "~negativeLiteral);
DEBUG("Negated literal: "~negativeLiteral);
// NOTE (X-platform): For cross-platform sake we should change the `long` to `ssize_t`
long literalValue = to!(long)(negativeLiteral);
@ -1151,7 +1151,7 @@ public final class TypeChecker
*/
private CastedValueInstruction attemptCoercion(Type toType, Value providedInstruction)
{
gprintln("VibeCheck?");
DEBUG("VibeCheck?");
/* Extract the type of the provided instruction */
Type providedType = providedInstruction.getInstrType();
@ -1179,7 +1179,7 @@ public final class TypeChecker
// We still need the component type to match the to-type's referred type
if(isSameType(stackArrCompType, toTypeReferred))
{
gprintln("Stack-array ('"~providedInstruction.toString()~"' coercion from type '"~providedType.getName()~"' to type of '"~toType.getName()~"' allowed :)");
DEBUG("Stack-array ('"~providedInstruction.toString()~"' coercion from type '"~providedType.getName()~"' to type of '"~toType.getName()~"' allowed :)");
// Return a cast instruction to the to-type
return new CastedValueInstruction(providedInstruction, toType);
@ -1241,7 +1241,7 @@ public final class TypeChecker
// If it is a LiteralValueFloat (support for issue #94)
else if(cast(LiteralValueFloat)providedInstruction)
{
gprintln("Coercion not yet supported for floating point literals", DebugType.ERROR);
ERROR("Coercion not yet supported for floating point literals");
assert(false);
}
// Unary operator (specifically with a minus)
@ -1289,14 +1289,14 @@ public final class TypeChecker
}
else
{
gprintln("Yo, 'fix me', just throw an exception thing ain't integral, too lazy to write it now", DebugType.ERROR);
ERROR("Yo, 'fix me', just throw an exception thing ain't integral, too lazy to write it now");
assert(false);
}
}
// If it is a negative LiteralValueFloat (floating-point literal)
else if(cast(LiteralValueFloat)operandInstr)
{
gprintln("Coercion not yet supported for floating point literals", DebugType.ERROR);
ERROR("Coercion not yet supported for floating point literals");
assert(false);
}
// If anything else is embedded
@ -1352,7 +1352,7 @@ public final class TypeChecker
}
else
{
gprintln("Mashallah why are we here? BECAUSE we should just use ze-value-based genral case!: "~providedInstruction.classinfo.toString());
ERROR("Mashallah why are we here? BECAUSE we should just use ze-value-based genral case!: "~providedInstruction.classinfo.toString());
throw new CoercionException(this, toType, providedType);
}
}
@ -1561,7 +1561,7 @@ public final class TypeChecker
public void typeCheckThing(DNode dnode)
{
gprintln("typeCheckThing(): "~dnode.toString());
DEBUG("typeCheckThing(): "~dnode.toString());
/* ExpressionDNodes */
if(cast(tlang.compiler.typecheck.dependency.expression.ExpressionDNode)dnode)
@ -1569,7 +1569,7 @@ public final class TypeChecker
tlang.compiler.typecheck.dependency.expression.ExpressionDNode expDNode = cast(tlang.compiler.typecheck.dependency.expression.ExpressionDNode)dnode;
Statement statement = expDNode.getEntity();
gprintln("Hdfsfdjfds"~to!(string)(statement));
DEBUG("Hdfsfdjfds"~to!(string)(statement));
/* Dependent on the type of Statement */
@ -1625,7 +1625,7 @@ public final class TypeChecker
{
FloatingLiteral floatLiteral = cast(FloatingLiteral)statement;
gprintln("We haven't sorted ouyt literal encoding for floating onts yet (null below hey!)", DebugType.ERROR);
ERROR("We haven't sorted ouyt literal encoding for floating onts yet (null below hey!)");
Type bruhType = null;
assert(bruhType);
@ -1641,13 +1641,13 @@ public final class TypeChecker
/* String literal */
else if(cast(StringExpression)statement)
{
gprintln("Typecheck(): String literal processing...");
DEBUG("Typecheck(): String literal processing...");
/**
* Add the char* type as string literals should be
* interned
*/
gprintln("Please implement strings", DebugType.ERROR);
ERROR("Please implement strings");
// assert(false);
// addType(getType(modulle, "char*"));
@ -1665,24 +1665,24 @@ public final class TypeChecker
else if(cast(VariableExpression)statement)
{
gprintln("Yaa, it's rewind time");
DEBUG("Yaa, it's rewind time");
auto g = cast(VariableExpression)statement;
assert(g);
/* FIXME: It would seem that g.getContext() is returning null, so within function body's context is not being set */
gprintln("VarExp: "~g.getName());
gprintln(g.getContext());
DEBUG("VarExp: "~g.getName());
DEBUG(g.getContext());
auto gVar = cast(TypedEntity)resolver.resolveBest(g.getContext().getContainer(), g.getName());
gprintln("gVar nullity?: "~to!(string)(gVar is null));
DEBUG("gVar nullity?: "~to!(string)(gVar is null));
/* TODO; Above crashes when it is a container, eish baba - from dependency generation with `TestClass.P.h` */
string variableName = resolver.generateName(this.program, gVar);
gprintln("VarName: "~variableName);
gprintln("Halo");
DEBUG("VarName: "~variableName);
DEBUG("Halo");
gprintln("Yaa, it's rewind time1: "~to!(string)(gVar.getType()));
gprintln("Yaa, it's rewind time2: "~to!(string)(gVar.getContext()));
DEBUG("Yaa, it's rewind time1: "~to!(string)(gVar.getType()));
DEBUG("Yaa, it's rewind time2: "~to!(string)(gVar.getContext()));
/* TODO: Above TYpedEntity check */
/* TODO: still wip the expresison parser */
@ -1690,7 +1690,7 @@ public final class TypeChecker
/* TODO: TYpe needs ansatz too `.updateName()` call */
Type variableType = getType(gVar.getContext().getContainer(), gVar.getType());
gprintln("Yaa, it's rewind time");
DEBUG("Yaa, it's rewind time");
/**
@ -1824,7 +1824,7 @@ public final class TypeChecker
else
{
// See issue #141: Binary Operators support for non-Integer types (https://deavmi.assigned.network/git/tlang/tlang/issues/141)
gprintln("FIXME: We need to add support for this, class equality, and others like floats", DebugType.ERROR);
ERROR("FIXME: We need to add support for this, class equality, and others like floats");
}
@ -1929,7 +1929,7 @@ public final class TypeChecker
/* If pointer dereference */
else if(unaryOperator == SymbolType.STAR)
{
gprintln("Type popped: "~to!(string)(expType));
DEBUG("Type popped: "~to!(string)(expType));
// Okay, so yes, we would pop `ptr`'s type as `int*` which is correct
// but now, we must a.) ensure that IS the case and b.)
@ -1962,7 +1962,7 @@ public final class TypeChecker
/* This should never occur */
else
{
gprintln("UnaryOperatorExpression: This should NEVER happen: "~to!(string)(unaryOperator), DebugType.ERROR);
ERROR("UnaryOperatorExpression: This should NEVER happen: "~to!(string)(unaryOperator));
assert(false);
}
@ -1976,7 +1976,7 @@ public final class TypeChecker
UnaryOpInstr addInst = new UnaryOpInstr(expInstr, unaryOperator);
gprintln("Made unaryop instr: "~to!(string)(addInst));
DEBUG("Made unaryop instr: "~to!(string)(addInst));
addInstr(addInst);
addInst.setInstrType(unaryOpType);
@ -2001,20 +2001,20 @@ public final class TypeChecker
/* TODO: Pass in FUnction, so we get function's body for calling too */
gprintln(format("funcCall.getName() %s", funcCall.getName()));
DEBUG(format("funcCall.getName() %s", funcCall.getName()));
FuncCallInstr funcCallInstr = new FuncCallInstr(funcCall.getName(), paremeters.length);
gprintln("Name of func call: "~func.getName(), DebugType.ERROR);
ERROR("Name of func call: "~func.getName());
/* If there are paremeters for this function (as per definition) */
if(!paremeters.length)
{
gprintln("No parameters for deez nuts: "~func.getName(), DebugType.ERROR);
ERROR("No parameters for deez nuts: "~func.getName());
}
/* Pop all args per type */
else
{
ulong parmCount = paremeters.length-1;
gprintln("Kachow: "~to!(string)(parmCount),DebugType.ERROR);
ERROR("Kachow: "~to!(string)(parmCount));
while(!isInstrEmpty())
{
@ -2027,8 +2027,8 @@ public final class TypeChecker
if(valueInstr && parmCount!=-1)
{
/* TODO: Determine type and match up */
gprintln("Yeah");
gprintln(valueInstr);
DEBUG("Yeah");
DEBUG(valueInstr);
Type argType = valueInstr.getInstrType();
// gprintln(argType);
@ -2066,7 +2066,7 @@ public final class TypeChecker
/* Add the instruction into the FunctionCallInstr */
funcCallInstr.setEvalInstr(parmCount, valueInstr);
gprintln(funcCallInstr.getEvaluationInstructions());
DEBUG(funcCallInstr.getEvaluationInstructions());
/* Decrement the parameter index (right-to-left, so move to left) */
parmCount--;
@ -2123,8 +2123,8 @@ public final class TypeChecker
else if(cast(CastedExpression)statement)
{
CastedExpression castedExpression = cast(CastedExpression)statement;
gprintln("Context: "~to!(string)(castedExpression.context));
gprintln("ParentOf: "~to!(string)(castedExpression.parentOf()));
DEBUG("Context: "~to!(string)(castedExpression.context));
DEBUG("ParentOf: "~to!(string)(castedExpression.parentOf()));
/* Extract the type that the cast is casting towards */
Type castToType = getType(castedExpression.context.container, castedExpression.getToType());
@ -2143,7 +2143,7 @@ public final class TypeChecker
/* Extract the type of the expression being casted */
Type typeBeingCasted = uncastedInstruction.getInstrType();
gprintln("TypeCast [FromType: "~to!(string)(typeBeingCasted)~", ToType: "~to!(string)(castToType)~"]");
DEBUG("TypeCast [FromType: "~to!(string)(typeBeingCasted)~", ToType: "~to!(string)(castToType)~"]");
printCodeQueue();
@ -2167,7 +2167,7 @@ public final class TypeChecker
Value indexToInstr = cast(Value)popInstr();
Type indexToType = indexToInstr.getInstrType();
assert(indexToType);
gprintln("ArrayIndex: Type of `indexToInstr`: "~indexToType.toString());
DEBUG("ArrayIndex: Type of `indexToInstr`: "~indexToType.toString());
/* Pop the index instruction (the index expression) */
Value indexInstr = cast(Value)popInstr();
@ -2192,7 +2192,7 @@ public final class TypeChecker
// TODO: Look up based on the name of the `FetchValueInstruction` (so if it is)
// ... AND if it refers to a stack array
bool isStackArray = isStackArrayIndex(indexToInstr);
gprintln("isStackArray (being indexed-on)?: "~to!(string)(isStackArray), DebugType.ERROR);
ERROR("isStackArray (being indexed-on)?: "~to!(string)(isStackArray));
@ -2206,10 +2206,10 @@ public final class TypeChecker
{
StackArray stackArray = cast(StackArray)indexToType;
accessType = stackArray.getComponentType();
gprintln("ArrayIndex: Stack-array access");
DEBUG("ArrayIndex: Stack-array access");
gprintln("<<<<<<<< STCK ARRAY INDEX CODE GEN >>>>>>>>", DebugType.ERROR);
ERROR("<<<<<<<< STCK ARRAY INDEX CODE GEN >>>>>>>>");
@ -2223,9 +2223,9 @@ public final class TypeChecker
stackArrayIndexInstr.setInstrType(accessType);
stackArrayIndexInstr.setContext(arrayIndex.context);
gprintln("IndexTo: "~indexToInstr.toString(), DebugType.ERROR);
gprintln("Index: "~indexInstr.toString(), DebugType.ERROR);
gprintln("Stack ARray type: "~stackArray.getComponentType().toString(), DebugType.ERROR);
ERROR("IndexTo: "~indexToInstr.toString());
ERROR("Index: "~indexInstr.toString());
ERROR("Stack ARray type: "~stackArray.getComponentType().toString());
@ -2235,7 +2235,7 @@ public final class TypeChecker
/* Array type `<componentType>[]` */
else if(cast(Pointer)indexToType)
{
gprintln("ArrayIndex: Pointer access");
DEBUG("ArrayIndex: Pointer access");
Pointer pointer = cast(Pointer)indexToType;
accessType = pointer.getReferredType();
@ -2256,7 +2256,7 @@ public final class TypeChecker
{
// TODO: Throw an error here
// throw new TypeMismatchException()
gprintln("Indexing to an entity other than a stack array or pointer!", DebugType.ERROR);
ERROR("Indexing to an entity other than a stack array or pointer!");
assert(false);
}
@ -2264,16 +2264,16 @@ public final class TypeChecker
// TODO: context (arrayIndex)
gprintln("ArrayIndex: [toInstr: "~indexToInstr.toString()~", indexInstr: "~indexInstr.toString()~"]");
DEBUG("ArrayIndex: [toInstr: "~indexToInstr.toString()~", indexInstr: "~indexInstr.toString()~"]");
gprintln("Array index not yet supported", DebugType.ERROR);
ERROR("Array index not yet supported");
// assert(false);
addInstr(generatedInstruction);
}
else
{
gprintln("This ain't it chief", DebugType.ERROR);
ERROR("This ain't it chief");
assert(false);
}
}
@ -2287,7 +2287,7 @@ public final class TypeChecker
VariableAssignmentNode varAssignDNode = cast(tlang.compiler.typecheck.dependency.variables.VariableAssignmentNode)dnode;
Variable assignTo = (cast(VariableAssignment)varAssignDNode.getEntity()).getVariable();
variableName = resolver.generateName(this.program, assignTo);
gprintln("VariableAssignmentNode: "~to!(string)(variableName));
DEBUG("VariableAssignmentNode: "~to!(string)(variableName));
/* Get the Context of the Variable Assigmnent */
Context variableAssignmentContext = (cast(VariableAssignment)varAssignDNode.getEntity()).context;
@ -2311,16 +2311,16 @@ public final class TypeChecker
assert(instr);
Value valueInstr = cast(Value)instr;
assert(valueInstr);
gprintln("VaribleAssignmentNode(): Just popped off valInstr?: "~to!(string)(valueInstr), DebugType.WARNING);
WARN("VaribleAssignmentNode(): Just popped off valInstr?: "~to!(string)(valueInstr));
Type rightHandType = valueInstr.getInstrType();
gprintln("RightHandType (assignment): "~to!(string)(rightHandType));
DEBUG("RightHandType (assignment): "~to!(string)(rightHandType));
gprintln(valueInstr is null);/*TODO: FUnc calls not implemented? Then is null for simple_1.t */
DEBUG(valueInstr is null);/*TODO: FUnc calls not implemented? Then is null for simple_1.t */
VariableAssignmentInstr varAssInstr = new VariableAssignmentInstr(variableName, valueInstr);
varAssInstr.setContext(variableAssignmentContext);
// NOTE: No need setting `varAssInstr.type` as the type if in `getEmbeddedInstruction().type`
@ -2344,10 +2344,10 @@ public final class TypeChecker
* Emit a variable declaration instruction
*/
Variable variablePNode = cast(Variable)dnode.getEntity();
gprintln("HELLO FELLA");
DEBUG("HELLO FELLA");
string variableName = resolver.generateName(this.program, variablePNode);
gprintln("HELLO FELLA (name): "~variableName);
DEBUG("HELLO FELLA (name): "~variableName);
Type variableDeclarationType = getType(variablePNode.context.container, variablePNode.getType());
@ -2400,7 +2400,7 @@ public final class TypeChecker
/* TODO: Get the STatement */
Statement statement = dnode.getEntity();
gprintln("Generic DNode typecheck(): Begin (examine: "~to!(string)(dnode)~" )");
DEBUG("Generic DNode typecheck(): Begin (examine: "~to!(string)(dnode)~" )");
/* VariableAssignmentStdAlone */
@ -2565,8 +2565,8 @@ public final class TypeChecker
if(branch.hasCondition())
{
Instruction instr = popInstr();
gprintln("BranchIdx: "~to!(string)(branchIdx));
gprintln("Instr is: "~to!(string)(instr));
DEBUG("BranchIdx: "~to!(string)(branchIdx));
DEBUG("Instr is: "~to!(string)(instr));
branchConditionInstr = cast(Value)instr;
assert(branchConditionInstr);
}
@ -2582,7 +2582,7 @@ public final class TypeChecker
Instruction bodyInstr = tailPopInstr();
bodyInstructions~=bodyInstr;
gprintln("tailPopp'd("~to!(string)(i)~"/"~to!(string)(bodyCount-1)~"): "~to!(string)(bodyInstr));
DEBUG("tailPopp'd("~to!(string)(i)~"/"~to!(string)(bodyCount-1)~"): "~to!(string)(bodyInstr));
i++;
}
@ -2615,7 +2615,7 @@ public final class TypeChecker
ifStatementInstruction.setContext(ifStatement.getContext());
addInstrB(ifStatementInstruction);
gprintln("If!");
DEBUG("If!");
}
/**
* While loop (WhileLoop)
@ -2627,7 +2627,7 @@ public final class TypeChecker
// FIXME: Do-while loops are still being considered in terms of dependency construction
if(whileLoop.isDoWhile)
{
gprintln("Still looking at dependency construction in this thing (do while loops )");
DEBUG("Still looking at dependency construction in this thing (do while loops )");
assert(false);
}
@ -2681,7 +2681,7 @@ public final class TypeChecker
/* Calculate the number of instructions representing the body to tailPopInstr() */
ulong bodyTailPopNumber = forLoop.getBranch().getStatements().length;
gprintln("bodyTailPopNumber: "~to!(string)(bodyTailPopNumber));
DEBUG("bodyTailPopNumber: "~to!(string)(bodyTailPopNumber));
/* Pop off the body instructions, then reverse final list */
Instruction[] bodyInstructions;
@ -2719,7 +2719,7 @@ public final class TypeChecker
{
Branch branch = cast(Branch)statement;
gprintln("Look at that y'all, cause this is it: "~to!(string)(branch));
DEBUG("Look at that y'all, cause this is it: "~to!(string)(branch));
}
/**
* Dereferencing pointer assignment statement (PointerDereferenceAssignment)
@ -2778,7 +2778,7 @@ public final class TypeChecker
{
ArrayAssignment arrayAssignment = cast(ArrayAssignment)statement;
gprintln("Note, dependency processing of ArrayAssignment is not yet implemented, recall seggy", DebugType.ERROR);
ERROR("Note, dependency processing of ArrayAssignment is not yet implemented, recall seggy");
printCodeQueue();
// TODO: We need to implement this, what should we put here
@ -2801,9 +2801,9 @@ public final class TypeChecker
Value arrayRefInstruction = cast(Value)popInstr();
Value assignmentInstr = cast(Value)popInstr();
gprintln("indexInstruction: "~indexInstruction.toString(), DebugType.WARNING);
gprintln("arrayRefInstruction: "~arrayRefInstruction.toString(), DebugType.WARNING);
gprintln("assignmentInstr: "~assignmentInstr.toString(), DebugType.WARNING);
WARN("indexInstruction: "~indexInstruction.toString());
WARN("arrayRefInstruction: "~arrayRefInstruction.toString());
WARN("assignmentInstr: "~assignmentInstr.toString());
/* Final Instruction generated */
@ -2813,14 +2813,14 @@ public final class TypeChecker
// TODO: We need to add a check here for if the `arrayRefInstruction` is a name
// ... and if so if its type is `StackArray`, else we will enter the wrong thing below
bool isStackArray = isStackArrayIndex(arrayRefInstruction);
gprintln("isStackArray (being assigned to)?: "~to!(string)(isStackArray), DebugType.ERROR);
ERROR("isStackArray (being assigned to)?: "~to!(string)(isStackArray));
/* The type of what is being indexed on */
Type indexingOnType = arrayRefInstruction.getInstrType();
gprintln("Indexing-on type: "~indexingOnType.toString(), DebugType.WARNING);
gprintln("Indexing-on type: "~indexingOnType.classinfo.toString(), DebugType.WARNING);
WARN("Indexing-on type: "~indexingOnType.toString());
WARN("Indexing-on type: "~indexingOnType.classinfo.toString());
/* Stack-array type `<compnentType>[<size>]` */
@ -2843,8 +2843,8 @@ public final class TypeChecker
Variable arrayVariable = cast(Variable)resolver.resolveBest(stackVarContext.container, arrayFetch.varName);
Type arrayVariableDeclarationType = getType(stackVarContext.container, arrayVariable.getType());
gprintln("TODO: We are still working on generating an assignment instruction for assigning to stack arrays", DebugType.ERROR);
gprintln("TODO: Implement instruction generation for stack-based arrays", DebugType.ERROR);
ERROR("TODO: We are still working on generating an assignment instruction for assigning to stack arrays");
ERROR("TODO: Implement instruction generation for stack-based arrays");
// TODO: Use StackArrayIndexAssignmentInstruction
StackArrayIndexAssignmentInstruction stackAssignmentInstr = new StackArrayIndexAssignmentInstruction(arrayFetch.varName, indexInstruction, assignmentInstr);
@ -2858,8 +2858,8 @@ public final class TypeChecker
stackAssignmentInstr.setContext(arrayAssignment.getContext());
gprintln(">>>>> "~stackAssignmentInstr.toString());
gprintln("Assigning into this array: "~to!(string)(assignmentInstr));
DEBUG(">>>>> "~stackAssignmentInstr.toString());
DEBUG("Assigning into this array: "~to!(string)(assignmentInstr));
// assert(false);
}
/* Array type `<componentType>[]` */
@ -2877,7 +2877,7 @@ public final class TypeChecker
ArrayIndexInstruction arrIndex = new ArrayIndexInstruction(arrayRefInstruction, indexInstruction);
ArrayIndexAssignmentInstruction arrDerefAssInstr = new ArrayIndexAssignmentInstruction(arrIndex, assignmentInstr);
gprintln("TODO: Implement instruction generation for pointer-based arrays", DebugType.ERROR);
ERROR("TODO: Implement instruction generation for pointer-based arrays");
generatedInstruction = arrDerefAssInstr;
// assert(false);
@ -2897,7 +2897,7 @@ public final class TypeChecker
/* Case of no matches */
else
{
gprintln("NO MATCHES FIX ME FOR: "~to!(string)(statement), DebugType.WARNING);
WARN("NO MATCHES FIX ME FOR: "~to!(string)(statement));
}
}
@ -2912,7 +2912,7 @@ public final class TypeChecker
private void doTypeCheck(DNode[] actionList)
{
/* Print the action list provided to us */
gprintln("Action list: "~to!(string)(actionList));
DEBUG("Action list: "~to!(string)(actionList));
/**
* Loop through each dependency-node in the action list
@ -2920,12 +2920,12 @@ public final class TypeChecker
*/
foreach(DNode node; actionList)
{
gprintln("Process: "~to!(string)(node));
DEBUG("Process: "~to!(string)(node));
/* Print the code queue each time */
gprintln("sdfhjkhdsfjhfdsj 1");
DEBUG("sdfhjkhdsfjhfdsj 1");
printCodeQueue();
gprintln("sdfhjkhdsfjhfdsj 2");
DEBUG("sdfhjkhdsfjhfdsj 2");
/* Type-check/code-gen this node */
typeCheckThing(node);
@ -2937,11 +2937,11 @@ public final class TypeChecker
/* Print the init queue */
gprintln("<<<<< FINAL ALLOCATE QUEUE >>>>>");
DEBUG("<<<<< FINAL ALLOCATE QUEUE >>>>>");
printInitQueue();
/* Print the code queue */
gprintln("<<<<< FINAL CODE QUEUE >>>>>");
DEBUG("<<<<< FINAL CODE QUEUE >>>>>");
printCodeQueue();
}
@ -3070,7 +3070,7 @@ public final class TypeChecker
{
/* Get the current class's parent */
string[] parentClasses = clazz.getInherit();
gprintln("Class: " ~ clazz.getName() ~ ": ParentInheritList: " ~ to!(
DEBUG("Class: " ~ clazz.getName() ~ ": ParentInheritList: " ~ to!(
string)(parentClasses));
/* Try resolve all of these */
@ -3081,7 +3081,7 @@ public final class TypeChecker
/* Check if the name is rooted */
string[] dotPath = split(parent, '.');
gprintln(dotPath.length);
DEBUG(dotPath.length);
/* Resolve the name */
namedEntity = resolver.resolveBest(c, parent);
@ -3196,7 +3196,7 @@ public final class TypeChecker
* Get all Entities of the Container with order Clazz, Function, Variable
*/
Entity[] entities = getContainerMembers(c);
gprintln("checkContainer(C): " ~ to!(string)(entities));
DEBUG("checkContainer(C): " ~ to!(string)(entities));
foreach (Entity entity; entities)
{
@ -3237,7 +3237,7 @@ public final class TypeChecker
string fullPath = resolver.generateName(this.program, entity);
// (MODMAN) This will need to be fixed (anchored at the Program-level)
string containerNameFullPath = resolver.generateName(this.program, containerEntity);
gprintln("Entity \"" ~ fullPath
DEBUG("Entity \"" ~ fullPath
~ "\" is allowed to be defined within container \""
~ containerNameFullPath ~ "\"");
@ -3464,7 +3464,7 @@ public final class TypeChecker
*/
foreach (Clazz clazz; classTypes)
{
gprintln("Check recursive " ~ to!(string)(clazz), DebugType.WARNING);
WARN("Check recursive " ~ to!(string)(clazz));
/* Check the current class's types within */
checkClassNames(clazz);

View File

@ -302,7 +302,7 @@ public class DNode
markCompleted();
/* TODO: I think using `isDone` we can linearise */
gprintln("Done/Not-done?: "~to!(string)(isDone));
DEBUG("Done/Not-done?: "~to!(string)(isDone));
// TODO: What is this for and do we even need it? See issue #41 Problem 5
if(isDone)
@ -594,8 +594,8 @@ public class DNodeGenerator
{
ExpressionDNode dnode = poolT!(ExpressionDNode, Expression)(exp);
gprintln("expressionPass(Exp): Processing "~exp.toString(), DebugType.WARNING);
gprintln("expressionPass(Exp): Context coming in "~to!(string)(context));
WARN("expressionPass(Exp): Processing "~exp.toString());
DEBUG("expressionPass(Exp): Context coming in "~to!(string)(context));
/* TODO: Add pooling */
@ -614,7 +614,7 @@ public class DNodeGenerator
{
/* TODO: Implement argument expression dependency */
FunctionCall funcCall = cast(FunctionCall)exp;
gprintln("FuncCall: "~funcCall.getName());
DEBUG("FuncCall: "~funcCall.getName());
/* TODO: We need to fetch the cached function definition here and call it */
Entity funcEntity = resolver.resolveBest(context.container, funcCall.getName());
@ -689,7 +689,7 @@ public class DNodeGenerator
expect("Only class-type may be used with `new`");
assert(false);
}
gprintln("King of the castle");
DEBUG("King of the castle");
}
else
{
@ -791,7 +791,7 @@ public class DNodeGenerator
FuncDecNode funcDecNode = poolT!(FuncDecNode, Function)(funcHandle);
dnode.needs(funcDecNode);
gprintln("Muh function handle: "~namedEntity.toString(), DebugType.WARNING);
WARN("Muh function handle: "~namedEntity.toString());
}
else
{
@ -977,7 +977,7 @@ public class DNodeGenerator
// dnode.needs()
gprintln("Interesting", DebugType.ERROR);
ERROR("Interesting");
}
@ -1088,20 +1088,20 @@ public class DNodeGenerator
else
{
// TODO: Add more advanced handling here
gprintln("Advanced component types l;ike arrays of arrays or arrays of classes etc not yet supported", DebugType.ERROR);
ERROR("Advanced component types l;ike arrays of arrays or arrays of classes etc not yet supported");
assert(false);
}
gprintln("Arrays (and these are stack arrays) are not yet supported", DebugType.ERROR);
ERROR("Arrays (and these are stack arrays) are not yet supported");
// assert(false);
}
/* Anything else */
else
{
/* This should never happen */
gprintln(variableType);
gprintln(variableType.classinfo);
gprintln("#ThisShouldNeverHappen Fault: A variable declaration with a kind-of type we don't know", DebugType.ERROR);
DEBUG(variableType);
DEBUG(variableType.classinfo);
ERROR("#ThisShouldNeverHappen Fault: A variable declaration with a kind-of type we don't know");
assert(false);
}
@ -1138,14 +1138,14 @@ public class DNodeGenerator
vAsStdAl.setContext(context);
/* TODO: CHeck avriable name even */
gprintln("YEAST ENJOYER");
DEBUG("YEAST ENJOYER");
// FIXME: The below assert fails for function definitions trying to refer to global values
// as a reoslveBest (up) is needed. We should firstly check if within fails, if so,
// resolveBest, if that fails, then it is an error (see #46)
assert(tc.getResolver().resolveBest(c, vAsStdAl.getVariableName()));
gprintln("YEAST ENJOYER");
DEBUG("YEAST ENJOYER");
Variable variable = cast(Variable)tc.getResolver().resolveBest(c, vAsStdAl.getVariableName());
assert(variable);
@ -1209,7 +1209,7 @@ public class DNodeGenerator
gprintln("Please implement array assignment dependency generation", DebugType.ERROR);
ERROR("Please implement array assignment dependency generation");
// assert(false);
return arrayAssDerefDNode;
@ -1226,7 +1226,7 @@ public class DNodeGenerator
func.context = context;
/* Add funtion definition */
gprintln("Hello"); // TODO: Check `root`, just use findContainerOfType
DEBUG("Hello"); // TODO: Check `root`, just use findContainerOfType
// Module owner = cast(Module)tc.getResolver().findContainerOfType(Module.classinfo, func));
this.funcDefStore.addFunctionDef(cast(Module)root.entity, func);
@ -1288,9 +1288,9 @@ public class DNodeGenerator
branchDNode.needs(branchConditionDNode);
}
gprintln("branch parentOf(): "~to!(string)(branch.parentOf()));
DEBUG("branch parentOf(): "~to!(string)(branch.parentOf()));
assert(branch.parentOf());
gprintln("branch generalPass(context="~to!(string)(context.getContainer())~")");
DEBUG("branch generalPass(context="~to!(string)(context.getContainer())~")");
// When generalPass()'ing a branch's body we don't want to pass in `context`
// as that is containing the branch container and hence we skip anything IN the
@ -1320,7 +1320,7 @@ public class DNodeGenerator
// Extract the branch (body Statement[] + condition)
Branch whileBranch = whileLoopStmt.getBranch();
DNode branchDNode = pool(whileBranch);
gprintln("Branch: "~to!(string)(whileBranch));
DEBUG("Branch: "~to!(string)(whileBranch));
// If this is a while-loop
if(!whileLoopStmt.isDoWhile)
@ -1445,7 +1445,7 @@ public class DNodeGenerator
discardStatement.setContext(context);
DNode discardStatementDNode = pool(discardStatement);
gprintln("Implement discard statement!", DebugType.ERROR);
ERROR("Implement discard statement!");
/* Pass the expression */
Expression discardExpression = discardStatement.getExpression();
@ -1474,7 +1474,7 @@ public class DNodeGenerator
// It MUST be if we are processing it in `generalPass()`
assert(funcCall.isStatementLevelFuncCall());
gprintln("Function calls (at statement level)", DebugType.INFO);
INFO("Function calls (at statement level)");
// The FunctionCall is an expression, so to get a DNode from it `expressionPass()` it
DNode funcCallDNode = expressionPass(funcCall, context);
@ -1537,7 +1537,7 @@ public class DNodeGenerator
*/
foreach(Statement entity; entities)
{
gprintln("generalPass(): Processing entity: "~entity.toString());
DEBUG("generalPass(): Processing entity: "~entity.toString());
Entity ent = cast(Entity)entity;
// NOTE: COme back to and re-enable when this makes sense (IF it even needs to be here)
@ -1553,7 +1553,7 @@ public class DNodeGenerator
DNode statementDNode = generalStatement(c, context, entity);
if(statementDNode is null)
{
gprintln("Not adding dependency '"~to!(string)(statementDNode)~"' as it is null");
DEBUG("Not adding dependency '"~to!(string)(statementDNode)~"' as it is null");
}
else
{
@ -1591,12 +1591,12 @@ public class DNodeGenerator
/* Get a DNode for the Class */
ClassStaticNode classDNode = poolClassStatic(clazz);
gprintln("classPassStatic(): Static init check for?: "~to!(string)(clazz));
DEBUG("classPassStatic(): Static init check for?: "~to!(string)(clazz));
/* Make sure we are static */
if(clazz.getModifierType()!=InitScope.STATIC)
{
gprintln("classPassStatic(): Not static class", DebugType.ERROR);
ERROR("classPassStatic(): Not static class");
assert(false);
}

View File

@ -53,7 +53,7 @@ public class MetaProcessor
foreach(Statement curStmt; stmts)
{
gprintln("MetaProcessor: Examining AST node '"~curStmt.toString()~"'...");
DEBUG("MetaProcessor: Examining AST node '"~curStmt.toString()~"'...");
// Perform replacement of all type alises to concrete types, such as `size_t`
doTypeAlias(container, curStmt);
@ -66,7 +66,7 @@ public class MetaProcessor
{
MStatementSearchable searchableStmt = cast(MStatementSearchable)curStmt;
Statement[] foundStmts = searchableStmt.search(FunctionCall.classinfo);
gprintln("Nah fr");
DEBUG("Nah fr");
foreach(Statement curFoundStmt; foundStmts)
{
@ -74,7 +74,7 @@ public class MetaProcessor
if(curFuncCall.getName() == "sizeof")
{
gprintln("Elo");
DEBUG("Elo");
Expression[] arguments = curFuncCall.getCallArguments();
if(arguments.length == 1)
{
@ -83,7 +83,7 @@ public class MetaProcessor
{
string typeName = potentialIdentExp.getName();
IntegerLiteral replacementStmt = sizeOf_Literalize(typeName);
gprintln("sizeof: Replace '"~curFoundStmt.toString()~"' with '"~replacementStmt.toString()~"'");
DEBUG("sizeof: Replace '"~curFoundStmt.toString()~"' with '"~replacementStmt.toString()~"'");
/* Traverse down from the `Container` we are process()'ing and apply the replacement */
MStatementReplaceable containerRepl = cast(MStatementReplaceable)container;
@ -92,13 +92,13 @@ public class MetaProcessor
else
{
// TODO: Throw an exception here that an ident_type should be present as the argument
gprintln("The argument to `sizeof` should be an ident", DebugType.ERROR);
ERROR("The argument to `sizeof` should be an ident");
}
}
else
{
// TODO: Throw an exception here as only 1 argument is allowed
gprintln("To use the `sizeof` macro you require a single argument to be passed to it", DebugType.ERROR);
ERROR("To use the `sizeof` macro you require a single argument to be passed to it");
}
}
}
@ -194,7 +194,7 @@ public class MetaProcessor
{
// Determine the concrete type
string concereteType = getConcreteType(identName);
gprintln("Found type alias '"~identName~"' which concretely is '"~concereteType~"'");
DEBUG("Found type alias '"~identName~"' which concretely is '"~concereteType~"'");
// Replace with concrete type
container.replace(identExp, new IdentExpression(concereteType));

View File

@ -227,17 +227,17 @@ public final class Resolver
do
{
gprintln
DEBUG
(
format("c isdecsenat: %s", c)
);
gprintln
DEBUG
(
format("currentEntity: %s", currentEntity)
);
Container parentOfCurrent = currentEntity.parentOf();
gprintln
DEBUG
(
format("currentEntity(parent): %s", parentOfCurrent)
);
@ -283,7 +283,7 @@ public final class Resolver
*/
public void resolveWithin(Container currentContainer, Predicate!(Entity) predicate, ref Entity[] collection)
{
gprintln
DEBUG
(
format
(
@ -292,7 +292,7 @@ public final class Resolver
)
);
Statement[] statements = currentContainer.getStatements();
gprintln
DEBUG
(
format
(
@ -332,7 +332,7 @@ public final class Resolver
{
Entity[] foundEnts;
resolveWithin(currentContainer, predicate, foundEnts);
gprintln(format("foundEnts: %s", foundEnts));
DEBUG(format("foundEnts: %s", foundEnts));
return foundEnts.length ? foundEnts[0] : null;
}
@ -358,7 +358,7 @@ public final class Resolver
bool nameMatch(Entity entity)
{
bool result = cmp(entity.getName(), nameToMatch) == 0;
gprintln(format("nameMatch(left=%s, right=%s) result: %s", nameToMatch, entity.getName(), result));
DEBUG(format("nameMatch(left=%s, right=%s) result: %s", nameToMatch, entity.getName(), result));
return result;
}
@ -386,7 +386,7 @@ public final class Resolver
public Entity resolveWithin(Container currentContainer, string name)
{
// Apply search with custom name-based matching predicate
gprintln(format("resolveWithin(cntnr=%s, name=%s) entering with predicate", currentContainer, name));
DEBUG(format("resolveWithin(cntnr=%s, name=%s) entering with predicate", currentContainer, name));
return resolveWithin(currentContainer, derive_nameMatch(name));
}
@ -414,7 +414,7 @@ public final class Resolver
public Entity resolveUp(Container currentContainer, Predicate!(Entity) predicate)
{
/* Try to find the Entity within the current Container */
gprintln
DEBUG
(
format
(
@ -424,7 +424,7 @@ public final class Resolver
)
);
Entity entity = resolveWithin(currentContainer, predicate);
gprintln
DEBUG
(
format
(
@ -447,7 +447,7 @@ public final class Resolver
*/
else if(cast(Program)currentContainer)
{
gprintln
DEBUG
(
format
(
@ -469,7 +469,7 @@ public final class Resolver
assert(cast(Entity)currentContainer);
Container possibleParent = (cast(Entity) currentContainer).parentOf();
gprintln
DEBUG
(
format
(
@ -479,7 +479,7 @@ public final class Resolver
currentContainer
)
);
gprintln
DEBUG
(
format
(
@ -498,7 +498,7 @@ public final class Resolver
/* If the current container has no parent container */
else
{
gprintln
DEBUG
(
format
(
@ -597,7 +597,7 @@ public final class Resolver
*/
public Entity resolveBest(Container c, string name)
{
gprintln
DEBUG
(
format
(
@ -615,7 +615,7 @@ public final class Resolver
// otherwise
if(cast(Program)c)
{
gprintln
DEBUG
(
format
(
@ -640,7 +640,7 @@ public final class Resolver
string moduleRequested = name;
foreach(Module curMod; programC.getModules())
{
gprintln
DEBUG
(
format
(
@ -654,10 +654,9 @@ public final class Resolver
}
}
gprintln
ERROR
(
"resolveBest(moduleHoritontal) We found nothing and will not go down from Program to any Module[]. You probably did a rooted search on the Program for a bnon-Module entity, didn't ya?",
DebugType.ERROR
"resolveBest(moduleHoritontal) We found nothing and will not go down from Program to any Module[]. You probably did a rooted search on the Program for a bnon-Module entity, didn't ya?"
);
return null;
}
@ -672,7 +671,7 @@ public final class Resolver
foreach(Module curMod; programC.getModules())
{
gprintln
DEBUG
(
format
(
@ -698,14 +697,13 @@ public final class Resolver
// If we could not find the module
else
{
gprintln
ERROR
(
format
(
"resolveBest(Program root): Could not find module '%s' for ANCHORED access",
moduleRequested
),
DebugType.ERROR
)
);
return null;
}
@ -724,7 +722,7 @@ public final class Resolver
*/
Entity containerEntity = cast(Entity) c;
assert(containerEntity);
gprintln
DEBUG
(
format
(
@ -816,7 +814,7 @@ public final class Resolver
{
if(cmp(curModule.getName(), path[0]) == 0)
{
gprintln
DEBUG
(
format
(
@ -837,18 +835,18 @@ public final class Resolver
if (con)
{
gprintln("fooook");
DEBUG("fooook");
return resolveBest(con, name);
}
else
{
gprintln("also a kill me");
DEBUG("also a kill me");
return null;
}
}
else
{
gprintln("killl me");
DEBUG("killl me");
return null;
}
}
@ -867,7 +865,7 @@ public final class Resolver
*/
public Container findContainerOfType(TypeInfo_Class containerType, Statement startingNode)
{
gprintln
DEBUG
(
format
(
@ -875,7 +873,7 @@ public final class Resolver
startingNode
)
);
gprintln
DEBUG
(
format
(
@ -900,7 +898,7 @@ public final class Resolver
// If not, swim up to the parent
else
{
gprintln
DEBUG
(
format
(