aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-03-03 19:18:07 +0000
committerMichael Williamson <mike@zwobble.org>2025-03-03 19:18:07 +0000
commitc049f4cb221a83e934ffe05981c17450f17b3310 (patch)
tree0c2fd6554d30ae01546f8660762d4a3b358f3a35 /src/main/java
parentc44a2f17b6ca5e53035fe3b21ba6ed0b9107ed2d (diff)
Handle references to native type method
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java
index 44fa6d47..9987944a 100644
--- a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java
+++ b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java
@@ -424,11 +424,12 @@ public class ShidCodeGen {
) {
context = compileExpression(node.receiver(), context);
// TODO: handle not a type with member
- var receiverType = node.receiver().type();
- var receiver = receiverTypeToReceiver(receiverType);
return switch (node.memberKind()) {
case FIELD -> {
+ var receiverType = node.receiver().type();
+ var receiver = fieldReceiverTypeToReceiver(receiverType);
+
yield context.addInstruction(new ShidFieldLoad(
receiver,
node.memberName(),
@@ -436,8 +437,8 @@ public class ShidCodeGen {
));
}
case METHOD -> {
- // TODO: handle not a struct type
- var structType = ((ShidFieldLoad.Receiver.Struct) receiver).type();
+ // TODO: handle not a concrete type
+ var structType = (SimpleConcreteType) Types.underlyingType(node.receiver().type());
// TODO: handle not a function type
var methodType = (FunctionType) node.type();
@@ -527,10 +528,10 @@ public class ShidCodeGen {
};
}
- private static ShidFieldLoad.Receiver receiverTypeToReceiver(Type receiverType) {
+ private static ShidFieldLoad.Receiver fieldReceiverTypeToReceiver(Type receiverType) {
return switch (receiverType) {
case ConstructedType<?> constructedType ->
- receiverTypeToReceiver(constructedType.genericType());
+ fieldReceiverTypeToReceiver(constructedType.genericType());
case NamespaceType namespaceType ->
new ShidFieldLoad.Receiver.Namespace(namespaceType.namespaceName());