mirror of
https://github.com/irmen/prog8.git
synced 2025-11-01 06:16:15 +00:00
start making '&' (address-of) return a typed pointer, fixes some errors
This commit is contained in:
@@ -173,6 +173,28 @@ class DataType private constructor(val base: BaseDataType, val sub: BaseDataType
|
||||
else -> throw IllegalArgumentException("not an array")
|
||||
}
|
||||
|
||||
fun typeForAddressOf(msb: Boolean): DataType {
|
||||
// TODO implement typed address-of.
|
||||
// TODO no typed pointer possible yet that points to an array
|
||||
if (isUndefined)
|
||||
return if(msb) pointer(BaseDataType.UBYTE) else UWORD
|
||||
else {
|
||||
// TODO implement these as well:
|
||||
// if(isBasic)
|
||||
// return pointer(base)
|
||||
// if(isString)
|
||||
// return pointer(BaseDataType.UBYTE)
|
||||
if (subType != null)
|
||||
return pointerToType(subType!!)
|
||||
else if (isArray) {
|
||||
if (msb || isSplitWordArray)
|
||||
return pointer(BaseDataType.UBYTE)
|
||||
return UWORD
|
||||
} else
|
||||
return UWORD // TODO("address-of type for $this")
|
||||
}
|
||||
}
|
||||
|
||||
override fun toString(): String = when(base) {
|
||||
BaseDataType.ARRAY -> {
|
||||
when(sub) {
|
||||
|
||||
Reference in New Issue
Block a user