github.com/bir3/gocompiler@v0.9.2202/src/cmd/compile/internal/noder/codes.go (about) 1 // Copyright 2021 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package noder 6 7 import "github.com/bir3/gocompiler/src/internal/pkgbits" 8 9 // A codeStmt distinguishes among statement encodings. 10 type codeStmt int 11 12 func (c codeStmt) Marker() pkgbits.SyncMarker { return pkgbits.SyncStmt1 } 13 func (c codeStmt) Value() int { return int(c) } 14 15 const ( 16 stmtEnd codeStmt = iota 17 stmtLabel 18 stmtBlock 19 stmtExpr 20 stmtSend 21 stmtAssign 22 stmtAssignOp 23 stmtIncDec 24 stmtBranch 25 stmtCall 26 stmtReturn 27 stmtIf 28 stmtFor 29 stmtSwitch 30 stmtSelect 31 ) 32 33 // A codeExpr distinguishes among expression encodings. 34 type codeExpr int 35 36 func (c codeExpr) Marker() pkgbits.SyncMarker { return pkgbits.SyncExpr } 37 func (c codeExpr) Value() int { return int(c) } 38 39 // TODO(mdempsky): Split expr into addr, for lvalues. 40 const ( 41 exprConst codeExpr = iota 42 exprLocal // local variable 43 exprGlobal // global variable or function 44 exprCompLit 45 exprFuncLit 46 exprFieldVal 47 exprMethodVal 48 exprMethodExpr 49 exprIndex 50 exprSlice 51 exprAssert 52 exprUnaryOp 53 exprBinaryOp 54 exprCall 55 exprConvert 56 exprNew 57 exprMake 58 exprSizeof 59 exprAlignof 60 exprOffsetof 61 exprZero 62 exprFuncInst 63 exprRecv 64 exprReshape 65 exprRuntimeBuiltin // a reference to a runtime function from transformed syntax. Followed by string name, e.g., "panicrangeexit" 66 ) 67 68 type codeAssign int 69 70 func (c codeAssign) Marker() pkgbits.SyncMarker { return pkgbits.SyncAssign } 71 func (c codeAssign) Value() int { return int(c) } 72 73 const ( 74 assignBlank codeAssign = iota 75 assignDef 76 assignExpr 77 ) 78 79 // A codeDecl distinguishes among declaration encodings. 80 type codeDecl int 81 82 func (c codeDecl) Marker() pkgbits.SyncMarker { return pkgbits.SyncDecl } 83 func (c codeDecl) Value() int { return int(c) } 84 85 const ( 86 declEnd codeDecl = iota 87 declFunc 88 declMethod 89 declVar 90 declOther 91 )