From 506e260c759b431269079089310a6af159aa1bf0 Mon Sep 17 00:00:00 2001 From: Jesse Brault Date: Mon, 2 Mar 2026 12:51:39 -0600 Subject: [PATCH] Add logic for checking if callee is platform fn. --- dmc-lib/src/asm/mod.rs | 2 +- dmc-lib/src/ast/call.rs | 21 ++++++++++++++++----- dmc-lib/src/symbol.rs | 4 ++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/dmc-lib/src/asm/mod.rs b/dmc-lib/src/asm/mod.rs index a4dc20a..7e611dd 100644 --- a/dmc-lib/src/asm/mod.rs +++ b/dmc-lib/src/asm/mod.rs @@ -22,7 +22,7 @@ mod smoke_tests { fn multiple_statements() { let asm_functions = assemble( " - fn println() end + extern fn println() fn main() let x = 42 println(x) diff --git a/dmc-lib/src/ast/call.rs b/dmc-lib/src/ast/call.rs index 7e85571..aeb95d5 100644 --- a/dmc-lib/src/ast/call.rs +++ b/dmc-lib/src/ast/call.rs @@ -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."), }; - context.instruction(AsmInstruction::InvokePlatformStatic( - InvokePlatformStatic::new(function_name), - )); + if function_symbol.is_platform() { + context.instruction(AsmInstruction::InvokePlatformStatic( + InvokePlatformStatic::new(function_symbol.name()), + )); + } else { + todo!("non-platform invoke") + } } pub fn source_range(&self) -> &SourceRange { diff --git a/dmc-lib/src/symbol.rs b/dmc-lib/src/symbol.rs index 93fcc0c..b3d2fba 100644 --- a/dmc-lib/src/symbol.rs +++ b/dmc-lib/src/symbol.rs @@ -32,6 +32,10 @@ impl FunctionSymbol { pub fn return_type(&self) -> TypeInfo { todo!() } + + pub fn is_platform(&self) -> bool { + self.is_platform + } } pub struct ParameterSymbol {