Browse Source

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.
master
cancel 4 years ago
parent
commit
35f0f61cc9
  1. 22
      sim.c

22
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)

Loading…
Cancel
Save