本文整理汇总了Golang中code/google/com/p/go/tools/go/types.Chan类的典型用法代码示例。如果您正苦于以下问题:Golang Chan类的具体用法?Golang Chan怎么用?Golang Chan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Chan类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: chanRuntimeType
func (tm *TypeMap) chanRuntimeType(c *types.Chan) (global, ptr llvm.Value) {
rtype := tm.makeRtype(c, reflect.Chan)
chanType := llvm.ConstNull(tm.runtime.chanType.llvm)
chanType = llvm.ConstInsertValue(chanType, rtype, []uint32{0})
chanType = llvm.ConstInsertValue(chanType, tm.ToRuntime(c.Elem()), []uint32{1})
// go/ast and reflect disagree on values for direction.
var dir reflect.ChanDir
switch c.Dir() {
case types.SendOnly:
dir = reflect.SendDir
case types.RecvOnly:
dir = reflect.RecvDir
case types.SendRecv:
dir = reflect.SendDir | reflect.RecvDir
}
uintptrdir := llvm.ConstInt(tm.target.IntPtrType(), uint64(dir), false)
chanType = llvm.ConstInsertValue(chanType, uintptrdir, []uint32{2})
return tm.makeRuntimeTypeGlobal(chanType, typeString(c))
}
示例2: chanRuntimeType
func (tm *TypeMap) chanRuntimeType(c *types.Chan) (global, ptr llvm.Value) {
rtype := tm.makeRtype(c, reflect.Chan)
chanType := llvm.ConstNull(tm.runtimeChanType)
chanType = llvm.ConstInsertValue(chanType, rtype, []uint32{0})
chanType = llvm.ConstInsertValue(chanType, tm.ToRuntime(c.Elem()), []uint32{1})
// go/ast and reflect disagree on values for direction.
var dir reflect.ChanDir
if c.Dir()&ast.SEND != 0 {
dir = reflect.SendDir
}
if c.Dir()&ast.RECV != 0 {
dir |= reflect.RecvDir
}
uintptrdir := llvm.ConstInt(tm.target.IntPtrType(), uint64(dir), false)
chanType = llvm.ConstInsertValue(chanType, uintptrdir, []uint32{2})
return tm.makeRuntimeTypeGlobal(chanType)
}