diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-05-04 20:19:40 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-05-04 20:20:03 -0700 |
commit | ba5f556543c94c3431148e7c7e3e0b705d9585af (patch) | |
tree | 089e0d5baf66874d27dcf59aa7b978423ff9e125 | |
parent | 5e0f4598488d5f88d60f67fa11465577b0446c87 (diff) | |
download | mu-ba5f556543c94c3431148e7c7e3e0b705d9585af.tar.gz |
.
-rw-r--r-- | shell/cell.mu | 1 | ||||
-rw-r--r-- | shell/evaluate.mu | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/shell/cell.mu b/shell/cell.mu index 5533efc2..ea14d7c0 100644 --- a/shell/cell.mu +++ b/shell/cell.mu @@ -15,6 +15,7 @@ type cell { # type 6: keyboard keyboard-data: (handle gap-buffer) # TODO: array, (associative) table + # if you add types here, don't forget to update cell-isomorphic? } fn allocate-symbol _out: (addr handle cell) { diff --git a/shell/evaluate.mu b/shell/evaluate.mu index 6fc9f840..bd4da78b 100644 --- a/shell/evaluate.mu +++ b/shell/evaluate.mu @@ -1058,6 +1058,46 @@ fn cell-isomorphic? _a: (addr cell), _b: (addr cell), trace: (addr trace) -> _/e } return match? } + # if objects are primitive functions, compare index-data + compare b-type, 4/primitive + { + break-if-!= + var a-val-addr/eax: (addr int) <- get a, index-data + var b-val-addr/ecx: (addr int) <- get b, index-data + var a-val/eax: int <- copy *a-val-addr + compare a-val, *b-val-addr + { + break-if-= + trace-higher trace + trace-text trace, "eval", "=> false (primitives)" + return 0/false + } + trace-higher trace + trace-text trace, "eval", "=> true (primitives)" + return 1/true + } + # if objects are screens, check if they're the same object + compare b-type, 5/screen + { + break-if-!= + var a-val-addr/eax: (addr handle screen) <- get a, screen-data + var b-val-addr/ecx: (addr handle screen) <- get b, screen-data + var result/eax: boolean <- handle-equal? *a-val-addr, *b-val-addr + compare result, 0/false + return result + } + # if objects are keyboards, check if they have the same contents + compare b-type, 6/keyboard + { + break-if-!= + var a-val-addr/ecx: (addr handle gap-buffer) <- get a, keyboard-data + var _a/eax: (addr gap-buffer) <- lookup *a-val-addr + var a/ecx: (addr gap-buffer) <- copy _a + var b-val-addr/eax: (addr handle gap-buffer) <- get b, keyboard-data + var b/eax: (addr gap-buffer) <- lookup *b-val-addr + var result/eax: boolean <- gap-buffers-equal? a, b + return result + } # if a is nil, b should be nil { # (assumes nil? returns 0 or 1) |