Class: Perl::Interpreter
- Includes:
- Common
- Defined in:
- lib/perl/interpreter.rb
Constant Summary collapse
- G_SCALAR =
0
- G_ARRAY =
1
- G_DISCARD =
2
- G_EVAL =
4
- G_NOARGS =
8
- G_KEEPERR =
16
- G_NODEBUG =
32
- G_METHOD =
64
- G_VOID =
128
Constants included from Common
Common::PERL_EXIT_DESTRUCT_END, Common::PERL_EXIT_EXPECTED
Instance Method Summary collapse
- #call(method_name, args, return_type) ⇒ Object
- #eval(str = nil, &block) ⇒ Object (also: #run)
-
#initialize ⇒ Interpreter
constructor
A new instance of Interpreter.
- #load(filename) ⇒ Object
Methods included from Common
#argv_to_ffi, #embedded_argv_to_ffi, #start, #stop
Constructor Details
#initialize ⇒ Interpreter
Returns a new instance of Interpreter.
19 20 21 |
# File 'lib/perl/interpreter.rb', line 19 def initialize start end |
Instance Method Details
#call(method_name, args, return_type) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/perl/interpreter.rb', line 37 def call(method_name, args, return_type) Perl::Stack.function_stack(args) do |stack| rc = do_call(method_name, (args, return_type)) ret = handle_return(rc, return_type, stack) if return_type == :void return nil else if block_given? return yield(ret) else ret.freeze! return ret end end end end |
#eval(str = nil, &block) ⇒ Object Also known as: run
23 24 25 26 27 28 29 |
# File 'lib/perl/interpreter.rb', line 23 def eval(str=nil, &block) return Perl.Perl_eval_pv(Perl.PL_curinterp, str, 1) if str if block_given? yield(Statement.new) end end |
#load(filename) ⇒ Object
32 33 34 35 |
# File 'lib/perl/interpreter.rb', line 32 def load(filename) file = File.read(filename) eval(file) end |