Class: Perl::Stack::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/perl/stack/function.rb

Instance Method Summary collapse

Constructor Details

#initialize(stack, args, &block) ⇒ Function

Returns a new instance of Function.



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/perl/stack/function.rb', line 2

def initialize(stack, args, &block)
  @stack = stack
  @stack.dSP
  @stack.enter
  @stack.savetmps

  case args
  when nil
    # nothing
  when Hash
    init_with_hash(args)
  else
    init_with_array(Array(args))
  end

  yield(self)
ensure
  if @stack
    @stack.freetmps
    @stack.leave
  end
end

Instance Method Details

#pop_scalarObject



30
31
32
33
34
35
# File 'lib/perl/stack/function.rb', line 30

def pop_scalar
  @stack.spagain
  return @stack.pops
ensure
  @stack.putback
end

#push(value) ⇒ Object



25
26
27
28
# File 'lib/perl/stack/function.rb', line 25

def push(value)
  value = Perl.Perl_sv_2mortal(Perl.PL_curinterp, value)
  @stack.push(value)
end