Ticket #1378: iglobals_hash_example.patch

File iglobals_hash_example.patch, 1.2 KB (added by cotto, 5 years ago)

mostly incomplete patch to allow hash-flavored iglobals access and chicanery

  • src/pmc/parrotinterpreter.pmc

     
    441441  "outer"; "<item>"         ... same for outer level 1 
    442442  "outer"; "<item>"; level  ... same for outer <level> 
    443443  "globals"                 ... return global stash 
     444  "iglobals"                ... return a string-indexed hash of iglobals 
    444445 
    445446=cut 
    446447 
     
    562563            return pmc_new(interp, enum_class_Hash); 
    563564        } 
    564565 
     566        name = CONST_STRING(interp, "iglobals"); 
     567 
     568        if (Parrot_str_equal(interp, item, name)) { 
     569            PMC *ig_hash = pmc_new(interp, enum_class_Hash); 
     570            PMC *one     = pmc_new(interp, enum_class_Integer); 
     571 
     572            VTABLE_set_pmc_keyed_str(interp, ig_hash, CONST_STRING(interp, "classname_hash"), interp->class_hash); 
     573 
     574            VTABLE_set_integer_native(interp, one, 1); 
     575            VTABLE_setprop(interp, ig_hash, CONST_STRING(interp, "_ro"), one); 
     576 
     577            return ig_hash; 
     578        } 
     579 
    565580        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_ATTRIB_NOT_FOUND, 
    566581                "No such item %Ss", item); 
    567582    }