Permalink
Browse files

compile given ll in compiler.html

  • Loading branch information...
1 parent 0833e5b commit 98d5842444b419181222db88c9a1725ffc174c4b @kripken committed Dec 28, 2012
Showing with 27 additions and 6 deletions.
  1. +21 −2 src/compiler.html
  2. +6 −4 src/compiler.js
View
@@ -5,7 +5,7 @@ <h2>Run the emscripten compiler in a web page, just for laughs</h2>
<hr>
<pre id="output"></pre>
<script>
- arguments = ['', 'hello_world.ll'];
+ arguments = [];
var outputElement = document.getElementById('output');
var compilerOutput = '';
@@ -23,7 +23,26 @@ <h2>Run the emscripten compiler in a web page, just for laughs</h2>
</script>
<script src="compiler.js">
</script>
-<input type="button" value="run!" onclick="eval(compilerOutput)">
+<textarea id="the_input" cols=50 rows=30>
+; ModuleID = 'tests/hello_world.bc'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
+target triple = "i386-pc-linux-gnu"
+
+@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
+
+; [#uses=0]
+define i32 @main() {
+entry:
+ %retval = alloca i32, align 4 ; [#uses=1 type=i32*]
+ store i32 0, i32* %retval
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
+ ret i32 1
+}
+
+; [#uses=1]
+declare i32 @printf(i8*, ...)
+</textarea>
+<input type="button" value="run!" onclick="compile(document.getElementById('the_input').value); eval(compilerOutput)">
</body>
</html>
View
@@ -268,9 +268,11 @@ function compile(raw) {
}
}
-if (ll_file.indexOf('\n') == -1) {
- compile(read(ll_file));
-} else {
- compile(ll_file); // we are given raw .ll
+if (ll_file) {
+ if (ll_file.indexOf(String.fromCharCode(10)) == -1) {
+ compile(read(ll_file));
+ } else {
+ compile(ll_file); // we are given raw .ll
+ }
}

0 comments on commit 98d5842

Please sign in to comment.