diff options
author | Denys Vlasenko | 2019-01-25 14:24:03 +0100 |
---|---|---|
committer | Denys Vlasenko | 2019-01-25 16:22:15 +0100 |
commit | 53799506acf69e7f7137d91fa5a4451211621469 (patch) | |
tree | 31e99c03e5597ad3546a50f1e94b5155a8a53235 /testsuite/bc_references.bc | |
parent | db5a6daa7f6fe92cdb70e53aec2f3717b6892b2a (diff) | |
download | busybox-53799506acf69e7f7137d91fa5a4451211621469.zip busybox-53799506acf69e7f7137d91fa5a4451211621469.tar.gz |
bc: implement pass-by-reference code from upstream
function old new delta
zxc_program_popResultAndCopyToVar 298 493 +195
bc_vec_pushIndex - 75 +75
zxc_vm_process 859 928 +69
xc_program_dereference - 66 +66
bc_vec_npush - 65 +65
zbc_num_s 239 249 +10
zxc_program_num 1024 1032 +8
zbc_num_divmod 150 156 +6
xc_program_search 143 146 +3
zxc_program_assign 392 389 -3
zdc_program_execStr 520 517 -3
xc_program_pushVar 198 195 -3
zxc_program_exec 4101 4092 -9
zbc_program_call 318 308 -10
zbc_func_insert 120 104 -16
zbc_parse_stmt_possibly_auto 1460 1439 -21
bc_vec_push 53 12 -41
xc_parse_pushIndex 61 18 -43
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 6/9 up/down: 497/-149) Total: 348 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite/bc_references.bc')
-rw-r--r-- | testsuite/bc_references.bc | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/testsuite/bc_references.bc b/testsuite/bc_references.bc new file mode 100644 index 0000000..fc48c1a --- /dev/null +++ b/testsuite/bc_references.bc @@ -0,0 +1,106 @@ +define printarray(a[], len) { + + auto i + + for (i = 0; i < len; ++i) { + a[i] + } +} + +define a2(a[], len) { + + auto i + + for (i = 0; i < len; ++i) { + a[i] = a[i] * a[i] + } + + printarray(a[], len) +} + +define a4(a__[], len) { + + auto i + + for (i = 0; i < len; ++i) { + a__[i] = a__[i] * a__[i] + } + + printarray(a__[], len) +} + +define a6(*a__[], len) { + + auto i + + for (i = 0; i < len; ++i) { + a__[i] = a__[i] * a__[i] + } + + printarray(a__[], len) +} + +define a1(*a[], len) { + + auto i + + for (i = 0; i < len; ++i) { + a[i] = i + } + + a2(a[], len) + + printarray(a[], len) +} + +define a3(*a__[], len) { + + auto i + + for (i = 0; i < len; ++i) { + a__[i] = i + } + + a4(a__[], len) + + printarray(a__[], len) +} + +define a5(*a__[], len) { + + auto i + + for (i = 0; i < len; ++i) { + a__[i] = i + } + + a2(a__[], len) + + printarray(a__[], len) +} + +define a7(*a__[], len) { + + auto i + + for (i = 0; i < len; ++i) { + a__[i] = i + } + + a6(a__[], len) + + printarray(a__[], len) +} + +len = 16 + +a1(a[], len) +printarray(a[], len) +a3(a[], len) +printarray(a[], len) +a5(a[], len) +printarray(a[], len) +a7(a[], len) +printarray(a[], len) + +halt |