#1885: Parrot_load_bytecode should only load bytecode
-------------------------+--------------------------------------------------
 Reporter:  whiteknight  |       Owner:  cotto   
     Type:  RFC          |      Status:  new     
 Priority:  normal       |   Milestone:          
Component:  core         |     Version:  master  
 Severity:  medium       |    Keywords:  pir, pbc
     Lang:               |       Patch:          
 Platform:  all          |  
-------------------------+--------------------------------------------------

Comment(by pmichaud):

 Replying to [comment:7 whiteknight]:
 >One question I have is whether the call "load_bytecode 'foo.pir'" Always
 triggers the :load functions and not the :init functions. For a .pbc file
 I agree that triggering the :load functions is the expected behavior, but
 I would be very very surprised if IMCC were smart enough to determine that
 it should trigger :load and not :init after compiling from the
 load_bytecode opcode. [...] I would be extremely surprised if
 "load_bytecode 'foo.pir'" did not trigger the :init functions.

 Prepare to be surprised then, because IMCC (2.10.1) definitely triggers
 the :load functions and not the :init ones when invoked via load_bytecode
 :-)

 {{{
 $ cat x.pir
 .sub 'first'
    say 'first'
 .end

 .sub 'load' :load
    say ':load'
 .end

 .sub 'init' :init
    say ':init'
 .end

 .sub 'loadinit' :load :init
    say ':load :init'
 .end

 .sub 'main' :main
    say ':main'
 .end

 $ cat y.pir
 .sub 'main' :main
     load_bytecode 'x.pir'
 .end

 $ ./parrot y.pir
 :load
 :load :init
 $
 }}}

 As you can see, the subs marked ":load" are the ones executed -- the one
 marked only with ":init" is not executed.

 > Also, I thought there was a way to output .pbc files from Parrot PIR
 code. If there isn't one, we need to make creating it a high priority.

 It was speculated at one point that one could simply write the object
 coming back from the PIR compiler to a file and use that.  That seems to
 work for very simple PIR files, but fails for anything much larger (i.e.,
 it didn't work for files generated by nqp-rx).

 Pm

-- 
Ticket URL: <https://trac.parrot.org/parrot/ticket/1885#comment:8>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets

Reply via email to