mirror of
https://github.com/irmen/prog8.git
synced 2024-09-07 19:54:26 +00:00
fix some problems with subroutine parameters
This commit is contained in:
parent
43c99f1d89
commit
30e2bdad79
@ -18,30 +18,30 @@ sub start() {
|
|||||||
word[10] wordarray
|
word[10] wordarray
|
||||||
|
|
||||||
c64.CHROUT(X)
|
c64.CHROUT(X)
|
||||||
c64.CHROUT(b1) ; @todo fix compiler crash expression identifierref should be a vardef, not null
|
c64.CHROUT(ub1)
|
||||||
c64.CHROUT(ub1) ; @todo fix compiler crash expression identifierref should be a vardef, not null
|
c64.CHROUT(mub1)
|
||||||
c64.CHROUT(mb1) ; @todo fix compiler crash "
|
c64.CHROUT(ubytearray[1])
|
||||||
c64.CHROUT(mub1) ; @todo fix compiler crash "
|
c64.CHROUT(memubytearray[1])
|
||||||
c64.CHROUT(bytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl
|
c64.CHROUT(ubytearray[X])
|
||||||
c64.CHROUT(ubytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl
|
c64.CHROUT(memubytearray[X])
|
||||||
c64.CHROUT(membytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl
|
c64.CHROUT(b1) ; @todo fix compiler crash incompatible data types
|
||||||
c64.CHROUT(memubytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl
|
c64.CHROUT(mb1) ; @todo fix compiler crash incompatible data types
|
||||||
c64.CHROUT(ubytearray[X]) ; @todo fix compiler crash "
|
c64.CHROUT(bytearray[1]) ; @todo fix compiler crash incompatible data types
|
||||||
c64.CHROUT(memubytearray[X]) ; @todo fix compiler crash "
|
c64.CHROUT(membytearray[1]) ; @todo fix compiler crash incompatible data types
|
||||||
c64.CHROUT(wordarray[1]) ; @todo fix compiler crash "
|
c64.CHROUT(wordarray[1]) ; @todo fix compiler crash incompatible data types
|
||||||
|
|
||||||
testsub(X) ; @todo fix compiler crash
|
testsub(X)
|
||||||
testsub(b1) ; @todo fix compiler crash
|
testsub(ub1)
|
||||||
testsub(ub1) ; @todo fix compiler crash
|
testsub(mub1)
|
||||||
testsub(mb1) ; @todo fix compiler crash
|
testsub(ubytearray[1])
|
||||||
testsub(mub1) ; @todo fix compiler crash
|
testsub(memubytearray[1])
|
||||||
testsub(bytearray[1]) ; @todo fix compiler crash
|
testsub(ubytearray[X])
|
||||||
testsub(ubytearray[1]) ; @todo fix compiler crash
|
testsub(memubytearray[X])
|
||||||
testsub(membytearray[1]) ; @todo fix compiler crash
|
testsub(b1) ; @todo should give datatype error
|
||||||
testsub(memubytearray[1]) ; @todo fix compiler crash
|
testsub(mb1) ; @todo should give datatype error
|
||||||
testsub(ubytearray[X]) ; @todo fix compiler crash
|
testsub(bytearray[1]) ; @todo should give datatype error
|
||||||
testsub(memubytearray[X]) ; @todo fix compiler crash
|
testsub(membytearray[1]) ; @todo should give datatype error
|
||||||
testsub(wordarray[1]) ; @todo fix compiler crash
|
testsub(wordarray[1]) ; @todo should give datatype error
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -707,9 +707,11 @@ class AstChecker(private val namespace: INameScope,
|
|||||||
if(argDt!=null && !argDt.assignableTo(arg.second.type))
|
if(argDt!=null && !argDt.assignableTo(arg.second.type))
|
||||||
checkResult.add(ExpressionError("subroutine argument ${arg.first.index+1} has invalid type, expected ${arg.second.type}", position))
|
checkResult.add(ExpressionError("subroutine argument ${arg.first.index+1} has invalid type, expected ${arg.second.type}", position))
|
||||||
|
|
||||||
if(target.asmParameterRegisters[arg.first.index].registerOrPair in setOf(RegisterOrPair.AX, RegisterOrPair.XY, RegisterOrPair.X)) {
|
if(target.isAsmSubroutine) {
|
||||||
if(arg.first.value !is LiteralValue && arg.first.value !is IdentifierReference)
|
if (target.asmParameterRegisters[arg.first.index].registerOrPair in setOf(RegisterOrPair.AX, RegisterOrPair.XY, RegisterOrPair.X)) {
|
||||||
printWarning("calling a subroutine that expects X as a parameter is problematic, more so when providing complex arguments. If you see a compiler error/crash about this later, try to simplify this call", position)
|
if (arg.first.value !is LiteralValue && arg.first.value !is IdentifierReference)
|
||||||
|
printWarning("calling a subroutine that expects X as a parameter is problematic, more so when providing complex arguments. If you see a compiler error/crash about this later, try to simplify this call", position)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -780,18 +780,18 @@ private class StatementTranslator(private val prog: IntermediateProgram,
|
|||||||
when (arg.second.registerOrPair!!) {
|
when (arg.second.registerOrPair!!) {
|
||||||
A -> {
|
A -> {
|
||||||
val assign = Assignment(listOf(AssignTarget(Register.A, null, null, callPosition)), null, arg.first, callPosition)
|
val assign = Assignment(listOf(AssignTarget(Register.A, null, null, callPosition)), null, arg.first, callPosition)
|
||||||
assign.linkParents(subroutine.parent)
|
assign.linkParents(arguments[0].parent)
|
||||||
translate(assign)
|
translate(assign)
|
||||||
}
|
}
|
||||||
X -> {
|
X -> {
|
||||||
// TODO: save X on stack & restore after call
|
// TODO: save X on stack & restore after call
|
||||||
val assign = Assignment(listOf(AssignTarget(Register.X, null, null, callPosition)), null, arg.first, callPosition)
|
val assign = Assignment(listOf(AssignTarget(Register.X, null, null, callPosition)), null, arg.first, callPosition)
|
||||||
assign.linkParents(subroutine.parent)
|
assign.linkParents(arguments[0].parent)
|
||||||
translate(assign)
|
translate(assign)
|
||||||
}
|
}
|
||||||
Y -> {
|
Y -> {
|
||||||
val assign = Assignment(listOf(AssignTarget(Register.Y, null, null, callPosition)), null, arg.first, callPosition)
|
val assign = Assignment(listOf(AssignTarget(Register.Y, null, null, callPosition)), null, arg.first, callPosition)
|
||||||
assign.linkParents(subroutine.parent)
|
assign.linkParents(arguments[0].parent)
|
||||||
translate(assign)
|
translate(assign)
|
||||||
}
|
}
|
||||||
AX -> {
|
AX -> {
|
||||||
@ -804,8 +804,8 @@ private class StatementTranslator(private val prog: IntermediateProgram,
|
|||||||
valueX=LiteralValue.optimalInteger(0, callPosition)
|
valueX=LiteralValue.optimalInteger(0, callPosition)
|
||||||
val assignA = Assignment(listOf(AssignTarget(Register.A, null, null, callPosition)), null, valueA, callPosition)
|
val assignA = Assignment(listOf(AssignTarget(Register.A, null, null, callPosition)), null, valueA, callPosition)
|
||||||
val assignX = Assignment(listOf(AssignTarget(Register.X, null, null, callPosition)), null, valueX, callPosition)
|
val assignX = Assignment(listOf(AssignTarget(Register.X, null, null, callPosition)), null, valueX, callPosition)
|
||||||
assignA.linkParents(subroutine.parent)
|
assignA.linkParents(arguments[0].parent)
|
||||||
assignX.linkParents(subroutine.parent)
|
assignX.linkParents(arguments[0].parent)
|
||||||
translate(assignA)
|
translate(assignA)
|
||||||
translate(assignX)
|
translate(assignX)
|
||||||
} else if(paramDt==DataType.UWORD) {
|
} else if(paramDt==DataType.UWORD) {
|
||||||
@ -823,8 +823,8 @@ private class StatementTranslator(private val prog: IntermediateProgram,
|
|||||||
valueY=LiteralValue.optimalInteger(0, callPosition)
|
valueY=LiteralValue.optimalInteger(0, callPosition)
|
||||||
val assignA = Assignment(listOf(AssignTarget(Register.A, null, null, callPosition)), null, valueA, callPosition)
|
val assignA = Assignment(listOf(AssignTarget(Register.A, null, null, callPosition)), null, valueA, callPosition)
|
||||||
val assignY = Assignment(listOf(AssignTarget(Register.Y, null, null, callPosition)), null, valueY, callPosition)
|
val assignY = Assignment(listOf(AssignTarget(Register.Y, null, null, callPosition)), null, valueY, callPosition)
|
||||||
assignA.linkParents(subroutine.parent)
|
assignA.linkParents(arguments[0].parent)
|
||||||
assignY.linkParents(subroutine.parent)
|
assignY.linkParents(arguments[0].parent)
|
||||||
translate(assignA)
|
translate(assignA)
|
||||||
translate(assignY)
|
translate(assignY)
|
||||||
} else if(paramDt==DataType.UWORD) {
|
} else if(paramDt==DataType.UWORD) {
|
||||||
@ -843,8 +843,8 @@ private class StatementTranslator(private val prog: IntermediateProgram,
|
|||||||
valueY=LiteralValue.optimalInteger(0, callPosition)
|
valueY=LiteralValue.optimalInteger(0, callPosition)
|
||||||
val assignX = Assignment(listOf(AssignTarget(Register.X, null, null, callPosition)), null, valueX, callPosition)
|
val assignX = Assignment(listOf(AssignTarget(Register.X, null, null, callPosition)), null, valueX, callPosition)
|
||||||
val assignY = Assignment(listOf(AssignTarget(Register.Y, null, null, callPosition)), null, valueY, callPosition)
|
val assignY = Assignment(listOf(AssignTarget(Register.Y, null, null, callPosition)), null, valueY, callPosition)
|
||||||
assignX.linkParents(subroutine.parent)
|
assignX.linkParents(arguments[0].parent)
|
||||||
assignY.linkParents(subroutine.parent)
|
assignY.linkParents(arguments[0].parent)
|
||||||
translate(assignX)
|
translate(assignX)
|
||||||
translate(assignY)
|
translate(assignY)
|
||||||
} else if(paramDt==DataType.UWORD) {
|
} else if(paramDt==DataType.UWORD) {
|
||||||
|
Loading…
Reference in New Issue
Block a user