diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-07-28 23:28:29 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-07-28 23:28:29 -0700 |
commit | e2f18e8866bd75669c04bff52c3f8e96d13eeb4e (patch) | |
tree | 129495b1009aa08f7715c5d58f6eba8fcad7e566 /shell/evaluate.mu | |
parent | e2f6e9011eb64b9f2372dbed6ed3838ce8e26ec0 (diff) | |
download | mu-e2f18e8866bd75669c04bff52c3f8e96d13eeb4e.tar.gz |
shell: literal images
Diffstat (limited to 'shell/evaluate.mu')
-rw-r--r-- | shell/evaluate.mu | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/shell/evaluate.mu b/shell/evaluate.mu index 932a0fa5..c78f1e23 100644 --- a/shell/evaluate.mu +++ b/shell/evaluate.mu @@ -171,6 +171,20 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han trace-higher trace return } + $evaluate:literal-image: { + # trees starting with "litimg" are literals + var expr/esi: (addr cell) <- copy in + var in/edx: (addr cell) <- copy in + var first-ah/ecx: (addr handle cell) <- get in, left + var first/eax: (addr cell) <- lookup *first-ah + var litimg?/eax: boolean <- litimg? first + compare litimg?, 0/false + break-if-= + trace-text trace, "eval", "literal image" + copy-object _in-ah, _out-ah + trace-higher trace + return + } $evaluate:anonymous-function: { # trees starting with "fn" are anonymous functions var expr/esi: (addr cell) <- copy in @@ -1546,6 +1560,20 @@ fn litmac? _x: (addr cell) -> _/eax: boolean { return result } +fn litimg? _x: (addr cell) -> _/eax: boolean { + var x/esi: (addr cell) <- copy _x + var type/eax: (addr int) <- get x, type + compare *type, 2/symbol + { + break-if-= + return 0/false + } + var contents-ah/eax: (addr handle stream byte) <- get x, text-data + var contents/eax: (addr stream byte) <- lookup *contents-ah + var result/eax: boolean <- stream-data-equal? contents, "litimg" + return result +} + fn test-evaluate-is-well-behaved { var t-storage: trace var t/esi: (addr trace) <- address t-storage |