Permalink
Browse files

Refactor sixmodel initialization to store objects in a global context…

… hash.
  • Loading branch information...
1 parent 28c4f1e commit c7805267b8eb8ad47131edb43ffebc1b34dfcff8 @arnsholt arnsholt committed Mar 17, 2013
Showing with 35 additions and 8 deletions.
  1. +23 −5 src/6model/sixmodelobject.c
  2. +1 −1 src/6model/sixmodelobject.h
  3. +11 −2 src/ops/nqp.ops
@@ -42,9 +42,14 @@ static PMC *boot_type(PARROT_INTERP, PMC *knowhow, char *type_name, char *repr_n
}
/* Initializes 6model and produces the KnowHOW core meta-object. */
-void SixModelObject_initialize(PARROT_INTERP, PMC **knowhow, PMC **knowhow_attribute, PMC **boot_array) {
+/*void SixModelObject_initialize(PARROT_INTERP, PMC **knowhow, PMC **knowhow_attribute, PMC **boot_array) {*/
+void SixModelObject_initialize(PARROT_INTERP) {
PMC *initial_sc;
STRING *initial_sc_name;
+ PMC *global_context = Parrot_pmc_new(interp, enum_class_Hash);
+ PMC *knowhow;
+ PMC *knowhow_attribute;
+ PMC *boot_array;
/* Look up and cache some type IDs and strings. */
stable_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "STable", 0));
@@ -64,14 +69,27 @@ void SixModelObject_initialize(PARROT_INTERP, PMC **knowhow, PMC **knowhow_attri
REPR_initialize_registry(interp);
/* Bootstrap the KnowHOW. */
- *knowhow = SixModelObject_bootstrap_knowhow(interp, initial_sc);
+ knowhow = SixModelObject_bootstrap_knowhow(interp, initial_sc);
/* Set up the simple KnowHOWAttribute. */
- *knowhow_attribute = SixModelObject_setup_knowhow_attribute(interp, initial_sc, *knowhow);
+ knowhow_attribute = SixModelObject_setup_knowhow_attribute(interp, initial_sc, knowhow);
- *boot_array = boot_type(interp, *knowhow, "BOOTArray", "VMArray", 2);
+ /* Set up the BOOT* types. */
+ boot_array = boot_type(interp, knowhow, "BOOTArray", "VMArray", 2);
- set_boolification_spec(interp, *boot_array, BOOL_MODE_HAS_ELEMS, NULL);
+ /* Set boolification specs for the BOOT types. */
+ set_boolification_spec(interp, boot_array, BOOL_MODE_HAS_ELEMS, NULL);
+
+ /* Save the global context to the Parrot root namespace and store all the
+ * things we just created in it. */
+ VTABLE_set_pmc_keyed_str(interp, interp->root_namespace,
+ Parrot_str_new_constant(interp, "_GLOBAL_CONTEXT"), global_context);
+ VTABLE_set_pmc_keyed_str(interp, global_context,
+ Parrot_str_new_constant(interp, "KnowHOW"), knowhow);
+ VTABLE_set_pmc_keyed_str(interp, global_context,
+ Parrot_str_new_constant(interp, "KnowHOWAttribute"), knowhow_attribute);
+ VTABLE_set_pmc_keyed_str(interp, global_context,
+ Parrot_str_new_constant(interp, "BOOTArray"), boot_array);
}
/* Sets the object that we'll wrap the next allocation in. */
@@ -414,7 +414,7 @@ typedef void (* st_sc_barrier_func) (PARROT_INTERP, STable *st);
}
/* Object model initialization. */
-void SixModelObject_initialize(PARROT_INTERP, PMC **knowhow, PMC **knowhow_attribute, PMC **boot_array);
+void SixModelObject_initialize(PARROT_INTERP);
/* Some utility functions. */
void set_wrapping_object(PMC *wrapper);
View
@@ -290,15 +290,24 @@ Does various setup tasks for the benefit of the other dynops.
inline op nqp_dynop_setup() :base_core {
if (!initialized) {
PMC *obj_sc_barrier, *st_sc_barrier;
+ PMC *global_context;
/* Look up and cache some type IDs. */
stable_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "STable", 0));
smo_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "SixModelObject", 0));
qrpa_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "QRPA", 0));
ohash_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "OwnedHash", 0));
- /* Initialize the object model. */
- SixModelObject_initialize(interp, &KnowHOW, &KnowHOWAttribute, &BOOTArray);
+ /* Initialize the object model and fetch the bootstrapped objects. */
+ SixModelObject_initialize(interp);
+ global_context = VTABLE_get_pmc_keyed_str(interp, interp->root_namespace,
+ Parrot_str_new_constant(interp, "_GLOBAL_CONTEXT"));
+ KnowHOW = VTABLE_get_pmc_keyed_str(interp, global_context,
+ Parrot_str_new_constant(interp, "KnowHOW"));
+ KnowHOWAttribute = VTABLE_get_pmc_keyed_str(interp, global_context,
+ Parrot_str_new_constant(interp, "KnowHOWAttribute"));
+ BOOTArray = VTABLE_get_pmc_keyed_str(interp, global_context,
+ Parrot_str_new_constant(interp, "BOOTArray"));
/* Cache the VMArray REPR ID. */
vmarray_repr_id = REPR_name_to_id(interp, Parrot_str_new(interp, "VMArray", 0));

0 comments on commit c780526

Please sign in to comment.