Changes between Version 1 and Version 2 of RewritingPMCsInNQP

Show
Ignore:
Timestamp:
06/26/09 06:11:15 (13 years ago)
Author:
cotto
Comment:

direct C function calls in nqp

Legend:

Unmodified
Added
Removed
Modified
  • RewritingPMCsInNQP

    v1 v2  
     1[[PageOutline(1-2)]] 
     2 
     3= Introduction =  
     4 
    15One of the main goals of the pmc_pct branch is the ability to use a prescription-strength compiler to compile PMCs into L1 and C, rather than the Perl5-based pmc2c.  Once pmcc is a viable replacement for pmc2c, we can start modifying it to support functions written in other languages such as nqp.  However, nqp as it stands it not adequate for doing everything that we currently do in C-based PMCs.  The purpose of this page is to document the known shortcomings of nqp in this area and to suggest possible ways to extend its syntax to handle these cases.  To accomplish this, we are attempting to rewrite three representative PMCs (Hash, ResizablePMCArray and String) in nqp by translating the C into nqp as directly as possible. 
     6 
     7= List of Shortcomings = 
     8 
     9== Direct C Function Calls == 
     10 
     11=== nqp syntax === 
     12{{{ 
     13nextkey   =       key_next( INTERP,  key); /* from hash.pmc:get_number_keyed */ 
     14$nextkey :=       key_next($INTERP, $key); /* proposed equivalent in nqp */ 
     15$nextkey := cfunc:key_next($INTERP, $key); /* possible alternative syntax */ 
     16}}} 
     17 
     18Much of Parrot will continue to be written in C well after our PMCs and ops are implemented in L1, and that L1 code (and any HLLs that compile down to L1) will need an efficient way to call those C functions directly.   
     19 
     20==== equivalent L1 code ==== 
     21{{{ 
     22??? 
     23}}} 
     24 
     25The equivalent L1 code will need to deal with C calling conventions and efficiently looking up (and caching) the appropriate symbol.