github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/ir/fmt.go (about)

     1  // Copyright 2011 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 ir
     6  
     7  import (
     8  	"github.com/shogo82148/std/fmt"
     9  	"github.com/shogo82148/std/io"
    10  )
    11  
    12  var OpNames = []string{
    13  	OADDR:             "&",
    14  	OADD:              "+",
    15  	OADDSTR:           "+",
    16  	OANDAND:           "&&",
    17  	OANDNOT:           "&^",
    18  	OAND:              "&",
    19  	OAPPEND:           "append",
    20  	OAS:               "=",
    21  	OAS2:              "=",
    22  	OBREAK:            "break",
    23  	OCALL:             "function call",
    24  	OCAP:              "cap",
    25  	OCASE:             "case",
    26  	OCLEAR:            "clear",
    27  	OCLOSE:            "close",
    28  	OCOMPLEX:          "complex",
    29  	OBITNOT:           "^",
    30  	OCONTINUE:         "continue",
    31  	OCOPY:             "copy",
    32  	ODELETE:           "delete",
    33  	ODEFER:            "defer",
    34  	ODIV:              "/",
    35  	OEQ:               "==",
    36  	OFALL:             "fallthrough",
    37  	OFOR:              "for",
    38  	OGE:               ">=",
    39  	OGOTO:             "goto",
    40  	OGT:               ">",
    41  	OIF:               "if",
    42  	OIMAG:             "imag",
    43  	OINLMARK:          "inlmark",
    44  	ODEREF:            "*",
    45  	OLEN:              "len",
    46  	OLE:               "<=",
    47  	OLSH:              "<<",
    48  	OLT:               "<",
    49  	OMAKE:             "make",
    50  	ONEG:              "-",
    51  	OMAX:              "max",
    52  	OMIN:              "min",
    53  	OMOD:              "%",
    54  	OMUL:              "*",
    55  	ONEW:              "new",
    56  	ONE:               "!=",
    57  	ONOT:              "!",
    58  	OOROR:             "||",
    59  	OOR:               "|",
    60  	OPANIC:            "panic",
    61  	OPLUS:             "+",
    62  	OPRINTLN:          "println",
    63  	OPRINT:            "print",
    64  	ORANGE:            "range",
    65  	OREAL:             "real",
    66  	ORECV:             "<-",
    67  	ORECOVER:          "recover",
    68  	ORETURN:           "return",
    69  	ORSH:              ">>",
    70  	OSELECT:           "select",
    71  	OSEND:             "<-",
    72  	OSUB:              "-",
    73  	OSWITCH:           "switch",
    74  	OUNSAFEADD:        "unsafe.Add",
    75  	OUNSAFESLICE:      "unsafe.Slice",
    76  	OUNSAFESLICEDATA:  "unsafe.SliceData",
    77  	OUNSAFESTRING:     "unsafe.String",
    78  	OUNSAFESTRINGDATA: "unsafe.StringData",
    79  	OXOR:              "^",
    80  }
    81  
    82  // GoString returns the Go syntax for the Op, or else its name.
    83  func (o Op) GoString() string
    84  
    85  // Format implements formatting for an Op.
    86  // The valid formats are:
    87  //
    88  //	%v	Go syntax ("+", "<-", "print")
    89  //	%+v	Debug syntax ("ADD", "RECV", "PRINT")
    90  func (o Op) Format(s fmt.State, verb rune)
    91  
    92  var OpPrec = []int{
    93  	OAPPEND:           8,
    94  	OBYTES2STR:        8,
    95  	OARRAYLIT:         8,
    96  	OSLICELIT:         8,
    97  	ORUNES2STR:        8,
    98  	OCALLFUNC:         8,
    99  	OCALLINTER:        8,
   100  	OCALLMETH:         8,
   101  	OCALL:             8,
   102  	OCAP:              8,
   103  	OCLEAR:            8,
   104  	OCLOSE:            8,
   105  	OCOMPLIT:          8,
   106  	OCONVIFACE:        8,
   107  	OCONVNOP:          8,
   108  	OCONV:             8,
   109  	OCOPY:             8,
   110  	ODELETE:           8,
   111  	OGETG:             8,
   112  	OLEN:              8,
   113  	OLITERAL:          8,
   114  	OMAKESLICE:        8,
   115  	OMAKESLICECOPY:    8,
   116  	OMAKE:             8,
   117  	OMAPLIT:           8,
   118  	OMAX:              8,
   119  	OMIN:              8,
   120  	ONAME:             8,
   121  	ONEW:              8,
   122  	ONIL:              8,
   123  	ONONAME:           8,
   124  	OPANIC:            8,
   125  	OPAREN:            8,
   126  	OPRINTLN:          8,
   127  	OPRINT:            8,
   128  	ORUNESTR:          8,
   129  	OSLICE2ARR:        8,
   130  	OSLICE2ARRPTR:     8,
   131  	OSTR2BYTES:        8,
   132  	OSTR2RUNES:        8,
   133  	OSTRUCTLIT:        8,
   134  	OTYPE:             8,
   135  	OUNSAFEADD:        8,
   136  	OUNSAFESLICE:      8,
   137  	OUNSAFESLICEDATA:  8,
   138  	OUNSAFESTRING:     8,
   139  	OUNSAFESTRINGDATA: 8,
   140  	OINDEXMAP:         8,
   141  	OINDEX:            8,
   142  	OSLICE:            8,
   143  	OSLICESTR:         8,
   144  	OSLICEARR:         8,
   145  	OSLICE3:           8,
   146  	OSLICE3ARR:        8,
   147  	OSLICEHEADER:      8,
   148  	OSTRINGHEADER:     8,
   149  	ODOTINTER:         8,
   150  	ODOTMETH:          8,
   151  	ODOTPTR:           8,
   152  	ODOTTYPE2:         8,
   153  	ODOTTYPE:          8,
   154  	ODOT:              8,
   155  	OXDOT:             8,
   156  	OMETHVALUE:        8,
   157  	OMETHEXPR:         8,
   158  	OPLUS:             7,
   159  	ONOT:              7,
   160  	OBITNOT:           7,
   161  	ONEG:              7,
   162  	OADDR:             7,
   163  	ODEREF:            7,
   164  	ORECV:             7,
   165  	OMUL:              6,
   166  	ODIV:              6,
   167  	OMOD:              6,
   168  	OLSH:              6,
   169  	ORSH:              6,
   170  	OAND:              6,
   171  	OANDNOT:           6,
   172  	OADD:              5,
   173  	OSUB:              5,
   174  	OOR:               5,
   175  	OXOR:              5,
   176  	OEQ:               4,
   177  	OLT:               4,
   178  	OLE:               4,
   179  	OGE:               4,
   180  	OGT:               4,
   181  	ONE:               4,
   182  	OSEND:             3,
   183  	OANDAND:           2,
   184  	OOROR:             1,
   185  
   186  	OAS:         -1,
   187  	OAS2:        -1,
   188  	OAS2DOTTYPE: -1,
   189  	OAS2FUNC:    -1,
   190  	OAS2MAPR:    -1,
   191  	OAS2RECV:    -1,
   192  	OASOP:       -1,
   193  	OBLOCK:      -1,
   194  	OBREAK:      -1,
   195  	OCASE:       -1,
   196  	OCONTINUE:   -1,
   197  	ODCL:        -1,
   198  	ODEFER:      -1,
   199  	OFALL:       -1,
   200  	OFOR:        -1,
   201  	OGOTO:       -1,
   202  	OIF:         -1,
   203  	OLABEL:      -1,
   204  	OGO:         -1,
   205  	ORANGE:      -1,
   206  	ORETURN:     -1,
   207  	OSELECT:     -1,
   208  	OSWITCH:     -1,
   209  
   210  	OEND: 0,
   211  }
   212  
   213  // StmtWithInit reports whether op is a statement with an explicit init list.
   214  func StmtWithInit(op Op) bool
   215  
   216  // Format implements formatting for a Nodes.
   217  // The valid formats are:
   218  //
   219  //	%v	Go syntax, semicolon-separated
   220  //	%.v	Go syntax, comma-separated
   221  //	%+v	Debug syntax, as in DumpList.
   222  func (l Nodes) Format(s fmt.State, verb rune)
   223  
   224  // Dump prints the message s followed by a debug dump of n.
   225  func Dump(s string, n Node)
   226  
   227  // DumpList prints the message s followed by a debug dump of each node in the list.
   228  func DumpList(s string, list Nodes)
   229  
   230  // FDumpList prints to w the message s followed by a debug dump of each node in the list.
   231  func FDumpList(w io.Writer, s string, list Nodes)
   232  
   233  // EscFmt is set by the escape analysis code to add escape analysis details to the node print.
   234  var EscFmt func(n Node) string