Skip to content

Commit

Permalink
add FORBID_PIR pseudo package which disallows Q:PIR { } and pir::stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Jul 8, 2010
1 parent 1971474 commit c80319f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Perl6/Actions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ method statement_control:sym<use>($/) {
elsif ~$<module_name> eq 'SETTING_MODE' {
$*SETTING_MODE := 1;
}
elsif ~$<module_name> eq 'FORBID_PIR' {
$*FORBID_PIR := 1;
}
else {
need($<module_name>);
import($/);
Expand Down Expand Up @@ -1998,6 +2001,9 @@ method term:sym<name>($/) {
}

method term:sym<pir::op>($/) {
if $*FORBID_PIR {
pir::die("pir::op forbidden in safe mode\n");
}
my $past := $<args> ?? $<args>[0].ast !! PAST::Op.new( :node($/) );
my $pirop := ~$<op>;
$pirop := Q:PIR {
Expand Down Expand Up @@ -2501,6 +2507,9 @@ method quote:sym<qq>($/) { make $<quote_EXPR>.ast; }
method quote:sym<q>($/) { make $<quote_EXPR>.ast; }
method quote:sym<Q>($/) { make $<quote_EXPR>.ast; }
method quote:sym<Q:PIR>($/) {
if $*FORBID_PIR {
pir::die("Q:PIR forbidden in safe mode\n");
}
make PAST::Op.new( :inline( $<quote_EXPR>.ast.value ),
:pasttype('inline'),
:node($/) );
Expand Down
1 change: 1 addition & 0 deletions src/Perl6/Grammar.pm
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ token comp_unit {
:my $*IN_DECL; # what declaration we're in
:my $*IMPLICIT; # whether we allow an implicit param
:my $*MONKEY_TYPING := 0; # whether augment/supersede are allowed
:my $*FORBID_PIR := 0; # whether pir::op and Q:PIR { } are disallowed
:my $*SETTING_MODE := 0; # are we compiling the SETTING
:my $*LEFTSIGIL; # sigil of LHS for item vs list assignment
:my $*SCOPE := ''; # which scope declarator we're under
Expand Down

0 comments on commit c80319f

Please sign in to comment.