kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

156_indirect_stack_args.toy (684B)


      1 // An indirect target must survive the complete argument-marshalling phase.
      2 // Ten integer arguments force two values through the outgoing stack while the
      3 // target itself arrives as a runtime parameter rather than a direct symbol.
      4 
      5 type Sum10 = fn(
      6   i64, i64, i64, i64, i64,
      7   i64, i64, i64, i64, i64
      8 ): i64;
      9 
     10 fn sum10(
     11   a0: i64, a1: i64, a2: i64, a3: i64, a4: i64,
     12   a5: i64, a6: i64, a7: i64, a8: i64, a9: i64
     13 ): i64 {
     14   return a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9;
     15 }
     16 
     17 fn apply10(fp: *Sum10, seed: i64): i64 {
     18   return fp(seed, 2, 3, 4, 5, 6, 7, 8, 9, 10);
     19 }
     20 
     21 fn __user_main(): i64 {
     22   return apply10(sum10, 1) - 55;
     23 }
     24 
     25 fn main(): i32 { return __user_main() as i32; }