- Added `getReferType()` to `Pointer` type to refer the `Type` instance of the data being pointed to

DGen

- Fixed bug whereby pointer types were not being transformed correctly in typeTransform()`
This commit is contained in:
Tristan B. Velloza Kildaire 2023-01-15 12:49:28 +02:00
parent 7f8973a4aa
commit bbb9aaaa51
2 changed files with 17 additions and 2 deletions

View File

@ -17,7 +17,7 @@ import compiler.codegen.mapper : SymbolMapper;
import compiler.symbols.data : SymbolType, Variable, Function, VariableParameter;
import compiler.symbols.check : getCharacter;
import misc.utils : Stack;
import compiler.symbols.typing.core : Type, Primitive, Integer, Void;
import compiler.symbols.typing.core : Type, Primitive, Integer, Void, Pointer;
public final class DCodeEmitter : CodeEmitter
{
@ -58,8 +58,18 @@ public final class DCodeEmitter : CodeEmitter
// TODO: Some types will ident transform
/* Pointer types */
if(cast(Pointer)typeIn)
{
/* Extract type being pointed to */
Pointer pointerType = cast(Pointer)typeIn;
Type referType = pointerType.getReferType();
/* The type is then `transform(<refertype>)*` */
return typeTransform(referType)~"*";
}
/* Integral types transformation */
if(cast(Integer)typeIn)
else if(cast(Integer)typeIn)
{
Integer integralType = cast(Integer)typeIn;

View File

@ -105,6 +105,11 @@ public class Pointer : Integer
super(name, 8);
this.dataType = dataType;
}
public Type getReferType()
{
return dataType;
}
}
/**