Permalink
Browse files

more stuff

  • Loading branch information...
1 parent 9f9577f commit 7d8787b4b5849b16703d213bb1ad9961971e28a1 @txus committed Feb 9, 2013
@@ -1,4 +1,8 @@
-a = 0
-while true
- a += 1
-end
+fn = -> {
+ a = 123
+ 2 * 2
+}
+
+fn.apply(1)
+fn.apply(2)
+fn.apply(3)
@@ -63,6 +63,7 @@ def pop(count)
def clear(count)
@ip += 2
+ @stack_size -= count
_clear count
end
@@ -178,8 +179,10 @@ def ret
def clear_stack
extra = @stack_size - 1
- @stack_size = 1
- clear extra
+ if extra > 0
+ @stack_size = 1
+ clear extra
+ end
end
private
@@ -42,9 +42,12 @@ def local_variable_access(node, parent)
def block(node, parent)
setline(node)
- node.array.each do |expression|
+ before = g.stack_size
+ node.array.each_with_index do |expression, idx|
expression.lazy_visit self, node
end
+ after = g.stack_size
+ g.clear after - before - 1
end
def nil_literal(node, parent)
@@ -2,7 +2,7 @@
_0_main
:5:39
123
-"3_block_2b871294a3446f2f82fc8ce923c0c16d
+"3_block_862fc117d97b6c8f0ac380ab7be90d34
"fn
2
"puts
@@ -26,7 +26,7 @@ _0_main
1 SETLINE
3
67 DEFN
-1 "3_block_2b871294a3446f2f82fc8ce923c0c16d"
+1 "3_block_862fc117d97b6c8f0ac380ab7be90d34"
65 SETSLOT
2 "fn"
1 SETLINE
@@ -41,12 +41,12 @@ _0_main
128 SEND
4 "puts"
1
-20 PUSHNIL
69 CLEAR
3
+20 PUSHNIL
144 RET
-_3_block_2b871294a3446f2f82fc8ce923c0c16d
-:1:13
+_3_block_862fc117d97b6c8f0ac380ab7be90d34
+:1:11
"+
1 SETLINE
5
@@ -58,7 +58,5 @@ _3_block_2b871294a3446f2f82fc8ce923c0c16d
128 SEND
0 "+"
1
-69 CLEAR
-0
144 RET
View
@@ -1,35 +1,70 @@
/Users/txus/Code/terrorvm/compiler/examples/gcstress.rb
_0_main
-:3:28
-0
+:5:37
+"1_block_e03b7b61cfed3a440d98099ad098d000
1
-"+
+"apply
+2
+3
1 SETLINE
1
-17 PUSH
-0 0
+67 DEFN
+0 "1_block_e03b7b61cfed3a440d98099ad098d000"
33 SETLOCAL
-0
-1 SETLINE
-2
-18 PUSHTRUE
-49 JIF
-13
+1
1 SETLINE
-3
+6
32 PUSHLOCAL
-0
+1
17 PUSH
1 1
128 SEND
-2 "+"
+2 "apply"
+1
+1 SETLINE
+7
+32 PUSHLOCAL
+1
+17 PUSH
+3 2
+128 SEND
+2 "apply"
+1
+1 SETLINE
+8
+32 PUSHLOCAL
+1
+17 PUSH
+4 3
+128 SEND
+2 "apply"
1
-33 SETLOCAL
-0
-51 GOTO
-10
-20 PUSHNIL
69 CLEAR
+3
+20 PUSHNIL
+144 RET
+_1_block_e03b7b61cfed3a440d98099ad098d000
+:3:19
+123
+2
+"*
+1 SETLINE
+2
+17 PUSH
+0 123
+35 SETLOCALDEPTH
+1
0
+1 SETLINE
+3
+17 PUSH
+1 2
+17 PUSH
+1 2
+128 SEND
+2 "*"
+1
+69 CLEAR
+1
144 RET
@@ -3,7 +3,7 @@ _0_main
:5:36
"hello
"to_map
-"3_block_19c74d1c94b2eb5f0406ed636daa1328
+"3_block_21a6c6f9729b2a9e79f3b26c123cd0b1
"greet
"world
1 SETLINE
@@ -26,7 +26,7 @@ _0_main
32 PUSHLOCAL
1
67 DEFN
-2 "3_block_19c74d1c94b2eb5f0406ed636daa1328"
+2 "3_block_21a6c6f9729b2a9e79f3b26c123cd0b1"
65 SETSLOT
3 "greet"
1 SETLINE
@@ -38,12 +38,12 @@ _0_main
128 SEND
3 "greet"
1
-20 PUSHNIL
69 CLEAR
2
+20 PUSHNIL
144 RET
-_3_block_19c74d1c94b2eb5f0406ed636daa1328
-:4:27
+_3_block_21a6c6f9729b2a9e79f3b26c123cd0b1
+:4:25
"
"+
"!
@@ -72,7 +72,5 @@ _3_block_19c74d1c94b2eb5f0406ed636daa1328
128 SEND
3 "puts"
1
-69 CLEAR
-0
144 RET
View
@@ -32,8 +32,8 @@ _0_main
128 SEND
4 "puts"
1
-20 PUSHNIL
69 CLEAR
1
+20 PUSHNIL
144 RET
@@ -1,6 +1,6 @@
/Users/txus/Code/terrorvm/compiler/examples/numbers.rb
_0_main
-:9:32
+:9:30
3
1
"-
@@ -39,7 +39,5 @@ _0_main
8 "puts"
1
20 PUSHNIL
-69 CLEAR
-0
144 RET
@@ -129,8 +129,8 @@ _0_main
128 SEND
9 "puts"
1
-20 PUSHNIL
69 CLEAR
11
+20 PUSHNIL
144 RET
View
@@ -6,11 +6,11 @@ _0_main
"to
"world
"hello
-"3_block_acf98724c25b92f44b060cc7a0af64f9
+"3_block_c8d724b303ae55a1b98d7e5a3df7c0fd
"each
"done!
"puts
-"9_block_64f8fde2f1bd07475d719a6304de3557
+"9_block_47568ad931ae1beb4e9628080a4c6fce
"map
1 SETLINE
1
@@ -35,7 +35,7 @@ _0_main
1 SETLINE
3
67 DEFN
-5 "3_block_acf98724c25b92f44b060cc7a0af64f9"
+5 "3_block_c8d724b303ae55a1b98d7e5a3df7c0fd"
33 SETLOCAL
2
1 SETLINE
@@ -63,19 +63,19 @@ _0_main
32 PUSHLOCAL
1
67 DEFN
-9 "9_block_64f8fde2f1bd07475d719a6304de3557"
+9 "9_block_47568ad931ae1beb4e9628080a4c6fce"
128 SEND
10 "map"
1
128 SEND
8 "puts"
1
-20 PUSHNIL
69 CLEAR
5
+20 PUSHNIL
144 RET
-_3_block_acf98724c25b92f44b060cc7a0af64f9
-:2:17
+_3_block_c8d724b303ae55a1b98d7e5a3df7c0fd
+:2:15
"+
"puts
1 SETLINE
@@ -92,11 +92,9 @@ _3_block_acf98724c25b92f44b060cc7a0af64f9
128 SEND
1 "puts"
1
-69 CLEAR
-0
144 RET
-_9_block_64f8fde2f1bd07475d719a6304de3557
-:2:12
+_9_block_47568ad931ae1beb4e9628080a4c6fce
+:2:10
"!!!!
"+
1 SETLINE
@@ -108,7 +106,5 @@ _9_block_64f8fde2f1bd07475d719a6304de3557
128 SEND
1 "+"
1
-69 CLEAR
-0
144 RET
View
@@ -29,9 +29,9 @@ _0_main
"<
"number_>
">
-"18_block_ece917e68a8016730db31cc5fa2eef0b
+"18_block_20a26f8b4a72da7dcf3fc30d9e61f48a
"<=
-"21_block_0bc65e8e1e755d1dafb6bd60ddfeda59
+"21_block_37835b2a9b2c1ad8618795864ec41f24
">=
"string
"string_+
@@ -432,7 +432,7 @@ _0_main
3 "[]"
1
67 DEFN
-28 "18_block_ece917e68a8016730db31cc5fa2eef0b"
+28 "18_block_20a26f8b4a72da7dcf3fc30d9e61f48a"
65 SETSLOT
29 "<="
1 SETLINE
@@ -449,7 +449,7 @@ _0_main
3 "[]"
1
67 DEFN
-30 "21_block_0bc65e8e1e755d1dafb6bd60ddfeda59"
+30 "21_block_37835b2a9b2c1ad8618795864ec41f24"
65 SETSLOT
31 ">="
1 SETLINE
@@ -730,12 +730,12 @@ _0_main
1
65 SETSLOT
52 "Map"
-20 PUSHNIL
69 CLEAR
28
+20 PUSHNIL
144 RET
-_18_block_ece917e68a8016730db31cc5fa2eef0b
-:3:20
+_18_block_20a26f8b4a72da7dcf3fc30d9e61f48a
+:3:18
"<
"==
"or
@@ -756,11 +756,9 @@ _18_block_ece917e68a8016730db31cc5fa2eef0b
128 SEND
2 "or"
1
-69 CLEAR
-0
144 RET
-_21_block_0bc65e8e1e755d1dafb6bd60ddfeda59
-:3:20
+_21_block_37835b2a9b2c1ad8618795864ec41f24
+:3:18
">
"==
"or
@@ -781,7 +779,5 @@ _21_block_0bc65e8e1e755d1dafb6bd60ddfeda59
128 SEND
2 "or"
1
-69 CLEAR
-0
144 RET
Oops, something went wrong. Retry.

0 comments on commit 7d8787b

Please sign in to comment.