diff options
Diffstat (limited to 'src/vm/vm.js')
| -rw-r--r-- | src/vm/vm.js | 36 | 
1 files changed, 36 insertions, 0 deletions
diff --git a/src/vm/vm.js b/src/vm/vm.js new file mode 100644 index 0000000..1ec890b --- /dev/null +++ b/src/vm/vm.js @@ -0,0 +1,36 @@ +'use strict'; + + +const { Core } = require('./core.js'); +const { +	DAT, +	MOV, ADD, SUB, CMP, SLT, +	JMP, JMZ, JMN, DJN, SPL, +} = require('./instruction.js'); + + +class Warrior { +	constructor(start) { +		this.queue = [start]; +	} + +	isDead() { return (this.queue.length === 0); } + +	append(heads) { +		this.queue.push(...heads); +	} + +	next() { +		const pc = this.queue[0]; +		this.queue = this.queue.slice(1); +		return next; +	} +}; + + +class RedcodeVm { +	constructor(coresize, warriors) { +		this.core = new Core(coresize); +		 +	} +};  | 
