end repeat*
Default for built-in types is object scalar
Default for next largest type is -1, signalling no bigger
Compile-time loop of scalar kinds
- begin repeat
- #NAME = BOOL,
- BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#
- #BIGGERTYPE = -1,
- NPY_SHORT, NPY_USHORT, NPY_INT, NPY_UINT, NPY_LONG, NPY_ULONG, NPY_LONGLONG, NPY_ULONGLONG, -1, -1, NPY_FLOAT, NPY_DOUBLE, NPY_LONGDOUBLE, -1, NPY_CDOUBLE, NPY_CLONGDOUBLE, -1#
- #SCKIND = BOOL,
- (INTNEG, INTPOS)*5, FLOAT*4, COMPLEX*3#
end repeat*
Identity
- Bool -> <Anything> except datetime (since
- it conceptually has no zero)
<Anything> -> Object
<Anything> -> Void
Compile-time loop of casting rules
- begin repeat
- #FROM_NAME = BYTE, UBYTE, SHORT, USHORT, INT, UINT,
- LONG, ULONG, LONGLONG, ULONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#
- #FROM_BASENAME = BYTE, BYTE, SHORT, SHORT, INT, INT,
- LONG, LONG, LONGLONG, LONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, FLOAT, DOUBLE, LONGDOUBLE#
- #from_isint = 1, 0, 1, 0, 1, 0, 1, 0,
- 1, 0, 0, 0, 0, 0, 0, 0, 0#
- #from_isuint = 0, 1, 0, 1, 0, 1, 0, 1,
- 0, 1, 0, 0, 0, 0, 0, 0, 0#
- #from_isfloat = 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 1, 1, 1, 1, 0, 0, 0#
- #from_iscomplex = 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 1, 1, 1#
Allow casts from any integer to the TIMEDELTA type
- begin repeat1
- #TO_NAME = BYTE, UBYTE, SHORT, USHORT, INT, UINT,
- LONG, ULONG, LONGLONG, ULONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#
- #TO_BASENAME = BYTE, BYTE, SHORT, SHORT, INT, INT,
- LONG, LONG, LONGLONG, LONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, FLOAT, DOUBLE, LONGDOUBLE#
- #to_isint = 1, 0, 1, 0, 1, 0, 1, 0,
- 1, 0, 0, 0, 0, 0, 0, 0, 0#
- #to_isuint = 0, 1, 0, 1, 0, 1, 0, 1,
- 0, 1, 0, 0, 0, 0, 0, 0, 0#
- #to_isfloat = 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 1, 1, 1, 1, 0, 0, 0#
- #to_iscomplex = 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 1, 1, 1#
- NOTE: _FROM_BSIZE and _TO_BSIZE are the sizes of the "base type"
- which is the same as the size of the type except for complex, where it is the size of the real type.
end repeat1*
end repeat*
Now that the _can_cast_safely table is finished, we can use it to build the _type_promotion table
Don't let number promote to string/unicode/void/datetime/timedelta
Promoting these types requires examining their contents
Except they can convert to OBJECT
Don't let number promote to string/unicode/void
If there's no kind (void/string/etc)
Start with the type of larger kind
Try the next larger type of this kind
If there is no larger, try a larger kind
Use -1 to signal no promoted type found