From 35f0f61cc9bfa2fa4d4830666dafe1c2c7894c74 Mon Sep 17 00:00:00 2001 From: cancel Date: Wed, 11 Nov 2020 08:18:07 +0900 Subject: [PATCH] Add chaining behavior to J and Y J and Y and now be chained (like YYYYYY) to copy a glyph across the 'wire' they form. This is a simple implementation of the feature. This changes both J and Y to have loops in their definitions, instead of being single reads and writes, which will make them heavier and have a adverse effect on benchmarks. It also makes it harder to explain how orca's VM works, since these operators are now non-trivial and can't be used as examples of trivial operators. But we've decided it's worth it. --- sim.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/sim.c b/sim.c index cd80690..191e681 100644 --- a/sim.c +++ b/sim.c @@ -499,8 +499,15 @@ END_OPERATOR BEGIN_OPERATOR(jump) LOWERCASE_REQUIRES_BANG; PORT(-1, 0, IN); - PORT(1, 0, OUT); - POKE(1, 0, PEEK(-1, 0)); + Glyph g = PEEK(-1, 0); + for (Isz i = 1;; ++i) { + if (PEEK(i, 0) != This_oper_char) { + PORT(i, 0, OUT); + POKE(i, 0, g); + break; + } + STUN(i, 0); + } END_OPERATOR // Note: this is merged from a pull request without being fully tested or @@ -700,8 +707,15 @@ END_OPERATOR BEGIN_OPERATOR(yump) LOWERCASE_REQUIRES_BANG; PORT(0, -1, IN); - PORT(0, 1, OUT); - POKE(0, 1, PEEK(0, -1)); + Glyph g = PEEK(0, -1); + for (Isz i = 1;; ++i) { + if (PEEK(0, i) != This_oper_char) { + PORT(0, i, OUT); + POKE(0, i, g); + break; + } + STUN(0, i); + } END_OPERATOR BEGIN_OPERATOR(lerp)