Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Flush stack upon encountering function return.

  • Loading branch information...
commit e40eea68ef232961d4a82995376ba3140957e441 1 parent cf5d43e
@whitequark authored
View
1  lib/furnace-avm2/abc.rb
@@ -16,6 +16,7 @@ module Furnace::AVM2::ABC
require_relative "abc/opcodes/push_literal_opcode"
require_relative "abc/opcodes/control_transfer_opcode"
require_relative "abc/opcodes/function_invocation_opcode"
+require_relative "abc/opcodes/function_return_opcode"
require_relative "abc/opcodes/property_opcode"
Dir[File.join(File.dirname(__FILE__), "abc", "opcodes", "*", "*.rb")].each do |file|
View
2  lib/furnace-avm2/abc/opcodes/function_return/as3_returnvalue.rb
@@ -1,5 +1,5 @@
module Furnace::AVM2::ABC
- class AS3ReturnValue < Opcode
+ class AS3ReturnValue < FunctionReturnOpcode
instruction 0x48
consume 1
View
2  lib/furnace-avm2/abc/opcodes/function_return/as3_returnvoid.rb
@@ -1,5 +1,5 @@
module Furnace::AVM2::ABC
- class AS3ReturnVoid < Opcode
+ class AS3ReturnVoid < FunctionReturnOpcode
instruction 0x47
consume 0
View
4 lib/furnace-avm2/abc/opcodes/function_return_opcode.rb
@@ -0,0 +1,4 @@
+module Furnace::AVM2::ABC
+ class FunctionReturnOpcode < Opcode
+ end
+ end
View
8 lib/furnace-avm2/transform/ast_build.rb
@@ -195,6 +195,14 @@ def transform(code, body)
node.children.concat opcode.parameters
node.children.concat parameters
+ # Spec does not require stack to be empty upon encountering return.
+ # If there's something left, it should have been here.
+ if opcode.is_a? ABC::FunctionReturnOpcode
+ while @stack.any?
+ emit(*consume(1))
+ end
+ end
+
# All opcodes which produce 2 results--that is, dup and swap--
# are already handled at the top.
if opcode.produces == 0
Please sign in to comment.
Something went wrong with that request. Please try again.