Skip to content

Commit 692bbeb

Browse files
committed
minor fixes.
1 parent a29368d commit 692bbeb

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

state/actions/compileCode.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ export const compileCode = async (activeId: number) => {
2929
if (file.name.endsWith('.wat')) {
3030
result = await compileWat(file);
3131
}
32-
if (navigator?.onLine === false) {
33-
throw Error('You seem offline, check you internet connection and try again!')
34-
}
35-
if (file.language === "ts") {
32+
else if (file.language === "ts") {
3633
result = await compileTs(file);
3734
}
35+
else if (navigator?.onLine === false) {
36+
throw Error('You seem offline, check you internet connection and try again!')
37+
}
3838
else if (file.language === 'c') {
3939
result = await compileC(file)
4040
}
@@ -144,10 +144,10 @@ export const compileC = async (file: IFile): Promise<CompilationResult> => {
144144

145145
export const compileWat = async (file: IFile): Promise<CompilationResult> => {
146146
const wabt = await (await import('wabt')).default()
147-
const module = wabt.parseWat(file.name, file.content);
148-
module.resolveNames();
149-
module.validate();
150-
const { buffer } = module.toBinary({
147+
const mod = wabt.parseWat(file.name, file.content);
148+
mod.resolveNames();
149+
mod.validate();
150+
const { buffer } = mod.toBinary({
151151
log: false,
152152
write_debug_names: true,
153153
});
@@ -165,12 +165,9 @@ export const compileTs = async (file: IFile): Promise<CompilationResult> => {
165165
file.name,
166166
"--outFile", `${file.name}.wasm`,
167167
"--textFile", `${file.name}.wat`,
168-
"--runtime",
169-
"stub",
170-
"--initialMemory",
171-
"1",
172-
"--maximumMemory",
173-
"1",
168+
"--runtime", "stub",
169+
"--initialMemory", "1",
170+
"--maximumMemory", "1",
174171
"--noExportMemory",
175172
"--optimize",
176173
], {

0 commit comments

Comments
 (0)