Skip to content

Commit

Permalink
Extract driving a node to parse or begin phase
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jun 5, 2023
1 parent 1600bd7 commit bb4dd9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/Raku/Actions.nqp
Expand Up @@ -22,12 +22,7 @@ role Raku::CommonActions {
# as we go. This factors out that process and attaches the AST to the match
# object.
method attach($/, $node, :$as-key-origin) {
if nqp::istype($node, self.r('ParseTime')) {
$node.ensure-parse-performed($*R, $*CU.context);
}
if nqp::istype($node, self.r('BeginTime')) {
$node.ensure-begin-performed($*R, $*CU.context);
}
$node.to-begin-time($*R, $*CU.context);
if nqp::istype($node, self.r('ImplicitLookups')) {
$node.resolve-implicit-lookups-with($*R);
}
Expand Down
19 changes: 19 additions & 0 deletions src/Raku/ast/base.rakumod
Expand Up @@ -81,6 +81,25 @@ class RakuAST::Node {
self
}

# Bring the node up to parse time. Returns the node itself.
method to-parse-time(RakuAST::Resolver $resolver, RakuAST::IMPL::QASTContext $context) {
if nqp::istype(self, RakuAST::ParseTime) {
self.ensure-parse-performed($resolver, $context);
}
self
}

# Bring the node up to begin time. Returns the node itself.
method to-begin-time(RakuAST::Resolver $resolver, RakuAST::IMPL::QASTContext $context) {
if nqp::istype(self, RakuAST::ParseTime) {
self.ensure-parse-performed($resolver, $context);
}
if nqp::istype(self, RakuAST::BeginTime) {
self.ensure-begin-performed($resolver, $context);
}
self
}

# Perform CHECK-time activities on this node.
method IMPL-CHECK(RakuAST::Resolver $resolver, RakuAST::IMPL::QASTContext $context, Bool $resolve-only) {
# Ensure parse time was performed already before visiting children, when it is a
Expand Down

0 comments on commit bb4dd9c

Please sign in to comment.