5668 - start reorg to permit syntax sugar in layers
Right now we always build the library before any apps. Apps are where our syntax sugar translators (sigils, calls, braces) live. So we can't use sugar in the standard library. New idea: move all code for SubX phases into the top-level. Perhaps we should also just build a single file rather than pipeline stages. But for now we'll build each phase by building up to some specific layer. This will simplify test_apps and move lots of one-off logic to a more standard form in test_layers. I'm also going to reorg existing layers so that we introduce each phase at a point where it mostly only gets the helpers it needs. This commit itself is just cleaning up some common strings. Using explicit names for them streamlines binaries a bit.
This commit is contained in:
parent
37d40d4096
commit
a9d473e224
14
051test.subx
14
051test.subx
|
@ -90,4 +90,18 @@ Newline:
|
|||
Num-test-failures:
|
||||
0/imm32
|
||||
|
||||
# length-prefixed string containing just a single space
|
||||
Space:
|
||||
# size
|
||||
1/imm32
|
||||
# data
|
||||
20/space
|
||||
|
||||
# length-prefixed string containing just a single slash
|
||||
Slash:
|
||||
# size
|
||||
1/imm32
|
||||
# data
|
||||
2f/slash
|
||||
|
||||
# . . vim:nowrap:textwidth=0
|
||||
|
|
|
@ -26,7 +26,7 @@ error: # ed : (address exit-descriptor), out : fd or (address stream), msg : (a
|
|||
e8/call write/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# write(out, Newline)
|
||||
# write(out, "\n")
|
||||
# . . push args
|
||||
68/push Newline/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)
|
||||
|
|
|
@ -859,7 +859,7 @@ $from-hex-char:abort:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
|
||||
# . _write(2/stderr, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
68/push 2/imm32/stderr
|
||||
# . . call
|
||||
e8/call _write/disp32
|
||||
|
|
|
@ -490,7 +490,7 @@ test-parse-array-of-ints-just-whitespace:
|
|||
89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp
|
||||
# eax = parse-array-of-ints(Heap, " ")
|
||||
# . . push args
|
||||
68/push " "/imm32
|
||||
68/push Space/imm32
|
||||
68/push Heap/imm32
|
||||
# . . call
|
||||
e8/call parse-array-of-ints/disp32
|
||||
|
|
|
@ -107,7 +107,7 @@ $get:abort:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . _write(2/stderr, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
68/push 2/imm32/stderr
|
||||
# . . call
|
||||
e8/call _write/disp32
|
||||
|
@ -288,7 +288,7 @@ $get-slice:abort:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
|
||||
# . _write(2/stderr, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
68/push 2/imm32/stderr
|
||||
# . . call
|
||||
e8/call _write/disp32
|
||||
|
@ -1010,7 +1010,7 @@ $get-or-stop:stop:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . write-buffered(err, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x18/disp8 . # push *(ebp+24)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
@ -1228,7 +1228,7 @@ $get-slice-or-stop:stop:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . write-buffered(err, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x18/disp8 . # push *(ebp+24)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
|
BIN
apps/assort
BIN
apps/assort
Binary file not shown.
|
@ -250,7 +250,7 @@ test-convert:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . write(_test-input-stream, "\n") # empty line
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
68/push _test-input-stream/imm32
|
||||
# . . call
|
||||
e8/call write/disp32
|
||||
|
|
BIN
apps/braces
BIN
apps/braces
Binary file not shown.
BIN
apps/calls
BIN
apps/calls
Binary file not shown.
BIN
apps/crenshaw2-1
BIN
apps/crenshaw2-1
Binary file not shown.
Binary file not shown.
BIN
apps/dquotes
BIN
apps/dquotes
Binary file not shown.
|
@ -226,7 +226,7 @@ $convert:regular-word:
|
|||
$convert:next-word:
|
||||
# write-buffered(out, " ")
|
||||
# . . push args
|
||||
68/push " "/imm32
|
||||
68/push Space/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
@ -472,7 +472,7 @@ test-convert-is-idempotent-by-default:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . write(_test-input-stream, "\n") # empty line
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
68/push _test-input-stream/imm32
|
||||
# . . call
|
||||
e8/call write/disp32
|
||||
|
@ -2315,20 +2315,6 @@ test-string-length-at-start-of-slice-escaped:
|
|||
Next-string-literal: # tracks the next auto-generated variable name
|
||||
1/imm32
|
||||
|
||||
# length-prefixed string containing just a single space
|
||||
Space:
|
||||
# size
|
||||
1/imm32
|
||||
# data
|
||||
20/space
|
||||
|
||||
# length-prefixed string containing just a single slash
|
||||
Slash:
|
||||
# size
|
||||
1/imm32
|
||||
# data
|
||||
2f/slash
|
||||
|
||||
_test-slice-abc:
|
||||
22/dquote 61/a 62/b 63/c 22/dquote # "abc"
|
||||
2f/slash 64/d
|
||||
|
|
BIN
apps/factorial
BIN
apps/factorial
Binary file not shown.
BIN
apps/handle
BIN
apps/handle
Binary file not shown.
|
@ -1133,7 +1133,7 @@ $convert-data:single-byte:
|
|||
$convert-data:break:
|
||||
# write-buffered(out, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
@ -2102,7 +2102,7 @@ $emit-opcodes:op1:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# write-buffered(out, " ")
|
||||
# . . push args
|
||||
68/push " "/imm32
|
||||
68/push Space/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
@ -2195,7 +2195,7 @@ $emit-opcodes:op2:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# write-buffered(out, " ")
|
||||
# . . push args
|
||||
68/push " "/imm32
|
||||
68/push Space/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
@ -2274,7 +2274,7 @@ $emit-opcodes:op3:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# write-buffered(out, " ")
|
||||
# . . push args
|
||||
68/push " "/imm32
|
||||
68/push Space/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
|
BIN
apps/sigils
BIN
apps/sigils
Binary file not shown.
|
@ -341,7 +341,7 @@ $convert:regular-word:
|
|||
$convert:next-word:
|
||||
# write-buffered(out, " ")
|
||||
# . . push args
|
||||
68/push " "/imm32
|
||||
68/push Space/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
@ -2582,7 +2582,7 @@ $parse-effective-address:error1:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . write-buffered(Stderr, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
68/push Stderr/imm32
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
@ -2621,7 +2621,7 @@ $parse-effective-address:error2:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . write-buffered(Stderr, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
68/push Stderr/imm32
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
@ -2660,7 +2660,7 @@ $parse-effective-address:error3:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . write-buffered(Stderr, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
68/push Stderr/imm32
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
@ -4194,7 +4194,7 @@ $next-hex-int:abort:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
|
||||
# . _write(2/stderr, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
68/push 2/imm32/stderr
|
||||
# . . call
|
||||
e8/call _write/disp32
|
||||
|
|
|
@ -699,7 +699,7 @@ $emit:name:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . write-buffered(out, " ")
|
||||
# . . push args
|
||||
68/push " "/imm32
|
||||
68/push Space/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
|
BIN
apps/survey
BIN
apps/survey
Binary file not shown.
|
@ -197,7 +197,7 @@ convert: # infile : (address buffered-file), out : (address buffered-file) -> <
|
|||
#? 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
|
||||
#? # . write(2/stderr, "\n")
|
||||
#? # . . push args
|
||||
#? 68/push "\n"/imm32
|
||||
#? 68/push Newline/imm32
|
||||
#? 68/push 2/imm32/stderr
|
||||
#? # . . call
|
||||
#? e8/call write/disp32
|
||||
|
@ -260,7 +260,7 @@ convert: # infile : (address buffered-file), out : (address buffered-file) -> <
|
|||
#? 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
|
||||
#? # . write(2/stderr, "\n")
|
||||
#? # . . push args
|
||||
#? 68/push "\n"/imm32
|
||||
#? 68/push Newline/imm32
|
||||
#? 68/push 2/imm32/stderr
|
||||
#? # . . call
|
||||
#? e8/call write/disp32
|
||||
|
@ -416,7 +416,7 @@ convert: # infile : (address buffered-file), out : (address buffered-file) -> <
|
|||
#? 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
|
||||
#? # . write(2/stderr, "\n")
|
||||
#? # . . push args
|
||||
#? 68/push "\n"/imm32
|
||||
#? 68/push Newline/imm32
|
||||
#? 68/push 2/imm32/stderr
|
||||
#? # . . call
|
||||
#? e8/call write/disp32
|
||||
|
@ -1160,7 +1160,7 @@ $compute-offsets:case-default:
|
|||
#? 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
|
||||
#? # . write(2/stderr, "\n")
|
||||
#? # . . push args
|
||||
#? 68/push "\n"/imm32
|
||||
#? 68/push Newline/imm32
|
||||
#? 68/push 2/imm32/stderr
|
||||
#? # . . call
|
||||
#? e8/call write/disp32
|
||||
|
@ -2214,7 +2214,7 @@ $emit-segments:2-character:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# write-buffered(out, " ")
|
||||
# . . push args
|
||||
68/push " "/imm32
|
||||
68/push Space/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
@ -3328,7 +3328,7 @@ $emit-headers:loop:
|
|||
#? 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
|
||||
#? # . write(2/stderr, "\n")
|
||||
#? # . . push args
|
||||
#? 68/push "\n"/imm32
|
||||
#? 68/push Newline/imm32
|
||||
#? 68/push 2/imm32/stderr
|
||||
#? # . . call
|
||||
#? e8/call write/disp32
|
||||
|
@ -3416,7 +3416,7 @@ emit-elf-header: # out : (address buffered-file), segments : (address stream {s
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# write-buffered(out, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
@ -3504,7 +3504,7 @@ $emit-elf-program-header-entry:really-emit:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# write-buffered(out, "\n")
|
||||
# . . push args
|
||||
68/push "\n"/imm32
|
||||
68/push Newline/imm32
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8)
|
||||
# . . call
|
||||
e8/call write-buffered/disp32
|
||||
|
|
BIN
apps/tests
BIN
apps/tests
Binary file not shown.
Loading…
Reference in New Issue