Started working on better breakpoints
This commit is contained in:
0
logo.png
Executable file → Normal file
0
logo.png
Executable file → Normal file
|
Before Width: | Height: | Size: 345 KiB After Width: | Height: | Size: 345 KiB |
0
progress_report/lit_review.tex
Executable file → Normal file
0
progress_report/lit_review.tex
Executable file → Normal file
0
proposal/letter.pdf
Executable file → Normal file
0
proposal/letter.pdf
Executable file → Normal file
0
proposal/letter.tex
Executable file → Normal file
0
proposal/letter.tex
Executable file → Normal file
0
proposal/proposal.pdf
Executable file → Normal file
0
proposal/proposal.pdf
Executable file → Normal file
0
proposal/proposal.tex
Executable file → Normal file
0
proposal/proposal.tex
Executable file → Normal file
0
public/vm/byte-stream.js
Executable file → Normal file
0
public/vm/byte-stream.js
Executable file → Normal file
@@ -125,6 +125,26 @@ Bc0File.prototype.line_for_indices = function(function_index, byte_offset) {
|
||||
return this.line_numbers[offset_in_file];
|
||||
}
|
||||
|
||||
Bc0File.prototype.indicies_for_line = function(line) {
|
||||
// Performs a linear search through the (bytecode to line number) map
|
||||
// to find the bytecode offsets corresponding to a line number
|
||||
var function_index = 0;
|
||||
while (function_index < this.function_pool.length - 1) {
|
||||
var function_start = this.function_pool[function_index + 1].code_byte_offset;
|
||||
if (this.line_numbers[function_start] > line) break;
|
||||
function_start++;
|
||||
}
|
||||
|
||||
// function_index should now be set to the index of the function containing our line
|
||||
var f = this.function_pool[function_index];
|
||||
var offset = 0;
|
||||
while (offset < f.code.length - 1) {
|
||||
if (this.line_numbers[f.code_byte_offset + offset] > line) break;
|
||||
offset++;
|
||||
}
|
||||
return [function_index, offset];
|
||||
}
|
||||
|
||||
function parse(bytecode) {
|
||||
return new Bc0File(bytecode);
|
||||
}
|
||||
|
||||
8
public/vm/c0vm.js
Executable file → Normal file
8
public/vm/c0vm.js
Executable file → Normal file
@@ -514,6 +514,14 @@ ProgramState.prototype.set_breakpoint = function(function_index, opcode_index) {
|
||||
this.breakpoints.push([function_index, opcode_index]);
|
||||
}
|
||||
|
||||
ProgramState.prototype.set_breakpoint_bytecode_line = function(line) {
|
||||
var indicies = this.file.indicies_for_line(line);
|
||||
if (indicies === null || indicies.length < 2) {
|
||||
console.log("Error - indicies_for_line returned an invalid result.");
|
||||
}
|
||||
this.set_breakpoint(indicies[0], indicies[1]);
|
||||
}
|
||||
|
||||
ProgramState.prototype.run = function() {
|
||||
while (true) {
|
||||
for (var i = 0; i < this.breakpoints.length; i++) {
|
||||
|
||||
0
public/vm/cc0.cgi
Executable file → Normal file
0
public/vm/cc0.cgi
Executable file → Normal file
0
test/abort.c0.ex
Executable file → Normal file
0
test/abort.c0.ex
Executable file → Normal file
0
test/arith.c0.ex
Executable file → Normal file
0
test/arith.c0.ex
Executable file → Normal file
0
test/arrays.c0.ex
Executable file → Normal file
0
test/arrays.c0.ex
Executable file → Normal file
0
test/dsquared.c0.ex
Executable file → Normal file
0
test/dsquared.c0.ex
Executable file → Normal file
0
test/easyMath.c0.ex
Executable file → Normal file
0
test/easyMath.c0.ex
Executable file → Normal file
0
test/hellosir.c0.ex
Executable file → Normal file
0
test/hellosir.c0.ex
Executable file → Normal file
0
test/iadd.c0
Executable file → Normal file
0
test/iadd.c0
Executable file → Normal file
0
test/iadd.c0.bc0
Executable file → Normal file
0
test/iadd.c0.bc0
Executable file → Normal file
0
test/iadd.c0.ex
Executable file → Normal file
0
test/iadd.c0.ex
Executable file → Normal file
0
test/ishr.c0.ex
Executable file → Normal file
0
test/ishr.c0.ex
Executable file → Normal file
0
test/isqrt.c0.ex
Executable file → Normal file
0
test/isqrt.c0.ex
Executable file → Normal file
0
test/mid.c0.ex
Executable file → Normal file
0
test/mid.c0.ex
Executable file → Normal file
0
test/moreArrays.c0.ex
Executable file → Normal file
0
test/moreArrays.c0.ex
Executable file → Normal file
0
test/piazza1.c0.ex
Executable file → Normal file
0
test/piazza1.c0.ex
Executable file → Normal file
0
test/sample2.5.c0.ex
Executable file → Normal file
0
test/sample2.5.c0.ex
Executable file → Normal file
0
test/strings.c0.ex
Executable file → Normal file
0
test/strings.c0.ex
Executable file → Normal file
0
test/structs.c0.ex
Executable file → Normal file
0
test/structs.c0.ex
Executable file → Normal file
0
test/testError.c0.ex
Executable file → Normal file
0
test/testError.c0.ex
Executable file → Normal file
0
test/testif.c0.ex
Executable file → Normal file
0
test/testif.c0.ex
Executable file → Normal file
Reference in New Issue
Block a user