const readArray2D = function (context, arrayType, address, rowCount, colCount, cellType) { const {core, oldCore} = context; const cellSize = cellType.size; const mops = getOpsArray2D(core, address, rowCount, colCount, cellSize); const rowSize = colCount * cellSize; const cellRefType = C.pointerType(cellType); const rows = []; for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) { const row = []; const rowAddress = address + rowIndex * rowSize; for (let colIndex = 0; colIndex < colCount; colIndex += 1) { const cellAddress = rowAddress + colIndex * cellSize; const content = readScalarBasic(core, cellRefType, cellAddress); const key = `${rowIndex},${colIndex}`; if (key in mops) { const mop = mops[key]; if ('load' in mop) { content.load = mop.load; } if ('store' in mop) { content.store = mop.store; content.previous = C.readValue(oldCore, content.ref); } } row.push({index: colIndex, address: cellAddress, key, content}); } rows.push({index: rowIndex, address: rowAddress, content: row}); } return rows; };
selection.forEach(function (index, position) { if (position === undefined) position = index; if (index === '…') { /* Generate a fake index so it can be used as a key for rendering. */ cells.push({position, gap: true, index: `#${position}`}); } else { const elemAddress = arrayBase + index * elemSize; const cell = {position, index, address: elemAddress}; if (index >= 0 && index < elemCount) { const content = readScalarBasic(core, elemRefType, elemAddress); if (index in mops) { const mop = mops[index]; if ('load' in mop) { content.load = mop.load; } if ('store' in mop) { content.store = mop.store; content.previous = C.readValue(oldCore, content.ref); } } cell.content = content; } cells.push(cell); } });