fix function parameter datatype checks

This commit is contained in:
Irmen de Jong 2018-11-26 22:12:36 +01:00
parent 30e2bdad79
commit f9ed92dc3a
2 changed files with 15 additions and 25 deletions

View File

@ -24,11 +24,6 @@ sub start() {
c64.CHROUT(memubytearray[1])
c64.CHROUT(ubytearray[X])
c64.CHROUT(memubytearray[X])
c64.CHROUT(b1) ; @todo fix compiler crash incompatible data types
c64.CHROUT(mb1) ; @todo fix compiler crash incompatible data types
c64.CHROUT(bytearray[1]) ; @todo fix compiler crash incompatible data types
c64.CHROUT(membytearray[1]) ; @todo fix compiler crash incompatible data types
c64.CHROUT(wordarray[1]) ; @todo fix compiler crash incompatible data types
testsub(X)
testsub(ub1)
@ -37,11 +32,6 @@ sub start() {
testsub(memubytearray[1])
testsub(ubytearray[X])
testsub(memubytearray[X])
testsub(b1) ; @todo should give datatype error
testsub(mb1) ; @todo should give datatype error
testsub(bytearray[1]) ; @todo should give datatype error
testsub(membytearray[1]) ; @todo should give datatype error
testsub(wordarray[1]) ; @todo should give datatype error
return
}

View File

@ -31,22 +31,22 @@ enum class DataType {
ARRAY_W,
ARRAY_F;
fun assignableTo(type: DataType) =
fun assignableTo(targetType: DataType) =
when(this) {
UBYTE -> type in NumericDatatypes
BYTE -> type in NumericDatatypes
UWORD -> type in NumericDatatypes
WORD -> type in NumericDatatypes
FLOAT -> type in NumericDatatypes
STR -> type == STR || type==STR_S || type == UWORD
STR_P -> type == STR_P || type==STR_PS || type == UWORD
STR_S -> type == STR || type==STR_S || type == UWORD
STR_PS -> type == STR_P || type==STR_PS || type == UWORD
ARRAY_UB -> type == UWORD
ARRAY_B -> type == UWORD
ARRAY_UW -> type == UWORD
ARRAY_W -> type == UWORD
ARRAY_F -> type == UWORD
UBYTE -> targetType == UBYTE || targetType == UWORD || targetType == FLOAT
BYTE -> targetType == BYTE || targetType == WORD || targetType == FLOAT
UWORD -> targetType == UWORD || targetType == FLOAT
WORD -> targetType == WORD || targetType == FLOAT
FLOAT -> targetType == FLOAT
STR -> targetType == STR || targetType==STR_S || targetType == UWORD
STR_P -> targetType == STR_P || targetType==STR_PS || targetType == UWORD
STR_S -> targetType == STR || targetType==STR_S || targetType == UWORD
STR_PS -> targetType == STR_P || targetType==STR_PS || targetType == UWORD
ARRAY_UB -> targetType == UWORD
ARRAY_B -> targetType == UWORD
ARRAY_UW -> targetType == UWORD
ARRAY_W -> targetType == UWORD
ARRAY_F -> targetType == UWORD
}
}