compiler, runtime, common: Support (in)out Parameters

When a function is called, if there is an (in)out parameter,
make sure that updated values are propogated to the calling
function.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-16 06:58:45 -04:00
parent 94086c8e17
commit 82c125e4d1
14 changed files with 322 additions and 139 deletions
+10 -1
View File
@@ -39,7 +39,16 @@ public struct Parameter: CustomStringConvertible, Equatable {
/// Calculate whether the `argument` is compatible with this parameter.
public func compatible(_ argument: Argument) -> Bool {
let arg_type = argument.argument.type()
return arg_type.eq(self.type)
// If the parameter is (in)out, then the argument must be an lvalue.
if let param_direction = self.type.direction(),
param_direction == Direction.In || param_direction == Direction.InOut
{
if !(argument.argument is EvaluatableLValueExpression) {
return false
}
}
return arg_type.dataType().eq(rhs: self.type.dataType())
}
}