Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mm] Implement multiregex list construction
  • Loading branch information
sorear committed Sep 19, 2010
1 parent fad06e5 commit cceef1a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Metamodel.pm
Expand Up @@ -123,6 +123,8 @@ our $global;
default => sub { [] });
has superclasses => (isa => 'ArrayRef[Metamodel::Class]', is => 'ro',
default => sub { [] });
has multi_regex_lists => (isa => 'HashRef[ArrayRef[Metamodel::StaticSub]]',
is => 'ro', lazy => 1, default => sub { +{} });

sub add_attribute {
my ($self, $name) = @_;
Expand All @@ -134,6 +136,11 @@ our $global;
push @{ $self->methods }, Metamodel::Method->new(name => $name, body => $body);
}

sub push_multi_regex {
my ($self, $name, $body) = @_;
push @{ $self->multi_regex_lists->{$name} //= [] }, $body;
}

sub add_super {
my ($self, $targ) = @_;
push @{ $self->superclasses }, $targ;
Expand Down Expand Up @@ -469,6 +476,10 @@ sub Op::SubDef::begin {
$body->strong_used(1);
$opensubs[-1]->body_of->add_method($self->method_too, $body);
}
if (defined($self->proto_too)) {
$body->strong_used(1);
$opensubs[-1]->body_of->push_multi_regex($self->proto_too, $body);
}
delete $self->{$_} for (qw( body method_too proto_too exports once ));
}

Expand Down

0 comments on commit cceef1a

Please sign in to comment.