本文整理汇总了Golang中golang.org/x/tools/go/types.Tuple.At方法的典型用法代码示例。如果您正苦于以下问题:Golang Tuple.At方法的具体用法?Golang Tuple.At怎么用?Golang Tuple.At使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类golang.org/x/tools/go/types.Tuple
的用法示例。
在下文中一共展示了Tuple.At方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: paramName
// paramName replaces incompatible name with a p0-pN name.
// Missing names, or existing names of the form p[0-9] are incompatible.
// TODO(crawshaw): Replace invalid unicode names.
func paramName(params *types.Tuple, pos int) string {
name := params.At(pos).Name()
if name == "" || name == "_" || paramRE.MatchString(name) {
name = fmt.Sprintf("p%d", pos)
}
return name
}
示例2: newVars
func newVars(tuple *types.Tuple) []*Var {
vars := make([]*Var, 0, tuple.Len())
for i := 0; i < tuple.Len(); i++ {
vars = append(vars, newVar(tuple.At(i)))
}
return vars
}
示例3: tuple
func (p *exporter) tuple(t *types.Tuple) {
n := t.Len()
p.int(n)
for i := 0; i < n; i++ {
p.param(t.At(i))
}
}
示例4: hashTuple
func (h Hasher) hashTuple(tuple *types.Tuple) uint32 {
// See go/types.identicalTypes for rationale.
n := tuple.Len()
var hash uint32 = 9137 + 2*uint32(n)
for i := 0; i < n; i++ {
hash += 3 * h.Hash(tuple.At(i).Type())
}
return hash
}
示例5: processTuple
func (sym *symtab) processTuple(tuple *types.Tuple) {
if tuple == nil {
return
}
for i := 0; i < tuple.Len(); i++ {
ivar := tuple.At(i)
ityp := ivar.Type()
isym := sym.symtype(ityp)
if isym == nil {
sym.addType(ivar, ityp)
}
}
}
示例6: tupleString
func (g *goGen) tupleString(tuple *types.Tuple) string {
n := tuple.Len()
if n <= 0 {
return ""
}
str := make([]string, 0, n)
for i := 0; i < tuple.Len(); i++ {
v := tuple.At(i)
n := v.Name()
typ := v.Type()
str = append(str, n+" "+g.qualifiedType(typ))
}
return strings.Join(str, ", ")
}
示例7: writeTuple
func (p *printer) writeTuple(this *types.Package, tup *types.Tuple, variadic bool, visited []types.Type) {
p.print("(")
for i, n := 0, tup.Len(); i < n; i++ {
if i > 0 {
p.print(", ")
}
v := tup.At(i)
if name := v.Name(); name != "" {
p.print(name)
p.print(" ")
}
typ := v.Type()
if variadic && i == n-1 {
p.print("...")
typ = typ.(*types.Slice).Elem()
}
p.writeTypeInternal(this, typ, visited)
}
p.print(")")
}
示例8: setupUnwindBlock
func (fr *frame) setupUnwindBlock(rec *ssa.BasicBlock, results *types.Tuple) {
recoverbb := llvm.AddBasicBlock(fr.function, "")
if rec != nil {
fr.translateBlock(rec, recoverbb)
} else if results.Len() == 0 || results.At(0).Anonymous() {
// TODO(pcc): Remove this code after https://codereview.appspot.com/87210044/ lands
fr.builder.SetInsertPointAtEnd(recoverbb)
values := make([]llvm.Value, results.Len())
for i := range values {
values[i] = llvm.ConstNull(fr.llvmtypes.ToLLVM(results.At(i).Type()))
}
fr.retInf.encode(llvm.GlobalContext(), fr.allocaBuilder, fr.builder, values)
} else {
fr.builder.SetInsertPointAtEnd(recoverbb)
fr.builder.CreateUnreachable()
}
checkunwindbb := llvm.AddBasicBlock(fr.function, "")
fr.builder.SetInsertPointAtEnd(checkunwindbb)
exc := fr.createLandingPad(true)
fr.runDefers()
frame := fr.builder.CreateLoad(fr.frameptr, "")
shouldresume := fr.builder.CreateIsNull(frame, "")
resumebb := llvm.AddBasicBlock(fr.function, "")
fr.builder.CreateCondBr(shouldresume, resumebb, recoverbb)
fr.builder.SetInsertPointAtEnd(resumebb)
fr.builder.CreateResume(exc)
fr.builder.SetInsertPointAtEnd(fr.unwindBlock)
fr.createLandingPad(false)
fr.runtime.checkDefer.invoke(fr, checkunwindbb, fr.frameptr)
fr.runDefers()
fr.builder.CreateBr(recoverbb)
}