Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Stub VMArray/VMHash/VMIter reprs.
Not going to fill them out just yet, but they should at least exist to facilitate cross-compilations involving them.
- Loading branch information
Showing
9 changed files
with
325 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| #define PARROT_IN_EXTENSION | ||
| #include "parrot/parrot.h" | ||
| #include "parrot/extend.h" | ||
| #include "../sixmodelobject.h" | ||
| #include "VMArray.h" | ||
|
|
||
| /* This representation's function pointer table. */ | ||
| static REPROps *this_repr; | ||
|
|
||
| /* Creates a new type object of this representation, and associates it with | ||
| * the given HOW. */ | ||
| static PMC * type_object_for(PARROT_INTERP, PMC *HOW) { | ||
| /* Create new object instance. */ | ||
| VMArrayInstance *obj = mem_allocate_zeroed_typed(VMArrayInstance); | ||
|
|
||
| /* Build an STable. */ | ||
| PMC *st_pmc = create_stable(interp, this_repr, HOW); | ||
| STable *st = STABLE_STRUCT(st_pmc); | ||
|
|
||
| /* Create type object and point it back at the STable. */ | ||
| obj->common.stable = st_pmc; | ||
| st->WHAT = wrap_object(interp, obj); | ||
| PARROT_GC_WRITE_BARRIER(interp, st_pmc); | ||
|
|
||
| /* Flag it as a type object. */ | ||
| MARK_AS_TYPE_OBJECT(st->WHAT); | ||
|
|
||
| return st->WHAT; | ||
| } | ||
|
|
||
| /* Composes the representation. */ | ||
| static void compose(PARROT_INTERP, STable *st, PMC *repr_info) { | ||
| /* Nothing to do yet, but should handle type in the future. */ | ||
| } | ||
|
|
||
| /* Creates a new instance based on the type object. */ | ||
| static PMC * allocate(PARROT_INTERP, STable *st) { | ||
| VMArrayInstance *obj = mem_allocate_zeroed_typed(VMArrayInstance); | ||
| obj->common.stable = st->stable_pmc; | ||
| return wrap_object(interp, obj); | ||
| } | ||
|
|
||
| /* Initialize a new instance. */ | ||
| static void initialize(PARROT_INTERP, STable *st, void *data) { | ||
| /* Nothing to do here. */ | ||
| } | ||
|
|
||
| /* Copies to the body of one object to another. */ | ||
| static void copy_to(PARROT_INTERP, STable *st, void *src, void *dest) { | ||
| VMArrayBody *src_body = (VMArrayBody *)src; | ||
| VMArrayBody *dest_body = (VMArrayBody *)dest; | ||
| /* Nothing to do yet. */ | ||
| } | ||
|
|
||
| /* This Parrot-specific addition to the API is used to free an object. */ | ||
| static void gc_free(PARROT_INTERP, PMC *obj) { | ||
| mem_sys_free(PMC_data(obj)); | ||
| PMC_data(obj) = NULL; | ||
| } | ||
|
|
||
| /* Gets the storage specification for this representation. */ | ||
| static storage_spec get_storage_spec(PARROT_INTERP, STable *st) { | ||
| storage_spec spec; | ||
| spec.inlineable = STORAGE_SPEC_REFERENCE; | ||
| spec.boxed_primitive = STORAGE_SPEC_BP_NONE; | ||
| spec.can_box = 0; | ||
| spec.bits = sizeof(void *) * 8; | ||
| spec.align = ALIGNOF1(void *); | ||
| return spec; | ||
| } | ||
|
|
||
| /* Initializes the VMArray representation. */ | ||
| REPROps * VMArray_initialize(PARROT_INTERP) { | ||
| /* Allocate and populate the representation function table. */ | ||
| this_repr = mem_allocate_zeroed_typed(REPROps); | ||
| this_repr->type_object_for = type_object_for; | ||
| this_repr->compose = compose; | ||
| this_repr->allocate = allocate; | ||
| this_repr->initialize = initialize; | ||
| this_repr->copy_to = copy_to; | ||
| this_repr->gc_free = gc_free; | ||
| this_repr->get_storage_spec = get_storage_spec; | ||
| return this_repr; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #ifndef VMARRAY_H_GUARD | ||
| #define VMARRAY_H_GUARD | ||
|
|
||
| /* Body of a VMArray. */ | ||
| typedef struct { | ||
| INTVAL elems; | ||
| INTVAL start; | ||
| INTVAL ssize; | ||
| PMC **slots; | ||
| } VMArrayBody; | ||
|
|
||
| /* This is how an instance with the VMArray representation looks. */ | ||
| typedef struct { | ||
| SixModelObjectCommonalities common; | ||
| VMArrayBody body; | ||
| } VMArrayInstance; | ||
|
|
||
| /* Initializes the VMArray REPR. */ | ||
| REPROps * VMArray_initialize(PARROT_INTERP); | ||
|
|
||
| #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| #define PARROT_IN_EXTENSION | ||
| #include "parrot/parrot.h" | ||
| #include "parrot/extend.h" | ||
| #include "../sixmodelobject.h" | ||
| #include "VMHash.h" | ||
|
|
||
| /* This representation's function pointer table. */ | ||
| static REPROps *this_repr; | ||
|
|
||
| /* Creates a new type object of this representation, and associates it with | ||
| * the given HOW. */ | ||
| static PMC * type_object_for(PARROT_INTERP, PMC *HOW) { | ||
| /* Create new object instance. */ | ||
| VMHashInstance *obj = mem_allocate_zeroed_typed(VMHashInstance); | ||
|
|
||
| /* Build an STable. */ | ||
| PMC *st_pmc = create_stable(interp, this_repr, HOW); | ||
| STable *st = STABLE_STRUCT(st_pmc); | ||
|
|
||
| /* Create type object and point it back at the STable. */ | ||
| obj->common.stable = st_pmc; | ||
| st->WHAT = wrap_object(interp, obj); | ||
| PARROT_GC_WRITE_BARRIER(interp, st_pmc); | ||
|
|
||
| /* Flag it as a type object. */ | ||
| MARK_AS_TYPE_OBJECT(st->WHAT); | ||
|
|
||
| return st->WHAT; | ||
| } | ||
|
|
||
| /* Composes the representation. */ | ||
| static void compose(PARROT_INTERP, STable *st, PMC *repr_info) { | ||
| /* Nothing to do yet, but should handle type in the future. */ | ||
| } | ||
|
|
||
| /* Creates a new instance based on the type object. */ | ||
| static PMC * allocate(PARROT_INTERP, STable *st) { | ||
| VMHashInstance *obj = mem_allocate_zeroed_typed(VMHashInstance); | ||
| obj->common.stable = st->stable_pmc; | ||
| return wrap_object(interp, obj); | ||
| } | ||
|
|
||
| /* Initialize a new instance. */ | ||
| static void initialize(PARROT_INTERP, STable *st, void *data) { | ||
| /* Nothing to do here. */ | ||
| } | ||
|
|
||
| /* Copies to the body of one object to another. */ | ||
| static void copy_to(PARROT_INTERP, STable *st, void *src, void *dest) { | ||
| VMHashBody *src_body = (VMHashBody *)src; | ||
| VMHashBody *dest_body = (VMHashBody *)dest; | ||
| /* Nothing to do yet. */ | ||
| } | ||
|
|
||
| /* This Parrot-specific addition to the API is used to free an object. */ | ||
| static void gc_free(PARROT_INTERP, PMC *obj) { | ||
| mem_sys_free(PMC_data(obj)); | ||
| PMC_data(obj) = NULL; | ||
| } | ||
|
|
||
| /* Gets the storage specification for this representation. */ | ||
| static storage_spec get_storage_spec(PARROT_INTERP, STable *st) { | ||
| storage_spec spec; | ||
| spec.inlineable = STORAGE_SPEC_REFERENCE; | ||
| spec.boxed_primitive = STORAGE_SPEC_BP_NONE; | ||
| spec.can_box = 0; | ||
| spec.bits = sizeof(void *) * 8; | ||
| spec.align = ALIGNOF1(void *); | ||
| return spec; | ||
| } | ||
|
|
||
| /* Initializes the VMHash representation. */ | ||
| REPROps * VMHash_initialize(PARROT_INTERP) { | ||
| /* Allocate and populate the representation function table. */ | ||
| this_repr = mem_allocate_zeroed_typed(REPROps); | ||
| this_repr->type_object_for = type_object_for; | ||
| this_repr->compose = compose; | ||
| this_repr->allocate = allocate; | ||
| this_repr->initialize = initialize; | ||
| this_repr->copy_to = copy_to; | ||
| this_repr->gc_free = gc_free; | ||
| this_repr->get_storage_spec = get_storage_spec; | ||
| return this_repr; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #ifndef VMHASH_H_GUARD | ||
| #define VMHASH_H_GUARD | ||
|
|
||
| /* Body of a VMHash. */ | ||
| typedef struct { | ||
| INTVAL dummy; /* Todo... */ | ||
| } VMHashBody; | ||
|
|
||
| /* This is how an instance with the VMHash representation looks. */ | ||
| typedef struct { | ||
| SixModelObjectCommonalities common; | ||
| VMHashBody body; | ||
| } VMHashInstance; | ||
|
|
||
| /* Initializes the VMHash REPR. */ | ||
| REPROps * VMHash_initialize(PARROT_INTERP); | ||
|
|
||
| #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| #define PARROT_IN_EXTENSION | ||
| #include "parrot/parrot.h" | ||
| #include "parrot/extend.h" | ||
| #include "../sixmodelobject.h" | ||
| #include "VMIter.h" | ||
|
|
||
| /* This representation's function pointer table. */ | ||
| static REPROps *this_repr; | ||
|
|
||
| /* Creates a new type object of this representation, and associates it with | ||
| * the given HOW. */ | ||
| static PMC * type_object_for(PARROT_INTERP, PMC *HOW) { | ||
| /* Create new object instance. */ | ||
| VMIterInstance *obj = mem_allocate_zeroed_typed(VMIterInstance); | ||
|
|
||
| /* Build an STable. */ | ||
| PMC *st_pmc = create_stable(interp, this_repr, HOW); | ||
| STable *st = STABLE_STRUCT(st_pmc); | ||
|
|
||
| /* Create type object and point it back at the STable. */ | ||
| obj->common.stable = st_pmc; | ||
| st->WHAT = wrap_object(interp, obj); | ||
| PARROT_GC_WRITE_BARRIER(interp, st_pmc); | ||
|
|
||
| /* Flag it as a type object. */ | ||
| MARK_AS_TYPE_OBJECT(st->WHAT); | ||
|
|
||
| return st->WHAT; | ||
| } | ||
|
|
||
| /* Composes the representation. */ | ||
| static void compose(PARROT_INTERP, STable *st, PMC *repr_info) { | ||
| /* Nothing to do yet, but should handle type in the future. */ | ||
| } | ||
|
|
||
| /* Creates a new instance based on the type object. */ | ||
| static PMC * allocate(PARROT_INTERP, STable *st) { | ||
| VMIterInstance *obj = mem_allocate_zeroed_typed(VMIterInstance); | ||
| obj->common.stable = st->stable_pmc; | ||
| return wrap_object(interp, obj); | ||
| } | ||
|
|
||
| /* Initialize a new instance. */ | ||
| static void initialize(PARROT_INTERP, STable *st, void *data) { | ||
| /* Nothing to do here. */ | ||
| } | ||
|
|
||
| /* Copies to the body of one object to another. */ | ||
| static void copy_to(PARROT_INTERP, STable *st, void *src, void *dest) { | ||
| VMIterBody *src_body = (VMIterBody *)src; | ||
| VMIterBody *dest_body = (VMIterBody *)dest; | ||
| /* Nothing to do yet. */ | ||
| } | ||
|
|
||
| /* This Parrot-specific addition to the API is used to free an object. */ | ||
| static void gc_free(PARROT_INTERP, PMC *obj) { | ||
| mem_sys_free(PMC_data(obj)); | ||
| PMC_data(obj) = NULL; | ||
| } | ||
|
|
||
| /* Gets the storage specification for this representation. */ | ||
| static storage_spec get_storage_spec(PARROT_INTERP, STable *st) { | ||
| storage_spec spec; | ||
| spec.inlineable = STORAGE_SPEC_REFERENCE; | ||
| spec.boxed_primitive = STORAGE_SPEC_BP_NONE; | ||
| spec.can_box = 0; | ||
| spec.bits = sizeof(void *) * 8; | ||
| spec.align = ALIGNOF1(void *); | ||
| return spec; | ||
| } | ||
|
|
||
| /* Initializes the VMIter representation. */ | ||
| REPROps * VMIter_initialize(PARROT_INTERP) { | ||
| /* Allocate and populate the representation function table. */ | ||
| this_repr = mem_allocate_zeroed_typed(REPROps); | ||
| this_repr->type_object_for = type_object_for; | ||
| this_repr->compose = compose; | ||
| this_repr->allocate = allocate; | ||
| this_repr->initialize = initialize; | ||
| this_repr->copy_to = copy_to; | ||
| this_repr->gc_free = gc_free; | ||
| this_repr->get_storage_spec = get_storage_spec; | ||
| return this_repr; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #ifndef VMITER_H_GUARD | ||
| #define VMITER_H_GUARD | ||
|
|
||
| /* Body of a VMIter. */ | ||
| typedef struct { | ||
| INTVAL dummy; /* Todo... */ | ||
| } VMIterBody; | ||
|
|
||
| /* This is how an instance with the VMIter representation looks. */ | ||
| typedef struct { | ||
| SixModelObjectCommonalities common; | ||
| VMIterBody body; | ||
| } VMIterInstance; | ||
|
|
||
| /* Initializes the VMIter REPR. */ | ||
| REPROps * VMIter_initialize(PARROT_INTERP); | ||
|
|
||
| #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters