From 374397f0cbd841bb76f0798eae7d3a18f5eef3b6 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 26 Nov 2019 22:21:06 -0800 Subject: 5766 --- html/apps/mu.subx.html | 496 +++++++++++++++++++++++++++++-------------------- 1 file changed, 299 insertions(+), 197 deletions(-) (limited to 'html/apps/mu.subx.html') diff --git a/html/apps/mu.subx.html b/html/apps/mu.subx.html index 964fc239..c1f45e1a 100644 --- a/html/apps/mu.subx.html +++ b/html/apps/mu.subx.html @@ -484,7 +484,7 @@ if ('onhashchange' in window) { 422 # convert 423 (convert-mu _test-input-buffered-file _test-output-buffered-file) 424 (flush _test-output-buffered-file) - 425 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 425 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 431 # check output 432 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-skeleton/0") 433 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-skeleton/1") @@ -538,7 +538,7 @@ if ('onhashchange' in window) { 481 # convert 482 (convert-mu _test-input-buffered-file _test-output-buffered-file) 483 (flush _test-output-buffered-file) - 484 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 484 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 490 # check first function 491 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-multiple-function-skeletons/0") 492 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-multiple-function-skeletons/1") @@ -594,7 +594,7 @@ if ('onhashchange' in window) { 542 # convert 543 (convert-mu _test-input-buffered-file _test-output-buffered-file) 544 (flush _test-output-buffered-file) - 545 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 545 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 551 # check output 552 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-skeleton/0") 553 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-skeleton/1") @@ -659,7 +659,7 @@ if ('onhashchange' in window) { 612 # if (line->write == 0) break 613 81 7/subop/compare *ecx 0/imm32 614 0f 84/jump-if-equal break/disp32 - 615 +-- 6 lines: #? # dump line ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 615 +-- 6 lines: #? # dump line --------------------------------------------------------------------------------------------------------------------------- 621 { # word loop 622 $parse-mu:word-loop: 623 (next-word-or-string %ecx %edx) @@ -991,9 +991,9 @@ if ('onhashchange' in window) { 949 # 950 (write-buffered %edi *ecx) 951 (write-buffered %edi ":\n") - 952 (emit-subx-prologue %edi) + 952 (emit-subx-prologue %edi) 953 (emit-subx-block %edi *(ecx+0x10)) # Function-body - 954 (emit-subx-epilogue %edi) + 954 (emit-subx-epilogue %edi) 955 $emit-subx-function:end: 956 # . restore registers 957 5f/pop-to-edi @@ -1751,7 +1751,7 @@ if ('onhashchange' in window) { 1709 # convert 1710 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0) 1711 (flush _test-output-buffered-file) -1712 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +1712 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 1718 # check output 1719 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0xfffffff8)" "F - test-emit-subx-statement-primitive") 1720 # . epilogue @@ -1830,7 +1830,7 @@ if ('onhashchange' in window) { 1793 # convert 1794 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0) 1795 (flush _test-output-buffered-file) -1796 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +1796 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 1802 # check output 1803 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-primitive-register") 1804 # . epilogue @@ -1922,7 +1922,7 @@ if ('onhashchange' in window) { 1890 # convert 1891 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0) 1892 (flush _test-output-buffered-file) -1893 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +1893 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 1899 # check output 1900 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive") 1901 # . epilogue @@ -2014,7 +2014,7 @@ if ('onhashchange' in window) { 1987 # convert 1988 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0) 1989 (flush _test-output-buffered-file) -1990 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +1990 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 1996 # check output 1997 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive-2") 1998 # . epilogue @@ -2069,7 +2069,7 @@ if ('onhashchange' in window) { 2047 # convert 2048 (emit-subx-statement _test-output-buffered-file %esi %edx Primitives 0) 2049 (flush _test-output-buffered-file) -2050 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +2050 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 2056 # check output 2057 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-increment-register") 2058 # . epilogue @@ -2124,7 +2124,7 @@ if ('onhashchange' in window) { 2107 # convert 2108 (emit-subx-statement _test-output-buffered-file %esi %edx Primitives 0) 2109 (flush _test-output-buffered-file) -2110 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +2110 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 2116 # check output 2117 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-increment-var") 2118 # . epilogue @@ -2175,7 +2175,7 @@ if ('onhashchange' in window) { 2163 # convert 2164 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0) 2165 (flush _test-output-buffered-file) -2166 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +2166 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 2172 # check output 2173 (check-next-stream-line-equal _test-output-stream "01 %eax 0x00000001/r32" "F - test-add-reg-to-reg") 2174 # . epilogue @@ -2183,10 +2183,10 @@ if ('onhashchange' in window) { 2176 5d/pop-to-ebp 2177 c3/return 2178 -2179 test-add-literal-to-reg: -2180 # var1/eax <- add 0x34 +2179 test-add-reg-to-mem: +2180 # add-to var1 var2/reg 2181 # => -2182 # 81 0/subop/add %eax 0x34/imm32 +2182 # 01 *(ebp+__) var2 2183 # 2184 # . prologue 2185 55/push-ebp @@ -2194,50 +2194,50 @@ if ('onhashchange' in window) { 2187 # setup 2188 (clear-stream _test-output-stream) 2189 (clear-stream _test-output-buffered-file->buffer) -2190 # var-var1/ecx : var in eax -2191 68/push "eax"/imm32/register -2192 68/push 0/imm32/no-stack-offset +2190 # var-var1/ecx : var +2191 68/push 0/imm32/no-register +2192 68/push 8/imm32/stack-offset 2193 68/push 1/imm32/block-depth 2194 68/push 1/imm32/type-int 2195 68/push "var1"/imm32 2196 89/<- %ecx 4/r32/esp -2197 # var-var2/edx : var literal -2198 68/push 0/imm32/no-register +2197 # var-var2/edx : var in ecx +2198 68/push "ecx"/imm32/register 2199 68/push 0/imm32/no-stack-offset 2200 68/push 1/imm32/block-depth -2201 68/push 0/imm32/type-literal -2202 68/push "0x34"/imm32 +2201 68/push 1/imm32/type-int +2202 68/push "var2"/imm32 2203 89/<- %edx 4/r32/esp 2204 # inouts/esi : (list var2) 2205 68/push 0/imm32/next 2206 52/push-edx/var-var2 2207 89/<- %esi 4/r32/esp -2208 # outputs/edi : (list var1) -2209 68/push 0/imm32/next +2208 # inouts = (list var1 var2) +2209 56/push-esi/next 2210 51/push-ecx/var-var1 -2211 89/<- %edi 4/r32/esp +2211 89/<- %esi 4/r32/esp 2212 # stmt/esi : statement 2213 68/push 0/imm32/next -2214 57/push-edi/outputs +2214 68/push 0/imm32/outputs 2215 56/push-esi/inouts -2216 68/push "add"/imm32/operation +2216 68/push "add-to"/imm32/operation 2217 68/push 1/imm32 2218 89/<- %esi 4/r32/esp 2219 # convert 2220 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0) 2221 (flush _test-output-buffered-file) -2222 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +2222 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 2228 # check output -2229 (check-next-stream-line-equal _test-output-stream "81 0/subop/add %eax 0x34/imm32" "F - test-add-literal-to-reg") +2229 (check-next-stream-line-equal _test-output-stream "01 *(ebp+0x00000008) 0x00000001/r32" "F - test-add-reg-to-mem") 2230 # . epilogue 2231 89/<- %esp 5/r32/ebp 2232 5d/pop-to-ebp 2233 c3/return 2234 -2235 test-add-literal-to-mem: -2236 # add-to var1, 0x34 +2235 test-add-mem-to-reg: +2236 # var1/reg <- add var2 2237 # => -2238 # 81 0/subop/add %eax 0x34/imm32 +2238 # 03 *(ebp+__) var1 2239 # 2240 # . prologue 2241 55/push-ebp @@ -2245,196 +2245,298 @@ if ('onhashchange' in window) { 2243 # setup 2244 (clear-stream _test-output-stream) 2245 (clear-stream _test-output-buffered-file->buffer) -2246 # var-var1/ecx : var -2247 68/push 0/imm32/no-register -2248 68/push 8/imm32/stack-offset +2246 # var-var1/ecx : var in eax +2247 68/push "eax"/imm32/register +2248 68/push 0/imm32/no-stack-offset 2249 68/push 1/imm32/block-depth 2250 68/push 1/imm32/type-int 2251 68/push "var1"/imm32 2252 89/<- %ecx 4/r32/esp -2253 # var-var2/edx : var literal +2253 # var-var2/edx : var 2254 68/push 0/imm32/no-register -2255 68/push 0/imm32/no-stack-offset +2255 68/push 8/imm32/stack-offset 2256 68/push 1/imm32/block-depth -2257 68/push 0/imm32/type-literal -2258 68/push "0x34"/imm32 +2257 68/push 1/imm32/type-int +2258 68/push "var2"/imm32 2259 89/<- %edx 4/r32/esp 2260 # inouts/esi : (list var2) 2261 68/push 0/imm32/next 2262 52/push-edx/var-var2 2263 89/<- %esi 4/r32/esp -2264 # inouts = (list var1 inouts) -2265 56/push-esi/next +2264 # outputs/edi : (list var1) +2265 68/push 0/imm32/next 2266 51/push-ecx/var-var1 -2267 89/<- %esi 4/r32/esp +2267 89/<- %edi 4/r32/esp 2268 # stmt/esi : statement 2269 68/push 0/imm32/next -2270 68/push 0/imm32/outputs +2270 57/push-edi/outputs 2271 56/push-esi/inouts -2272 68/push "add-to"/imm32/operation +2272 68/push "add"/imm32/operation 2273 68/push 1/imm32 2274 89/<- %esi 4/r32/esp 2275 # convert 2276 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0) 2277 (flush _test-output-buffered-file) -2278 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +2278 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- 2284 # check output -2285 (check-next-stream-line-equal _test-output-stream "81 0/subop/add *(ebp+0x00000008) 0x34/imm32" "F - test-add-literal-to-mem") +2285 (check-next-stream-line-equal _test-output-stream "03 *(ebp+0x00000008) 0x00000000/r32" "F - test-add-mem-to-reg") 2286 # . epilogue 2287 89/<- %esp 5/r32/ebp 2288 5d/pop-to-ebp 2289 c3/return 2290 -2291 test-emit-subx-statement-function-call: -2292 # Call a function on a variable on the stack. -2293 # f foo -2294 # => -2295 # (f2 *(ebp-8)) -2296 # (Changing the function name supports overloading in general, but here it -2297 # just serves to help disambiguate things.) -2298 # -2299 # There's a variable on the var stack as follows: -2300 # name: 'foo' -2301 # type: int -2302 # stack-offset: -8 -2303 # -2304 # There's nothing in primitives. -2305 # -2306 # There's a function with this info: -2307 # name: 'f' -2308 # inout: int/mem -2309 # value: 'f2' -2310 # -2311 # . prologue -2312 55/push-ebp -2313 89/<- %ebp 4/r32/esp -2314 # setup -2315 (clear-stream _test-output-stream) -2316 (clear-stream _test-output-buffered-file->buffer) -2317 # var-foo/ecx : var -2318 68/push 0/imm32/no-register -2319 68/push -8/imm32/stack-offset -2320 68/push 0/imm32/block-depth -2321 68/push 1/imm32/type-int -2322 68/push "foo"/imm32 -2323 89/<- %ecx 4/r32/esp -2324 # vars/edx = (stack 1) -2325 51/push-ecx/var-foo -2326 68/push 1/imm32/data-length -2327 68/push 1/imm32/top -2328 89/<- %edx 4/r32/esp -2329 # operands/esi : (list var) -2330 68/push 0/imm32/next -2331 51/push-ecx/var-foo -2332 89/<- %esi 4/r32/esp -2333 # stmt/esi : statement -2334 68/push 0/imm32/next -2335 68/push 0/imm32/outputs -2336 56/push-esi/inouts -2337 68/push "f"/imm32/operation -2338 68/push 1/imm32 -2339 89/<- %esi 4/r32/esp -2340 # functions/ebx : function -2341 68/push 0/imm32/next -2342 68/push 0/imm32/body -2343 68/push 0/imm32/outputs -2344 51/push-ecx/inouts # hack; in practice we won't have the same var in function definition and call -2345 68/push "f2"/imm32/subx-name -2346 68/push "f"/imm32/name -2347 89/<- %ebx 4/r32/esp -2348 # convert -2349 (emit-subx-statement _test-output-buffered-file %esi %edx 0 %ebx) -2350 (flush _test-output-buffered-file) -2351 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -2357 # check output -2358 (check-next-stream-line-equal _test-output-stream "(f2 *(ebp+0xfffffff8))" "F - test-emit-subx-statement-function-call") -2359 # . epilogue -2360 89/<- %esp 5/r32/ebp -2361 5d/pop-to-ebp -2362 c3/return -2363 -2364 test-emit-subx-statement-function-call-with-literal-arg: -2365 # Call a function on a literal. -2366 # f 34 -2367 # => -2368 # (f2 34) -2369 # -2370 # . prologue -2371 55/push-ebp -2372 89/<- %ebp 4/r32/esp -2373 # setup -2374 (clear-stream _test-output-stream) -2375 (clear-stream _test-output-buffered-file->buffer) -2376 # var-foo/ecx : literal -2377 68/push 0/imm32/no-register -2378 68/push 0/imm32/no-stack-offset -2379 68/push 0/imm32/block-depth -2380 68/push 0/imm32/type-literal -2381 68/push "34"/imm32 -2382 89/<- %ecx 4/r32/esp -2383 # vars/edx = (stack 1) -2384 51/push-ecx/var-foo -2385 68/push 1/imm32/data-length -2386 68/push 1/imm32/top -2387 89/<- %edx 4/r32/esp -2388 # operands/esi : (list var) -2389 68/push 0/imm32/next -2390 51/push-ecx/var-foo -2391 89/<- %esi 4/r32/esp -2392 # stmt/esi : statement -2393 68/push 0/imm32/next -2394 68/push 0/imm32/outputs -2395 56/push-esi/inouts -2396 68/push "f"/imm32/operation -2397 68/push 1/imm32 -2398 89/<- %esi 4/r32/esp -2399 # functions/ebx : function -2400 68/push 0/imm32/next -2401 68/push 0/imm32/body -2402 68/push 0/imm32/outputs -2403 51/push-ecx/inouts # hack; in practice we won't have the same var in function definition and call -2404 68/push "f2"/imm32/subx-name -2405 68/push "f"/imm32/name -2406 89/<- %ebx 4/r32/esp -2407 # convert -2408 (emit-subx-statement _test-output-buffered-file %esi %edx 0 %ebx) -2409 (flush _test-output-buffered-file) -2410 +-- 6 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -2416 # check output -2417 (check-next-stream-line-equal _test-output-stream "(f2 34)" "F - test-emit-subx-statement-function-call-with-literal-arg") -2418 # . epilogue -2419 89/<- %esp 5/r32/ebp -2420 5d/pop-to-ebp -2421 c3/return -2422 -2423 emit-subx-prologue: # out : (address buffered-file) -2424 # . prologue -2425 55/push-ebp -2426 89/<- %ebp 4/r32/esp -2427 # -2428 (write-buffered *(ebp+8) "# . prologue\n") -2429 (write-buffered *(ebp+8) "55/push-ebp\n") -2430 (write-buffered *(ebp+8) "89/<- %ebp 4/r32/esp\n") -2431 $emit-subx-prologue:end: -2432 # . epilogue -2433 89/<- %esp 5/r32/ebp -2434 5d/pop-to-ebp -2435 c3/return -2436 -2437 emit-subx-epilogue: # out : (address buffered-file) -2438 # . prologue -2439 55/push-ebp -2440 89/<- %ebp 4/r32/esp -2441 # -2442 (write-buffered *(ebp+8) "# . epilogue\n") -2443 (write-buffered *(ebp+8) "89/<- %esp 5/r32/ebp\n") -2444 (write-buffered *(ebp+8) "5d/pop-to-ebp\n") -2445 (write-buffered *(ebp+8) "c3/return\n") -2446 $emit-subx-epilogue:end: -2447 # . epilogue -2448 89/<- %esp 5/r32/ebp -2449 5d/pop-to-ebp -2450 c3/return +2291 test-add-literal-to-reg: +2292 # var1/eax <- add 0x34 +2293 # => +2294 # 81 0/subop/add %eax 0x34/imm32 +2295 # +2296 # . prologue +2297 55/push-ebp +2298 89/<- %ebp 4/r32/esp +2299 # setup +2300 (clear-stream _test-output-stream) +2301 (clear-stream _test-output-buffered-file->buffer) +2302 # var-var1/ecx : var in eax +2303 68/push "eax"/imm32/register +2304 68/push 0/imm32/no-stack-offset +2305 68/push 1/imm32/block-depth +2306 68/push 1/imm32/type-int +2307 68/push "var1"/imm32 +2308 89/<- %ecx 4/r32/esp +2309 # var-var2/edx : var literal +2310 68/push 0/imm32/no-register +2311 68/push 0/imm32/no-stack-offset +2312 68/push 1/imm32/block-depth +2313 68/push 0/imm32/type-literal +2314 68/push "0x34"/imm32 +2315 89/<- %edx 4/r32/esp +2316 # inouts/esi : (list var2) +2317 68/push 0/imm32/next +2318 52/push-edx/var-var2 +2319 89/<- %esi 4/r32/esp +2320 # outputs/edi : (list var1) +2321 68/push 0/imm32/next +2322 51/push-ecx/var-var1 +2323 89/<- %edi 4/r32/esp +2324 # stmt/esi : statement +2325 68/push 0/imm32/next +2326 57/push-edi/outputs +2327 56/push-esi/inouts +2328 68/push "add"/imm32/operation +2329 68/push 1/imm32 +2330 89/<- %esi 4/r32/esp +2331 # convert +2332 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0) +2333 (flush _test-output-buffered-file) +2334 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- +2340 # check output +2341 (check-next-stream-line-equal _test-output-stream "81 0/subop/add %eax 0x34/imm32" "F - test-add-literal-to-reg") +2342 # . epilogue +2343 89/<- %esp 5/r32/ebp +2344 5d/pop-to-ebp +2345 c3/return +2346 +2347 test-add-literal-to-mem: +2348 # add-to var1, 0x34 +2349 # => +2350 # 81 0/subop/add %eax 0x34/imm32 +2351 # +2352 # . prologue +2353 55/push-ebp +2354 89/<- %ebp 4/r32/esp +2355 # setup +2356 (clear-stream _test-output-stream) +2357 (clear-stream _test-output-buffered-file->buffer) +2358 # var-var1/ecx : var +2359 68/push 0/imm32/no-register +2360 68/push 8/imm32/stack-offset +2361 68/push 1/imm32/block-depth +2362 68/push 1/imm32/type-int +2363 68/push "var1"/imm32 +2364 89/<- %ecx 4/r32/esp +2365 # var-var2/edx : var literal +2366 68/push 0/imm32/no-register +2367 68/push 0/imm32/no-stack-offset +2368 68/push 1/imm32/block-depth +2369 68/push 0/imm32/type-literal +2370 68/push "0x34"/imm32 +2371 89/<- %edx 4/r32/esp +2372 # inouts/esi : (list var2) +2373 68/push 0/imm32/next +2374 52/push-edx/var-var2 +2375 89/<- %esi 4/r32/esp +2376 # inouts = (list var1 inouts) +2377 56/push-esi/next +2378 51/push-ecx/var-var1 +2379 89/<- %esi 4/r32/esp +2380 # stmt/esi : statement +2381 68/push 0/imm32/next +2382 68/push 0/imm32/outputs +2383 56/push-esi/inouts +2384 68/push "add-to"/imm32/operation +2385 68/push 1/imm32 +2386 89/<- %esi 4/r32/esp +2387 # convert +2388 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0) +2389 (flush _test-output-buffered-file) +2390 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- +2396 # check output +2397 (check-next-stream-line-equal _test-output-stream "81 0/subop/add *(ebp+0x00000008) 0x34/imm32" "F - test-add-literal-to-mem") +2398 # . epilogue +2399 89/<- %esp 5/r32/ebp +2400 5d/pop-to-ebp +2401 c3/return +2402 +2403 test-emit-subx-statement-function-call: +2404 # Call a function on a variable on the stack. +2405 # f foo +2406 # => +2407 # (f2 *(ebp-8)) +2408 # (Changing the function name supports overloading in general, but here it +2409 # just serves to help disambiguate things.) +2410 # +2411 # There's a variable on the var stack as follows: +2412 # name: 'foo' +2413 # type: int +2414 # stack-offset: -8 +2415 # +2416 # There's nothing in primitives. +2417 # +2418 # There's a function with this info: +2419 # name: 'f' +2420 # inout: int/mem +2421 # value: 'f2' +2422 # +2423 # . prologue +2424 55/push-ebp +2425 89/<- %ebp 4/r32/esp +2426 # setup +2427 (clear-stream _test-output-stream) +2428 (clear-stream _test-output-buffered-file->buffer) +2429 # var-foo/ecx : var +2430 68/push 0/imm32/no-register +2431 68/push -8/imm32/stack-offset +2432 68/push 0/imm32/block-depth +2433 68/push 1/imm32/type-int +2434 68/push "foo"/imm32 +2435 89/<- %ecx 4/r32/esp +2436 # vars/edx = (stack 1) +2437 51/push-ecx/var-foo +2438 68/push 1/imm32/data-length +2439 68/push 1/imm32/top +2440 89/<- %edx 4/r32/esp +2441 # operands/esi : (list var) +2442 68/push 0/imm32/next +2443 51/push-ecx/var-foo +2444 89/<- %esi 4/r32/esp +2445 # stmt/esi : statement +2446 68/push 0/imm32/next +2447 68/push 0/imm32/outputs +2448 56/push-esi/inouts +2449 68/push "f"/imm32/operation +2450 68/push 1/imm32 +2451 89/<- %esi 4/r32/esp +2452 # functions/ebx : function +2453 68/push 0/imm32/next +2454 68/push 0/imm32/body +2455 68/push 0/imm32/outputs +2456 51/push-ecx/inouts # hack; in practice we won't have the same var in function definition and call +2457 68/push "f2"/imm32/subx-name +2458 68/push "f"/imm32/name +2459 89/<- %ebx 4/r32/esp +2460 # convert +2461 (emit-subx-statement _test-output-buffered-file %esi %edx 0 %ebx) +2462 (flush _test-output-buffered-file) +2463 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- +2469 # check output +2470 (check-next-stream-line-equal _test-output-stream "(f2 *(ebp+0xfffffff8))" "F - test-emit-subx-statement-function-call") +2471 # . epilogue +2472 89/<- %esp 5/r32/ebp +2473 5d/pop-to-ebp +2474 c3/return +2475 +2476 test-emit-subx-statement-function-call-with-literal-arg: +2477 # Call a function on a literal. +2478 # f 34 +2479 # => +2480 # (f2 34) +2481 # +2482 # . prologue +2483 55/push-ebp +2484 89/<- %ebp 4/r32/esp +2485 # setup +2486 (clear-stream _test-output-stream) +2487 (clear-stream _test-output-buffered-file->buffer) +2488 # var-foo/ecx : literal +2489 68/push 0/imm32/no-register +2490 68/push 0/imm32/no-stack-offset +2491 68/push 0/imm32/block-depth +2492 68/push 0/imm32/type-literal +2493 68/push "34"/imm32 +2494 89/<- %ecx 4/r32/esp +2495 # vars/edx = (stack 1) +2496 51/push-ecx/var-foo +2497 68/push 1/imm32/data-length +2498 68/push 1/imm32/top +2499 89/<- %edx 4/r32/esp +2500 # operands/esi : (list var) +2501 68/push 0/imm32/next +2502 51/push-ecx/var-foo +2503 89/<- %esi 4/r32/esp +2504 # stmt/esi : statement +2505 68/push 0/imm32/next +2506 68/push 0/imm32/outputs +2507 56/push-esi/inouts +2508 68/push "f"/imm32/operation +2509 68/push 1/imm32 +2510 89/<- %esi 4/r32/esp +2511 # functions/ebx : function +2512 68/push 0/imm32/next +2513 68/push 0/imm32/body +2514 68/push 0/imm32/outputs +2515 51/push-ecx/inouts # hack; in practice we won't have the same var in function definition and call +2516 68/push "f2"/imm32/subx-name +2517 68/push "f"/imm32/name +2518 89/<- %ebx 4/r32/esp +2519 # convert +2520 (emit-subx-statement _test-output-buffered-file %esi %edx 0 %ebx) +2521 (flush _test-output-buffered-file) +2522 +-- 6 lines: #? # dump _test-output-stream -------------------------------------------------------------------------------------------------------------- +2528 # check output +2529 (check-next-stream-line-equal _test-output-stream "(f2 34)" "F - test-emit-subx-statement-function-call-with-literal-arg") +2530 # . epilogue +2531 89/<- %esp 5/r32/ebp +2532 5d/pop-to-ebp +2533 c3/return +2534 +2535 emit-subx-prologue: # out : (address buffered-file) +2536 # . prologue +2537 55/push-ebp +2538 89/<- %ebp 4/r32/esp +2539 # +2540 (write-buffered *(ebp+8) "# . prologue\n") +2541 (write-buffered *(ebp+8) "55/push-ebp\n") +2542 (write-buffered *(ebp+8) "89/<- %ebp 4/r32/esp\n") +2543 $emit-subx-prologue:end: +2544 # . epilogue +2545 89/<- %esp 5/r32/ebp +2546 5d/pop-to-ebp +2547 c3/return +2548 +2549 emit-subx-epilogue: # out : (address buffered-file) +2550 # . prologue +2551 55/push-ebp +2552 89/<- %ebp 4/r32/esp +2553 # +2554 (write-buffered *(ebp+8) "# . epilogue\n") +2555 (write-buffered *(ebp+8) "89/<- %esp 5/r32/ebp\n") +2556 (write-buffered *(ebp+8) "5d/pop-to-ebp\n") +2557 (write-buffered *(ebp+8) "c3/return\n") +2558 $emit-subx-epilogue:end: +2559 # . epilogue +2560 89/<- %esp 5/r32/ebp +2561 5d/pop-to-ebp +2562 c3/return -- cgit 1.4.1-2-gfad0