From 5e0529a1e01916c2264624208ed83799653442d6 Mon Sep 17 00:00:00 2001 From: Mitchell Plamann Date: Sun, 3 May 2015 16:37:15 -0400 Subject: [PATCH] Started working on better breakpoints --- logo.png | Bin progress_report/lit_review.tex | 0 proposal/letter.pdf | Bin proposal/letter.tex | 0 proposal/proposal.pdf | Bin proposal/proposal.tex | 0 public/vm/byte-stream.js | 0 public/vm/bytecode-parser.js | 20 ++++++++++++++++++++ public/vm/c0vm.js | 8 ++++++++ public/vm/cc0.cgi | 0 test/abort.c0.ex | Bin test/arith.c0.ex | Bin test/arrays.c0.ex | Bin test/dsquared.c0.ex | Bin test/easyMath.c0.ex | Bin test/hellosir.c0.ex | Bin test/iadd.c0 | 0 test/iadd.c0.bc0 | 0 test/iadd.c0.ex | Bin test/ishr.c0.ex | Bin test/isqrt.c0.ex | Bin test/mid.c0.ex | Bin test/moreArrays.c0.ex | Bin test/piazza1.c0.ex | Bin test/sample2.5.c0.ex | Bin test/strings.c0.ex | Bin test/structs.c0.ex | Bin test/testError.c0.ex | Bin test/testif.c0.ex | Bin 29 files changed, 28 insertions(+) mode change 100755 => 100644 logo.png mode change 100755 => 100644 progress_report/lit_review.tex mode change 100755 => 100644 proposal/letter.pdf mode change 100755 => 100644 proposal/letter.tex mode change 100755 => 100644 proposal/proposal.pdf mode change 100755 => 100644 proposal/proposal.tex mode change 100755 => 100644 public/vm/byte-stream.js mode change 100755 => 100644 public/vm/c0vm.js mode change 100755 => 100644 public/vm/cc0.cgi mode change 100755 => 100644 test/abort.c0.ex mode change 100755 => 100644 test/arith.c0.ex mode change 100755 => 100644 test/arrays.c0.ex mode change 100755 => 100644 test/dsquared.c0.ex mode change 100755 => 100644 test/easyMath.c0.ex mode change 100755 => 100644 test/hellosir.c0.ex mode change 100755 => 100644 test/iadd.c0 mode change 100755 => 100644 test/iadd.c0.bc0 mode change 100755 => 100644 test/iadd.c0.ex mode change 100755 => 100644 test/ishr.c0.ex mode change 100755 => 100644 test/isqrt.c0.ex mode change 100755 => 100644 test/mid.c0.ex mode change 100755 => 100644 test/moreArrays.c0.ex mode change 100755 => 100644 test/piazza1.c0.ex mode change 100755 => 100644 test/sample2.5.c0.ex mode change 100755 => 100644 test/strings.c0.ex mode change 100755 => 100644 test/structs.c0.ex mode change 100755 => 100644 test/testError.c0.ex mode change 100755 => 100644 test/testif.c0.ex 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