diff --git a/logo.png b/logo.png old mode 100755 new mode 100644 diff --git a/progress_report/lit_review.tex b/progress_report/lit_review.tex old mode 100755 new mode 100644 diff --git a/proposal/letter.pdf b/proposal/letter.pdf old mode 100755 new mode 100644 diff --git a/proposal/letter.tex b/proposal/letter.tex old mode 100755 new mode 100644 diff --git a/proposal/proposal.pdf b/proposal/proposal.pdf old mode 100755 new mode 100644 diff --git a/proposal/proposal.tex b/proposal/proposal.tex old mode 100755 new mode 100644 diff --git a/public/vm/byte-stream.js b/public/vm/byte-stream.js old mode 100755 new mode 100644 diff --git a/public/vm/bytecode-parser.js b/public/vm/bytecode-parser.js index 1804c86..ec80412 100644 --- a/public/vm/bytecode-parser.js +++ b/public/vm/bytecode-parser.js @@ -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); } diff --git a/public/vm/c0vm.js b/public/vm/c0vm.js old mode 100755 new mode 100644 index 267df54..572fe6b --- a/public/vm/c0vm.js +++ b/public/vm/c0vm.js @@ -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++) { diff --git a/public/vm/cc0.cgi b/public/vm/cc0.cgi old mode 100755 new mode 100644 diff --git a/test/abort.c0.ex b/test/abort.c0.ex old mode 100755 new mode 100644 diff --git a/test/arith.c0.ex b/test/arith.c0.ex old mode 100755 new mode 100644 diff --git a/test/arrays.c0.ex b/test/arrays.c0.ex old mode 100755 new mode 100644 diff --git a/test/dsquared.c0.ex b/test/dsquared.c0.ex old mode 100755 new mode 100644 diff --git a/test/easyMath.c0.ex b/test/easyMath.c0.ex old mode 100755 new mode 100644 diff --git a/test/hellosir.c0.ex b/test/hellosir.c0.ex old mode 100755 new mode 100644 diff --git a/test/iadd.c0 b/test/iadd.c0 old mode 100755 new mode 100644 diff --git a/test/iadd.c0.bc0 b/test/iadd.c0.bc0 old mode 100755 new mode 100644 diff --git a/test/iadd.c0.ex b/test/iadd.c0.ex old mode 100755 new mode 100644 diff --git a/test/ishr.c0.ex b/test/ishr.c0.ex old mode 100755 new mode 100644 diff --git a/test/isqrt.c0.ex b/test/isqrt.c0.ex old mode 100755 new mode 100644 diff --git a/test/mid.c0.ex b/test/mid.c0.ex old mode 100755 new mode 100644 diff --git a/test/moreArrays.c0.ex b/test/moreArrays.c0.ex old mode 100755 new mode 100644 diff --git a/test/piazza1.c0.ex b/test/piazza1.c0.ex old mode 100755 new mode 100644 diff --git a/test/sample2.5.c0.ex b/test/sample2.5.c0.ex old mode 100755 new mode 100644 diff --git a/test/strings.c0.ex b/test/strings.c0.ex old mode 100755 new mode 100644 diff --git a/test/structs.c0.ex b/test/structs.c0.ex old mode 100755 new mode 100644 diff --git a/test/testError.c0.ex b/test/testError.c0.ex old mode 100755 new mode 100644 diff --git a/test/testif.c0.ex b/test/testif.c0.ex old mode 100755 new mode 100644