Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implement ITER boolification and set up BOOTIter type.

  • Loading branch information...
commit 09c5aea0c03de3678634525bd321039b58a30624 1 parent c780526
@arnsholt arnsholt authored
View
8 src/6model/sixmodelobject.c
@@ -42,14 +42,13 @@ 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 *initial_sc;
STRING *initial_sc_name;
PMC *global_context = Parrot_pmc_new(interp, enum_class_Hash);
PMC *knowhow;
PMC *knowhow_attribute;
- PMC *boot_array;
+ PMC *boot_array, *boot_iter;
/* Look up and cache some type IDs and strings. */
stable_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "STable", 0));
@@ -76,9 +75,12 @@ void SixModelObject_initialize(PARROT_INTERP) {
/* Set up the BOOT* types. */
boot_array = boot_type(interp, knowhow, "BOOTArray", "VMArray", 2);
+ /* TODO: BOOTHash types goes here with index 4. */
+ boot_iter = boot_type(interp, knowhow, "BOOTIter", "VMIter", 6);
/* Set boolification specs for the BOOT types. */
set_boolification_spec(interp, boot_array, BOOL_MODE_HAS_ELEMS, NULL);
+ set_boolification_spec(interp, boot_iter, BOOL_MODE_ITER, NULL);
/* Save the global context to the Parrot root namespace and store all the
* things we just created in it. */
@@ -90,6 +92,8 @@ void SixModelObject_initialize(PARROT_INTERP) {
Parrot_str_new_constant(interp, "KnowHOWAttribute"), knowhow_attribute);
VTABLE_set_pmc_keyed_str(interp, global_context,
Parrot_str_new_constant(interp, "BOOTArray"), boot_array);
+ VTABLE_set_pmc_keyed_str(interp, global_context,
+ Parrot_str_new_constant(interp, "BOOTIter"), boot_iter);
}
/* Sets the object that we'll wrap the next allocation in. */
View
1  src/6model/sixmodelobject.h
@@ -71,6 +71,7 @@ typedef struct {
#define BOOL_MODE_UNBOX_STR_NOT_EMPTY_OR_ZERO 4
#define BOOL_MODE_NOT_TYPE_OBJECT 5
#define BOOL_MODE_BIGINT 6
+#define BOOL_MODE_ITER 7
#define BOOL_MODE_HAS_ELEMS 8
/* Controls the way that type checks are performed. By default, if there is
View
7 src/pmc/sixmodelobject.pmc
@@ -25,6 +25,7 @@
#include "parrot/exceptions.h"
#include "parrot/events.h"
#include "../6model/sixmodelobject.h"
+#include "../6model/reprs/VMIter.h"
/* We need to know how to boolify bigints. Really need something better,
* but this will do for now. */
@@ -300,6 +301,12 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
STABLE(decont), OBJECT_BODY(decont), bigint_repr_id))->i);
}
return 0;
+ case BOOL_MODE_ITER:
+ if (IS_CONCRETE(decont)) {
+ VMIterBody *body = (VMIterBody *) OBJECT_BODY(decont);
+ return body->idx + 1 < body->limit;
+ }
+ return 0;
case BOOL_MODE_HAS_ELEMS:
return IS_CONCRETE(decont) &&
REPR(decont)->elems(interp, STABLE(decont), OBJECT_BODY(decont));
Please sign in to comment.
Something went wrong with that request. Please try again.