本文整理汇总了Golang中go/types.Basic类的典型用法代码示例。如果您正苦于以下问题:Golang Basic类的具体用法?Golang Basic怎么用?Golang Basic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Basic类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: javaBasicType
func (g *javaGen) javaBasicType(T *types.Basic) string {
switch T.Kind() {
case types.Bool, types.UntypedBool:
return "boolean"
case types.Int:
return "long"
case types.Int8:
return "byte"
case types.Int16:
return "short"
case types.Int32, types.UntypedRune: // types.Rune
return "int"
case types.Int64, types.UntypedInt:
return "long"
case types.Uint8: // types.Byte
// TODO(crawshaw): Java bytes are signed, so this is
// questionable, but vital.
return "byte"
// TODO(crawshaw): case types.Uint, types.Uint16, types.Uint32, types.Uint64:
case types.Float32:
return "float"
case types.Float64, types.UntypedFloat:
return "double"
case types.String, types.UntypedString:
return "String"
default:
g.errorf("unsupported basic type: %s", T)
return "TODO"
}
}
开发者ID:ych1,项目名称:mobile,代码行数:30,代码来源:genjava.go
示例2: convertBasic
func (c *converter) convertBasic(v *gotypes.Basic) *types.Basic {
if v == nil {
return nil
}
if v, ok := c.converted[v]; ok {
return v.(*types.Basic)
}
var ret *types.Basic
for i, b := range gotypes.Typ {
if v == b {
ret = types.Typ[i]
break
}
}
switch v.Kind() {
case gotypes.Byte:
ret = types.ByteType
case gotypes.Rune:
ret = types.RuneType
}
if ret == nil {
panic(fmt.Sprintf("unknown basic type %v", v))
}
c.converted[v] = ret
return ret
}
开发者ID:tcard,项目名称:sgo,代码行数:26,代码来源:importer.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:snyderep,项目名称:pongish,代码行数:15,代码来源:utils.go
示例4: 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, types.UntypedInt:
return c.formatParenExpr("%s >> 0", value)
case types.Uint32, types.Uint, types.Uintptr:
return c.formatParenExpr("%s >>> 0", value)
case types.Float32:
return c.formatExpr("$fround(%s)", value)
case types.Float64:
return value
default:
panic(fmt.Sprintf("fixNumber: unhandled basic.Kind(): %s", basic.String()))
}
}
开发者ID:camlistore,项目名称:camlistore,代码行数:22,代码来源:expressions.go
示例5: basicKindString
func basicKindString(b *types.Basic) string {
switch b.Kind() {
case types.Invalid:
return "invalid"
case types.Bool:
return "bool"
case types.Int:
return "int"
case types.Int8:
return "int8"
case types.Int16:
return "int16"
case types.Int32:
return "int32"
case types.Int64:
return "int64"
case types.Uint:
return "uint"
case types.Uint8:
return "uint8"
case types.Uint16:
return "uint16"
case types.Uint32:
return "uint32"
case types.Uint64:
return "uint64"
case types.Uintptr:
return "uintptr"
case types.Float32:
return "float32"
case types.Float64:
return "float64"
case types.Complex64:
return "complex64"
case types.Complex128:
return "complex128"
case types.String:
return "string"
case types.UnsafePointer:
return "unsafepointer"
// types for untyped values
case types.UntypedBool:
return "bool"
case types.UntypedInt:
return "int"
case types.UntypedRune:
return "rune"
case types.UntypedFloat:
return "float"
case types.UntypedComplex:
return "complex"
case types.UntypedString:
return "string"
case types.UntypedNil:
return "nil"
default:
return "unsupported"
}
}
开发者ID:jasonkuhrt,项目名称:oden,代码行数:63,代码来源:objects.go
示例6: isUnsigned
func isUnsigned(t *types.Basic) bool {
return t.Info()&types.IsUnsigned != 0
}
开发者ID:snyderep,项目名称:pongish,代码行数:3,代码来源:utils.go
示例7: isString
func isString(t *types.Basic) bool {
return t.Info()&types.IsString != 0
}
开发者ID:snyderep,项目名称:pongish,代码行数:3,代码来源:utils.go
示例8: isNumeric
func isNumeric(t *types.Basic) bool {
return t.Info()&types.IsNumeric != 0
}
开发者ID:snyderep,项目名称:pongish,代码行数:3,代码来源:utils.go
示例9: isInteger
func isInteger(t *types.Basic) bool {
return t.Info()&types.IsInteger != 0
}
开发者ID:snyderep,项目名称:pongish,代码行数:3,代码来源:utils.go
示例10: isFloat
func isFloat(t *types.Basic) bool {
return t.Info()&types.IsFloat != 0
}
开发者ID:snyderep,项目名称:pongish,代码行数:3,代码来源:utils.go
示例11: isComplex
func isComplex(t *types.Basic) bool {
return t.Info()&types.IsComplex != 0
}
开发者ID:snyderep,项目名称:pongish,代码行数:3,代码来源:utils.go
示例12: isBoolean
func isBoolean(t *types.Basic) bool {
return t.Info()&types.IsBoolean != 0
}
开发者ID:snyderep,项目名称:pongish,代码行数:3,代码来源:utils.go
示例13: is64Bit
func is64Bit(t *types.Basic) bool {
return t.Kind() == types.Int64 || t.Kind() == types.Uint64
}
开发者ID:snyderep,项目名称:pongish,代码行数:3,代码来源:utils.go
注:本文中的go/types.Basic类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论