Skip to content

Commit

Permalink
Implement translation for self
Browse files Browse the repository at this point in the history
  • Loading branch information
amomchilov committed Aug 21, 2024
1 parent 459c726 commit 1749b46
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion parser/prism/Translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,12 @@ std::unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {

return make_unique<parser::Return>(parser.translateLocation(loc), std::move(returnValues));
}
case PM_SELF_NODE: {
auto selfNode = reinterpret_cast<pm_singleton_class_node *>(node);
pm_location_t *loc = &selfNode->base.location;

return make_unique<parser::Self>(parser.translateLocation(loc));
}
case PM_STATEMENTS_NODE: {
auto inlineIfSingle = true;
return translateStatements(reinterpret_cast<pm_statements_node *>(node), inlineIfSingle);
Expand Down Expand Up @@ -584,7 +590,6 @@ std::unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {
case PM_RESCUE_MODIFIER_NODE:
case PM_RESCUE_NODE:
case PM_RETRY_NODE:
case PM_SELF_NODE:
case PM_SHAREABLE_CONSTANT_NODE:
case PM_SINGLETON_CLASS_NODE:
case PM_SOURCE_ENCODING_NODE:
Expand Down
2 changes: 2 additions & 0 deletions test/prism_regression/self.parse-tree.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Self {
}
3 changes: 3 additions & 0 deletions test/prism_regression/self.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# typed: strict

self

0 comments on commit 1749b46

Please sign in to comment.