added warning about using X as sub parameter

This commit is contained in:
Irmen de Jong 2018-11-21 22:07:13 +01:00
parent e89788eeab
commit c40fc584d6
2 changed files with 19 additions and 23 deletions

View File

@ -16,33 +16,24 @@ sub start() {
byte b1
;v1=foo()
address =c64.MEMBOT(1, 40000.w) ; ok!
address =c64.MEMBOT(1, address) ; ok!
address =c64.MEMBOT(1, memaddr) ; ok!
;address =c64.MEMBOT(1, 40000.w) ; ok!
;address =c64.MEMBOT(1, address) ; ok!
;address =c64.MEMBOT(1, memaddr) ; ok!i
;address =c64.MEMBOT(1, wordarray[1]) ; @todo nice error about loading X register from stack
;A, Y =c64.GETADR() ; ok!
;Y, A =c64.GETADR() ; ok!
;address = c64flt.GETADRAY() ; ok!
;memaddr = c64flt.GETADRAY() ; ok!
;wordarray[1] = c64flt.GETADRAY() ; ok!
;v1, v2 =c64.GETADR() ; ok!
;address =c64.IOBASE() ; ok!
;A = c64.CHRIN() ; ok !
;X = c64.CHRIN() ; ok !
;Y = c64.CHRIN() ; ok!
;v1 = c64.CHRIN() ; ok !
A, Y =c64.GETADR() ; ok!
Y, A =c64.GETADR() ; ok!
address = c64flt.GETADRAY() ; ok!
memaddr = c64flt.GETADRAY() ; ok!
wordarray[1] = c64flt.GETADRAY() ; ok!
v1, v2 =c64.GETADR() ; ok!
address =c64.IOBASE() ; ok!
A = c64.CHRIN() ; ok !
X = c64.CHRIN() ; ok !
Y = c64.CHRIN() ; ok!
v1 = c64.CHRIN() ; ok !
return
}
sub foo() -> float {
return 1 ; @todo fix error: '1' as byte or float literal (not ubyte)
}
}

View File

@ -693,6 +693,11 @@ class AstChecker(private val namespace: INameScope,
for (arg in args.withIndex().zip(target.parameters)) {
if(arg.first.value.resultingDatatype(namespace, heap) != arg.second.type)
checkResult.add(ExpressionError("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(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)
}
}
}
}