import { MemoryView } from "./memory-view" ; export class MemoryBlock { private _data : ArrayBuffer ; constructor ( size ) { this . _data = new ArrayBuffer ( size ) ; } public load ( address , size = 4 , signed = false ) { return new MemoryView ( this , size , address , signed ) ; } public isValid ( address ) { return address >= 0 && address < this . size ; } public clear ( ) { for ( let i = 0 ; i < this . size ; i ++ ) { this . load ( i , 1 ) . setValue ( 0 ) ; } } get data ( ) : ArrayBuffer { return this . _data ; } get size ( ) : number { return this . data . byteLength ; } }