Added placeholders for type casts
This commit is contained in:
@ -3,6 +3,7 @@ package types
|
||||
var (
|
||||
Any = &Base{name: "any", size: 0}
|
||||
AnyArray = &Array{Of: Any}
|
||||
AnyInt = &Base{name: "int"}
|
||||
AnyPointer = &Pointer{To: Any}
|
||||
Bool = &Base{name: "bool", size: 1}
|
||||
Int64 = &Base{name: "int64", size: 8}
|
||||
@ -12,15 +13,15 @@ var (
|
||||
Float64 = &Base{name: "float64", size: 8}
|
||||
Float32 = &Base{name: "float32", size: 4}
|
||||
String = &Array{Of: Byte}
|
||||
UInt64 = &Base{name: "uint64", size: 8}
|
||||
UInt32 = &Base{name: "uint32", size: 4}
|
||||
UInt16 = &Base{name: "uint16", size: 2}
|
||||
UInt8 = &Base{name: "uint8", size: 1}
|
||||
)
|
||||
|
||||
var (
|
||||
Byte = UInt8
|
||||
Int = Int64
|
||||
Float = Float64
|
||||
UInt = Int
|
||||
UInt64 = Int64
|
||||
UInt32 = Int32
|
||||
UInt16 = Int16
|
||||
UInt8 = Int8
|
||||
Byte = UInt8
|
||||
Float = Float64
|
||||
Int = Int64
|
||||
UInt = UInt64
|
||||
)
|
||||
|
@ -25,13 +25,11 @@ func Is(a Type, b Type) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Temporary hacks
|
||||
if a == Int32 && b == Int64 {
|
||||
return true
|
||||
}
|
||||
|
||||
if a == Int64 && b == Int32 {
|
||||
return true
|
||||
if a == AnyInt {
|
||||
switch b {
|
||||
case Int64, Int32, Int16, Int8, UInt64, UInt32, UInt16, UInt8:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
|
@ -13,7 +13,7 @@ func TestName(t *testing.T) {
|
||||
assert.Equal(t, types.AnyPointer.Name(), "*any")
|
||||
assert.Equal(t, (&types.Pointer{To: types.Int}).Name(), "*int64")
|
||||
assert.Equal(t, (&types.Array{Of: types.Int}).Name(), "[]int64")
|
||||
assert.Equal(t, types.String.Name(), "[]int8")
|
||||
assert.Equal(t, types.String.Name(), "[]uint8")
|
||||
}
|
||||
|
||||
func TestSize(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user