class RubyRunJs::OPCODES::FOR_IN
Public Class Methods
new(name, label_start, label_continue, label_break)
click to toggle source
# File lib/ruby_run_js/opcodes.rb, line 867 def initialize(name, label_start, label_continue, label_break) @name = name @label_start = label_start @label_continue = label_continue @label_break = label_break end
Public Instance Methods
eval(ctx)
click to toggle source
# File lib/ruby_run_js/opcodes.rb, line 874 def eval(ctx) iterable = ctx.stack.pop() if iterable == null || iterable == undefined ctx.stack.pop() ctx.stack.append(undefined) return @label_break end obj = to_object(iterable, ctx.builtin) obj.own.keys.sort.each do |k| unless obj.own[k]['enumerable'] next end ctx.set_binding(@name, k) status = ctx.builtin.executor.run_under_control(\ ctx, @label_start, @label_break) ctx.stack.pop() type, return_value, label = status if type == 0 # normal ctx.stack.append(return_value) return nil elsif type == 1 # return ctx.stack.append(return_value) return :Return # send return signal elsif type == 2 # jump outside ctx.stack.append(return_value) if label == @label_continue next end return label elsif type == 3 raise return_value else raise "Unexpected Type: #{type}" end end return @label_break end