@@ -151,7 +151,9 @@ data class WOODDumpResponse(
151151 val events : List <InterruptEvent >? ,
152152 val io : List <IOState >? ,
153153 val overrides : List <PrimitiveOverride >?
154- )
154+ ) {
155+ fun isRestorable (): Boolean = globals != null && table != null && memory != null
156+ }
155157
156158data class Checkpoint (
157159 val instructions_executed : Int ,
@@ -452,7 +454,7 @@ class WOODState(woodResponse: WOODDumpResponse) {
452454
453455 private fun serialiseAllocationMessage (stateMsgs : HexaStateMessages ) {
454456 val wr = this .woodResponse
455- if (wr.globals == null || wr.table == null || wr.memory == null ) {
457+ if (! wr.isRestorable() ) {
456458 throw Error (" cannot serialise Allocaton Message when state is missing" )
457459 }
458460
@@ -462,19 +464,19 @@ class WOODState(woodResponse: WOODDumpResponse) {
462464
463465 // Globals
464466
465- val gblsAmountHex = HexaEncoder .serializeUInt32BE(wr.globals.size)
467+ val gblsAmountHex = HexaEncoder .serializeUInt32BE(wr.globals!! .size)
466468 logger.trace(" Globals: total=${wr.globals.size} " )
467469 val globals = " ${ExecutionStateType .globalsState}${gblsAmountHex} "
468470
469471 // Table
470- val tblInitHex = HexaEncoder .serializeUInt32BE(wr.table.init )
472+ val tblInitHex = HexaEncoder .serializeUInt32BE(wr.table!! .init )
471473 val tblMaxHex = HexaEncoder .serializeUInt32BE(wr.table.max)
472474 val tblSizeHex = HexaEncoder .serializeUInt32BE(wr.table.elements.size)
473475 val tbl = " ${ExecutionStateType .tableState}${tblInitHex}${tblMaxHex}${tblSizeHex} "
474476
475477 logger.trace(" Table: init=${wr.table.init } max=${wr.table.max} size=${wr.table.elements.size} " )
476478 // Memory
477- val memInitHex = HexaEncoder .serializeUInt32BE(wr.memory.init )
479+ val memInitHex = HexaEncoder .serializeUInt32BE(wr.memory!! .init )
478480 val memMaxHex = HexaEncoder .serializeUInt32BE(wr.memory.max)
479481 val memPagesHex = HexaEncoder .serializeUInt32BE(wr.memory.pages)
480482 val mem = " ${ExecutionStateType .memState}${memMaxHex}${memInitHex}${memPagesHex} "
0 commit comments