Skip to content
Browse files

compile and run in compiler.html

  • Loading branch information...
1 parent 275adcf commit 0bf4db93ed9f57809c75739430bb619a693aed96 @kripken committed
Showing with 14 additions and 2 deletions.
  1. +11 −1 src/compiler.html
  2. +3 −1 src/compiler.js
View
12 src/compiler.html
@@ -8,12 +8,22 @@
arguments = ['', 'hello_world.ll'];
var outputElement = document.getElementById('output');
+ var compilerOutput = '';
print = function(x) {
- outputElement.innerHTML += x;
+ //outputElement.innerHTML += x;
+ compilerOutput += x;
+ };
+
+ // For generated code
+ var Module = {
+ print: function(x) {
+ outputElement.innerHTML += x;
+ }
};
</script>
<script src="compiler.js">
</script>
+<input type="button" value="run!" onclick="eval(compilerOutput)">
</body>
</html>
View
4 src/compiler.js
@@ -76,10 +76,12 @@ if (ENVIRONMENT_IS_NODE) {
}
} else if (ENVIRONMENT_IS_WEB) {
- this['print'] = printErr = function(x) {
+ printErr = function(x) {
console.log(x);
};
+ if (!this['print']) this['print'] = printErr;
+
this['read'] = function(url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);

0 comments on commit 0bf4db9

Please sign in to comment.
Something went wrong with that request. Please try again.