diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-04-28 09:45:39 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-04-28 09:45:39 -0700 |
commit | a71ff2383a2f354a718aa58b7708fc1d45b96f04 (patch) | |
tree | a98c3ddf7a591727880e18f9864f22cd54d04889 /shell | |
parent | 55cde01edfe504855f171b6dbdc312cbcc02872b (diff) | |
download | mu-a71ff2383a2f354a718aa58b7708fc1d45b96f04.tar.gz |
.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/cell.mu | 14 | ||||
-rw-r--r-- | shell/evaluate.mu | 42 |
2 files changed, 20 insertions, 36 deletions
diff --git a/shell/cell.mu b/shell/cell.mu index 8b9307c7..5533efc2 100644 --- a/shell/cell.mu +++ b/shell/cell.mu @@ -40,6 +40,20 @@ fn new-symbol out: (addr handle cell), val: (addr array byte) { initialize-symbol out, val } +fn symbol-equal? _in: (addr cell), name: (addr array byte) -> _/eax: boolean { + var in/esi: (addr cell) <- copy _in + var in-type/eax: (addr int) <- get in, type + compare *in-type, 2/symbol + { + break-if-= + return 0/false + } + var in-data-ah/eax: (addr handle stream byte) <- get in, text-data + var in-data/eax: (addr stream byte) <- lookup *in-data-ah + var result/eax: boolean <- stream-data-equal? in-data, name + return result +} + fn allocate-stream _out: (addr handle cell) { var out/eax: (addr handle cell) <- copy _out allocate out diff --git a/shell/evaluate.mu b/shell/evaluate.mu index fae2519c..a856f7fa 100644 --- a/shell/evaluate.mu +++ b/shell/evaluate.mu @@ -149,12 +149,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel 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, "'" + var quote?/eax: boolean <- symbol-equal? first, "'" compare quote?, 0/false break-if-= # @@ -170,12 +165,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel 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 def?/eax: boolean <- stream-data-equal? sym-data, "def" + var def?/eax: boolean <- symbol-equal? first, "def" compare def?, 0/false break-if-= # @@ -220,12 +210,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel 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 set?/eax: boolean <- stream-data-equal? sym-data, "set" + var set?/eax: boolean <- symbol-equal? first, "set" compare set?, 0/false break-if-= # @@ -263,12 +248,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel 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 and?/eax: boolean <- stream-data-equal? sym-data, "and" + var and?/eax: boolean <- symbol-equal? first, "and" compare and?, 0/false break-if-= # @@ -306,12 +286,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel 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 or?/eax: boolean <- stream-data-equal? sym-data, "or" + var or?/eax: boolean <- symbol-equal? first, "or" compare or?, 0/false break-if-= # @@ -350,12 +325,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel 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 if?/eax: boolean <- stream-data-equal? sym-data, "if" + var if?/eax: boolean <- symbol-equal? first, "if" compare if?, 0/false break-if-= # |