class RubyRunJs::OPCODES::STORE_MEMBER_OP

Public Class Methods

new(op) click to toggle source
# File lib/ruby_run_js/opcodes.rb, line 558
def initialize(op)
  @op = op
end

Public Instance Methods

eval(ctx) click to toggle source
# File lib/ruby_run_js/opcodes.rb, line 562
def eval(ctx)
  value = ctx.stack.pop()
  name = ctx.stack.pop()
  left = ctx.stack.pop()

  if is_primitive(left)
    if left.js_type == :Null
        raise make_error('TypeError',
                        "Cannot set property '#{name}' of null")
    elsif left.js_type == :Undefined
        raise make_error('TypeError',
                        "Cannot set property '#{name}' of undefined")
    end
    ctx.stack.append(binary_operation(@op, get_member(left, name, ctx.builtin), value))
  else
    ctx.stack.append(binary_operation(@op, get_member(left, name, ctx.builtin), value))
    left.put(name, ctx.stack[-1])
  end
  nil
end