Changes between Version 4 and Version 5 of RewritingPMCsInNQP
- Timestamp:
- 06/27/09 00:44:43 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
RewritingPMCsInNQP
v4 v5 16 16 /* possible equivalent nqp-like code */ 17 17 $nextkey := key_next($INTERP, $key); 18 $nextkey := cfunc:key_next($INTERP, $key); /* possible alternative syntax */ 18 19 /* possible alternative syntax */ 20 $nextkey := cfunc:key_next($INTERP, $key); 21 22 /* Another alternative syntax. Doesn't require parsing adjustment, iiuc. Any function in "C" namespace */ 23 $nextkey := c::key_next($INTERP, $key); 19 24 }}} 20 25 … … 33 38 }}} 34 39 40 41 Another possible L1 code: 42 {{{ 43 # NOTE: See above 44 # NOTE2: We use some kind of C-function-proxy object to encapsulate call. 45 find_cfunc $P0, 'next_key' #find the function or get it from a cache or something 46 push_c_arg $P0, INTERP #set INTERP as the first arg to whatever function is called next 47 push_c_arg $P0, key #set key to the second arg 48 c_return $P0, nextkey #stick the return value into nextkey 49 call_cfunc $P0 #call it! 50 }}} 51 35 52 The equivalent L1 code will need to deal with C calling conventions and efficiently looking up (and caching) the appropriate symbol.