mirror of
https://github.com/irmen/prog8.git
synced 2024-12-25 23:29:55 +00:00
fix: also allow pass-by-reference arguments to builtin functions that accept UWORD (adds implicit type cast)
This commit is contained in:
parent
7c5ec1853d
commit
68b75fd558
@ -192,6 +192,18 @@ class TypecastsAdder(val program: Program, val errors: IErrorReporter) : AstWalk
|
||||
call as Node)
|
||||
break
|
||||
}
|
||||
else if(DataType.UWORD in pair.first.possibleDatatypes && argtype in PassByReferenceDatatypes) {
|
||||
// We allow STR/ARRAY values in place of UWORD parameters.
|
||||
// Take their address instead, UNLESS it's a str parameter in the containing subroutine
|
||||
val identifier = pair.second as? IdentifierReference
|
||||
if(identifier?.isSubroutineParameter(program)==false) {
|
||||
modifications += IAstModification.ReplaceNode(
|
||||
call.args[index],
|
||||
AddressOf(identifier, pair.second.position),
|
||||
call as Node)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,28 +3,34 @@
|
||||
|
||||
main {
|
||||
|
||||
ubyte[23] savedata
|
||||
ubyte[17] cargohold = 0
|
||||
|
||||
sub start() {
|
||||
test_stack.test()
|
||||
|
||||
uword @shared uw
|
||||
ubyte @shared ub
|
||||
word @shared ww
|
||||
sys.memcopy(&savedata + 2, cargohold, len(cargohold))
|
||||
sys.memcopy(cargohold, &savedata + 2, len(cargohold))
|
||||
|
||||
push(127)
|
||||
pop(ub)
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
pushw(32767)
|
||||
popw(uw)
|
||||
txt.print_uw(uw)
|
||||
txt.nl()
|
||||
|
||||
uw=10000
|
||||
routines(44,uw+123)
|
||||
routines2(44,uw+123)
|
||||
|
||||
routine(uw+123, 22,33, true, 44)
|
||||
routine2(uw+123, 22,33, true, 44)
|
||||
; uword @shared uw
|
||||
; ubyte @shared ub
|
||||
; word @shared ww
|
||||
;
|
||||
; push(127)
|
||||
; pop(ub)
|
||||
; txt.print_ub(ub)
|
||||
; txt.nl()
|
||||
; pushw(32767)
|
||||
; popw(uw)
|
||||
; txt.print_uw(uw)
|
||||
; txt.nl()
|
||||
;
|
||||
; uw=10000
|
||||
; routines(44,uw+123)
|
||||
; routines2(44,uw+123)
|
||||
;
|
||||
; routine(uw+123, 22,33, true, 44)
|
||||
; routine2(uw+123, 22,33, true, 44)
|
||||
|
||||
test_stack.test()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user