mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
29 lines
745 B
C
29 lines
745 B
C
// #target: macos-x64
|
|
import std::io;
|
|
import std::math::vector;
|
|
import std::math;
|
|
|
|
typedef Callback = fn int();
|
|
|
|
fn int xy(Callback a) => a();
|
|
|
|
fn void main()
|
|
{
|
|
const Callback F = fn int() { io::printfn("Hello"); return 23; };
|
|
int z = xy(F);
|
|
io::printfn("%d", z);
|
|
int y = xy(fn () { return 3; });
|
|
}
|
|
|
|
/* #expect: simple_lambda.ll
|
|
|
|
define void @simple_lambda_main() #0 {
|
|
entry:
|
|
%F = alloca ptr, align 8
|
|
%z = alloca i32, align 4
|
|
store ptr @"simple_lambda_main$lambda1", ptr %F, align 8
|
|
%0 = call i32 @simple_lambda_xy(ptr @"simple_lambda_main$lambda1")
|
|
%5 = call i32 @simple_lambda_xy(ptr @"simple_lambda_main$lambda2")
|
|
|
|
define internal i32 @"simple_lambda_main$lambda2"() #0 {
|
|
define internal i32 @"simple_lambda_main$lambda1"() #0 {
|