Skip to content

Instantly share code, notes, and snippets.

@arnsholt
Created March 16, 2013 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnsholt/5177904 to your computer and use it in GitHub Desktop.
Save arnsholt/5177904 to your computer and use it in GitHub Desktop.
static PMC *boot_type(PARROT_INTERP, PMC *knowhow, char *type_name, char *repr_name) {
PMC *knowhow_how = STABLE(knowhow)->HOW;
PMC *meta_obj = REPR(knowhow_how)->allocate(interp, STABLE(knowhow_how));
PMC *sc = SC_get_sc(interp, Parrot_str_new_constant(interp, "__6MODEL_CORE__"));
REPROps *repr;
PMC *type_obj;
REPR(meta_obj)->initialize(interp, STABLE(meta_obj), OBJECT_BODY(meta_obj));
/* XXX: Doesn't look like NQP/Parrot 6model types have a name... */
repr = REPR_get_by_name(interp, Parrot_str_new_constant(interp, repr_name));
type_obj = repr->type_object_for(interp, meta_obj);
STABLE(type_obj)->method_cache = ((KnowHOWREPRInstance *)PMC_data(meta_obj))->body.methods;
STABLE(type_obj)->mode_flags = METHOD_CACHE_AUTHORITATIVE;
SC_repossess_object(interp, sc, NULL, type_obj);
STABLE_PMC(type_obj) = sc;
SC_repossess_object(interp, sc, NULL, STABLE(type_obj)->HOW);
STABLE_PMC(STABLE(type_obj)->HOW) = sc;
SC_repossess_stable(interp, sc, NULL, STABLE_PMC(type_obj));
STABLE(type_obj)->sc = sc;
return type_obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment