Module: LiveAST::Evaler

Extended by:
Common
Defined in:
lib/live_ast/evaler.rb

Class Method Summary collapse

Methods included from Common

arg_to_str, arg_to_str2, check_arity, check_is_binding, location_for_eval

Class Method Details

.eval(parser_source, evaler_source, bind, filename = nil, lineno = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/live_ast/evaler.rb', line 8

def eval(parser_source, evaler_source, bind, filename = nil, lineno = nil)
  evaler_source = arg_to_str evaler_source
  check_is_binding bind
  filename = arg_to_str filename if filename

  file, line = location_for_eval(bind, filename, lineno)
  file = LiveAST.strip_token(file)

  key, = Linker.new_cache_synced(parser_source, file, line, false)

  begin
    NATIVE_EVAL.call(evaler_source, bind, key, line)
  rescue Exception => e
    e.backtrace.map! { |s| LiveAST.strip_token s }
    raise e
  end
end