diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-04-06 09:40:13 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-04-06 09:40:13 -0700 |
commit | 26a184989549e700ffb84f18222197813f317cc4 (patch) | |
tree | 9018654bc70a9ed211cf9be11bd6f05f8a2434d3 /shell/evaluate.mu | |
parent | 6ef0eabdcff3d02b3f0610311f61aa7d0bf79f7e (diff) | |
download | mu-26a184989549e700ffb84f18222197813f317cc4.tar.gz |
shell: quote
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 bf95cde5..4066db20 100644 --- a/shell/evaluate.mu +++ b/shell/evaluate.mu @@ -2,6 +2,12 @@ # we never modify `in` or `env` fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace) { var in/esi: (addr handle cell) <- copy _in +#? dump-cell in +#? { +#? var foo/eax: byte <- read-key 0/keyboard +#? compare foo, 0 +#? loop-if-= +#? } # trace "evaluate " in " in environment " env {{{ { var stream-storage: (stream byte 0x40) @@ -60,6 +66,28 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel trace-higher trace return } + # builtins with "special" evaluation rules + $evaluate:quote: { + # trees starting with single quote create literals + var expr/esi: (addr cell) <- copy in-addr + # if its first elem is not "'", break + var first-ah/ecx: (addr handle cell) <- get in-addr, left + var rest-ah/edx: (addr handle cell) <- get in-addr, right + var first/eax: (addr cell) <- lookup *first-ah + var first-type/ecx: (addr int) <- get first, type + compare *first-type, 2/symbol + break-if-!= + var sym-data-ah/eax: (addr handle stream byte) <- get first, text-data + var sym-data/eax: (addr stream byte) <- lookup *sym-data-ah + var quote?/eax: boolean <- stream-data-equal? sym-data, "'" + compare quote?, 0/false + break-if-= + # + trace-text trace, "eval", "quote" + copy-object rest-ah, out + trace-higher trace + return + } trace-text trace, "eval", "function call" trace-text trace, "eval", "evaluating list elements" var evaluated-list-storage: (handle cell) |