Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created January 26, 2023 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizmat/136cee1a104ff73e34b26cf528ac95c6 to your computer and use it in GitHub Desktop.
Save lizmat/136cee1a104ff73e34b26cf528ac95c6 to your computer and use it in GitHub Desktop.
PRE phaser implementation
# The PRE phaser.
class RakuAST::StatementPrefix::Phaser::Pre
is RakuAST::StatementPrefix::Thunky
is RakuAST::Attaching
{
method new(RakuAST::Blorst $condition) {
my $obj := nqp::create(self);
nqp::bindattr($obj, RakuAST::StatementPrefix, '$!blorst',
RakuAST::Statement::Expression.new(
expression => RakuAST::ApplyPostfix.new(
operand => RakuAST::ApplyPostfix.new(
operand => RakuAST::Type::Simple.new(
RakuAST::Name.from-identifier-parts(
'X','Phaser','PrePost'
)
),
postfix => RakuAST::Call::Method.new(
name => RakuAST::Name.from-identifier('new'),
args => RakuAST::ArgList.new(
ColonPair::Value.new(
key => 'phaser',
value => 'PRE'
),
ColonPair::Value.new(
key => 'condition',
value => $condition.DEPARSE
)
)
)
),
postfix => RakuAST::Call::Method.new(
name => RakuAST::Name.from-identifier('throw')
)
)
),
condition-modifier => $condition
);
$obj
}
method attach(RakuAST::Resolver $resolver) {
$resolver.find-attach-target('block').add-pre-phaser(self);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment