- Implemented code emit for variable expressions (fetching their values)

----

Test cases

- Updated test case `simple_variables.t` to be able to test the newly implemented `FetchValueInstr` code emit
This commit is contained in:
Tristan B. Velloza Kildaire 2022-12-13 11:51:44 +02:00
parent 3afdd5b05d
commit 990f0ed1cc
2 changed files with 9 additions and 1 deletions

View File

@ -113,7 +113,15 @@ public final class DCodeEmitter : CodeEmitter
/* FetchValueVar */
else if(cast(FetchValueVar)instruction)
{
FetchValueVar fetchValueVarInstr = cast(FetchValueVar)instruction;
Context context = fetchValueVarInstr.getContext();
Variable typedEntityVariable = cast(Variable)context.tc.getResolver().resolveBest(context.getContainer(), fetchValueVarInstr.varName); //TODO: Remove `auto`
string typedEntityVariableName = context.tc.getResolver().generateName(context.getContainer(), typedEntityVariable);
string renamedSymbol = SymbolMapper.symbolLookup(context.getContainer(), typedEntityVariableName);
return renamedSymbol;
}
/* BinOpInstr */
else if(cast(BinOpInstr)instruction)

View File

@ -2,7 +2,7 @@ module simple_variables_decls_ass;
int x = 1+2*2/1-6;
int y = 2;
int y = 2+x;
discard "TODO: Technically the below should not be allowed as we cannot do it in C - sadly";
y = 5+5;