diff options
author | sanine-a <sanine.not@pm.me> | 2023-05-23 14:15:18 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2023-05-23 14:15:18 -0500 |
commit | 29ed5eacb80cdfe49bff0d9335241dc3e2188981 (patch) | |
tree | 5414dcc72c76a879966b9f283b47d9dbc1432ee6 /src/vm/core.js | |
parent | 6826d32ca70ec6b6e751813bb595b6ade288cb69 (diff) |
add step()
Diffstat (limited to 'src/vm/core.js')
-rw-r--r-- | src/vm/core.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/vm/core.js b/src/vm/core.js index 184be00..a8fbce7 100644 --- a/src/vm/core.js +++ b/src/vm/core.js @@ -81,6 +81,27 @@ class Core { } + initialize(programs) { + const ranges = this.getRanges( + programs.map(p => p.program.length) + ) + + const pc = []; + for (let i=0; i<programs.length; i++) { + const range = ranges[i]; + const program = programs[i].program; + pc.push(programs[i].start + range.start); + + for (let j=0; j<program.length; j++) { + const index = this.normalize(range.start, j); + this.data[index] = JSON.parse(JSON.stringify(program[j])); + } + } + + return pc; + } + + normalize(pc, value) { return mod((pc + value), this.data.length); } |