MooseX-Compile

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

license:             ~
author:              ~
generated_by:        ExtUtils::MakeMaker version 6.42
distribution_type:   module
requires:     
    Class::Inspector:              0
    Data::Dump:                    0
    Data::Visitor:                 0.15
    Devel::INC::Sorted:            0
    Moose:                         0.34
    PadWalker:                     0
    Test::use::ok:                 0
meta-spec:
    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
    version: 1.3

Makefile.PL  view on Meta::CPAN

WriteMakefile(
	NAME         => 'MooseX::Compile',
	VERSION_FROM => 'lib/MooseX/Compile/Base.pm',
	INSTALLDIRS  => 'site',
	SIGN         => 1,
	PL_FILES     => { },
	PREREQ_PM    => {
		'Test::use::ok' => 0,
        'Moose' => '0.34',
        'Data::Visitor' => '0.15',
        'PadWalker' => 0,
        'Class::Inspector' => 0,
        'Data::Dump' => 0,
        'Devel::INC::Sorted' => 0,
	},
);

TODO  view on Meta::CPAN

    - use Manip::END in addition to Check::UnitCheck as a compilation option
      (at_exit => 1) for better 5.8 support and also if the metaclass gets
      changed
    - Accept options like immutable => 1

- Inlinable & Deparsable code roles
    - Inlinable
        - just stupid macros with named parameters
    - Deparsable
        - serializable components
            - shared environment (shared per compilation unit) - like PadWalker::closed_over
            - private environment (per method) - like PadWalker::closed_over
            - body - perl text (B::Simple in the future)
        - mangling
            - alias mangled names from shared env to private names in private
              env?
            - look into DDS's mangling
        - extensible custom deparsing for closed values too

- add a no meta compilation option, for non introspectable classes which are
  completely Moose free

lib/MooseX/Compile/Compiler.pm  view on Meta::CPAN

use base qw(MooseX::Compile::Base);

use strict;
use warnings;

use Data::Dump qw(dump);
use Data::Visitor::Callback;
use Storable;
use B;
use B::Deparse;
use PadWalker;
use Class::Inspector;

our %compiled_classes;

use constant DEBUG => MooseX::Compile::Base::DEBUG();

# FIXME make this Moose based eventually
sub new {
    my ( $class, %args ) = @_;
    bless \%args, $class;

lib/MooseX/Compile/Compiler.pm  view on Meta::CPAN

sub compile_method {
    my ( $self, %args ) = @_;
    my ( $class, $method ) = @args{qw(class method)};

    my $d = B::Deparse->new;

    my $body = $method->body;

    my $body_str = $d->coderef2text($body);

    my $closure_vars = PadWalker::closed_over($body);

    my @env;

    if ( my $constraints = delete $closure_vars->{'@type_constraints'} ) {
        my @constraint_code = map {
            my $name = $_->name;

            defined $name
                ? "Moose::Util::TypeConstraints::find_type_constraint(". dump($name) .")"
                : "die 'missing constraint'"



( run in 1.054 second using v1.01-cache-2.11-cpan-05444aca049 )