Skip to content

Commit

Permalink
Add chaining behavior to J and Y
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cancel committed Nov 10, 2020
1 parent f145d7d commit 35f0f61
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 35f0f61

Please sign in to comment.