TypeChecker
- Pass in the type of the variable being declared to the `VariableDeclaration` instruction VariableDeclaration - Emitted code now contains the type of the variable being declared
This commit is contained in:
parent
c39bc20d1c
commit
57a9e86d5f
|
@ -74,20 +74,22 @@ public final class VariableDeclaration : StorageDeclaration
|
||||||
/* Length */
|
/* Length */
|
||||||
public byte length;
|
public byte length;
|
||||||
|
|
||||||
|
/* Type of the variable being declared */
|
||||||
|
public string varType;
|
||||||
|
|
||||||
//TODO: This must take in type information
|
//TODO: This must take in type information
|
||||||
this(string varName, byte len)
|
this(string varName, byte len, string varType)
|
||||||
{
|
{
|
||||||
this.varName = varName;
|
this.varName = varName;
|
||||||
this.length = len;
|
this.length = len;
|
||||||
|
this.varType = varType;
|
||||||
|
|
||||||
addInfo = "varName: "~varName;
|
addInfo = "varName: "~varName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string emit()
|
public override string emit()
|
||||||
{
|
{
|
||||||
// TODO: This should change
|
string type = varType;
|
||||||
// TODO: We should be having a type pushed into this thing (lookup via Context?)
|
|
||||||
string type = "<type: TODO>";
|
|
||||||
string fullEntityName = context.tc.getResolver().generateName(context.getContainer(), context.tc.getResolver().resolveBest(context.getContainer(), varName));
|
string fullEntityName = context.tc.getResolver().generateName(context.getContainer(), context.tc.getResolver().resolveBest(context.getContainer(), varName));
|
||||||
|
|
||||||
return type~" "~fullEntityName~";";
|
return type~" "~fullEntityName~";";
|
||||||
|
|
|
@ -655,7 +655,7 @@ public final class TypeChecker
|
||||||
Variable variablePNode = cast(Variable)dnode.getEntity();
|
Variable variablePNode = cast(Variable)dnode.getEntity();
|
||||||
gprintln("HELLO FELLA");
|
gprintln("HELLO FELLA");
|
||||||
string variableName = resolver.generateName(modulle, variablePNode);
|
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 */
|
/* NEW CODE (9th November 2021) Set the context */
|
||||||
varDecInstr.context = variablePNode.context;
|
varDecInstr.context = variablePNode.context;
|
||||||
|
|
Loading…
Reference in New Issue