...
This commit is contained in:
@@ -13,9 +13,19 @@ struct Human
|
|||||||
|
|
||||||
export func main(args: []cstring): i64
|
export func main(args: []cstring): i64
|
||||||
{
|
{
|
||||||
let x: cstring = "test"
|
let x = alloc Human
|
||||||
|
{
|
||||||
c::puts(x)
|
name = alloc Name {
|
||||||
|
first = "john"
|
||||||
|
last = "doe"
|
||||||
|
}
|
||||||
|
age = 23
|
||||||
|
}
|
||||||
|
|
||||||
|
print_name(x&)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func print_name(human: ^Human) {
|
||||||
|
c::puts(human^.name.last)
|
||||||
|
}
|
||||||
|
|||||||
@@ -827,13 +827,24 @@ public static class QBEGenerator
|
|||||||
|
|
||||||
private static Val EmitDereference(BoundDereferenceNode dereference)
|
private static Val EmitDereference(BoundDereferenceNode dereference)
|
||||||
{
|
{
|
||||||
var result = EmitUnwrap(EmitExpression(dereference.Expression));
|
var pointerType = (NubPointerType)dereference.Expression.Type;
|
||||||
return EmitLoad(dereference.Type, result);
|
|
||||||
|
var pointer = EmitExpression(dereference.Expression);
|
||||||
|
|
||||||
|
// Complex types are already pointers, so no need to load them
|
||||||
|
if (pointerType.BaseType is NubComplexType)
|
||||||
|
{
|
||||||
|
return pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EmitLoad(dereference.Type, EmitUnwrap(pointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Val EmitAddressOf(BoundAddressOfNode addressOf)
|
private static Val EmitAddressOf(BoundAddressOfNode addressOf)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var value = EmitExpression(addressOf.Expression);
|
||||||
|
Debug.Assert(value.Kind == ValKind.Pointer);
|
||||||
|
return new Val(value.Name, addressOf.Type, ValKind.Direct);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Val EmitBinaryExpression(BoundBinaryExpressionNode binaryExpression)
|
private static Val EmitBinaryExpression(BoundBinaryExpressionNode binaryExpression)
|
||||||
|
|||||||
Reference in New Issue
Block a user