Exemple #1
0
func generateBuiltinType(t BuiltinType, m int32) (r string) {
	switch types.BasicKind(t) {
	case types.Bool:
		r = chooseType("bool", "*ntypes.Bool", "*ntypes.Bool", m)
	case types.Int:
		r = chooseType("int", "*ntypes.Int", "*qtypes.Int64", m)
	case types.Int8:
		r = chooseType("int8", "*int8", "*int8", m)
	case types.Int16:
		r = chooseType("int16", "*int16", "*int16", m)
	case types.Int32:
		r = chooseType("int32", "*ntypes.Int32", "*qtypes.Int64", m)
	case types.Int64:
		r = chooseType("int64", "*ntypes.Int64", "*qtypes.Int64", m)
	case types.Uint:
		r = chooseType("uint", "*uint", "*uint", m)
	case types.Uint8:
		r = chooseType("uint8", "*uint8", "*uint8", m)
	case types.Uint16:
		r = chooseType("uint16", "*uint16", "*uint16", m)
	case types.Uint32:
		r = chooseType("uint32", "*ntypes.Uint32", "*ntypes.Uint32", m)
	case types.Uint64:
		r = chooseType("uint64", "*uint64", "*uint64", m)
	case types.Float32:
		r = chooseType("float32", "*ntypes.Float32", "*qtypes.Float64", m)
	case types.Float64:
		r = chooseType("float64", "*ntypes.Float64", "*qtypes.Float64", m)
	case types.Complex64:
		r = chooseType("complex64", "*complex64", "*complex64", m)
	case types.Complex128:
		r = chooseType("complex128", "*complex128", "*complex128", m)
	case types.String:
		r = chooseType("string", "*ntypes.String", "*qtypes.String", m)
	default:
		r = "invalid"
	}

	return
}
Exemple #2
0
func (bt BuiltinType) String() string {
	switch types.BasicKind(bt) {
	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.Float32:
		return "float32"
	case types.Float64:
		return "float64"
	case types.Complex64:
		return "complex64"
	case types.Complex128:
		return "complex128"
	case types.String:
		return "string"
	default:
		return "invalid"
	}
}