Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Various fixes and tweaks to allow switching /.../ regexes to use Rege…
…x::Cursor2 and thus 6model, to the point that the test suite passes again (though I know various things don't work at all just yet).
  • Loading branch information
jnthn committed Jan 22, 2011
1 parent 5d977a8 commit 1307e73
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Regex/Cursor.pir
Expand Up @@ -909,7 +909,7 @@ are first compiled to regexes prior to being matched.

=cut

.sub '' :vtable('get_bool') :method
.sub 'Bool' :vtable('get_bool') :method
.local pmc match
match = getattribute self, '$!match'
if null match goto false
Expand Down
6 changes: 4 additions & 2 deletions src/Regex/Cursor2.pir
Expand Up @@ -143,6 +143,8 @@ grammars.
how.'add_method'(type_obj, '!PREFIX__!subrule', $P15)
.const 'Sub' $P16 = 'Regex_Cursor_meth_DUMP_TOKRX'
how.'add_method'(type_obj, 'DUMP_TOKRX', $P16)
.const 'Sub' $P17 = 'Regex_Cursor2_meth_Bool'
how.'add_method'(type_obj, 'Bool', $P17)

# Add attributes.
.local pmc NQPAttribute, attr
Expand All @@ -155,7 +157,7 @@ grammars.
how."add_attribute"(type_obj, attr)
attr = NQPAttribute."new"("$!match" :named("name"))
how."add_attribute"(type_obj, attr)
attr = NQPAttribute."new"("$!name" :named("name"))
attr = NQPAttribute."new"("$!names" :named("name"))
how."add_attribute"(type_obj, attr)
attr = NQPAttribute."new"("$!debug" :named("name"))
how."add_attribute"(type_obj, attr)
Expand Down Expand Up @@ -1072,7 +1074,7 @@ are first compiled to regexes prior to being matched.

=cut

.sub '' :vtable('get_bool') :method
.sub 'Bool' :vtable('get_bool') :method :subid('Regex_Cursor2_meth_Bool')
.local pmc match, cur_class
cur_class = get_global '$?CLASS'
match = getattribute self, cur_class, '$!match'
Expand Down
2 changes: 1 addition & 1 deletion src/Regex/Method.pir
Expand Up @@ -62,7 +62,7 @@ Perform a match against target, return the result.
.param pmc target

.local pmc curproto, match
curproto = get_hll_global ['Regex'], 'Cursor'
curproto = get_hll_global ['Regex'], 'Cursor2'
match = curproto.'parse'(target, 'rule'=>self, 'c'=>0)
.return (match)
.end
Expand Down
16 changes: 15 additions & 1 deletion src/pmc/rakudoobject.pmc
Expand Up @@ -36,7 +36,7 @@ pmclass RakudoObject manual_attrs dynpmc group nqp {
}

VTABLE PMC * find_method(STRING *name) {
STABLE(SELF)->find_method(interp, SELF, name, NO_HINT);
return STABLE(SELF)->find_method(interp, SELF, name, NO_HINT);
}

VTABLE PMC* get_attr_keyed(PMC *class_handle, STRING *name) {
Expand All @@ -46,4 +46,18 @@ pmclass RakudoObject manual_attrs dynpmc group nqp {
VTABLE void set_attr_keyed(PMC *class_handle, STRING *name, PMC* value) {
REPR(SELF)->bind_attribute(interp, REPR_PMC(SELF), SELF, class_handle, name, value);
}

VTABLE INTVAL get_bool() {
/* XXX This shouldn't be here; rather, we should have a general
* mechanism. This is here to get the grammar port to 6model moved
* along. */
PMC *bool_meth = STABLE(SELF)->find_method(interp, SELF, CONST_STRING(interp, "Bool"), NO_HINT);
PMC *old_ctx = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
PMC *cappy = Parrot_pmc_new(interp, enum_class_CallContext);
VTABLE_push_pmc(interp, cappy, SELF);
Parrot_pcc_invoke_from_sig_object(interp, bool_meth, cappy);
cappy = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
return VTABLE_get_bool(interp, VTABLE_get_pmc_keyed_int(interp, cappy, 0));
}
}

0 comments on commit 1307e73

Please sign in to comment.