Add logic for checking if callee is platform fn.

This commit is contained in:
Jesse Brault 2026-03-02 12:51:39 -06:00
parent b7b495178b
commit 506e260c75
3 changed files with 21 additions and 6 deletions

View File

@ -22,7 +22,7 @@ mod smoke_tests {
fn multiple_statements() { fn multiple_statements() {
let asm_functions = assemble( let asm_functions = assemble(
" "
fn println() end extern fn println()
fn main() fn main()
let x = 42 let x = 42
println(x) println(x)

View File

@ -143,14 +143,25 @@ impl Call {
}, },
} }
} }
let function_name = match self.callee() {
Expression::Identifier(identifier) => identifier.name(), let function_symbol = match self.callee() {
Expression::Identifier(identifier) => {
let expressible_symbol = identifier.expressible_symbol();
match expressible_symbol {
ExpressibleSymbol::Function(function_symbol) => function_symbol.clone(),
_ => panic!("Calling things other than functions not yet supported."),
}
}
_ => panic!("Calling things other than identifiers not yet supported."), _ => panic!("Calling things other than identifiers not yet supported."),
}; };
context.instruction(AsmInstruction::InvokePlatformStatic( if function_symbol.is_platform() {
InvokePlatformStatic::new(function_name), context.instruction(AsmInstruction::InvokePlatformStatic(
)); InvokePlatformStatic::new(function_symbol.name()),
));
} else {
todo!("non-platform invoke")
}
} }
pub fn source_range(&self) -> &SourceRange { pub fn source_range(&self) -> &SourceRange {

View File

@ -32,6 +32,10 @@ impl FunctionSymbol {
pub fn return_type(&self) -> TypeInfo { pub fn return_type(&self) -> TypeInfo {
todo!() todo!()
} }
pub fn is_platform(&self) -> bool {
self.is_platform
}
} }
pub struct ParameterSymbol { pub struct ParameterSymbol {