Method: ExecJS::RubyRacerRuntime::Context#eval

Defined in:
lib/execjs/ruby_racer_runtime.rb

#eval(source, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/execjs/ruby_racer_runtime.rb', line 23

def eval(source, options = {})
  source = encode(source)

  if /\S/ =~ source
    lock do
      begin
        unbox @v8_context.eval("(#{source})")
      rescue ::V8::JSError => e
        if e.value["name"] == "SyntaxError"
          raise RuntimeError, e.value.to_s
        else
          raise ProgramError, e.value.to_s
        end
      end
    end
  end
end