Source file src/cmd/compile/internal/noder/codes.go

     1  // UNREVIEWED
     2  
     3  // Copyright 2021 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package noder
     8  
     9  type code interface {
    10  	marker() syncMarker
    11  	value() int
    12  }
    13  
    14  type codeVal int
    15  
    16  func (c codeVal) marker() syncMarker { return syncVal }
    17  func (c codeVal) value() int         { return int(c) }
    18  
    19  const (
    20  	valBool codeVal = iota
    21  	valString
    22  	valInt64
    23  	valBigInt
    24  	valBigRat
    25  	valBigFloat
    26  )
    27  
    28  type codeType int
    29  
    30  func (c codeType) marker() syncMarker { return syncType }
    31  func (c codeType) value() int         { return int(c) }
    32  
    33  const (
    34  	typeBasic codeType = iota
    35  	typeNamed
    36  	typePointer
    37  	typeSlice
    38  	typeArray
    39  	typeChan
    40  	typeMap
    41  	typeSignature
    42  	typeStruct
    43  	typeInterface
    44  	typeUnion
    45  	typeTypeParam
    46  )
    47  
    48  type codeObj int
    49  
    50  func (c codeObj) marker() syncMarker { return syncCodeObj }
    51  func (c codeObj) value() int         { return int(c) }
    52  
    53  const (
    54  	objAlias codeObj = iota
    55  	objConst
    56  	objType
    57  	objFunc
    58  	objVar
    59  	objStub
    60  )
    61  
    62  type codeStmt int
    63  
    64  func (c codeStmt) marker() syncMarker { return syncStmt1 }
    65  func (c codeStmt) value() int         { return int(c) }
    66  
    67  const (
    68  	stmtEnd codeStmt = iota
    69  	stmtLabel
    70  	stmtBlock
    71  	stmtExpr
    72  	stmtSend
    73  	stmtAssign
    74  	stmtAssignOp
    75  	stmtIncDec
    76  	stmtBranch
    77  	stmtCall
    78  	stmtReturn
    79  	stmtIf
    80  	stmtFor
    81  	stmtSwitch
    82  	stmtSelect
    83  
    84  	// TODO(mdempsky): Remove after we don't care about toolstash -cmp.
    85  	stmtTypeDeclHack
    86  )
    87  
    88  type codeExpr int
    89  
    90  func (c codeExpr) marker() syncMarker { return syncExpr }
    91  func (c codeExpr) value() int         { return int(c) }
    92  
    93  // TODO(mdempsky): Split expr into addr, for lvalues.
    94  const (
    95  	exprNone codeExpr = iota
    96  	exprConst
    97  	exprType  // type expression
    98  	exprLocal // local variable
    99  	exprName  // global variable or function
   100  	exprBlank
   101  	exprCompLit
   102  	exprFuncLit
   103  	exprSelector
   104  	exprIndex
   105  	exprSlice
   106  	exprAssert
   107  	exprUnaryOp
   108  	exprBinaryOp
   109  	exprCall
   110  	exprConvert
   111  )
   112  
   113  type codeDecl int
   114  
   115  func (c codeDecl) marker() syncMarker { return syncDecl }
   116  func (c codeDecl) value() int         { return int(c) }
   117  
   118  const (
   119  	declEnd codeDecl = iota
   120  	declFunc
   121  	declMethod
   122  	declVar
   123  	declOther
   124  )
   125  

View as plain text