Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* lib/unholy/pyasm.rb: jump opcode and empty arrays.

  • Loading branch information...
commit ea44e7aaf62d17574d85407d85af286c9879c366 1 parent 12d52c4
_why authored
Showing with 31 additions and 1 deletion.
  1. +4 −1 lib/unholy/pyasm.rb
  2. +27 −0 tests/07if.rb
5 lib/unholy/pyasm.rb
View
@@ -81,7 +81,7 @@ def build_tuple(n)
bc(0x66, n, 0x0)
end
def build_list(n)
- @stack.slice! -(n-1), (n-1)
+ @stack.slice! -(n-1), (n-1) if n > 0
bc(0x67, n, 0x0)
end
def load_attr(name)
@@ -96,6 +96,9 @@ def import_name(name)
def import_from(name)
bc 0x6c, add_sym(name), 0x0
end
+ def jump(n)
+ mark_jump n, bc(0x6e, n, 0x0)
+ end
def jump_if_false(n)
mark_jump n, bc(0x6f, n, 0x0)
end
27 tests/07if.rb
View
@@ -0,0 +1,27 @@
+# 123
+# 123
+# 456
+# 123
+a = []
+if true
+ a << 123
+end
+puts a[0]
+
+a = []
+if true
+ a << 123
+else
+ a << 456
+end
+puts a[0]
+
+a = []
+if false
+ a << 123
+else
+ a << 456
+end
+puts a[0]
+
+puts 123 if true
Please sign in to comment.
Something went wrong with that request. Please try again.