mirror of https://github.com/tbklang/tlang.git
LiteralValue, LiteralValueFloat
- Made the `data` field `private` and now accessible through a call to `string getLiteralValue()` UnaryOpInstr - Use `Value` instead of `Instruction` for unary operator instructions DGen - Switched to using `getLiteralValue()` where required due to the aforementioned reasons
This commit is contained in:
parent
de37eeec8c
commit
c1ee7d06ba
|
@ -170,6 +170,7 @@ public final class DCodeEmitter : CodeEmitter
|
|||
if(typedEntityVariable.getAssignment())
|
||||
{
|
||||
Value varAssInstr = varDecInstr.getAssignmentInstr();
|
||||
gprintln("VarDec(with assignment): My assignment type is: "~varAssInstr.getInstrType().getName());
|
||||
|
||||
// Generate the code to emit
|
||||
return typeTransform(cast(Type)varDecInstr.varType)~" "~renamedSymbol~" = "~transform(varAssInstr)~";";
|
||||
|
@ -191,7 +192,7 @@ public final class DCodeEmitter : CodeEmitter
|
|||
|
||||
LiteralValue literalValueInstr = cast(LiteralValue)instruction;
|
||||
|
||||
return to!(string)(literalValueInstr.data);
|
||||
return to!(string)(literalValueInstr.getLiteralValue());
|
||||
}
|
||||
/* FetchValueVar */
|
||||
else if(cast(FetchValueVar)instruction)
|
||||
|
|
|
@ -140,7 +140,7 @@ public final class FetchValueVar : Value
|
|||
public final class LiteralValue : Value
|
||||
{
|
||||
/* Data */
|
||||
public string data;
|
||||
private string data;
|
||||
|
||||
this(string data, Type type)
|
||||
{
|
||||
|
@ -150,6 +150,11 @@ public final class LiteralValue : Value
|
|||
addInfo = "Data: "~to!(string)(data)~", Type: "~to!(string)(type);
|
||||
}
|
||||
|
||||
public string getLiteralValue()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
public override string toString()
|
||||
{
|
||||
return produceToStrEnclose("Data: "~to!(string)(data)~", Type: "~to!(string)(type));
|
||||
|
@ -159,7 +164,7 @@ public final class LiteralValue : Value
|
|||
public final class LiteralValueFloat : Value
|
||||
{
|
||||
/* Data */
|
||||
public string data; /* TODO: Is this best way to store? Consirring floats/doubles */
|
||||
private string data;
|
||||
|
||||
this(string data, Type type)
|
||||
{
|
||||
|
@ -169,6 +174,11 @@ public final class LiteralValueFloat : Value
|
|||
addInfo = "Data: "~to!(string)(data)~", Type: "~to!(string)(type);
|
||||
}
|
||||
|
||||
public string getLiteralValue()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
public override string toString()
|
||||
{
|
||||
return produceToStrEnclose("Data: "~to!(string)(data)~", Type: "~to!(string)(type));
|
||||
|
@ -252,10 +262,10 @@ public class BinOpInstr : Value
|
|||
*/
|
||||
public class UnaryOpInstr : Value
|
||||
{
|
||||
private Instruction exp;
|
||||
private Value exp;
|
||||
private SymbolType operator;
|
||||
|
||||
this(Instruction exp, SymbolType operator)
|
||||
this(Value exp, SymbolType operator)
|
||||
{
|
||||
this.exp = exp;
|
||||
this.operator = operator;
|
||||
|
@ -268,7 +278,7 @@ public class UnaryOpInstr : Value
|
|||
return operator;
|
||||
}
|
||||
|
||||
public Instruction getOperand()
|
||||
public Value getOperand()
|
||||
{
|
||||
return exp;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue