7115
This commit is contained in:
parent
ddcc5dfe3a
commit
71418907f6
|
@ -56,7 +56,7 @@ $copy-bytes:end:
|
|||
5d/pop-to-ebp
|
||||
c3/return
|
||||
|
||||
stream-to-string: # in: (addr stream _), out: (addr handle array _)
|
||||
stream-to-array: # in: (addr stream _), out: (addr handle array _)
|
||||
# . prologue
|
||||
55/push-ebp
|
||||
89/<- %ebp 4/r32/esp
|
||||
|
@ -81,7 +81,7 @@ stream-to-string: # in: (addr stream _), out: (addr handle array _)
|
|||
8d/copy-address *(eax+4) 0/r32/eax
|
||||
#
|
||||
(copy-bytes %edx %eax %ecx)
|
||||
$stream-to-string:end:
|
||||
$stream-to-array:end:
|
||||
# . restore registers
|
||||
5e/pop-to-esi
|
||||
5a/pop-to-edx
|
||||
|
@ -92,7 +92,7 @@ $stream-to-string:end:
|
|||
5d/pop-to-ebp
|
||||
c3/return
|
||||
|
||||
test-stream-to-string:
|
||||
test-stream-to-array:
|
||||
# . prologue
|
||||
55/push-ebp
|
||||
89/<- %ebp 4/r32/esp
|
||||
|
@ -106,7 +106,7 @@ test-stream-to-string:
|
|||
68/push 0/imm32
|
||||
89/<- %ecx 4/r32/esp
|
||||
#
|
||||
(stream-to-string _test-input-stream %ecx)
|
||||
(stream-to-array _test-input-stream %ecx)
|
||||
(lookup *ecx *(ecx+4)) # => eax
|
||||
(check-strings-equal %eax "bc")
|
||||
# . epilogue
|
||||
|
@ -114,9 +114,9 @@ test-stream-to-string:
|
|||
5d/pop-to-ebp
|
||||
c3/return
|
||||
|
||||
# like stream-to-string but ignore surrounding quotes
|
||||
# like stream-to-array but ignore surrounding quotes
|
||||
# we might do other stuff here later
|
||||
unquote-stream-to-string: # in: (addr stream _), out: (addr handle array _)
|
||||
unquote-stream-to-array: # in: (addr stream _), out: (addr handle array _)
|
||||
# . prologue
|
||||
55/push-ebp
|
||||
89/<- %ebp 4/r32/esp
|
||||
|
@ -131,7 +131,7 @@ unquote-stream-to-string: # in: (addr stream _), out: (addr handle array _)
|
|||
8b/-> *esi 1/r32/ecx
|
||||
2b/subtract *(esi+4) 1/r32/ecx
|
||||
81 7/subop/compare %ecx 2/imm32
|
||||
7c/jump-if-< $unquote-stream-to-string:end/disp8
|
||||
7c/jump-if-< $unquote-stream-to-array:end/disp8
|
||||
81 5/subop/subtract %ecx 2/imm32
|
||||
# allocate
|
||||
(allocate-array Heap %ecx *(ebp+0xc))
|
||||
|
@ -144,7 +144,7 @@ unquote-stream-to-string: # in: (addr stream _), out: (addr handle array _)
|
|||
8d/copy-address *(eax+4) 0/r32/eax
|
||||
#
|
||||
(copy-bytes %edx %eax %ecx)
|
||||
$unquote-stream-to-string:end:
|
||||
$unquote-stream-to-array:end:
|
||||
# . restore registers
|
||||
5e/pop-to-esi
|
||||
5a/pop-to-edx
|
||||
|
|
4
400.mu
4
400.mu
|
@ -176,8 +176,8 @@ sig new-buffered-file out: (addr handle buffered-file)
|
|||
|
||||
sig stream-empty? s: (addr stream _) -> result/eax: boolean
|
||||
sig stream-full? s: (addr stream _) -> result/eax: boolean
|
||||
sig stream-to-string in: (addr stream _), out: (addr handle array _)
|
||||
sig unquote-stream-to-string in: (addr stream _), out: (addr handle array _)
|
||||
sig stream-to-array in: (addr stream _), out: (addr handle array _)
|
||||
sig unquote-stream-to-array in: (addr stream _), out: (addr handle array _)
|
||||
sig stream-first s: (addr stream byte) -> result/eax: byte
|
||||
sig stream-final s: (addr stream byte) -> result/eax: byte
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ fn gap-buffer-to-string self: (addr gap-buffer), out: (addr handle array byte) {
|
|||
var s-storage: (stream byte 0x100)
|
||||
var s/ecx: (addr stream byte) <- address s-storage
|
||||
emit-gap-buffer self, s
|
||||
stream-to-string s, out
|
||||
stream-to-array s, out
|
||||
}
|
||||
|
||||
fn emit-gap-buffer _self: (addr gap-buffer), out: (addr stream byte) {
|
||||
|
|
|
@ -161,7 +161,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
|
|||
var s-addr/ecx: (addr stream byte) <- address s
|
||||
read-line-buffered file, s-addr
|
||||
var target/eax: (addr handle array byte) <- get target-val, text-data
|
||||
stream-to-string s-addr, target
|
||||
stream-to-array s-addr, target
|
||||
# save result into target-val
|
||||
var type-addr/eax: (addr int) <- get target-val, type
|
||||
copy-to *type-addr, 1 # string
|
||||
|
@ -192,7 +192,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
|
|||
# create binding from curr-stream to target-val
|
||||
var key-h: (handle array byte)
|
||||
var key/ecx: (addr handle array byte) <- address key-h
|
||||
stream-to-string curr-stream, key
|
||||
stream-to-array curr-stream, key
|
||||
bind-in-table bindings, key, target-val
|
||||
# process next line if necessary
|
||||
var line/eax: (addr line) <- copy scratch
|
||||
|
@ -275,7 +275,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
|
|||
break-if-=
|
||||
var tmp: (handle array byte)
|
||||
var curr-string-ah/edx: (addr handle array byte) <- address tmp
|
||||
stream-to-string curr-stream, curr-string-ah # unfortunate leak
|
||||
stream-to-array curr-stream, curr-string-ah # unfortunate leak
|
||||
var curr-string/eax: (addr array byte) <- lookup *curr-string-ah
|
||||
var val-storage: (handle value)
|
||||
var val-ah/edi: (addr handle value) <- address val-storage
|
||||
|
@ -296,7 +296,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
|
|||
break-if-!=
|
||||
var h: (handle array byte)
|
||||
var s/eax: (addr handle array byte) <- address h
|
||||
unquote-stream-to-string curr-stream, s # leak
|
||||
unquote-stream-to-array curr-stream, s # leak
|
||||
push-string-to-value-stack out, *s
|
||||
break $evaluate:process-word
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
|
|||
# wastefully create a new input string to strip quotes
|
||||
var h: (handle array value)
|
||||
var input-ah/eax: (addr handle array byte) <- address h
|
||||
unquote-stream-to-string curr-stream, input-ah # leak
|
||||
unquote-stream-to-array curr-stream, input-ah # leak
|
||||
# wastefully parse input into int-array
|
||||
# TODO: support parsing arrays of other types
|
||||
var input/eax: (addr array byte) <- lookup *input-ah
|
||||
|
|
Loading…
Reference in New Issue