010 cross target host line routing

✓ Passing This code compiles and runs correctly.

Code

input.k

Actual

counter = 96

Expected output

✓ Zig✓ JavaScript
counter = 96
Emitted JavaScript source
let counter = 0;
const main_module = {
  run_event: {
    handler(input, H) {
      const key = H.key;
      const tick = H.tick;
      const n = input.n;
      for (let i = 0; i < n; i++) { if (i % 2 === 0) { key(i); } else { tick(i); } }
    },
  },
  bumpKey_event: {
    handler(input) {
      const v = input.v;
      counter = counter + v;
    },
  },
  bumpTick_event: {
    handler(input) {
      const v = input.v;
      counter = counter + v * 10;
    },
  },
  report_event: {
    handler(input) {
      console.log("counter = " + counter);
    },
  },
  flow0() {
    const __arg_0 = 6;
    {
      const n = __arg_0;
      for (let i = 0; i < n; i++) { if (i % 2 === 0) {
      {
        const k = i;
        {
          const v = k;
          counter = counter + v;
        }
      }
      } else {
      {
        const t = i;
        {
          const v = t;
          counter = counter + v * 10;
        }
      }
      } }    }
  },
  flow1() {
    {
      console.log("counter = " + counter);
    }
  },
};
main_module.flow0();
main_module.flow1();

Test Configuration

MUST_RUN