mirror of
https://github.com/irmen/prog8.git
synced 2024-12-25 08:29:25 +00:00
fix return type error for asmsubs with >1 result values
This commit is contained in:
parent
156cf7315c
commit
20d06d9f9d
@ -985,9 +985,21 @@ class FunctionCallExpression(override var target: IdentifierReference,
|
||||
return InferredTypes.knownFor(stmt.returntypes[0])
|
||||
|
||||
// multiple return values. Can occur for asmsub routines. If there is exactly one register return value, take that.
|
||||
val numRegisterReturns = stmt.asmReturnvaluesRegisters.count { it.registerOrPair!=null }
|
||||
if(numRegisterReturns==1)
|
||||
return InferredTypes.InferredType.known(DataType.UBYTE)
|
||||
val registerReturns = stmt.asmReturnvaluesRegisters.filter {it.registerOrPair != null }
|
||||
if(registerReturns.size==1) {
|
||||
val reg = registerReturns.single().registerOrPair!!
|
||||
return when(reg) {
|
||||
RegisterOrPair.A,
|
||||
RegisterOrPair.X,
|
||||
RegisterOrPair.Y -> InferredTypes.InferredType.known(DataType.UBYTE)
|
||||
RegisterOrPair.AX,
|
||||
RegisterOrPair.AY,
|
||||
RegisterOrPair.XY, in Cx16VirtualRegisters -> InferredTypes.InferredType.known(DataType.UWORD)
|
||||
RegisterOrPair.FAC1,
|
||||
RegisterOrPair.FAC2 -> InferredTypes.InferredType.known(DataType.FLOAT)
|
||||
else -> throw FatalAstException("weird reg")
|
||||
}
|
||||
}
|
||||
|
||||
return InferredTypes.unknown() // has multiple return types... so not a single resulting datatype possible
|
||||
}
|
||||
|
@ -7,27 +7,35 @@ main {
|
||||
|
||||
sub start() {
|
||||
|
||||
txt.print("keyboard api test\n")
|
||||
|
||||
cx16.kbdbuf_put('l')
|
||||
cx16.kbdbuf_put('o')
|
||||
cx16.kbdbuf_put('a')
|
||||
cx16.kbdbuf_put('d')
|
||||
cx16.kbdbuf_put(13)
|
||||
|
||||
; the "pixelshader":
|
||||
syscall1(8, 0) ; enable lo res creen
|
||||
ubyte shifter
|
||||
|
||||
shifter >>= 1
|
||||
|
||||
repeat {
|
||||
uword xx
|
||||
uword yy = 0
|
||||
repeat 240 {
|
||||
xx = 0
|
||||
repeat 320 {
|
||||
syscall3(10, xx, yy, xx*yy + shifter) ; plot pixel
|
||||
xx++
|
||||
}
|
||||
yy++
|
||||
}
|
||||
shifter+=4
|
||||
|
||||
txt.print_ub(shifter)
|
||||
txt.nl()
|
||||
}
|
||||
; syscall1(8, 0) ; enable lo res creen
|
||||
; ubyte shifter
|
||||
;
|
||||
; shifter >>= 1
|
||||
;
|
||||
; repeat {
|
||||
; uword xx
|
||||
; uword yy = 0
|
||||
; repeat 240 {
|
||||
; xx = 0
|
||||
; repeat 320 {
|
||||
; syscall3(10, xx, yy, xx*yy + shifter) ; plot pixel
|
||||
; xx++
|
||||
; }
|
||||
; yy++
|
||||
; }
|
||||
; shifter+=4
|
||||
;
|
||||
; txt.print_ub(shifter)
|
||||
; txt.nl()
|
||||
; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user