From bbd72c211156f5bb844c7a376e4d0938cba03cc6 Mon Sep 17 00:00:00 2001 From: Aaron Gutierrez Date: Mon, 13 Apr 2015 22:50:30 -0400 Subject: [PATCH] VM works in browser for simple examples. --- public/vm/bytecode-parser.js | 1 + public/vm/index.js | 3 ++- public/vm/vm.js | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/public/vm/bytecode-parser.js b/public/vm/bytecode-parser.js index dd8240b..bce7604 100644 --- a/public/vm/bytecode-parser.js +++ b/public/vm/bytecode-parser.js @@ -18,6 +18,7 @@ function getBytes(data) { // Data contains our file, but we want it as a string var string_data = data.toString(); + console.log(string_data); // Strip all the comments for easier parsing var without_comments = string_data.replace(new RegExp("#.*", "gi"), ""); diff --git a/public/vm/index.js b/public/vm/index.js index b242194..940c5d0 100644 --- a/public/vm/index.js +++ b/public/vm/index.js @@ -10,6 +10,7 @@ c0vm = require("./c0vm.js"); // console.log(file.function_pool[0].code); $("#run").click(function() { - var file = parser.parse($("#bytecode").text); + var input = $("#bytecode").html().replace(/(\r\n|\n|\r)/gm,""); + var file = parser.parse($("#bytecode").text()); $("#output").text(c0vm.execute(file)); }); diff --git a/public/vm/vm.js b/public/vm/vm.js index fee13b5..d8675d3 100644 --- a/public/vm/vm.js +++ b/public/vm/vm.js @@ -60,6 +60,7 @@ function getBytes(data) { // Data contains our file, but we want it as a string var string_data = data.toString(); + console.log(string_data); // Strip all the comments for easier parsing var without_comments = string_data.replace(new RegExp("#.*", "gi"), ""); @@ -404,7 +405,8 @@ c0vm = require("./c0vm.js"); // console.log(file.function_pool[0].code); $("#run").click(function() { - var file = parser.parse($("#bytecode").text); + var input = $("#bytecode").html().replace(/(\r\n|\n|\r)/gm,""); + var file = parser.parse($("#bytecode").text()); $("#output").text(c0vm.execute(file)); });