mirror of
https://github.com/irmen/prog8.git
synced 2024-09-08 10:55:08 +00:00
fix invalid address-of error when taking address of struct variable
This commit is contained in:
parent
095c8b2309
commit
cd825e386d
@ -464,6 +464,7 @@ internal class AstChecker(private val program: Program,
|
|||||||
else {
|
else {
|
||||||
if(variable.datatype !in ArrayDatatypes
|
if(variable.datatype !in ArrayDatatypes
|
||||||
&& variable.type!=VarDeclType.MEMORY
|
&& variable.type!=VarDeclType.MEMORY
|
||||||
|
&& variable.struct == null
|
||||||
&& variable.datatype != DataType.STR && variable.datatype!=DataType.STRUCT)
|
&& variable.datatype != DataType.STR && variable.datatype!=DataType.STRUCT)
|
||||||
errors.err("invalid pointer-of operand type", addressOf.position)
|
errors.err("invalid pointer-of operand type", addressOf.position)
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,40 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import diskio
|
%import diskio
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
%option no_sysinit
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
txt.print("saving...")
|
ubyte[100] cargohold
|
||||||
diskio.delete(8, "data.bin")
|
|
||||||
if diskio.save(8, "data.bin", $0400, 40*25) {
|
struct SaveData {
|
||||||
txt.clear_screenchars('*')
|
ubyte galaxy
|
||||||
txt.print("loading...")
|
ubyte planet
|
||||||
uword size = diskio.load(8, "data.bin", $0400)
|
ubyte cargo0
|
||||||
txt.print_uwhex(size, true)
|
ubyte cargo1
|
||||||
txt.chrout('\n')
|
ubyte cargo2
|
||||||
} else txt.print("io error\n")
|
ubyte cargo3
|
||||||
|
ubyte cargo4
|
||||||
|
ubyte cargo5
|
||||||
|
ubyte cargo6
|
||||||
|
ubyte cargo7
|
||||||
|
ubyte cargo8
|
||||||
|
ubyte cargo9
|
||||||
|
ubyte cargo10
|
||||||
|
ubyte cargo11
|
||||||
|
ubyte cargo12
|
||||||
|
ubyte cargo13
|
||||||
|
ubyte cargo14
|
||||||
|
ubyte cargo15
|
||||||
|
ubyte cargo16
|
||||||
|
uword cash
|
||||||
|
ubyte max_cargo
|
||||||
|
ubyte fuel
|
||||||
|
}
|
||||||
|
SaveData savedata
|
||||||
|
|
||||||
|
memcopy(&savedata.cargo0, cargohold, len(cargohold)) ; TODO fix compiler error about pointer
|
||||||
|
|
||||||
testX()
|
testX()
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ trader {
|
|||||||
ship.cash = savedata.cash
|
ship.cash = savedata.cash
|
||||||
ship.Max_cargo = savedata.max_cargo
|
ship.Max_cargo = savedata.max_cargo
|
||||||
ship.fuel = savedata.fuel
|
ship.fuel = savedata.fuel
|
||||||
;memcopy(&savedata.cargo0, ship.cargohold, len(ship.cargohold)) ; TODO fix compiler error about pointer
|
memcopy(&savedata.cargo0, ship.cargohold, len(ship.cargohold))
|
||||||
galaxy.travel_to(savedata.galaxy, savedata.planet)
|
galaxy.travel_to(savedata.galaxy, savedata.planet)
|
||||||
; TODO CHECK IF GALAXY AND MARKET ARE OKAY AFTER LOAD
|
; TODO CHECK IF GALAXY AND MARKET ARE OKAY AFTER LOAD
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ trader {
|
|||||||
savedata.cash = ship.cash
|
savedata.cash = ship.cash
|
||||||
savedata.max_cargo = ship.Max_cargo
|
savedata.max_cargo = ship.Max_cargo
|
||||||
savedata.fuel = ship.fuel
|
savedata.fuel = ship.fuel
|
||||||
;memcopy(ship.cargohold, &savedata.cargo0, len(ship.cargohold)) ; TODO fix compiler error about pointer
|
memcopy(ship.cargohold, &savedata.cargo0, len(ship.cargohold))
|
||||||
|
|
||||||
txt.print("\nSaving universe...")
|
txt.print("\nSaving universe...")
|
||||||
diskio.delete(8, Savegame)
|
diskio.delete(8, Savegame)
|
||||||
|
Loading…
Reference in New Issue
Block a user