From a9d473e22426a7636980b8266e9b48cbae3bba05 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Thu, 19 Sep 2019 14:57:55 -0700 Subject: 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. --- apps/assort | Bin 40205 -> 40175 bytes apps/assort.subx | 2 +- apps/braces | Bin 39594 -> 39569 bytes apps/calls | Bin 44955 -> 44930 bytes apps/crenshaw2-1 | Bin 33939 -> 33919 bytes apps/crenshaw2-1b | Bin 34498 -> 34478 bytes apps/dquotes | Bin 45409 -> 45364 bytes apps/dquotes.subx | 18 ++---------------- apps/factorial | Bin 32951 -> 32931 bytes apps/handle | Bin 33805 -> 33785 bytes apps/hex | Bin 42598 -> 42573 bytes apps/pack | Bin 52891 -> 52846 bytes apps/pack.subx | 8 ++++---- apps/sigils | Bin 52918 -> 52868 bytes apps/sigils.subx | 10 +++++----- apps/subx-common.subx | 2 +- apps/survey | Bin 49488 -> 49448 bytes apps/survey.subx | 16 ++++++++-------- apps/tests | Bin 39017 -> 38992 bytes 19 files changed, 21 insertions(+), 35 deletions(-) (limited to 'apps') diff --git a/apps/assort b/apps/assort index aac0b75a..69d3436b 100755 Binary files a/apps/assort and b/apps/assort differ diff --git a/apps/assort.subx b/apps/assort.subx index 71aee164..2e9fee47 100644 --- a/apps/assort.subx +++ b/apps/assort.subx @@ -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 diff --git a/apps/braces b/apps/braces index c3f88cd8..67c0f75a 100755 Binary files a/apps/braces and b/apps/braces differ diff --git a/apps/calls b/apps/calls index 11179969..2ec41b22 100755 Binary files a/apps/calls and b/apps/calls differ diff --git a/apps/crenshaw2-1 b/apps/crenshaw2-1 index 62c12a81..e8992622 100755 Binary files a/apps/crenshaw2-1 and b/apps/crenshaw2-1 differ diff --git a/apps/crenshaw2-1b b/apps/crenshaw2-1b index e22acd4a..cddb2555 100755 Binary files a/apps/crenshaw2-1b and b/apps/crenshaw2-1b differ diff --git a/apps/dquotes b/apps/dquotes index d3f84e8b..ede07c89 100755 Binary files a/apps/dquotes and b/apps/dquotes differ diff --git a/apps/dquotes.subx b/apps/dquotes.subx index 6e5882b9..337992e4 100644 --- a/apps/dquotes.subx +++ b/apps/dquotes.subx @@ -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 diff --git a/apps/factorial b/apps/factorial index ad02a27e..19f57d7a 100755 Binary files a/apps/factorial and b/apps/factorial differ diff --git a/apps/handle b/apps/handle index c4ed2356..1ac9ea30 100755 Binary files a/apps/handle and b/apps/handle differ diff --git a/apps/hex b/apps/hex index e5cdd533..f0828df4 100755 Binary files a/apps/hex and b/apps/hex differ diff --git a/apps/pack b/apps/pack index 55fcfb6d..56826bf4 100755 Binary files a/apps/pack and b/apps/pack differ diff --git a/apps/pack.subx b/apps/pack.subx index f4caceba..4dda514b 100644 --- a/apps/pack.subx +++ b/apps/pack.subx @@ -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 diff --git a/apps/sigils b/apps/sigils index 22dadf70..4a4bebf1 100755 Binary files a/apps/sigils and b/apps/sigils differ diff --git a/apps/sigils.subx b/apps/sigils.subx index e495483e..8c8beba7 100644 --- a/apps/sigils.subx +++ b/apps/sigils.subx @@ -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 diff --git a/apps/subx-common.subx b/apps/subx-common.subx index 7cce0d20..cc3b12af 100644 --- a/apps/subx-common.subx +++ b/apps/subx-common.subx @@ -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 diff --git a/apps/survey b/apps/survey index b55bc007..ec7e318f 100755 Binary files a/apps/survey and b/apps/survey differ diff --git a/apps/survey.subx b/apps/survey.subx index e685d436..678ed116 100644 --- a/apps/survey.subx +++ b/apps/survey.subx @@ -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 diff --git a/apps/tests b/apps/tests index 2fc7071c..36ba05ea 100755 Binary files a/apps/tests and b/apps/tests differ -- cgit 1.4.1-2-gfad0