Class: Perl::Stack
Defined Under Namespace
Classes: Function
Class Method Summary collapse
Instance Method Summary collapse
- #dSP ⇒ Object (also: #spagain)
- #enter ⇒ Object
- #freetmps ⇒ Object
-
#initialize ⇒ Stack
constructor
A new instance of Stack.
- #leave ⇒ Object
- #pops ⇒ Object
- #push(sv) ⇒ Object
- #pushmark ⇒ Object
- #putback ⇒ Object
- #savetmps ⇒ Object
Constructor Details
#initialize ⇒ Stack
Returns a new instance of Stack.
13 14 15 |
# File 'lib/perl/stack.rb', line 13 def initialize @sp = nil end |
Class Method Details
Instance Method Details
#dSP ⇒ Object Also known as: spagain
17 18 19 |
# File 'lib/perl/stack.rb', line 17 def dSP @sp = Perl.curinterp[:Istack_sp].tap { |sp| trace("dSP: @sp=#{sp}") } end |
#enter ⇒ Object
22 23 24 |
# File 'lib/perl/stack.rb', line 22 def enter Perl.Perl_push_scope(Perl.PL_curinterp) end |
#freetmps ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/perl/stack.rb', line 80 def freetmps curinterp = Perl.curinterp trace("#{curinterp[:Itmps_ix].inspect} > #{curinterp[:Itmps_floor].inspect}") if curinterp[:Itmps_ix] > curinterp[:Itmps_floor] Perl.Perl_free_tmps(Perl.PL_curinterp) trace("#{curinterp[:Itmps_ix].inspect} > #{curinterp[:Itmps_floor].inspect}") end end |
#leave ⇒ Object
90 91 92 |
# File 'lib/perl/stack.rb', line 90 def leave Perl.Perl_pop_scope(Perl.PL_curinterp) end |
#pops ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/perl/stack.rb', line 71 def pops trace("pops: @sp=#{@sp}") ret = @sp.get_pointer(0) @sp = FFI::Pointer.new(@sp.address - FFI.type_size(:pointer)) trace("pops: now @sp=#{@sp}") ret end |
#push(sv) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/perl/stack.rb', line 57 def push(sv) trace("push: @sp=#{@sp}") @sp += FFI.type_size(:pointer) @sp.put_pointer(0, sv) trace("push: is now @sp=#{@sp}") end |
#pushmark ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/perl/stack.rb', line 42 def pushmark trace("pushmark: @sp=#{@sp}") curinterp = Perl.curinterp trace("curinterp[:Imarkstack_ptr] was #{curinterp[:Imarkstack_ptr].inspect} == #{curinterp[:Imarkstack_max].inspect}") curinterp[:Imarkstack_ptr] += FFI.type_size(:int32) trace("curinterp[:Imarkstack_ptr] now #{curinterp[:Imarkstack_ptr].inspect}") if curinterp[:Imarkstack_ptr] == curinterp[:Imarkstack_max] Perl.Perl_markstack_grow(Perl.PL_curinterp) end trace("curinterp[:Imarkstack_ptr] <= #{@sp.address - curinterp[:Istack_base].address}") curinterp[:Imarkstack_ptr].put_pointer(0, @sp.address - curinterp[:Istack_base].address) trace("curinterp[:Imarkstack_ptr] now #{curinterp[:Imarkstack_ptr].inspect}") end |
#putback ⇒ Object
64 65 66 67 68 69 |
# File 'lib/perl/stack.rb', line 64 def putback trace("putback: @sp=#{@sp}") curinterp = Perl.curinterp curinterp[:Istack_sp] = @sp end |
#savetmps ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/perl/stack.rb', line 26 def savetmps curinterp = Perl.curinterp trace("savetmps: curinterp=#{curinterp.to_ptr.inspect}") trace("savetmps: tmps_floor=#{curinterp[:Itmps_floor].inspect}") addr = Perl.PL_curinterp + curinterp.offset_of(:Itmps_floor) trace("addr=#{addr.inspect}") Perl.Perl_save_int(Perl.PL_curinterp, addr) trace("savetmps: tmps_floor now #{curinterp[:Itmps_floor].inspect}") trace("curinterp[:Itmps_ix] was #{curinterp[:Itmps_ix].inspect}") curinterp[:Itmps_floor] = curinterp[:Itmps_ix] trace("savetmps: tmps_floor now #{curinterp[:Itmps_floor].inspect}") end |