Skip to content

Commit

Permalink
Add deparsing/.raku for Type::Enum
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Mar 5, 2023
1 parent 6489eb8 commit 6c3468c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/core.c/RakuAST/Deparse.pm6
Expand Up @@ -1789,6 +1789,18 @@ class RakuAST::Deparse {

#- Type ------------------------------------------------------------------------

multi method deparse(RakuAST::Type::Enum:D $ast --> Str:D) {
my str @parts = 'enum';
my str $scope = $ast.scope;

@parts.unshift($scope) if $scope && $scope ne 'our'; # XXX
@parts.unshift(self.deparse($_)) with $ast.of;
@parts.push(self.deparse($_)) with $ast.name;
@parts.push(self.deparse($ast.term));

@parts.join(' ');
}

multi method deparse(RakuAST::Type::Simple:D $ast --> Str:D) {
self.deparse($ast.name)
}
Expand Down
4 changes: 4 additions & 0 deletions src/core.c/RakuAST/Raku.pm6
Expand Up @@ -1076,6 +1076,10 @@ augment class RakuAST::Node {

#- Type ------------------------------------------------------------------------

multi method raku(RakuAST::Type::Enum:D: --> Str:D) {
self!nameds: <scope name term of>
}

multi method raku(RakuAST::Type::Simple:D: --> Str:D) {
self!positional(self.name)
}
Expand Down

0 comments on commit 6c3468c

Please sign in to comment.