Skip to content

Commit

Permalink
Add Mu.RAWCREATE
Browse files Browse the repository at this point in the history
This is a bit of a crutch until has / BUILD is added, and will be useful
anyways for thawing procedutres.  Also stub Decl::Regex.
  • Loading branch information
sorear committed Jul 20, 2010
1 parent e538c83 commit c9d4a66
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Decl.pm
Expand Up @@ -8,6 +8,8 @@ use CgOp;
package Decl;
use Moose;

has zyg => (is => 'ro', isa => 'ArrayRef', default => sub { [] });

sub used_slots { }
sub preinit_code { CgOp::noop }
sub enter_code { CgOp::noop }
Expand Down Expand Up @@ -308,4 +310,19 @@ use CgOp;
no Moose;
}

{
package Decl::Regex;
use Moose;
extends 'Decl';

has slot => (is => 'ro', isa => 'Str', required => 1);

sub preinit_code {
my ($self, $body) = @_;
}

__PACKAGE__->meta->make_immutable;
no Moose;
}

1;
20 changes: 20 additions & 0 deletions setting
Expand Up @@ -331,6 +331,26 @@ PRE-INIT {
anon method notdef() { self.Bool });
Mu.HOW.add-method(Q:CgOp { (w (clr_string "not")) },
anon method notdef() { ! self.Bool });
Mu.HOW.add-method(Q:CgOp { (w (clr_string "RAWCREATE")) },
anon method RAWCREATE(*@fields) {
my $obj = Q:CgOp {
(ns (rawnew DynObject (getfield klass
(cast DynObject (@ (l self))))))
};
while @fields {
my $name = @fields.shift;
my $value = @fields.shift;

Q:CgOp {
(prog
(setindex (unbox String (@ (l $name)))
(getfield slots (cast DynObject (@ (l $obj))))
(l $value))
(null Variable))
};
}
$obj;
});
Any.HOW.add-method(Q:CgOp { (w (clr_string "ACCEPTS")) },
anon method ACCEPTS($t) { self === $t });
Expand Down

0 comments on commit c9d4a66

Please sign in to comment.