| 1 | package VAST::routine_def; | ||
| 2 | BEGIN { | ||
| 3 | $VAST::routine_def::VERSION = '0.05'; | ||
| 4 | } | ||
| 5 | use utf8; | ||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | use Mildew::AST::Helpers; | ||
| 9 | |||
| 10 | sub emit_m0ld { | ||
| 11 | my ($m, $visibility) = @_; | ||
| 12 | $visibility ||= 'our'; | ||
| 13 | |||
| 14 | my ($anon, $name); | ||
| 15 | if ($m->{deflongname}[0]) { | ||
| 16 | $name = '&'.$m->{deflongname}[0]{name}{identifier}{TEXT}; | ||
| 17 | } else { | ||
| 18 | $anon = 1; | ||
| 19 | } | ||
| 20 | my $sig = $m->{multisig}[0]{signature}[0]; | ||
| 21 | my $rout = routine($m->{blockoid},($sig ? $sig->emit_m0ld : empty_sig)); | ||
| 22 | |||
| 23 | if ($anon) { | ||
| 24 | return $rout; | ||
| 25 | } | ||
| 26 | |||
| 27 | let $rout, sub { | ||
| 28 | my $value = shift; | ||
| 29 | my @trait_statement = (); | ||
| 30 | if (ref $m->{trait} eq 'ARRAY') { | ||
| 31 | foreach my $trait (@{$m->{trait}}) { | ||
| 32 | my $aux = $trait->{trait_auxiliary}; | ||
| 33 | if ($aux->{SYM} eq 'is') { | ||
| 34 | if ($aux->{longname}{name}{identifier}{TEXT} eq 'export') { | ||
| 35 | push @trait_statement, | ||
| 36 | call(BIND => | ||
| 37 | (call 'postcircumfix:{ }' => | ||
| 38 | FETCH(call 'postcircumfix:{ }' => | ||
| 39 | FETCH(call 'postcircumfix:{ }' => | ||
| 40 | FETCH(call 'lookup' => reg '$scope', [ string '$?PACKAGE' ]), | ||
| 41 | [ string 'EXPORT::' ]), | ||
| 42 | [ string 'ALL::' ]), | ||
| 43 | [ string $name ]), | ||
| 44 | [ $value ]); | ||
| 45 | if (ref $trait->{postcircumfix} eq 'ARRAY') { | ||
| 46 | } | ||
| 47 | } else { | ||
| 48 | XXX; | ||
| 49 | } | ||
| 50 | } else { | ||
| 51 | XXX; | ||
| 52 | } | ||
| 53 | } | ||
| 54 | } | ||
| 55 | Mildew::AST::Seq->new(stmts => [ | ||
| 56 | ( $visibility eq 'our' ? | ||
| 57 | call(BIND => (call 'postcircumfix:{ }' => FETCH(lookup '$?PACKAGE'), | ||
| 58 | [ string $name ]),[$value]) | ||
| 59 | : ()), | ||
| 60 | call(BIND => (call 'postcircumfix:{ }' => reg('$scope'), | ||
| 61 | [ string $name ]),[$value]), | ||
| 62 | @trait_statement | ||
| 63 | ]); | ||
| 64 | }; | ||
| 65 | } | ||
| 66 | |||
| 67 | 1; |