summaryrefslogtreecommitdiff
path: root/src/vm/vm.js
blob: 1ec890be19e52b09f837a0aacda455ae6c0b85da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
		
	}
};