diff --git a/source/tlang/compiler/codegen/instruction.d b/source/tlang/compiler/codegen/instruction.d index 7e92597a..0ceb9f31 100644 --- a/source/tlang/compiler/codegen/instruction.d +++ b/source/tlang/compiler/codegen/instruction.d @@ -74,20 +74,22 @@ public final class VariableDeclaration : StorageDeclaration /* Length */ public byte length; + /* Type of the variable being declared */ + public string varType; + //TODO: This must take in type information - this(string varName, byte len) + this(string varName, byte len, string varType) { this.varName = varName; this.length = len; + this.varType = varType; addInfo = "varName: "~varName; } public override string emit() { - // TODO: This should change - // TODO: We should be having a type pushed into this thing (lookup via Context?) - string type = ""; + string type = varType; string fullEntityName = context.tc.getResolver().generateName(context.getContainer(), context.tc.getResolver().resolveBest(context.getContainer(), varName)); return type~" "~fullEntityName~";"; diff --git a/source/tlang/compiler/typecheck/core.d b/source/tlang/compiler/typecheck/core.d index 6aa98a4c..d7491619 100644 --- a/source/tlang/compiler/typecheck/core.d +++ b/source/tlang/compiler/typecheck/core.d @@ -655,7 +655,7 @@ public final class TypeChecker Variable variablePNode = cast(Variable)dnode.getEntity(); gprintln("HELLO FELLA"); string variableName = resolver.generateName(modulle, variablePNode); - VariableDeclaration varDecInstr = new VariableDeclaration(variableName, 4); + VariableDeclaration varDecInstr = new VariableDeclaration(variableName, 4, variablePNode.getType()); /* NEW CODE (9th November 2021) Set the context */ varDecInstr.context = variablePNode.context;