-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
220 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ html { | |
body { | ||
margin: 0; | ||
height: 100%; | ||
background-color: black; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Emception from "./emception.js"; | ||
|
||
const emception = new Emception(); | ||
|
||
await emception.init(); | ||
|
||
emception.run('emcc --check -Wno-version-check'); | ||
|
||
let comps = 0; | ||
export const comp = (cBuf) => { | ||
comps += 1; | ||
emception.fileSystem.writeFile(`/working/in${comps}.c`, cBuf); | ||
const result = emception.run(`emcc -O3 -s EXPORT_ALL=1 -s SIDE_MODULE=1 /working/in${comps}.c -o /working/out${comps}.wasm -Wno-version-check -Wno-incompatible-library-redeclaration -Wno-parentheses-equality`); | ||
if (result.returncode !== 0) { | ||
console.error(`emcc exited with code ${result.returncode}`) | ||
} | ||
return emception.fileSystem.readFile(`/working/out${comps}.wasm`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
import { comp } from './comp.js'; | ||
|
||
self.onmessage = ({data}) => { | ||
switch (data.type) { | ||
case 'comp': { | ||
const output = comp(data.input); | ||
self.postMessage({ | ||
type: 'result', | ||
output: output, | ||
number: data.number, | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
self.postMessage({type: 'ready'}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
import {run} from './lua.js'; | ||
|
||
const stdout = (msg) => { | ||
self.postMessage({ | ||
type: 'stdout', | ||
stdout: msg, | ||
}); | ||
}; | ||
|
||
const stderr = (msg) => { | ||
self.postMessage({ | ||
type: 'stderr', | ||
stderr: msg, | ||
}); | ||
}; | ||
|
||
let wait; | ||
let ret; | ||
const comp = (input) => { | ||
self.postMessage({ | ||
type: 'comp', | ||
input: input, | ||
}); | ||
new Int32Array(wait)[0] = 0; | ||
Atomics.wait(new Int32Array(wait), 0, 0); | ||
const len = new Int32Array(wait)[0]; | ||
const old = new Uint8Array(ret); | ||
const tmp = new Uint8Array(len); | ||
for (let i = 0; i < len; i++) { | ||
tmp[i] = old[i]; | ||
} | ||
return tmp; | ||
}; | ||
|
||
const onArgs = (args) => { | ||
run(args, {stdout, stderr, comp}); | ||
self.postMessage({ | ||
type: 'exit-ok', | ||
}); | ||
}; | ||
|
||
self.onmessage = ({data}) => { | ||
switch(data.type) { | ||
case 'buffer': { | ||
self.postMessage({type: 'get-args'}); | ||
wait = data.wait; | ||
ret = data.ret; | ||
break; | ||
} | ||
case 'args': { | ||
onArgs(data.args); | ||
break; | ||
} | ||
} | ||
}; | ||
|
||
self.postMessage({type: 'get-buffer'}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.