<?phpnamespace App\Alis\Compiled\Templates;use App\Alis\Compiled\Context;use App\Alis\Compiled\Templates;/** * cstore, ceval, cadd, csub, and the simplest expression elements (constants, the script's own and the main * script's variables) and store / add targets: the examples of the contract (Context), checked against the VM. */final class Expressions{ public static function register(): void { // instructions (fn/opcodes_a.php) Templates::$op['cstore'] = static fn (array $i, Context $c): string => $c->opernameSaveD7($i['ops'][0][1]) . "\n" . '[Alis::$sd7, Alis::$oldsd7] = [Alis::$oldsd7, Alis::$sd7];' . "\n" . $c->storename($i['ops'][1][1]); Templates::$op['ceval'] = static fn (array $i, Context $c): string => $c->opernameSaveD7($i['ops'][0][1]); Templates::$op['cadd'] = static fn (array $i, Context $c): string => $c->opernameSaveD7($i['ops'][0][1]) . "\n" . $c->addnameSwap($i['ops'][1][1]); Templates::$op['csub'] = static function (array $i, Context $c): string { // fn/opcodes_a.php csub(): D7 negated before the add target return $c->opernameSaveD7($i['ops'][0][1]) . "\n" . 'Alis::$varD7 = \App\Alis\s32(-Alis::$varD7);' . "\n" . $c->addnameSwap($i['ops'][1][1]); }; // expression elements (fn/opernames.php) Templates::$oper[0x00] = static fn (array $e): string => sprintf('Alis::$varD7 = %d;', $e['a']); // oimmb Templates::$oper[0x02] = static fn (array $e): string => sprintf('Alis::$varD7 = %d;', $e['a']); // oimmw Templates::$oper[0x06] = static fn (array $e): string => sprintf('Alis::$varD7 = \App\Alis\s8(\App\Alis\xread8($s->vram_org + %d));', $e['a']); // olocb Templates::$oper[0x08] = static fn (array $e): string => sprintf('Alis::$varD7 = \App\Alis\xread16($s->vram_org + %d);', $e['a']); // olocw // store targets (fn/storenames.php) Templates::$store[0x06] = static fn (array $e): string => sprintf('\App\Alis\xwrite8($s->vram_org + %d, Alis::$varD7);', $e['a']); // slocb Templates::$store[0x08] = static fn (array $e): string => sprintf('\App\Alis\xwrite16($s->vram_org + %d, Alis::$varD7);', $e['a']); // slocw }}