Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pull in a few more bits of the NQP setting.
  • Loading branch information
jnthn committed Feb 1, 2013
1 parent 3fdbbd0 commit 5621514
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions nqp-src/NQPCORE.setting
Expand Up @@ -92,6 +92,90 @@ my knowhow NQPSignature {
has $!definednesses;
}

my knowhow NQPRegex {
has $!do;
has $!caps;
has $!nfa;
has %!alt_nfas;
has $!generic_nfa;
has @!nested_codes;
method SET_CAPS($caps) {
$!caps := $caps;
}
method SET_NFA($nfa) {
$!nfa := $nfa;
}
method SET_ALT_NFA($name, $nfa) {
nqp::ifnull(%!alt_nfas, %!alt_nfas := {});
%!alt_nfas{$name} := $nfa;
}
method SET_GENERIC_NFA($nfa) {
$!generic_nfa := $nfa.save();
}
method ADD_NESTED_CODE($code) {
nqp::ifnull(@!nested_codes, @!nested_codes := nqp::list());
nqp::push(@!nested_codes, $code);
}
method CAPS() {
$!caps
}
method NFA() {
$!nfa
}
method ALT_NFAS() {
nqp::isnull(%!alt_nfas) ?? nqp::hash() !! %!alt_nfas
}
method ALT_NFA(str $name) {
nqp::isnull(%!alt_nfas) ?? nqp::null() !! %!alt_nfas{$name}
}
method NESTED_CODES() {
nqp::isnull(@!nested_codes) ?? nqp::list() !! @!nested_codes
}
method clone() {
# Clone the underlying VM code ref.
my $do := nqp::clone($!do);

# Clone and attach the code object.
my $der := nqp::clone(self);
nqp::bindattr($der, NQPRegex, '$!do', $do);
nqp::setcodeobj($do, $der);

# If needed, arrange for a fixup of the cloned code-ref.
# my $clone_callback := pir::getprop__PPs($!do, 'CLONE_CALLBACK');
# if nqp::defined($clone_callback) {
# $clone_callback($!do, $do, $der);
# }

$der
}
my $nfa_type;
method SET_NFA_TYPE($type) {
$nfa_type := $type;
}
method instantiate_generic($env) {
if nqp::isnull($!generic_nfa) {
self
}
else {
my $ins := self.clone();
nqp::bindattr($ins, NQPRegex, '$!nfa',
$nfa_type.from_saved($!generic_nfa).instantiate_generic($env).save());
nqp::bindattr($ins, NQPRegex, '$!generic_nfa', nqp::null());
$ins
}
}
method name() {
nqp::getcodename($!do)
}
method !set_name($name) {
nqp::setcodename($!do, $name);
}
}
nqp::setinvokespec(NQPRegex, NQPRegex, '$!do', nqp::null);
nqp::setboolspec(NQPRegex, 5, nqp::null());
#pir::stable_publish_vtable_handler_mapping__vPP(NQPRegex,
# nqp::hash('get_string', nqp::list(NQPRegex, '$!do')));

# From src\core\NQPMu.pm

my class NQPMu {
Expand Down Expand Up @@ -183,6 +267,12 @@ sub join($delim, @things) {
nqp::join($delim, @strs)
}

# vim: ft=perl6
# From src\core\Hash.pm

sub hash(*%new) {
%new
}
# From src\core\testing.pm

my $test_counter := 0;
Expand Down Expand Up @@ -221,8 +311,10 @@ sub skip($desc) {
say("ok $test_counter # SKIP $desc\n");
}

# vim: ft=perl6
# From src\core\YOUAREHERE.pm


1;
{YOU_ARE_HERE}

Expand Down

0 comments on commit 5621514

Please sign in to comment.