From c9d4a66017eb9c5c33fc190a04d3514d98ca264f Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Tue, 20 Jul 2010 02:27:11 -0700 Subject: [PATCH] Add Mu.RAWCREATE This is a bit of a crutch until has / BUILD is added, and will be useful anyways for thawing procedutres. Also stub Decl::Regex. --- Decl.pm | 17 +++++++++++++++++ setting | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/Decl.pm b/Decl.pm index e5a7949b..8516fc3a 100644 --- a/Decl.pm +++ b/Decl.pm @@ -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 } @@ -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; diff --git a/setting b/setting index b06f119e..b2967d80 100644 --- a/setting +++ b/setting @@ -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 });