From e24ffd6854bda8d1b76089d26c6b255ce001b1b4 Mon Sep 17 00:00:00 2001 From: Shyam Raghavan Date: Tue, 28 Apr 2015 03:14:01 -0400 Subject: [PATCH] Added breakpoints and added LESS --- public/css/site.css | 29 ++++++++++++++++++++++++++++- public/less/site.less | 5 ++++- public/vm/c0vm.js | 4 ++-- public/vm/index.js | 24 +++++++++++++++++++++++- public/vm/vm.js | 28 +++++++++++++++++++++++++--- views/base.jade | 2 -- views/index.jade | 39 ++++++++++++++++++++++++--------------- 7 files changed, 106 insertions(+), 25 deletions(-) diff --git a/public/css/site.css b/public/css/site.css index db1d266..ee16652 100644 --- a/public/css/site.css +++ b/public/css/site.css @@ -1 +1,28 @@ -.code{font-family:"DejaVu Sans Mono",Consolas,monospace;width:100%;border-radius:4px;padding:4px;border-color:#ddd;max-height:300px;overflow-y:auto}.brad{font-family:"Courier New",Courier,monospace;font-size:26pt;color:#166d00}.brad :hover{text-decoration:none}nav{background-color:#d8d8d8}.lbl{font-weight:bold;margin-bottom:4px}.btm-btn{margin-bottom:4px;margin-top:-14px} \ No newline at end of file +.code { + font-family: "DejaVu Sans Mono", Consolas, monospace; + width: 100%; + border-radius: 4px; + padding: 4px; + border-color: #ddd; + max-height: 300px; + overflow-y: auto; +} +.brad { + font-family: "Courier New", Courier, monospace; + font-size: 26pt; + color: #166d00; +} +.brad :hover { + text-decoration: none; +} +nav { + background-color: #d8d8d8; +} +.lbl { + font-weight: bold; + margin-bottom: 4px; +} +.btm-btn { + margin-bottom: 4px; + margin-top: -10px; +} diff --git a/public/less/site.less b/public/less/site.less index 6fe8ab7..1625904 100644 --- a/public/less/site.less +++ b/public/less/site.less @@ -29,5 +29,8 @@ nav { .btm-btn { margin-bottom: 4px; - margin-top: -14px; + margin-top: -10px; +} + +.no_disp { } diff --git a/public/vm/c0vm.js b/public/vm/c0vm.js index fe73a80..3769522 100755 --- a/public/vm/c0vm.js +++ b/public/vm/c0vm.js @@ -4,7 +4,7 @@ var INT_MIN = 0x80000000; var INT_MAX = 0x7FFFFFFF; function log(message) { - if (verbose) console.log(message); + if (verbose) $("#internals").val($("#internals").val() + "\n" + message); } function c0_assertion_failure(val) { @@ -500,7 +500,7 @@ function run_vm(vm) { } var val = vm.step(); - if (val !== undefined) return val; + if (val !== undefined) return vm; if (verbose) { console.log("Machine vm:"); diff --git a/public/vm/index.js b/public/vm/index.js index 05d0232..f8a03fe 100644 --- a/public/vm/index.js +++ b/public/vm/index.js @@ -43,5 +43,27 @@ $("#run").click(function() { $("#output").val(""); var file = parser.parse($("#bytecode").val()); - c0vm.execute(file, callbacks, true); + state = c0vm.execute(file, callbacks, true); + state = c0vm.initialize_vm(file, callbacks, true); +}); + +$("#break").click(function() { + var input = $("#breakpoints").val().replace(/(\r\n|\n|\r)/gm,""); + var temp = input.split(","); + for (a in temp) { + temp2 = temp[a].split(" "); + state.set_breakpoint(parseInt(temp2[0], 10), parseInt(temp2[1], 10)); + } + + $("#output").val(""); + $("#breakpoints").val(""); + $("#internals").val(""); +}); + +$("#continue").click(function () { + c0vm.run_vm(state); +}); + +$("#step").click(function () { + state.step(); }); diff --git a/public/vm/vm.js b/public/vm/vm.js index 67c86b4..d7b5343 100644 --- a/public/vm/vm.js +++ b/public/vm/vm.js @@ -332,7 +332,7 @@ var INT_MIN = 0x80000000; var INT_MAX = 0x7FFFFFFF; function log(message) { - if (verbose) console.log(message); + if (verbose) $("#internals").val($("#internals").val() + "\n" + message); } function c0_assertion_failure(val) { @@ -828,7 +828,7 @@ function run_vm(vm) { } var val = vm.step(); - if (val !== undefined) return val; + if (val !== undefined) return vm; if (verbose) { console.log("Machine vm:"); @@ -908,7 +908,29 @@ $("#run").click(function() { $("#output").val(""); var file = parser.parse($("#bytecode").val()); - c0vm.execute(file, callbacks, true); + state = c0vm.execute(file, callbacks, true); + state = c0vm.initialize_vm(file, callbacks, true); +}); + +$("#break").click(function() { + var input = $("#breakpoints").val().replace(/(\r\n|\n|\r)/gm,""); + var temp = input.split(","); + for (a in temp) { + temp2 = temp[a].split(" "); + state.set_breakpoint(parseInt(temp2[0], 10), parseInt(temp2[1], 10)); + } + + $("#output").val(""); + $("#breakpoints").val(""); + $("#internals").val(""); +}); + +$("#continue").click(function () { + c0vm.run_vm(state); +}); + +$("#step").click(function () { + state.step(); }); },{"./bytecode-parser":2,"./c0ffi.js":3,"./c0vm.js":4}],6:[function(require,module,exports){ diff --git a/views/base.jade b/views/base.jade index b562ce8..7372348 100644 --- a/views/base.jade +++ b/views/base.jade @@ -7,8 +7,6 @@ html href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css") link(rel="stylesheet" href="/css/site.css") - link(rel="stylesheet" href="/css/sh_emacs.min.css") - block head body diff --git a/views/index.jade b/views/index.jade index 2290c5f..329578d 100644 --- a/views/index.jade +++ b/views/index.jade @@ -3,9 +3,6 @@ extends base block head title c0db - link(rel="stylesheet" href="/css/codemirror.css") - - block nav +navbar("home") @@ -19,20 +16,32 @@ block body button(onclick="compile()" type="button").btn.btn-default.btm-btn.pull-right Compile #codearea textarea.code.formControl.sh_c(rows="12" id="inputCode") - .col-md-6 - p.lbl. - Bytecode - textarea.code.formControl.sh_c(rows="12" id="bytecode") -   + form + .form-group + label(for="bytecode") Bytecode + button(type="button")#run.btn.btn-default.btm-btn.pull-right Run + textarea.code.formControl.sh_c(rows="12" id="bytecode") .row - .col-md-12 - p.lbl. - Output - button(type="button")#run.btn.btn-default.btm-btn.pull-right Run - textarea#output.panel.panel-default.code -   - + .col-md-3 + form + .form-group + label(for="output") Output + button(type="button")#continue.no_disp.btn.btn-default.btm-btn.pull-right Continue + button(type="button")#step.no_disp.btn.btn-default.btm-btn.pull-right Step + textarea.code.sh_c(id="output") + .col-md-6 + form + .form-group + label(for="internals") Stack Output + button(type="button")#download.btn.btn-default.btm-btn.pull-right Download + textarea.code.sh_c(rows="12" id="internals") + .col-md-3 + form + .form-group + label(for="breakpoints") Breakpoints + button(type="button")#break.btn.btn-default.btm-btn.pull-right Save + textarea.code.sh_c(id="breakpoints") block script script(type="text/javascript" src="js/codemirror-compressed.js")