package B::Simple;
use Moose;

our @NODE_TYPES;

BEGIN {
    @NODE_TYPES = map { 
        Class::MOP::load_class("B::Simple::Node::${_}");
        $_;
    } qw[
        Sym
        Op

        Args
        Param

        Const
        List
        Thunk
        PadVar
        Var

        Seq
        Apply   
    ];
}

sub import {
    my $pkg = caller; 
    no strict 'refs';    
    foreach my $node (@NODE_TYPES) {
        *{"${pkg}::${node}"} = \&{__PACKAGE__ . "::${node}"};
    }    
}

sub Seq { 
    B::Simple::Node::Seq->new(children => [ @_ ])
}

sub Apply { 
    my ($operator, @operands) = @_;
    B::Simple::Node::Apply->new(
        operator => $operator,
        operands => \@operands,
    )
}

sub Sym    { 
    B::Simple::Node::Sym->new(value => $_[0])
}

sub Op     { 
    B::Simple::Node::Op->new(value => $_[0])
}

sub Args   { 
    B::Simple::Node::Args->new(children => [ @_ ])
}

sub Param  { 
    B::Simple::Node::Param->new(value => $_[0])    
}

sub Const  { 
    B::Simple::Node::Const->new(value => $_[0])
}

sub List   { 
    B::Simple::Node::List->new(children => [ @_ ])
}

sub Thunk  { 
    B::Simple::Node::Thunk->new(children => [ @_ ])
}

sub PadVar { 
    B::Simple::Node::PadVar->new(value => $_[0])
}

sub Var    { 
    B::Simple::Node::Var->new(value => $_[0])
}

1;

__END__

=pod

=cut