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