github.com/goplus/gox@v1.14.13-0.20240308130321-6ff7f61cfae8/_builtin.gop (about)

     1  /*
     2   Copyright 2021 The GoPlus Authors (goplus.org)
     3   Licensed under the Apache License, Version 2.0 (the "License");
     4   you may not use this file except in compliance with the License.
     5   You may obtain a copy of the License at
     6       http://www.apache.org/licenses/LICENSE-2.0
     7   Unless required by applicable law or agreed to in writing, software
     8   distributed under the License is distributed on an "AS IS" BASIS,
     9   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    10   See the License for the specific language governing permissions and
    11   limitations under the License.
    12  */
    13  
    14  // +build ignore
    15  
    16  // -----------------------------------------------------------------------------
    17  
    18  type ninteger interface {
    19      type int, int64, int32, int16, int8, uint, uintptr, uint64, uint32, uint16, uint8
    20  }
    21  
    22  type integer interface {
    23      ninteger
    24  }
    25  
    26  type float interface {
    27      type float32, float64
    28  }
    29  
    30  type number interface { // - * /
    31      integer
    32      float
    33      type complex64, complex128
    34  }
    35  
    36  type addable interface { // +
    37      number
    38      type string
    39  }
    40  
    41  type orderable interface { // < <= > >=
    42      integer
    43      float
    44      type string
    45  }
    46  
    47  type comparable interface { // == !=
    48      addable
    49      type bool, interface, pointer, array, chan, struct
    50      // slice/map/func is very special, can only be compared to nil
    51  }
    52  
    53  func [T addable] (a T) + (b T) T    // func Gop_Add[T addable](a, b T) T
    54  func [T number] (a T) - (b T) T     // func Gop_Sub[T number](a, b T) T
    55  func [T number] (a T) * (b T) T     // func Gop_Mul[T number](a, b T) T
    56  func [T number] (a T) / (b T) T     // func Gop_Quo[T number](a, b T) T
    57  func [T integer] (a T) % (b T) T    // func Gop_Rem[T integer](a, b T) T
    58  
    59  func [T integer] (a T) | (b T) T    // func Gop_Or[T integer](a, b T) T
    60  func [T integer] (a T) ^ (b T) T    // func Gop_Xor[T integer](a, b T) T
    61  func [T integer] (a T) & (b T) T    // func Gop_And[T integer](a, b T) T
    62  func [T integer] (a T) &^ (b T) T   // func Gop_AndNot[T integer](a, b T) T
    63  
    64  func [T integer, N ninteger] (a T) << (n N) T // func Gop_Lsh[T integer, N ninteger](a T, n N) T
    65  func [T integer, N ninteger] (a T) >> (n N) T // func Gop_Rsh[T integer, N ninteger](a T, n N) T
    66  
    67  func [T orderable] (a T) < (b T) untyped_bool   // func Gop_LT[T orderable](a, b T) untyped_bool
    68  func [T orderable] (a T) <= (b T) untyped_bool  // func Gop_LE[T orderable](a, b T) untyped_bool
    69  func [T orderable] (a T) > (b T) untyped_bool   // func Gop_GT[T orderable](a, b T) untyped_bool
    70  func [T orderable] (a T) >= (b T) untyped_bool  // func Gop_GE[T orderable](a, b T) untyped_bool
    71  
    72  func [T comparable] (a T) == (b T) untyped_bool // func Gop_EQ[T comparable](a, b T) untyped_bool
    73  func [T comparable] (a T) != (b T) untyped_bool // func Gop_NE[T comparable](a, b T) untyped_bool
    74  
    75  func [T bool] (a T) || (b T) T // func Gop_LOr[T bool](a, b T) T
    76  func [T bool] (a T) && (b T) T // func Gop_LAnd[T bool](a, b T) T
    77  
    78  func [T number] -(a T) T  // func Gop_Neg[T number](a T) T
    79  func [T number] +(a T) T  // func Gop_Dup[T number](a T) T
    80  func [T integer] ^(a T) T // func Gop_Not[T integer](a T) T
    81  func [T bool] !(a T) T    // func Gop_LNot[T bool](a T) T
    82  
    83  func [T addable] (a *T) += (b T) // func Gop_AddAssign[T addable](a *T, b T)
    84  func [T number] (a *T) -= (b T)  // func Gop_SubAssign[T number](a *T, b T)
    85  func [T number] (a *T) *= (b T)  // func Gop_MulAssign[T number](a *T, b T)
    86  func [T number] (a *T) /= (b T)  // func Gop_QuoAssign[T number](a *T, b T)
    87  func [T integer] (a *T) %= (b T)  // func Gop_RemAssign[T integer](a *T, b T)
    88  
    89  func [T integer] (a *T) |= (b T)    // func Gop_OrAssign[T integer](a *T, b T)
    90  func [T integer] (a *T) ^= (b T)    // func Gop_XorAssign[T integer](a *T, b T)
    91  func [T integer] (a *T) &= (b T)    // func Gop_AndAssign[T integer](a *T, b T)
    92  func [T integer] (a *T) &^= (b T)   // func Gop_AndNotAssign[T integer](a *T, b T)
    93  
    94  func [T integer, N ninteger] (a *T) <<= (n N) // func Gop_LshAssign[T integer, N ninteger](a *T, n N)
    95  func [T integer, N ninteger] (a *T) >>= (n N) // func Gop_RshAssign[T integer, N ninteger](a *T, n N)
    96  
    97  // -----------------------------------------------------------------------------
    98  
    99  func [T integer] ++(a *T)   // func Gop_Inc[T integer](a *T)
   100  func [T integer] --(a *T)   // func Gop_Dec[T integer](a *T)
   101  
   102  // -----------------------------------------------------------------------------
   103  
   104  func [T any, N ninteger, U int] arrayGet(a *[U]T, i N) T
   105  func [T any, N ninteger, U int] sliceGet(a *[U]T, i N) T
   106  func [K comparable, V any] mapGet(a map[K]V, key K) T
   107  
   108  func [T any, N ninteger, U int] arraySet(a *[U]T, i N, elem T)
   109  func [T any, N ninteger, U int] sliceSet(a *[U]T, i N, elem T)
   110  func [K comparable, V any] mapSet(a map[K]V, key K, elem T)
   111  
   112  func [] = (
   113      sliceGet
   114      sliceSet
   115      mapGet
   116      mapSet
   117      arrayGet
   118      arraySet
   119  )
   120  
   121  // -----------------------------------------------------------------------------
   122  
   123  type any interface {
   124  }
   125  
   126  type capable interface {
   127      type slice, chan, array, array_pointer
   128  }
   129  
   130  type lenable interface {
   131      capable
   132      type map, string
   133  }
   134  
   135  type makable interface {
   136      type slice, chan, map
   137  }
   138  
   139  func [Type any] copy(dst, src []Type) int
   140  func [Type any] close(c chan<- Type)
   141  
   142  func [Type lenable] len(v Type) int
   143  func [Type capable] cap(v Type) int
   144  
   145  // new & make are special cases, they require to pass a type.
   146  func [] new(T any) *T
   147  func [N ninteger] make(Type makable, size ...N) Type
   148  
   149  // As a special case, it is legal to append a string to a byte slice, like this:
   150  //	slice = append([]byte("hello "), "world"...)
   151  func [Type any] append(slice []Type, elems ...Type) []Type
   152  
   153  func complexFlt32(r, i float32) complex64
   154  func complexFlt64(r, i float64) complex128
   155  func complex = (
   156      complexFlt32
   157      complexFlt64
   158  )
   159  
   160  func realComplex64(c complex64) float32
   161  func realComplex128(c complex128) float64
   162  func real = (
   163      realComplex64
   164      realComplex128
   165  )
   166  
   167  func imagComplex64(c complex64) float32
   168  func imagComplex128(c complex128) float64
   169  func imag = (
   170      imagComplex64
   171      imagComplex128
   172  )
   173  
   174  func [Key comparable, Elem any] delete(m map[Key]Elem, key Key)
   175  
   176  func panic(v interface{})
   177  func recover() interface{}
   178  
   179  func print(args ...interface{})
   180  func println(args ...interface{})
   181  
   182  // -----------------------------------------------------------------------------