@@ -640,7 +640,7 @@ class GenJS {
640
640
visitESTreeNode (*this , id, parent);
641
641
}
642
642
if (superClass) {
643
- OS_ << ' ' ;
643
+ OS_ << " extends " ;
644
644
visitESTreeNode (*this , superClass, parent);
645
645
}
646
646
space ();
@@ -653,15 +653,94 @@ class GenJS {
653
653
return ;
654
654
}
655
655
incIndent ();
656
- newline ();
657
656
658
657
for (auto &p : node->_body ) {
659
- visitESTreeNode (*this , &p, node);
660
658
newline ();
659
+ visitESTreeNode (*this , &p, node);
661
660
}
662
661
663
- OS_ << ' }' ;
664
662
decIndent ();
663
+ newline ();
664
+ OS_ << ' }' ;
665
+ }
666
+ void visit (MethodDefinitionNode *node) {
667
+ if (node->_static ) {
668
+ OS_ << " static " ;
669
+ }
670
+ if (auto *funExprValue =
671
+ llvh::dyn_cast_or_null<FunctionExpressionNode>(node->_value )) {
672
+ if (funExprValue->_async ) {
673
+ OS_ << " async " ;
674
+ }
675
+ if (funExprValue->_generator ) {
676
+ OS_ << ' *' ;
677
+ }
678
+ llvh::StringRef kind = node->_kind ->str ();
679
+ if (kind == " get" ) {
680
+ OS_ << " get " ;
681
+ } else if (kind == " set" ) {
682
+ OS_ << " set " ;
683
+ }
684
+ }
685
+ if (node->_computed ) {
686
+ OS_ << ' [' ;
687
+ }
688
+ visitESTreeNode (*this , node->_key , node);
689
+ if (node->_computed ) {
690
+ OS_ << ' ]' ;
691
+ }
692
+ auto *funExprValue = llvh::cast<FunctionExpressionNode>(node->_value );
693
+ visitFuncParamsAndBody (
694
+ funExprValue->_params , funExprValue->_body , funExprValue);
695
+ }
696
+ void visit (ClassPrivatePropertyNode *node) {
697
+ constexpr bool isComputed = false ;
698
+ constexpr bool isPrivate = true ;
699
+ visitClassProperty (
700
+ node->_static , isComputed, isPrivate, node->_key , node->_value , node);
701
+ }
702
+ void visit (ClassPropertyNode *node) {
703
+ // node should not be a private identifier (i.e., a #id member); but if it
704
+ // is, visitClassProperty will visit it, and visit(PrivateNameNode *) below
705
+ // will print the '#' appropriately.
706
+ constexpr bool isPrivate = false ;
707
+ visitClassProperty (
708
+ node->_static ,
709
+ node->_computed ,
710
+ isPrivate,
711
+ node->_key ,
712
+ node->_value ,
713
+ node);
714
+ }
715
+ void visitClassProperty (
716
+ bool isStatic,
717
+ bool isComputed,
718
+ bool isPrivate,
719
+ Node *key,
720
+ Node *value,
721
+ Node *parent) {
722
+ if (isStatic) {
723
+ OS_ << " static " ;
724
+ }
725
+ if (isComputed) {
726
+ OS_ << ' [' ;
727
+ }
728
+ if (isPrivate) {
729
+ OS_ << ' #' ;
730
+ }
731
+ visitESTreeNode (*this , key, parent);
732
+ if (isComputed) {
733
+ OS_ << ' ]' ;
734
+ }
735
+ if (value) {
736
+ OS_ << " = " ;
737
+ visitESTreeNode (*this , value, parent);
738
+ }
739
+ OS_ << ' ;' ;
740
+ }
741
+ void visit (PrivateNameNode *node) {
742
+ OS_ << ' #' ;
743
+ visitESTreeNode (*this , node->_id , node);
665
744
}
666
745
667
746
void visit (FunctionExpressionNode *node) {
0 commit comments