go.ketch.com/lib/goja@v0.0.1/ast/node.go (about)

     1  /*
     2  Package ast declares types representing a JavaScript AST.
     3  
     4  # Warning
     5  
     6  The parser and AST interfaces are still works-in-progress (particularly where
     7  node types are concerned) and may change in the future.
     8  */
     9  package ast
    10  
    11  import (
    12  	"go.ketch.com/lib/goja/file"
    13  	"go.ketch.com/lib/goja/token"
    14  	"go.ketch.com/lib/goja/unistring"
    15  )
    16  
    17  type PropertyKind string
    18  
    19  const (
    20  	PropertyKindValue  PropertyKind = "value"
    21  	PropertyKindGet    PropertyKind = "get"
    22  	PropertyKindSet    PropertyKind = "set"
    23  	PropertyKindMethod PropertyKind = "method"
    24  )
    25  
    26  // All nodes implement the Node interface.
    27  type Node interface {
    28  	Idx0() file.Idx // The index of the first character belonging to the node
    29  	Idx1() file.Idx // The index of the first character immediately after the node
    30  }
    31  
    32  // ========== //
    33  // Expression //
    34  // ========== //
    35  
    36  type (
    37  	// All expression nodes implement the Expression interface.
    38  	Expression interface {
    39  		Node
    40  		_expressionNode()
    41  	}
    42  
    43  	BindingTarget interface {
    44  		Expression
    45  		_bindingTarget()
    46  	}
    47  
    48  	Binding struct {
    49  		Target      BindingTarget
    50  		Initializer Expression
    51  	}
    52  
    53  	Pattern interface {
    54  		BindingTarget
    55  		_pattern()
    56  	}
    57  
    58  	ArrayLiteral struct {
    59  		LeftBracket  file.Idx
    60  		RightBracket file.Idx
    61  		Value        []Expression
    62  	}
    63  
    64  	ArrayPattern struct {
    65  		LeftBracket  file.Idx
    66  		RightBracket file.Idx
    67  		Elements     []Expression
    68  		Rest         Expression
    69  	}
    70  
    71  	AssignExpression struct {
    72  		Operator token.Token
    73  		Left     Expression
    74  		Right    Expression
    75  	}
    76  
    77  	BadExpression struct {
    78  		From file.Idx
    79  		To   file.Idx
    80  	}
    81  
    82  	BinaryExpression struct {
    83  		Operator   token.Token
    84  		Left       Expression
    85  		Right      Expression
    86  		Comparison bool
    87  	}
    88  
    89  	BooleanLiteral struct {
    90  		Idx     file.Idx
    91  		Literal string
    92  		Value   bool
    93  	}
    94  
    95  	BracketExpression struct {
    96  		Left         Expression
    97  		Member       Expression
    98  		LeftBracket  file.Idx
    99  		RightBracket file.Idx
   100  	}
   101  
   102  	CallExpression struct {
   103  		Callee           Expression
   104  		LeftParenthesis  file.Idx
   105  		ArgumentList     []Expression
   106  		RightParenthesis file.Idx
   107  	}
   108  
   109  	ConditionalExpression struct {
   110  		Test       Expression
   111  		Consequent Expression
   112  		Alternate  Expression
   113  	}
   114  
   115  	DotExpression struct {
   116  		Left       Expression
   117  		Identifier Identifier
   118  	}
   119  
   120  	PrivateDotExpression struct {
   121  		Left       Expression
   122  		Identifier PrivateIdentifier
   123  	}
   124  
   125  	OptionalChain struct {
   126  		Expression
   127  	}
   128  
   129  	Optional struct {
   130  		Expression
   131  	}
   132  
   133  	FunctionLiteral struct {
   134  		Function      file.Idx
   135  		Name          *Identifier
   136  		ParameterList *ParameterList
   137  		Body          *BlockStatement
   138  		Source        string
   139  
   140  		DeclarationList []*VariableDeclaration
   141  	}
   142  
   143  	ClassLiteral struct {
   144  		Class      file.Idx
   145  		RightBrace file.Idx
   146  		Name       *Identifier
   147  		SuperClass Expression
   148  		Body       []ClassElement
   149  		Source     string
   150  	}
   151  
   152  	ConciseBody interface {
   153  		Node
   154  		_conciseBody()
   155  	}
   156  
   157  	ExpressionBody struct {
   158  		Expression Expression
   159  	}
   160  
   161  	ArrowFunctionLiteral struct {
   162  		Start           file.Idx
   163  		ParameterList   *ParameterList
   164  		Body            ConciseBody
   165  		Source          string
   166  		DeclarationList []*VariableDeclaration
   167  	}
   168  
   169  	Identifier struct {
   170  		Name unistring.String
   171  		Idx  file.Idx
   172  	}
   173  
   174  	PrivateIdentifier struct {
   175  		Identifier
   176  	}
   177  
   178  	NewExpression struct {
   179  		New              file.Idx
   180  		Callee           Expression
   181  		LeftParenthesis  file.Idx
   182  		ArgumentList     []Expression
   183  		RightParenthesis file.Idx
   184  	}
   185  
   186  	NullLiteral struct {
   187  		Idx     file.Idx
   188  		Literal string
   189  	}
   190  
   191  	NumberLiteral struct {
   192  		Idx     file.Idx
   193  		Literal string
   194  		Value   interface{}
   195  	}
   196  
   197  	ObjectLiteral struct {
   198  		LeftBrace  file.Idx
   199  		RightBrace file.Idx
   200  		Value      []Property
   201  	}
   202  
   203  	ObjectPattern struct {
   204  		LeftBrace  file.Idx
   205  		RightBrace file.Idx
   206  		Properties []Property
   207  		Rest       Expression
   208  	}
   209  
   210  	ParameterList struct {
   211  		Opening file.Idx
   212  		List    []*Binding
   213  		Rest    Expression
   214  		Closing file.Idx
   215  	}
   216  
   217  	Property interface {
   218  		Expression
   219  		_property()
   220  	}
   221  
   222  	PropertyShort struct {
   223  		Name        Identifier
   224  		Initializer Expression
   225  	}
   226  
   227  	PropertyKeyed struct {
   228  		Key      Expression
   229  		Kind     PropertyKind
   230  		Value    Expression
   231  		Computed bool
   232  	}
   233  
   234  	SpreadElement struct {
   235  		Expression
   236  	}
   237  
   238  	RegExpLiteral struct {
   239  		Idx     file.Idx
   240  		Literal string
   241  		Pattern string
   242  		Flags   string
   243  	}
   244  
   245  	SequenceExpression struct {
   246  		Sequence []Expression
   247  	}
   248  
   249  	StringLiteral struct {
   250  		Idx     file.Idx
   251  		Literal string
   252  		Value   unistring.String
   253  	}
   254  
   255  	TemplateElement struct {
   256  		Idx     file.Idx
   257  		Literal string
   258  		Parsed  unistring.String
   259  		Valid   bool
   260  	}
   261  
   262  	TemplateLiteral struct {
   263  		OpenQuote   file.Idx
   264  		CloseQuote  file.Idx
   265  		Tag         Expression
   266  		Elements    []*TemplateElement
   267  		Expressions []Expression
   268  	}
   269  
   270  	ThisExpression struct {
   271  		Idx file.Idx
   272  	}
   273  
   274  	SuperExpression struct {
   275  		Idx file.Idx
   276  	}
   277  
   278  	UnaryExpression struct {
   279  		Operator token.Token
   280  		Idx      file.Idx // If a prefix operation
   281  		Operand  Expression
   282  		Postfix  bool
   283  	}
   284  
   285  	MetaProperty struct {
   286  		Meta, Property *Identifier
   287  		Idx            file.Idx
   288  	}
   289  )
   290  
   291  // _expressionNode
   292  
   293  func (*ArrayLiteral) _expressionNode()          {}
   294  func (*AssignExpression) _expressionNode()      {}
   295  func (*BadExpression) _expressionNode()         {}
   296  func (*BinaryExpression) _expressionNode()      {}
   297  func (*BooleanLiteral) _expressionNode()        {}
   298  func (*BracketExpression) _expressionNode()     {}
   299  func (*CallExpression) _expressionNode()        {}
   300  func (*ConditionalExpression) _expressionNode() {}
   301  func (*DotExpression) _expressionNode()         {}
   302  func (*PrivateDotExpression) _expressionNode()  {}
   303  func (*FunctionLiteral) _expressionNode()       {}
   304  func (*ClassLiteral) _expressionNode()          {}
   305  func (*ArrowFunctionLiteral) _expressionNode()  {}
   306  func (*Identifier) _expressionNode()            {}
   307  func (*NewExpression) _expressionNode()         {}
   308  func (*NullLiteral) _expressionNode()           {}
   309  func (*NumberLiteral) _expressionNode()         {}
   310  func (*ObjectLiteral) _expressionNode()         {}
   311  func (*RegExpLiteral) _expressionNode()         {}
   312  func (*SequenceExpression) _expressionNode()    {}
   313  func (*StringLiteral) _expressionNode()         {}
   314  func (*TemplateLiteral) _expressionNode()       {}
   315  func (*ThisExpression) _expressionNode()        {}
   316  func (*SuperExpression) _expressionNode()       {}
   317  func (*UnaryExpression) _expressionNode()       {}
   318  func (*MetaProperty) _expressionNode()          {}
   319  func (*ObjectPattern) _expressionNode()         {}
   320  func (*ArrayPattern) _expressionNode()          {}
   321  func (*Binding) _expressionNode()               {}
   322  
   323  func (*PropertyShort) _expressionNode() {}
   324  func (*PropertyKeyed) _expressionNode() {}
   325  
   326  // ========= //
   327  // Statement //
   328  // ========= //
   329  
   330  type (
   331  	// All statement nodes implement the Statement interface.
   332  	Statement interface {
   333  		Node
   334  		_statementNode()
   335  	}
   336  
   337  	BadStatement struct {
   338  		From file.Idx
   339  		To   file.Idx
   340  	}
   341  
   342  	BlockStatement struct {
   343  		LeftBrace  file.Idx
   344  		List       []Statement
   345  		RightBrace file.Idx
   346  	}
   347  
   348  	BranchStatement struct {
   349  		Idx   file.Idx
   350  		Token token.Token
   351  		Label *Identifier
   352  	}
   353  
   354  	CaseStatement struct {
   355  		Case       file.Idx
   356  		Test       Expression
   357  		Consequent []Statement
   358  	}
   359  
   360  	CatchStatement struct {
   361  		Catch     file.Idx
   362  		Parameter BindingTarget
   363  		Body      *BlockStatement
   364  	}
   365  
   366  	DebuggerStatement struct {
   367  		Debugger file.Idx
   368  	}
   369  
   370  	DoWhileStatement struct {
   371  		Do   file.Idx
   372  		Test Expression
   373  		Body Statement
   374  	}
   375  
   376  	EmptyStatement struct {
   377  		Semicolon file.Idx
   378  	}
   379  
   380  	ExpressionStatement struct {
   381  		Expression Expression
   382  	}
   383  
   384  	ForInStatement struct {
   385  		For    file.Idx
   386  		Into   ForInto
   387  		Source Expression
   388  		Body   Statement
   389  	}
   390  
   391  	ForOfStatement struct {
   392  		For    file.Idx
   393  		Into   ForInto
   394  		Source Expression
   395  		Body   Statement
   396  	}
   397  
   398  	ForStatement struct {
   399  		For         file.Idx
   400  		Initializer ForLoopInitializer
   401  		Update      Expression
   402  		Test        Expression
   403  		Body        Statement
   404  	}
   405  
   406  	IfStatement struct {
   407  		If         file.Idx
   408  		Test       Expression
   409  		Consequent Statement
   410  		Alternate  Statement
   411  	}
   412  
   413  	LabelledStatement struct {
   414  		Label     *Identifier
   415  		Colon     file.Idx
   416  		Statement Statement
   417  	}
   418  
   419  	ReturnStatement struct {
   420  		Return   file.Idx
   421  		Argument Expression
   422  	}
   423  
   424  	SwitchStatement struct {
   425  		Switch       file.Idx
   426  		Discriminant Expression
   427  		Default      int
   428  		Body         []*CaseStatement
   429  	}
   430  
   431  	ThrowStatement struct {
   432  		Throw    file.Idx
   433  		Argument Expression
   434  	}
   435  
   436  	TryStatement struct {
   437  		Try     file.Idx
   438  		Body    *BlockStatement
   439  		Catch   *CatchStatement
   440  		Finally *BlockStatement
   441  	}
   442  
   443  	VariableStatement struct {
   444  		Var  file.Idx
   445  		List []*Binding
   446  	}
   447  
   448  	LexicalDeclaration struct {
   449  		Idx   file.Idx
   450  		Token token.Token
   451  		List  []*Binding
   452  	}
   453  
   454  	WhileStatement struct {
   455  		While file.Idx
   456  		Test  Expression
   457  		Body  Statement
   458  	}
   459  
   460  	WithStatement struct {
   461  		With   file.Idx
   462  		Object Expression
   463  		Body   Statement
   464  	}
   465  
   466  	FunctionDeclaration struct {
   467  		Function *FunctionLiteral
   468  	}
   469  
   470  	ClassDeclaration struct {
   471  		Class *ClassLiteral
   472  	}
   473  )
   474  
   475  // _statementNode
   476  
   477  func (*BadStatement) _statementNode()        {}
   478  func (*BlockStatement) _statementNode()      {}
   479  func (*BranchStatement) _statementNode()     {}
   480  func (*CaseStatement) _statementNode()       {}
   481  func (*CatchStatement) _statementNode()      {}
   482  func (*DebuggerStatement) _statementNode()   {}
   483  func (*DoWhileStatement) _statementNode()    {}
   484  func (*EmptyStatement) _statementNode()      {}
   485  func (*ExpressionStatement) _statementNode() {}
   486  func (*ForInStatement) _statementNode()      {}
   487  func (*ForOfStatement) _statementNode()      {}
   488  func (*ForStatement) _statementNode()        {}
   489  func (*IfStatement) _statementNode()         {}
   490  func (*LabelledStatement) _statementNode()   {}
   491  func (*ReturnStatement) _statementNode()     {}
   492  func (*SwitchStatement) _statementNode()     {}
   493  func (*ThrowStatement) _statementNode()      {}
   494  func (*TryStatement) _statementNode()        {}
   495  func (*VariableStatement) _statementNode()   {}
   496  func (*WhileStatement) _statementNode()      {}
   497  func (*WithStatement) _statementNode()       {}
   498  func (*LexicalDeclaration) _statementNode()  {}
   499  func (*FunctionDeclaration) _statementNode() {}
   500  func (*ClassDeclaration) _statementNode()    {}
   501  
   502  // =========== //
   503  // Declaration //
   504  // =========== //
   505  
   506  type (
   507  	VariableDeclaration struct {
   508  		Var  file.Idx
   509  		List []*Binding
   510  	}
   511  
   512  	ClassElement interface {
   513  		Node
   514  		_classElement()
   515  	}
   516  
   517  	FieldDefinition struct {
   518  		Idx         file.Idx
   519  		Key         Expression
   520  		Initializer Expression
   521  		Computed    bool
   522  		Static      bool
   523  	}
   524  
   525  	MethodDefinition struct {
   526  		Idx      file.Idx
   527  		Key      Expression
   528  		Kind     PropertyKind // "method", "get" or "set"
   529  		Body     *FunctionLiteral
   530  		Computed bool
   531  		Static   bool
   532  	}
   533  
   534  	ClassStaticBlock struct {
   535  		Static          file.Idx
   536  		Block           *BlockStatement
   537  		Source          string
   538  		DeclarationList []*VariableDeclaration
   539  	}
   540  )
   541  
   542  type (
   543  	ForLoopInitializer interface {
   544  		_forLoopInitializer()
   545  	}
   546  
   547  	ForLoopInitializerExpression struct {
   548  		Expression Expression
   549  	}
   550  
   551  	ForLoopInitializerVarDeclList struct {
   552  		Var  file.Idx
   553  		List []*Binding
   554  	}
   555  
   556  	ForLoopInitializerLexicalDecl struct {
   557  		LexicalDeclaration LexicalDeclaration
   558  	}
   559  
   560  	ForInto interface {
   561  		Node
   562  		_forInto()
   563  	}
   564  
   565  	ForIntoVar struct {
   566  		Binding *Binding
   567  	}
   568  
   569  	ForDeclaration struct {
   570  		Idx     file.Idx
   571  		IsConst bool
   572  		Target  BindingTarget
   573  	}
   574  
   575  	ForIntoExpression struct {
   576  		Expression Expression
   577  	}
   578  )
   579  
   580  func (*ForLoopInitializerExpression) _forLoopInitializer()  {}
   581  func (*ForLoopInitializerVarDeclList) _forLoopInitializer() {}
   582  func (*ForLoopInitializerLexicalDecl) _forLoopInitializer() {}
   583  
   584  func (*ForIntoVar) _forInto()        {}
   585  func (*ForDeclaration) _forInto()    {}
   586  func (*ForIntoExpression) _forInto() {}
   587  
   588  func (*ArrayPattern) _pattern()       {}
   589  func (*ArrayPattern) _bindingTarget() {}
   590  
   591  func (*ObjectPattern) _pattern()       {}
   592  func (*ObjectPattern) _bindingTarget() {}
   593  
   594  func (*BadExpression) _bindingTarget() {}
   595  
   596  func (*PropertyShort) _property() {}
   597  func (*PropertyKeyed) _property() {}
   598  func (*SpreadElement) _property() {}
   599  
   600  func (*Identifier) _bindingTarget() {}
   601  
   602  func (*BlockStatement) _conciseBody() {}
   603  func (*ExpressionBody) _conciseBody() {}
   604  
   605  func (*FieldDefinition) _classElement()  {}
   606  func (*MethodDefinition) _classElement() {}
   607  func (*ClassStaticBlock) _classElement() {}
   608  
   609  // ==== //
   610  // Node //
   611  // ==== //
   612  
   613  type Program struct {
   614  	Body []Statement
   615  
   616  	DeclarationList []*VariableDeclaration
   617  
   618  	File *file.File
   619  }
   620  
   621  // ==== //
   622  // Idx0 //
   623  // ==== //
   624  
   625  func (self *ArrayLiteral) Idx0() file.Idx          { return self.LeftBracket }
   626  func (self *ArrayPattern) Idx0() file.Idx          { return self.LeftBracket }
   627  func (self *ObjectPattern) Idx0() file.Idx         { return self.LeftBrace }
   628  func (self *AssignExpression) Idx0() file.Idx      { return self.Left.Idx0() }
   629  func (self *BadExpression) Idx0() file.Idx         { return self.From }
   630  func (self *BinaryExpression) Idx0() file.Idx      { return self.Left.Idx0() }
   631  func (self *BooleanLiteral) Idx0() file.Idx        { return self.Idx }
   632  func (self *BracketExpression) Idx0() file.Idx     { return self.Left.Idx0() }
   633  func (self *CallExpression) Idx0() file.Idx        { return self.Callee.Idx0() }
   634  func (self *ConditionalExpression) Idx0() file.Idx { return self.Test.Idx0() }
   635  func (self *DotExpression) Idx0() file.Idx         { return self.Left.Idx0() }
   636  func (self *PrivateDotExpression) Idx0() file.Idx  { return self.Left.Idx0() }
   637  func (self *FunctionLiteral) Idx0() file.Idx       { return self.Function }
   638  func (self *ClassLiteral) Idx0() file.Idx          { return self.Class }
   639  func (self *ArrowFunctionLiteral) Idx0() file.Idx  { return self.Start }
   640  func (self *Identifier) Idx0() file.Idx            { return self.Idx }
   641  func (self *NewExpression) Idx0() file.Idx         { return self.New }
   642  func (self *NullLiteral) Idx0() file.Idx           { return self.Idx }
   643  func (self *NumberLiteral) Idx0() file.Idx         { return self.Idx }
   644  func (self *ObjectLiteral) Idx0() file.Idx         { return self.LeftBrace }
   645  func (self *RegExpLiteral) Idx0() file.Idx         { return self.Idx }
   646  func (self *SequenceExpression) Idx0() file.Idx    { return self.Sequence[0].Idx0() }
   647  func (self *StringLiteral) Idx0() file.Idx         { return self.Idx }
   648  func (self *TemplateLiteral) Idx0() file.Idx       { return self.OpenQuote }
   649  func (self *ThisExpression) Idx0() file.Idx        { return self.Idx }
   650  func (self *SuperExpression) Idx0() file.Idx       { return self.Idx }
   651  func (self *UnaryExpression) Idx0() file.Idx       { return self.Idx }
   652  func (self *MetaProperty) Idx0() file.Idx          { return self.Idx }
   653  
   654  func (self *BadStatement) Idx0() file.Idx        { return self.From }
   655  func (self *BlockStatement) Idx0() file.Idx      { return self.LeftBrace }
   656  func (self *BranchStatement) Idx0() file.Idx     { return self.Idx }
   657  func (self *CaseStatement) Idx0() file.Idx       { return self.Case }
   658  func (self *CatchStatement) Idx0() file.Idx      { return self.Catch }
   659  func (self *DebuggerStatement) Idx0() file.Idx   { return self.Debugger }
   660  func (self *DoWhileStatement) Idx0() file.Idx    { return self.Do }
   661  func (self *EmptyStatement) Idx0() file.Idx      { return self.Semicolon }
   662  func (self *ExpressionStatement) Idx0() file.Idx { return self.Expression.Idx0() }
   663  func (self *ForInStatement) Idx0() file.Idx      { return self.For }
   664  func (self *ForOfStatement) Idx0() file.Idx      { return self.For }
   665  func (self *ForStatement) Idx0() file.Idx        { return self.For }
   666  func (self *IfStatement) Idx0() file.Idx         { return self.If }
   667  func (self *LabelledStatement) Idx0() file.Idx   { return self.Label.Idx0() }
   668  func (self *Program) Idx0() file.Idx             { return self.Body[0].Idx0() }
   669  func (self *ReturnStatement) Idx0() file.Idx     { return self.Return }
   670  func (self *SwitchStatement) Idx0() file.Idx     { return self.Switch }
   671  func (self *ThrowStatement) Idx0() file.Idx      { return self.Throw }
   672  func (self *TryStatement) Idx0() file.Idx        { return self.Try }
   673  func (self *VariableStatement) Idx0() file.Idx   { return self.Var }
   674  func (self *WhileStatement) Idx0() file.Idx      { return self.While }
   675  func (self *WithStatement) Idx0() file.Idx       { return self.With }
   676  func (self *LexicalDeclaration) Idx0() file.Idx  { return self.Idx }
   677  func (self *FunctionDeclaration) Idx0() file.Idx { return self.Function.Idx0() }
   678  func (self *ClassDeclaration) Idx0() file.Idx    { return self.Class.Idx0() }
   679  func (self *Binding) Idx0() file.Idx             { return self.Target.Idx0() }
   680  
   681  func (self *ForLoopInitializerVarDeclList) Idx0() file.Idx { return self.List[0].Idx0() }
   682  func (self *PropertyShort) Idx0() file.Idx                 { return self.Name.Idx }
   683  func (self *PropertyKeyed) Idx0() file.Idx                 { return self.Key.Idx0() }
   684  func (self *ExpressionBody) Idx0() file.Idx                { return self.Expression.Idx0() }
   685  
   686  func (self *FieldDefinition) Idx0() file.Idx  { return self.Idx }
   687  func (self *MethodDefinition) Idx0() file.Idx { return self.Idx }
   688  func (self *ClassStaticBlock) Idx0() file.Idx { return self.Static }
   689  
   690  func (self *ForDeclaration) Idx0() file.Idx    { return self.Idx }
   691  func (self *ForIntoVar) Idx0() file.Idx        { return self.Binding.Idx0() }
   692  func (self *ForIntoExpression) Idx0() file.Idx { return self.Expression.Idx0() }
   693  
   694  // ==== //
   695  // Idx1 //
   696  // ==== //
   697  
   698  func (self *ArrayLiteral) Idx1() file.Idx          { return self.RightBracket + 1 }
   699  func (self *ArrayPattern) Idx1() file.Idx          { return self.RightBracket + 1 }
   700  func (self *AssignExpression) Idx1() file.Idx      { return self.Right.Idx1() }
   701  func (self *BadExpression) Idx1() file.Idx         { return self.To }
   702  func (self *BinaryExpression) Idx1() file.Idx      { return self.Right.Idx1() }
   703  func (self *BooleanLiteral) Idx1() file.Idx        { return file.Idx(int(self.Idx) + len(self.Literal)) }
   704  func (self *BracketExpression) Idx1() file.Idx     { return self.RightBracket + 1 }
   705  func (self *CallExpression) Idx1() file.Idx        { return self.RightParenthesis + 1 }
   706  func (self *ConditionalExpression) Idx1() file.Idx { return self.Test.Idx1() }
   707  func (self *DotExpression) Idx1() file.Idx         { return self.Identifier.Idx1() }
   708  func (self *PrivateDotExpression) Idx1() file.Idx  { return self.Identifier.Idx1() }
   709  func (self *FunctionLiteral) Idx1() file.Idx       { return self.Body.Idx1() }
   710  func (self *ClassLiteral) Idx1() file.Idx          { return self.RightBrace + 1 }
   711  func (self *ArrowFunctionLiteral) Idx1() file.Idx  { return self.Body.Idx1() }
   712  func (self *Identifier) Idx1() file.Idx            { return file.Idx(int(self.Idx) + len(self.Name)) }
   713  func (self *NewExpression) Idx1() file.Idx {
   714  	if self.ArgumentList != nil {
   715  		return self.RightParenthesis + 1
   716  	} else {
   717  		return self.Callee.Idx1()
   718  	}
   719  }
   720  func (self *NullLiteral) Idx1() file.Idx        { return file.Idx(int(self.Idx) + 4) } // "null"
   721  func (self *NumberLiteral) Idx1() file.Idx      { return file.Idx(int(self.Idx) + len(self.Literal)) }
   722  func (self *ObjectLiteral) Idx1() file.Idx      { return self.RightBrace + 1 }
   723  func (self *ObjectPattern) Idx1() file.Idx      { return self.RightBrace + 1 }
   724  func (self *RegExpLiteral) Idx1() file.Idx      { return file.Idx(int(self.Idx) + len(self.Literal)) }
   725  func (self *SequenceExpression) Idx1() file.Idx { return self.Sequence[len(self.Sequence)-1].Idx1() }
   726  func (self *StringLiteral) Idx1() file.Idx      { return file.Idx(int(self.Idx) + len(self.Literal)) }
   727  func (self *TemplateLiteral) Idx1() file.Idx    { return self.CloseQuote + 1 }
   728  func (self *ThisExpression) Idx1() file.Idx     { return self.Idx + 4 }
   729  func (self *SuperExpression) Idx1() file.Idx    { return self.Idx + 5 }
   730  func (self *UnaryExpression) Idx1() file.Idx {
   731  	if self.Postfix {
   732  		return self.Operand.Idx1() + 2 // ++ --
   733  	}
   734  	return self.Operand.Idx1()
   735  }
   736  func (self *MetaProperty) Idx1() file.Idx {
   737  	return self.Property.Idx1()
   738  }
   739  
   740  func (self *BadStatement) Idx1() file.Idx        { return self.To }
   741  func (self *BlockStatement) Idx1() file.Idx      { return self.RightBrace + 1 }
   742  func (self *BranchStatement) Idx1() file.Idx     { return self.Idx }
   743  func (self *CaseStatement) Idx1() file.Idx       { return self.Consequent[len(self.Consequent)-1].Idx1() }
   744  func (self *CatchStatement) Idx1() file.Idx      { return self.Body.Idx1() }
   745  func (self *DebuggerStatement) Idx1() file.Idx   { return self.Debugger + 8 }
   746  func (self *DoWhileStatement) Idx1() file.Idx    { return self.Test.Idx1() }
   747  func (self *EmptyStatement) Idx1() file.Idx      { return self.Semicolon + 1 }
   748  func (self *ExpressionStatement) Idx1() file.Idx { return self.Expression.Idx1() }
   749  func (self *ForInStatement) Idx1() file.Idx      { return self.Body.Idx1() }
   750  func (self *ForOfStatement) Idx1() file.Idx      { return self.Body.Idx1() }
   751  func (self *ForStatement) Idx1() file.Idx        { return self.Body.Idx1() }
   752  func (self *IfStatement) Idx1() file.Idx {
   753  	if self.Alternate != nil {
   754  		return self.Alternate.Idx1()
   755  	}
   756  	return self.Consequent.Idx1()
   757  }
   758  func (self *LabelledStatement) Idx1() file.Idx { return self.Colon + 1 }
   759  func (self *Program) Idx1() file.Idx           { return self.Body[len(self.Body)-1].Idx1() }
   760  func (self *ReturnStatement) Idx1() file.Idx   { return self.Return + 6 }
   761  func (self *SwitchStatement) Idx1() file.Idx   { return self.Body[len(self.Body)-1].Idx1() }
   762  func (self *ThrowStatement) Idx1() file.Idx    { return self.Argument.Idx1() }
   763  func (self *TryStatement) Idx1() file.Idx {
   764  	if self.Finally != nil {
   765  		return self.Finally.Idx1()
   766  	}
   767  	if self.Catch != nil {
   768  		return self.Catch.Idx1()
   769  	}
   770  	return self.Body.Idx1()
   771  }
   772  func (self *VariableStatement) Idx1() file.Idx   { return self.List[len(self.List)-1].Idx1() }
   773  func (self *WhileStatement) Idx1() file.Idx      { return self.Body.Idx1() }
   774  func (self *WithStatement) Idx1() file.Idx       { return self.Body.Idx1() }
   775  func (self *LexicalDeclaration) Idx1() file.Idx  { return self.List[len(self.List)-1].Idx1() }
   776  func (self *FunctionDeclaration) Idx1() file.Idx { return self.Function.Idx1() }
   777  func (self *ClassDeclaration) Idx1() file.Idx    { return self.Class.Idx1() }
   778  func (self *Binding) Idx1() file.Idx {
   779  	if self.Initializer != nil {
   780  		return self.Initializer.Idx1()
   781  	}
   782  	return self.Target.Idx1()
   783  }
   784  
   785  func (self *ForLoopInitializerVarDeclList) Idx1() file.Idx { return self.List[len(self.List)-1].Idx1() }
   786  
   787  func (self *PropertyShort) Idx1() file.Idx {
   788  	if self.Initializer != nil {
   789  		return self.Initializer.Idx1()
   790  	}
   791  	return self.Name.Idx1()
   792  }
   793  
   794  func (self *PropertyKeyed) Idx1() file.Idx { return self.Value.Idx1() }
   795  
   796  func (self *ExpressionBody) Idx1() file.Idx { return self.Expression.Idx1() }
   797  
   798  func (self *FieldDefinition) Idx1() file.Idx {
   799  	if self.Initializer != nil {
   800  		return self.Initializer.Idx1()
   801  	}
   802  	return self.Key.Idx1()
   803  }
   804  
   805  func (self *MethodDefinition) Idx1() file.Idx {
   806  	return self.Body.Idx1()
   807  }
   808  
   809  func (self *ClassStaticBlock) Idx1() file.Idx {
   810  	return self.Block.Idx1()
   811  }
   812  
   813  func (self *ForDeclaration) Idx1() file.Idx    { return self.Target.Idx1() }
   814  func (self *ForIntoVar) Idx1() file.Idx        { return self.Binding.Idx1() }
   815  func (self *ForIntoExpression) Idx1() file.Idx { return self.Expression.Idx1() }