expression function calls

This commit is contained in:
nub31
2026-02-09 22:30:25 +01:00
parent 88fe03c048
commit d3e2dcede8
5 changed files with 63 additions and 21 deletions

View File

@@ -200,6 +200,7 @@ public sealed class Generator(List<TypedNodeDefinitionFunc> functions, ModuleGra
TypedNodeExpressionMemberAccess expression => EmitExpressionMemberAccess(expression),
TypedNodeExpressionLocalIdent expression => expression.Value.Ident,
TypedNodeExpressionModuleIdent expression => expression.Value.Ident,
TypedNodeExpressionFuncCall expression => EmitExpressionFuncCall(expression),
_ => throw new ArgumentOutOfRangeException(nameof(node), node, null)
};
}
@@ -263,6 +264,13 @@ public sealed class Generator(List<TypedNodeDefinitionFunc> functions, ModuleGra
return $"{target}.{expression.Name.Ident}";
}
private string EmitExpressionFuncCall(TypedNodeExpressionFuncCall expression)
{
var name = EmitExpression(expression.Target);
var parameterValues = expression.Parameters.Select(EmitExpression).ToList();
return $"{name}({string.Join(", ", parameterValues)})";
}
private string CType(NubType node, string? varName = null)
{
return node switch