summaryrefslogtreecommitdiffstats
path: root/tests/assemble.test
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2010-10-24 01:46:41 (GMT)
committerKevin B Kenny <kennykb@acm.org>2010-10-24 01:46:41 (GMT)
commitd9008e316e4915e8fef1f292c59446c15560c022 (patch)
treea508bccd84a1b4a024e25bdc08b64604acbd7723 /tests/assemble.test
parent8ebae5e9d270bca732c4b07bb2d264bd07d16806 (diff)
downloadtcl-d9008e316e4915e8fef1f292c59446c15560c022.zip
tcl-d9008e316e4915e8fef1f292c59446c15560c022.tar.gz
tcl-d9008e316e4915e8fef1f292c59446c15560c022.tar.bz2
* tclAssembly.c:
* assembly.test (assemble-17.15): Reworked branch handling so that forward branches can use jump1 (jumpTrue1, jumpFalse1). Added test cases that the forward branches will expand to jump4, jumpTrue4, jumpFalse4 when needed.
Diffstat (limited to 'tests/assemble.test')
-rw-r--r--tests/assemble.test34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/assemble.test b/tests/assemble.test
index 08295d6..c5898c1 100644
--- a/tests/assemble.test
+++ b/tests/assemble.test
@@ -1914,7 +1914,7 @@ test assemble-17.9 {jump - resolve a label multiple times} {
-cleanup {rename x {}}
}
-test assemble-17.10 {jump4} {
+test assemble-17.10 {jump4 needed} {
-body {
assemble "push x; jump one; label two; [string repeat {dup; pop;} 128]
jump three; label one; jump two; label three"
@@ -1982,6 +1982,38 @@ test assemble-17.14 {jump to undefined label, line number correct?} {
-result {*"assemble" body, line 4*}
}
+test assemble-17.15 {multiple passes of code resizing} {
+ -setup {
+ set body {
+ push -
+ }
+ for {set i 0} {$i < 14} {incr i} {
+ append body "label a" $i \
+ "; push a; concat 2; nop; nop; jump b" \
+ $i \n
+ }
+ append body {label a14; push a; concat 2; push 1; jumpTrue b14} \n
+ append body {label a15; push a; concat 2; push 0; jumpFalse b15} \n
+ for {set i 0} {$i < 15} {incr i} {
+ append body "label b" $i \
+ "; push b; concat 2; nop; nop; jump a" \
+ [expr {$i+1}] \n
+ }
+ append body {label c; push -; concat 2; nop; nop; nop; jump d} \n
+ append body {label b15; push b; concat 2; nop; nop; jump c} \n
+ append body {label d}
+ proc x {} [list assemble $body]
+ }
+ -body {
+ x
+ }
+ -cleanup {
+ catch {unset body}
+ catch {rename x {}}
+ }
+ -result -abababababababababababababababab-
+}
+
# assemble-18 - lindexMulti
test assemble-18.1 {lindexMulti - wrong # args} {