• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang types.Basic类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中code/google/com/p/go/tools/go/types.Basic的典型用法代码示例。如果您正苦于以下问题:Golang Basic类的具体用法?Golang Basic怎么用?Golang Basic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Basic类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: basicLLVMType

func (tm *llvmTypeMap) basicLLVMType(b *types.Basic) llvm.Type {
	switch b.Kind() {
	case types.Bool:
		return llvm.Int1Type()
	case types.Int8, types.Uint8:
		return llvm.Int8Type()
	case types.Int16, types.Uint16:
		return llvm.Int16Type()
	case types.Int32, types.Uint32:
		return llvm.Int32Type()
	case types.Uint, types.Int:
		return tm.inttype
	case types.Int64, types.Uint64:
		return llvm.Int64Type()
	case types.Float32:
		return llvm.FloatType()
	case types.Float64:
		return llvm.DoubleType()
	case types.UnsafePointer, types.Uintptr:
		return tm.target.IntPtrType()
	case types.Complex64:
		f32 := llvm.FloatType()
		elements := []llvm.Type{f32, f32}
		return llvm.StructType(elements, false)
	case types.Complex128:
		f64 := llvm.DoubleType()
		elements := []llvm.Type{f64, f64}
		return llvm.StructType(elements, false)
	case types.String:
		i8ptr := llvm.PointerType(llvm.Int8Type(), 0)
		elements := []llvm.Type{i8ptr, tm.inttype}
		return llvm.StructType(elements, false)
	}
	panic(fmt.Sprint("unhandled kind: ", b.Kind))
}
开发者ID:minux,项目名称:llgo,代码行数:35,代码来源:typemap.go


示例2: toJavaScriptType

func toJavaScriptType(t *types.Basic) string {
	switch t.Kind() {
	case types.UntypedInt:
		return "Int"
	default:
		name := t.String()
		return strings.ToUpper(name[:1]) + name[1:]
	}
}
开发者ID:umisama,项目名称:gopherjs,代码行数:9,代码来源:package.go


示例3: toJavaScriptType

func toJavaScriptType(t *types.Basic) string {
	switch t.Kind() {
	case types.UntypedInt:
		return "Int"
	case types.Byte:
		return "Uint8"
	case types.Rune:
		return "Int32"
	case types.UnsafePointer:
		return "UnsafePointer"
	default:
		name := t.String()
		return strings.ToUpper(name[:1]) + name[1:]
	}
}
开发者ID:nvdnkpr,项目名称:gopherjs,代码行数:15,代码来源:utils.go


示例4: fixNumber

func fixNumber(value string, basic *types.Basic) string {
	switch basic.Kind() {
	case types.Int8:
		return "(" + value + " << 24 >> 24)"
	case types.Uint8:
		return "(" + value + " << 24 >>> 24)"
	case types.Int16:
		return "(" + value + " << 16 >> 16)"
	case types.Uint16:
		return "(" + value + " << 16 >>> 16)"
	case types.Int32:
		return "(" + value + " >> 0)"
	case types.Uint32, types.Uintptr:
		return "(" + value + " >>> 0)"
	}
	return "(" + value + ")"
}
开发者ID:umisama,项目名称:gopherjs,代码行数:17,代码来源:expressions.go


示例5: fixNumber

func (c *funcContext) fixNumber(value *expression, basic *types.Basic) *expression {
	switch basic.Kind() {
	case types.Int8:
		return c.formatParenExpr("%s << 24 >> 24", value)
	case types.Uint8:
		return c.formatParenExpr("%s << 24 >>> 24", value)
	case types.Int16:
		return c.formatParenExpr("%s << 16 >> 16", value)
	case types.Uint16:
		return c.formatParenExpr("%s << 16 >>> 16", value)
	case types.Int32, types.Int:
		return c.formatParenExpr("%s >> 0", value)
	case types.Uint32, types.Uint, types.Uintptr:
		return c.formatParenExpr("%s >>> 0", value)
	default:
		panic(int(basic.Kind()))
	}
}
开发者ID:nvdnkpr,项目名称:gopherjs,代码行数:18,代码来源:expressions.go


示例6: basicRuntimeType

// basicRuntimeType creates the runtime type structure for
// a basic type. If underlying is true, then a new global
// is always created.
func (tm *TypeMap) basicRuntimeType(b *types.Basic, underlying bool) (global, ptr llvm.Value) {
	var globalname string
	if !underlying {
		globalname = "__llgo.type.runtime." + tm.TypeString(b)
		if tm.pkgpath != "runtime" {
			global := llvm.AddGlobal(tm.module, tm.runtimeType, globalname)
			global.SetInitializer(llvm.ConstNull(tm.runtimeType))
			global.SetLinkage(llvm.CommonLinkage)
			return global, global
		}
	}
	rtype := tm.makeRtype(b, basicReflectKinds[b.Kind()])
	global, ptr = tm.makeRuntimeTypeGlobal(rtype)
	if globalname != "" {
		global.SetName(globalname)
	}
	return global, ptr
}
开发者ID:quarnster,项目名称:llgo,代码行数:21,代码来源:typemap.go


示例7: basicRuntimeType

// basicRuntimeType creates the runtime type structure for
// a basic type. If underlying is true, then a new global
// is always created.
func (tm *TypeMap) basicRuntimeType(b *types.Basic, underlying bool) (global, ptr llvm.Value) {
	b = types.Typ[b.Kind()] // unalias
	var name string
	if !underlying {
		name = typeString(b)
		if tm.pkgpath != "runtime" {
			global := llvm.AddGlobal(tm.module, tm.runtime.rtype.llvm, typeSymbol(name))
			global.SetInitializer(llvm.ConstNull(tm.runtime.rtype.llvm))
			global.SetLinkage(llvm.CommonLinkage)
			return global, global
		}
	}
	rtype := tm.makeRtype(b, basicReflectKinds[b.Kind()])
	global, ptr = tm.makeRuntimeTypeGlobal(rtype, name)
	global.SetLinkage(llvm.ExternalLinkage)
	if !underlying {
		switch b.Kind() {
		case types.Int32:
			llvm.AddAlias(tm.module, global.Type(), global, typeSymbol("rune"))
		case types.Uint8:
			llvm.AddAlias(tm.module, global.Type(), global, typeSymbol("byte"))
		}
	}
	return global, ptr
}
开发者ID:minux,项目名称:llgo,代码行数:28,代码来源:typemap.go


示例8: descriptorBasic

func (m *TypeMap) descriptorBasic(t *types.Basic, name string) TypeDebugDescriptor {
	switch t.Kind() {
	case types.String:
		return m.descriptorStruct(types.NewStruct([]*types.Var{
			types.NewVar(0, nil, "ptr", types.NewPointer(types.Typ[types.Uint8])),
			types.NewVar(0, nil, "len", types.Typ[types.Int]),
		}, nil), name)
	case types.UnsafePointer:
		return &BasicTypeDescriptor{
			TypeDescriptorCommon: TypeDescriptorCommon{
				Name:      name,
				Size:      uint64(m.Sizes.Sizeof(t) * 8),
				Alignment: uint64(m.Sizes.Alignof(t) * 8),
			},
			TypeEncoding: DW_ATE_unsigned,
		}
	default:
		bt := &BasicTypeDescriptor{
			TypeDescriptorCommon: TypeDescriptorCommon{
				Name:      t.String(),
				Size:      uint64(m.Sizes.Sizeof(t) * 8),
				Alignment: uint64(m.Sizes.Alignof(t) * 8),
			},
		}
		switch bi := t.Info(); {
		case bi&types.IsBoolean != 0:
			bt.TypeEncoding = DW_ATE_boolean
		case bi&types.IsUnsigned != 0:
			bt.TypeEncoding = DW_ATE_unsigned
		case bi&types.IsInteger != 0:
			bt.TypeEncoding = DW_ATE_signed
		case bi&types.IsFloat != 0:
			bt.TypeEncoding = DW_ATE_float
		case bi&types.IsComplex != 0:
			bt.TypeEncoding = DW_ATE_imaginary_float
		case bi&types.IsUnsigned != 0:
			bt.TypeEncoding = DW_ATE_unsigned
		default:
			panic(fmt.Sprintf("unhandled: %#v", t))
		}
		return bt
	}
}
开发者ID:minux,项目名称:llgo,代码行数:43,代码来源:types.go


示例9: isComplex

func isComplex(t *types.Basic) bool {
	return t.Kind() == types.Complex64 || t.Kind() == types.Complex128
}
开发者ID:nvdnkpr,项目名称:gopherjs,代码行数:3,代码来源:utils.go


示例10: is64Bit

func is64Bit(t *types.Basic) bool {
	return t.Kind() == types.Int64 || t.Kind() == types.Uint64
}
开发者ID:nvdnkpr,项目名称:gopherjs,代码行数:3,代码来源:utils.go


示例11: basicRuntimeType

func (tm *TypeMap) basicRuntimeType(b *types.Basic) (global, ptr llvm.Value) {
	rtype := tm.makeRtype(b, basicReflectKinds[b.Kind()])
	return tm.makeRuntimeTypeGlobal(rtype)
}
开发者ID:hzmangel,项目名称:llgo,代码行数:4,代码来源:typemap.go



注:本文中的code/google/com/p/go/tools/go/types.Basic类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang types.Chan类代码示例发布时间:2022-05-24
下一篇:
Golang types.Array类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap