Skip to content

Commit 37bad15

Browse files
committed
Set up a BOOTArray type.
1 parent 1ee8aa8 commit 37bad15

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

src/6model/sixmodelobject.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "repr_registry.h"
66
#include "knowhow_bootstrapper.h"
77
#include "serialization_context.h"
8+
#include "reprs/KnowHOWREPR.h"
89

910
/* Cached type IDs. */
1011
static INTVAL stable_id = 0;
@@ -16,8 +17,32 @@ static STRING *find_method_str = NULL;
1617
static STRING *type_check_str = NULL;
1718
static STRING *accepts_type_str = NULL;
1819

20+
static PMC *boot_type(PARROT_INTERP, PMC *knowhow, char *type_name, char *repr_name, INTVAL index) {
21+
PMC *knowhow_how = STABLE(knowhow)->HOW;
22+
PMC *meta_obj = REPR(knowhow_how)->allocate(interp, STABLE(knowhow_how));
23+
PMC *sc = SC_get_sc(interp, Parrot_str_new_constant(interp, "__6MODEL_CORE__"));
24+
REPROps *repr;
25+
PMC *type_obj;
26+
27+
REPR(meta_obj)->initialize(interp, STABLE(meta_obj), OBJECT_BODY(meta_obj));
28+
((KnowHOWREPRInstance *)PMC_data(meta_obj))->body.name = Parrot_str_new_constant(interp, type_name);
29+
repr = REPR_get_by_name(interp, Parrot_str_new_constant(interp, repr_name));
30+
type_obj = repr->type_object_for(interp, meta_obj);
31+
STABLE(type_obj)->method_cache = ((KnowHOWREPRInstance *)PMC_data(meta_obj))->body.methods;
32+
STABLE(type_obj)->mode_flags = METHOD_CACHE_AUTHORITATIVE;
33+
34+
VTABLE_set_pmc_keyed_int(interp, sc, index, type_obj);
35+
SC_PMC(type_obj) = sc;
36+
STABLE(type_obj)->sc = sc;
37+
VTABLE_set_pmc_keyed_int(interp, sc, index+1, STABLE(type_obj)->HOW);
38+
SC_PMC(STABLE(type_obj)->HOW) = sc;
39+
STABLE(STABLE(type_obj)->HOW)->sc = sc;
40+
41+
return type_obj;
42+
}
43+
1944
/* Initializes 6model and produces the KnowHOW core meta-object. */
20-
void SixModelObject_initialize(PARROT_INTERP, PMC **knowhow, PMC **knowhow_attribute) {
45+
void SixModelObject_initialize(PARROT_INTERP, PMC **knowhow, PMC **knowhow_attribute, PMC **boot_array) {
2146
PMC *initial_sc;
2247
STRING *initial_sc_name;
2348

@@ -43,6 +68,8 @@ void SixModelObject_initialize(PARROT_INTERP, PMC **knowhow, PMC **knowhow_attri
4368

4469
/* Set up the simple KnowHOWAttribute. */
4570
*knowhow_attribute = SixModelObject_setup_knowhow_attribute(interp, initial_sc, *knowhow);
71+
72+
*boot_array = boot_type(interp, *knowhow, "BOOTArray", "VMArray", 2);
4673
}
4774

4875
/* Sets the object that we'll wrap the next allocation in. */

src/6model/sixmodelobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ typedef void (* st_sc_barrier_func) (PARROT_INTERP, STable *st);
413413
}
414414

415415
/* Object model initialization. */
416-
void SixModelObject_initialize(PARROT_INTERP, PMC **knowhow, PMC **knowhow_attribute);
416+
void SixModelObject_initialize(PARROT_INTERP, PMC **knowhow, PMC **knowhow_attribute, PMC **boot_array);
417417

418418
/* Some utility functions. */
419419
void set_wrapping_object(PMC *wrapper);

src/ops/nqp.ops

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static INTVAL vmarray_repr_id = 0;
3636
/* Built-in meta-objects. */
3737
static PMC *KnowHOW = NULL;
3838
static PMC *KnowHOWAttribute = NULL;
39+
static PMC *BOOTArray = NULL;
3940

4041
/* FileHandle PMC for nqpevent */
4142
static PMC *nqpevent_fh = NULL;
@@ -297,7 +298,7 @@ inline op nqp_dynop_setup() :base_core {
297298
ohash_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "OwnedHash", 0));
298299

299300
/* Initialize the object model. */
300-
SixModelObject_initialize(interp, &KnowHOW, &KnowHOWAttribute);
301+
SixModelObject_initialize(interp, &KnowHOW, &KnowHOWAttribute, &BOOTArray);
301302

302303
/* Cache the VMArray REPR ID. */
303304
vmarray_repr_id = REPR_name_to_id(interp, Parrot_str_new(interp, "VMArray", 0));

0 commit comments

Comments
 (0)