Module: RubyRunJs::OPCODES

Extended by:
Helper
Defined in:
lib/ruby_run_js/opcodes.rb

Defined Under Namespace

Classes: BASE_JUMP, BINARY_OP, CALL, CALL_METHOD, CALL_METHOD_DOT, CALL_METHOD_DOT_NO_ARGS, CALL_METHOD_NO_ARGS, CALL_NO_ARGS, DELETE, DELETE_MEMBER, FOR_IN, JUMP, JUMP_IF_EQ, JUMP_IF_FALSE, JUMP_IF_FALSE_WITHOUT_POP, JUMP_IF_TRUE, JUMP_IF_TRUE_WITHOUT_POP, LABEL, LOAD, LOAD_ARRAY, LOAD_BOOLEAN, LOAD_FUNCTION, LOAD_MEMBER, LOAD_MEMBER_DOT, LOAD_NONE, LOAD_NULL, LOAD_NUMBER, LOAD_N_TUPLE, LOAD_OBJECT, LOAD_REGEXP, LOAD_STRING, LOAD_THIS, LOAD_UNDEFINED, NEW, NEW_NO_ARGS, NOP, OP_CODE, POP, POSTFIX, POSTFIX_MEMBER, POSTFIX_MEMBER_DOT, RETURN, STORE, STORE_MEMBER, STORE_MEMBER_DOT, STORE_MEMBER_DOT_OP, STORE_MEMBER_OP, STORE_OP, THROW, TRY_CATCH_FINALLY, TYPEOF, UNARY_OP, WITH

Class Method Summary collapse

Methods included from Helper

check_object, get_member, get_member_dot, is_accessor_descriptor, is_callable, is_data_descriptor, is_generic_descriptor, is_primitive, make_error, strict_equality

Methods included from ConversionHelper

#convert_to_js_type, #to_boolean, #to_int32, #to_integer, #to_number, #to_object, #to_primitive, #to_string, #to_uint16, #to_uint32

Class Method Details

.bytecode_call(ctx, func, this, args) ⇒ Object

————— CALLS ————–



615
616
617
618
619
620
621
622
623
624
625
# File 'lib/ruby_run_js/opcodes.rb', line 615

def self.bytecode_call(ctx, func, this, args)
  if func.js_class != 'Function'
    raise make_error('TypeError', "#{func.js_class} is not a function")
  end
  if func.is_native  # call to built-in function or method
    ctx.stack.append(func.call(this, args))
    return nil
  end
  # therefore not native. we have to return [new_context, function_label] to instruct interpreter to call
  return func.generate_my_scope(this, args), func.code
end