Ticket #551: pointerref.patch

File pointerref.patch, 4.9 KB (added by rg, 13 years ago)

different solution for pointer pmc

  • src/vtable.tbl

     
    6363void* get_pointer_keyed(PMC* key) 
    6464void* get_pointer_keyed_int(INTVAL key) 
    6565void* get_pointer_keyed_str(STRING* key) 
     66void** get_pointerref() 
    6667 
    6768[STORE] :write 
    6869void set_integer_native(INTVAL value) 
  • src/pmc/pointer.pmc

     
    121121 
    122122/* 
    123123 
     124=item C<void **get_pointerref()> 
     125 
     126Returns the pointer address. 
     127 
     128=cut 
     129 
     130*/ 
     131 
     132    VTABLE void **get_pointerref() { 
     133        return &PARROT_POINTER(SELF)->pointer; 
     134    } 
     135 
     136/* 
     137 
    124138=item C<INTVAL get_integer()> 
    125139 
    126140Returns the pointer value as an integer. 
  • src/jit/i386/jit_defs.c

     
    22682268            case 'V': 
    22692269                emitm_call_cfunc(pc, get_nci_P); 
    22702270                emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, temp_calls_offset + 4); 
    2271                 /* Call the get_pointer VTABLE on the Pointer PMC to get the returned pointer */ 
     2271                /* Call the get_pointer VTABLE on the Pointer PMC to get the pointer address */ 
    22722272                emitm_movl_m_r(interp, pc, emit_EAX, emit_EAX, 0, 1, offsetof(PMC, vtable)); 
    2273                 emitm_movl_m_r(interp, pc, emit_EAX, emit_EAX, 0, 1, offsetof(VTABLE, get_pointer)); 
     2273                emitm_movl_m_r(interp, pc, emit_EAX, emit_EAX, 0, 1, offsetof(VTABLE, get_pointerref)); 
    22742274                emitm_callr(pc, emit_EAX); 
    22752275                emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, args_offset); 
     2276                /* reset ESP(4) */ 
     2277                emitm_lea_m_r(interp, pc, emit_EAX, emit_EBP, 0, 1, st_offset); 
     2278                emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, temp_calls_offset + 4); 
    22762279                break; 
    22772280            case 'b':   /* buffer (void*) pass PObj_bufstart(SReg) */ 
    22782281                emitm_call_cfunc(pc, get_nci_S); 
  • tools/build/nativecall.pl

     
    353353    }; 
    354354    /V/ && do { 
    355355        push @{$temps_ref},          "PMC *t_$temp_num;"; 
    356         push @{$temps_ref},          "void *v_$temp_num;"; 
     356        push @{$temps_ref},          "void **v_$temp_num;"; 
    357357        push @{$extra_preamble_ref}, "t_$temp_num = GET_NCI_P($reg_num);"; 
    358         push @{$extra_preamble_ref}, "v_$temp_num = VTABLE_get_pointer(interp, t_$temp_num);"; 
    359         push @{$extra_postamble_ref}, "VTABLE_set_pointer(interp, t_$temp_num, v_$temp_num);"; 
    360         return "&v_$temp_num"; 
     358        push @{$extra_preamble_ref}, "v_$temp_num = VTABLE_get_pointerref(interp, t_$temp_num);"; 
     359#        push @{$extra_postamble_ref}, "VTABLE_set_pointer(interp, t_$temp_num, v_$temp_num);"; 
     360        return "v_$temp_num"; 
    361361    }; 
    362362    /[ilIscfdNS]/ && do { 
    363363        my $ret_type = $sig_table{$_}{return_type}; 
  • lib/Parrot/Vtable.pm

     
    398398    my %typemap = ( 
    399399        'STRING*'   => 'Parrot_String', 
    400400        'void*'     => 'void*', 
     401        'void**'    => 'void**', 
    401402        'INTVAL'    => 'Parrot_Int', 
    402403        'PMC*'      => 'Parrot_PMC', 
    403404        'FLOATVAL'  => 'Parrot_Float', 
  • lib/Parrot/Pmc2c/Parser.pm

     
    213213 
    214214        my $returntype = ''; 
    215215 
    216         if ($methodname =~ /(.*\s+\*?)(\w+)/) { 
     216        if ($methodname =~ /(.*\s+\*{0,2})(\w+)/) { 
    217217            ($returntype, $methodname) = ($1, $2); 
    218218        } 
    219219 
  • t/pmc/nci.t

     
    264726473 
    26482648OUTPUT 
    26492649 
    2650 { 
    2651     local $TODO = 0; 
    2652     if ($PConfig{jitcapable}){ 
    2653         $TODO = "TT #551 - jitted NCI sig with V is broken"; 
    2654     } 
    26552650pir_output_is( << 'CODE', << 'OUTPUT', "nci_vVi - void** out parameter" ); 
    26562651.sub test :main 
    26572652    .local string library_name 
     
    26742669CODE 
    26752670got 10 
    26762671OUTPUT 
    2677 } 
    26782672 
    26792673pir_output_is( << 'CODE', << 'OUTPUT', "nci_ttt - t_tt parameter" ); 
    26802674.sub test :main 
     
    271227061 
    27132707OUTPUT 
    27142708 
    2715 { 
    2716     local $TODO = 0; 
    2717     if ($PConfig{jitcapable}){ 
    2718         $TODO = "TT #551 - jitted NCI sig with V is broken"; 
    2719     } 
    27202709pir_output_is( << 'CODE', << 'OUTPUT', "nci_vV - char** out parameter" ); 
    27212710.sub test :main 
    27222711    .local string library_name 
     
    27642753It is a beautiful day! 
    27652754Go suck a lemon. 
    27662755OUTPUT 
    2767 } 
    27682756 
    27692757# Local Variables: 
    27702758#   mode: cperl