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)
|
call as Node)
|
||||||
break
|
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 {
|
main {
|
||||||
|
|
||||||
|
ubyte[23] savedata
|
||||||
|
ubyte[17] cargohold = 0
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
test_stack.test()
|
test_stack.test()
|
||||||
|
|
||||||
uword @shared uw
|
sys.memcopy(&savedata + 2, cargohold, len(cargohold))
|
||||||
ubyte @shared ub
|
sys.memcopy(cargohold, &savedata + 2, len(cargohold))
|
||||||
word @shared ww
|
|
||||||
|
|
||||||
push(127)
|
; uword @shared uw
|
||||||
pop(ub)
|
; ubyte @shared ub
|
||||||
txt.print_ub(ub)
|
; word @shared ww
|
||||||
txt.nl()
|
;
|
||||||
pushw(32767)
|
; push(127)
|
||||||
popw(uw)
|
; pop(ub)
|
||||||
txt.print_uw(uw)
|
; txt.print_ub(ub)
|
||||||
txt.nl()
|
; txt.nl()
|
||||||
|
; pushw(32767)
|
||||||
uw=10000
|
; popw(uw)
|
||||||
routines(44,uw+123)
|
; txt.print_uw(uw)
|
||||||
routines2(44,uw+123)
|
; txt.nl()
|
||||||
|
;
|
||||||
routine(uw+123, 22,33, true, 44)
|
; uw=10000
|
||||||
routine2(uw+123, 22,33, true, 44)
|
; 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()
|
test_stack.test()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user