about summary refs log tree commit diff
path: root/boot/ir.c
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2026-05-24 20:01:38 +0200
committerMel <mel@rnrd.eu>2026-05-24 20:01:38 +0200
commitf028bc7ef3101facfa004c21f3aa5feb3dc6f107 (patch)
tree3458a0ec69c9552354cb7d3dde38d8f6edd0ad14 /boot/ir.c
parent99d57398863ab1734a9f81c2d336f82dab556383 (diff)
downloadcatskill-f028bc7ef3101facfa004c21f3aa5feb3dc6f107.tar.zst
catskill-f028bc7ef3101facfa004c21f3aa5feb3dc6f107.zip
Support named-unnamed call and construction arguments and fields with final resolved order
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot/ir.c')
-rw-r--r--boot/ir.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/boot/ir.c b/boot/ir.c
index 6ea055e..d8d8aa2 100644
--- a/boot/ir.c
+++ b/boot/ir.c
@@ -294,12 +294,21 @@ struct Expression_Sizeof_Operator
     struct Type_Ref target;
 };
 
+// one argument of a call, tagged with the parameter slot it fills.
+struct Call_Argument
+{
+    struct Expression* value;
+    // slot decides the final emission order.
+    // slots that are higher than the parameter count of a function
+    // are always counted as variadic extras, and an error for non-variadics.
+    uint slot;
+};
+
 struct Expression_Call
 {
     struct Expression* subject;
-    // call arguments are positional, named and out-of-order
-    // arguments get re-ordered until they are correct.
-    Array(struct Expression*) arguments;
+    // arguments of call in written order, the inner slot decides final ordering.
+    Array(struct Call_Argument) arguments;
 };
 
 struct Expression_Member
@@ -459,6 +468,10 @@ enum Lower_Error_Kind
     LOWER_ERROR_UNSUPPORTED_TOP_LEVEL,
     LOWER_ERROR_UNKNOWN_LOOP_STYLE,
     LOWER_ERROR_UNKNOWN_COMPOUND_ASSIGN,
+    LOWER_ERROR_UNKNOWN_NAMED_ARGUMENT,
+    LOWER_ERROR_DUPLICATE_ARGUMENT,
+    LOWER_ERROR_TOO_MANY_ARGUMENTS,
+    LOWER_ERROR_NAMED_ARGUMENT_ON_UNKNOWN_CALLEE,
     LOWER_ERROR_UNIMPLEMENTED,
 };
 
@@ -466,7 +479,7 @@ struct Lower_Error
 {
     enum Lower_Error_Kind kind;
     struct Span span;
-    
+
     // per-error details, meaning depends on each error kind!
     struct String name;
     struct String detail;
@@ -625,7 +638,7 @@ ir_make_sizeof(struct Type_Ref target, struct Span span)
 }
 
 struct Expression*
-ir_make_call(struct Expression* subject, Array(struct Expression*) arguments, struct Span span)
+ir_make_call(struct Expression* subject, Array(struct Call_Argument) arguments, struct Span span)
 {
     union Expression_Value v = { 0 };
     v.call.subject = subject;