create rudimentary try-kraken-online
This commit is contained in:
4
compile_for_web.sh
Executable file
4
compile_for_web.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
emcc ./k_prime.krak.c -o k_prime.html -s EXPORTED_FUNCTIONS='["_main"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -s ERROR_ON_UNDEFINED_SYMBOLS=0
|
||||||
|
#emcc ./k_prime.krak.c -o k_prime.js -s EXPORTED_FUNCTIONS='["_fun_execute_code_starcharactercolonobkcbk_"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -s ERROR_ON_UNDEFINED_SYMBOLS=0
|
||||||
37
index.html
Normal file
37
index.html
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en-us">
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Code: <br>
|
||||||
|
<textarea id="code" cols=80 rows=10>
|
||||||
|
(println (+ 1 2))
|
||||||
|
; Comment! For this script, the final value is returned
|
||||||
|
(/ 8 2)
|
||||||
|
</textarea>
|
||||||
|
<button onclick="executeKraken()">Run</button> <br>
|
||||||
|
Output: <br>
|
||||||
|
<textarea id="output" cols=80 rows=10>Output will appear here</textarea>
|
||||||
|
<script>
|
||||||
|
var Module = {
|
||||||
|
noInitialRun: true,
|
||||||
|
onRuntimeInitialized: () => {
|
||||||
|
},
|
||||||
|
print: txt => {
|
||||||
|
document.getElementById("output").value += txt + "\n";
|
||||||
|
},
|
||||||
|
printErr: txt => {
|
||||||
|
document.getElementById("output").value += "STDERR:[" + txt + "]\n";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function executeKraken() {
|
||||||
|
document.getElementById("output").value = "";
|
||||||
|
let code = document.getElementById("code").value;
|
||||||
|
console.log("gonna execute", code);
|
||||||
|
Module.callMain(["-C", code]);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="k_prime.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user