github.com/Rookout/GoSDK@v0.1.48/pkg/services/assembler/internal/goobj/builtin.go (about)

     1  // Copyright 2019 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.assembler file.
     4  
     5  package goobj
     6  
     7  import "github.com/Rookout/GoSDK/pkg/services/assembler/internal/buildcfg"
     8  
     9  
    10  
    11  
    12  
    13  
    14  
    15  func NBuiltin() int {
    16  	return len(builtins)
    17  }
    18  
    19  
    20  
    21  func BuiltinName(i int) (string, int) {
    22  	return builtins[i].name, builtins[i].abi
    23  }
    24  
    25  
    26  
    27  func BuiltinIdx(name string, abi int) int {
    28  	i, ok := builtinMap[name]
    29  	if !ok {
    30  		return -1
    31  	}
    32  	if buildcfg.Experiment.RegabiWrappers && builtins[i].abi != abi {
    33  		return -1
    34  	}
    35  	return i
    36  }
    37  
    38  //go:generate go run mkbuiltin.go
    39  
    40  var builtinMap map[string]int
    41  
    42  func init() {
    43  	builtinMap = make(map[string]int, len(builtins))
    44  	for i, b := range builtins {
    45  		builtinMap[b.name] = i
    46  	}
    47  }