mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 07:02:13 +00:00
Unified continue/break labels with binaryen labels; Module-level global exports
This commit is contained in:
parent
f045975a4b
commit
29468846ab
@ -38,7 +38,7 @@ $> npm install
|
||||
$> node bin\asc yourModule.ts
|
||||
```
|
||||
|
||||
Building a browser bundle to `dist/assemblyscript.js` (still requires [binaryen.js](https://github.com/AssemblyScript/binaryen.js)):
|
||||
Building an UMD bundle to `dist/assemblyscript.js` (does not bundle [binaryen.js](https://github.com/AssemblyScript/binaryen.js):
|
||||
|
||||
```
|
||||
$> npm run build
|
||||
|
38
bin/asc.js
38
bin/asc.js
@ -44,15 +44,9 @@ if (args.help || args._.length < 1) {
|
||||
var options = [];
|
||||
Object.keys(conf).forEach(name => {
|
||||
var option = conf[name];
|
||||
var text = "";
|
||||
if (option.aliases) {
|
||||
option.aliases.forEach((alias, i) => {
|
||||
if (i > 0)
|
||||
text += ", ";
|
||||
text += "-" + alias;
|
||||
});
|
||||
text += ", ";
|
||||
}
|
||||
var text = " ";
|
||||
if (option.aliases)
|
||||
text += "-" + option.aliases[0] + ", ";
|
||||
text += "--" + name;
|
||||
while (text.length < 20)
|
||||
text += " ";
|
||||
@ -69,8 +63,20 @@ if (args.help || args._.length < 1) {
|
||||
process.exit(args.help ? 0 : 1);
|
||||
}
|
||||
|
||||
var entryPath = args._[0];
|
||||
var entryText = fs.readFileSync(entryPath, { encoding: "utf8" });
|
||||
var entryPath = args._[0].replace(/\\/g, "/").replace(/(\.ts|\/)$/, "");
|
||||
var entryDir = path.dirname(entryPath);
|
||||
var entryText;
|
||||
try {
|
||||
entryText = fs.readFileSync(entryPath + ".ts", { encoding: "utf8" });
|
||||
} catch (e) {
|
||||
try {
|
||||
entryText = fs.readFileSync(entryPath + "/index.ts", { encoding: "utf8" });
|
||||
entryPath = entryPath + "/index";
|
||||
} catch (e) {
|
||||
console.error("File '" + entryPath + ".ts' not found.");
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
var parser = assemblyscript.parseFile(entryText, entryPath);
|
||||
|
||||
@ -79,9 +85,15 @@ var nextText;
|
||||
|
||||
while ((nextPath = parser.nextFile()) != null) {
|
||||
try {
|
||||
nextText = fs.readFileSync(path.join(path.dirname(entryPath), nextPath + ".ts"), { encoding: "utf8" });
|
||||
nextText = fs.readFileSync(nextPath + ".ts", { encoding: "utf8" });
|
||||
} catch (e) {
|
||||
nextText = fs.readFileSync(path.join(path.dirname(entryPath), nextPath, "index.ts"), { encoding: "utf8" });
|
||||
try {
|
||||
nextText = fs.readFileSync(nextPath + "/index.ts", { encoding: "utf8" });
|
||||
nextPath = nextPath + "/index";
|
||||
} catch (e) {
|
||||
console.error("Imported file '" + nextPath + ".ts' not found.");
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
assemblyscript.parseFile(nextText, nextPath, parser);
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
heapStartBuffer[2] = (initial.lo >>> 16) as u8;
|
||||
heapStartBuffer[3] = (initial.lo >>> 24) as u8;
|
||||
}
|
||||
this.memorySegments.push(MemorySegment.create(heapStartBuffer, new U64(heapStartOffset, 0)));
|
||||
this.memorySegments.push(MemorySegment.create(heapStartBuffer, new U64(heapStartOffset, 0))); // TODO: use a global instead?
|
||||
// determine initial page size
|
||||
const initialOverlaps: U64 = initial.clone();
|
||||
initialOverlaps.and32(0xffff);
|
||||
@ -295,9 +295,15 @@ export class Compiler extends DiagnosticEmitter {
|
||||
const element: Element | null = <Element | null>this.program.elements.get(declaration.internalName);
|
||||
if (!element || element.kind != ElementKind.GLOBAL)
|
||||
throw new Error("unexpected missing global");
|
||||
return this.compileGlobal(<Global>element)
|
||||
? <Global>element
|
||||
: null;
|
||||
if (!this.compileGlobal(<Global>element))
|
||||
return null;
|
||||
if (declaration.range.source.isEntry && (<VariableStatement>declaration.parent).parent == declaration.range.source && hasModifier(ModifierKind.EXPORT, declaration.modifiers)) {
|
||||
if (!(<Global>element).isCompiledMutable)
|
||||
this.module.addGlobalExport(element.internalName, declaration.identifier.name);
|
||||
else
|
||||
this.warning(DiagnosticCode.Cannot_export_a_mutable_global, declaration.range);
|
||||
}
|
||||
return <Global>element;
|
||||
}
|
||||
|
||||
compileGlobal(element: Global): bool {
|
||||
@ -336,7 +342,6 @@ export class Compiler extends DiagnosticEmitter {
|
||||
} else
|
||||
initializer = this.module.createI32(element.constantIntegerValue ? element.constantIntegerValue.toI32() : 0);
|
||||
initializeInStart = false;
|
||||
this.module.addGlobal(element.internalName, nativeType, element.isMutable, initializer);
|
||||
} else if (declaration) {
|
||||
if (declaration.initializer) {
|
||||
initializer = this.compileExpression(declaration.initializer, type);
|
||||
@ -351,11 +356,10 @@ export class Compiler extends DiagnosticEmitter {
|
||||
if (initializeInStart) {
|
||||
this.module.addGlobal(internalName, nativeType, true, typeToNativeZero(this.module, type));
|
||||
this.startFunctionBody.push(this.module.createSetGlobal(internalName, initializer));
|
||||
element.isCompiledMutable = true;
|
||||
} else {
|
||||
this.module.addGlobal(internalName, nativeType, element.isMutable, initializer);
|
||||
if (!element.isMutable) {
|
||||
// TODO: check export
|
||||
}
|
||||
element.isCompiledMutable = element.isMutable;
|
||||
}
|
||||
return element.isCompiled = true;
|
||||
}
|
||||
@ -557,10 +561,9 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
compileExportStatement(statement: ExportStatement): void {
|
||||
const members: ExportMember[] = statement.members;
|
||||
const internalPath: string | null = statement.path ? statement.internalPath : statement.range.source.internalPath;
|
||||
for (let i: i32 = 0, k: i32 = members.length; i < k; ++i) {
|
||||
const member: ExportMember = members[i];
|
||||
const internalExportName: string = internalPath + PATH_DELIMITER + member.externalIdentifier.name;
|
||||
const internalExportName: string = statement.range.source.internalPath + PATH_DELIMITER + member.externalIdentifier.name;
|
||||
const element: Element | null = <Element | null>this.program.exports.get(internalExportName);
|
||||
if (!element) // reported in Program#initialize
|
||||
continue;
|
||||
@ -584,7 +587,12 @@ export class Compiler extends DiagnosticEmitter {
|
||||
break;
|
||||
|
||||
case ElementKind.GLOBAL:
|
||||
this.compileGlobal(<Global>element);
|
||||
if (this.compileGlobal(<Global>element) && statement.range.source.isEntry) {
|
||||
if (!(<Global>element).isCompiledMutable)
|
||||
this.module.addGlobalExport(element.internalName, member.externalIdentifier.name);
|
||||
else
|
||||
this.warning(DiagnosticCode.Cannot_export_a_mutable_global, member.range);
|
||||
}
|
||||
break;
|
||||
|
||||
case ElementKind.NAMESPACE:
|
||||
@ -713,7 +721,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
throw new Error("not implemented");
|
||||
const context: string | null = this.currentFunction.breakContext;
|
||||
if (context != null)
|
||||
return this.module.createBreak("break$" + (<string>context));
|
||||
return this.module.createBreak("break|" + (<string>context));
|
||||
this.error(DiagnosticCode.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement, statement.range);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
@ -723,7 +731,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
throw new Error("not implemented");
|
||||
const context: string | null = this.currentFunction.breakContext;
|
||||
if (context != null && !this.disallowContinue)
|
||||
return this.module.createBreak("continue$" + (<string>context));
|
||||
return this.module.createBreak("continue|" + (<string>context));
|
||||
this.error(DiagnosticCode.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement, statement.range);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
@ -733,8 +741,8 @@ export class Compiler extends DiagnosticEmitter {
|
||||
const condition: ExpressionRef = this.compileExpression(statement.condition, Type.i32);
|
||||
const body: ExpressionRef = this.compileStatement(statement.statement);
|
||||
this.currentFunction.leaveBreakContext();
|
||||
const breakLabel: string = "break$" + label;
|
||||
const continueLabel: string = "continue$" + label;
|
||||
const breakLabel: string = "break|" + label;
|
||||
const continueLabel: string = "continue|" + label;
|
||||
return this.module.createBlock(breakLabel, [
|
||||
this.module.createLoop(continueLabel,
|
||||
this.module.createBlock(null, [
|
||||
@ -768,8 +776,8 @@ export class Compiler extends DiagnosticEmitter {
|
||||
const incrementor: ExpressionRef = statement.incrementor ? this.compileExpression(<Expression>statement.incrementor, Type.void) : this.module.createNop();
|
||||
const body: ExpressionRef = this.compileStatement(statement.statement);
|
||||
this.currentFunction.leaveBreakContext();
|
||||
const continueLabel: string = "continue$" + context;
|
||||
const breakLabel: string = "break$" + context;
|
||||
const continueLabel: string = "continue|" + context;
|
||||
const breakLabel: string = "break|" + context;
|
||||
return this.module.createBlock(breakLabel, [
|
||||
initializer,
|
||||
this.module.createLoop(continueLabel, this.module.createBlock(null, [
|
||||
@ -816,7 +824,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
for (i = 0; i < k; ++i) {
|
||||
const case_: SwitchCase = statement.cases[i];
|
||||
if (case_.label) {
|
||||
breaks[breakIndex++] = this.module.createBreak("case" + i.toString(10) + "$" + context,
|
||||
breaks[breakIndex++] = this.module.createBreak("case" + i.toString(10) + "|" + context,
|
||||
this.module.createBinary(BinaryOp.EqI32,
|
||||
this.module.createGetLocal(local.index, NativeType.I32),
|
||||
this.compileExpression(case_.label, Type.i32)
|
||||
@ -830,15 +838,15 @@ export class Compiler extends DiagnosticEmitter {
|
||||
breaks[breakIndex] = this.module.createBreak((defaultIndex >= 0
|
||||
? "case" + defaultIndex.toString(10)
|
||||
: "break"
|
||||
) + "$" + context);
|
||||
) + "|" + context);
|
||||
|
||||
// nest blocks in order
|
||||
let currentBlock: ExpressionRef = this.module.createBlock("case0$" + context, breaks, NativeType.None);
|
||||
let currentBlock: ExpressionRef = this.module.createBlock("case0|" + context, breaks, NativeType.None);
|
||||
for (i = 0; i < k; ++i) {
|
||||
const case_: SwitchCase = statement.cases[i];
|
||||
const nextLabel: string = i == k - 1
|
||||
? "break$" + context
|
||||
: "case" + (i + 1).toString(10) + "$" + context;
|
||||
? "break|" + context
|
||||
: "case" + (i + 1).toString(10) + "|" + context;
|
||||
const l: i32 = case_.statements.length;
|
||||
const body: ExpressionRef[] = new Array(1 + l);
|
||||
body[0] = currentBlock;
|
||||
@ -895,8 +903,8 @@ export class Compiler extends DiagnosticEmitter {
|
||||
compileWhileStatement(statement: WhileStatement): ExpressionRef {
|
||||
const label: string = this.currentFunction.enterBreakContext();
|
||||
const condition: ExpressionRef = this.compileExpression(statement.condition, Type.i32);
|
||||
const breakLabel: string = "break$" + label;
|
||||
const continueLabel: string = "continue$" + label;
|
||||
const breakLabel: string = "break|" + label;
|
||||
const continueLabel: string = "continue|" + label;
|
||||
const body: ExpressionRef = this.compileStatement(statement.statement);
|
||||
this.currentFunction.leaveBreakContext();
|
||||
return this.module.createBlock(breakLabel, [
|
||||
|
@ -5,6 +5,7 @@ export enum DiagnosticCode {
|
||||
Basic_type_0_cannot_be_nullable = 101,
|
||||
Operation_not_supported = 102,
|
||||
Operation_is_unsafe = 103,
|
||||
Cannot_export_a_mutable_global = 104,
|
||||
Unterminated_string_literal = 1002,
|
||||
Identifier_expected = 1003,
|
||||
_0_expected = 1005,
|
||||
@ -74,6 +75,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string {
|
||||
case 101: return "Basic type '{0}' cannot be nullable.";
|
||||
case 102: return "Operation not supported.";
|
||||
case 103: return "Operation is unsafe.";
|
||||
case 104: return "Cannot export a mutable global.";
|
||||
case 1002: return "Unterminated string literal.";
|
||||
case 1003: return "Identifier expected.";
|
||||
case 1005: return "'{0}' expected.";
|
||||
|
@ -3,6 +3,7 @@
|
||||
"Basic type '{0}' cannot be nullable.": 101,
|
||||
"Operation not supported.": 102,
|
||||
"Operation is unsafe.": 103,
|
||||
"Cannot export a mutable global.": 104,
|
||||
|
||||
"Unterminated string literal.": 1002,
|
||||
"Identifier expected.": 1003,
|
||||
|
@ -12,6 +12,10 @@ globalScope["select"] = function select<T>(ifTrue: T, ifFalse: T, condition: boo
|
||||
return condition ? ifTrue : ifFalse;
|
||||
};
|
||||
|
||||
globalScope["assert"] = function(isTrue: bool): void {
|
||||
if (!isTrue) throw new Error("assertion failed");
|
||||
};
|
||||
|
||||
let binaryen: any;
|
||||
try {
|
||||
binaryen = require("binaryen");
|
||||
|
@ -340,7 +340,7 @@ export class Program extends DiagnosticEmitter {
|
||||
|
||||
// export external element
|
||||
} else {
|
||||
referencedName = (<string>internalPath) + PATH_DELIMITER + member.externalIdentifier.name;
|
||||
referencedName = (<string>internalPath) + PATH_DELIMITER + member.identifier.name;
|
||||
|
||||
// resolve right away if the export exists
|
||||
if (this.exports.has(referencedName)) {
|
||||
@ -771,6 +771,7 @@ export class Global extends Element {
|
||||
hasConstantValue: bool = false;
|
||||
constantIntegerValue: I64 | null = null;
|
||||
constantFloatValue: f64 = 0;
|
||||
isCompiledMutable: bool = false;
|
||||
|
||||
constructor(program: Program, internalName: string, declaration: VariableLikeDeclarationStatement | null, type: Type | null) {
|
||||
super(program, internalName);
|
||||
|
@ -6,8 +6,8 @@
|
||||
(export "loopDoInDo" (func $do/loopDoInDo))
|
||||
(export "memory" (memory $0))
|
||||
(func $do/loopDo (; 0 ;) (type $iv) (param $0 i32)
|
||||
(loop $continue$1.1
|
||||
(br_if $continue$1.1
|
||||
(loop $continue|1.1
|
||||
(br_if $continue|1.1
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
@ -18,15 +18,15 @@
|
||||
)
|
||||
)
|
||||
(func $do/loopDoInDo (; 1 ;) (type $iv) (param $0 i32)
|
||||
(loop $continue$1.1
|
||||
(loop $continue|1.1
|
||||
(set_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(loop $continue$1.2
|
||||
(br_if $continue$1.2
|
||||
(loop $continue|1.2
|
||||
(br_if $continue|1.2
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
@ -35,7 +35,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(br_if $continue$1.1
|
||||
(br_if $continue|1.1
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
|
@ -6,23 +6,23 @@
|
||||
(export "loopDoInDo" (func $do/loopDoInDo))
|
||||
(export "memory" (memory $0))
|
||||
(func $do/loopDo (; 0 ;) (type $iv) (param $0 i32)
|
||||
(block $break$1.1
|
||||
(loop $continue$1.1
|
||||
(block $break|1.1
|
||||
(loop $continue|1.1
|
||||
(set_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br_if $continue$1.1
|
||||
(br_if $continue|1.1
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $do/loopDoInDo (; 1 ;) (type $iv) (param $0 i32)
|
||||
(block $break$1.1
|
||||
(loop $continue$1.1
|
||||
(block $break|1.1
|
||||
(loop $continue|1.1
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.sub
|
||||
@ -30,21 +30,21 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block $break$1.2
|
||||
(loop $continue$1.2
|
||||
(block $break|1.2
|
||||
(loop $continue|1.2
|
||||
(set_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br_if $continue$1.2
|
||||
(br_if $continue|1.2
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br_if $continue$1.1
|
||||
(br_if $continue|1.1
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
|
@ -1,9 +1,13 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(global $export/a i32 (i32.const 1))
|
||||
(global $export/b i32 (i32.const 2))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08")
|
||||
(export "add" (func $export/add))
|
||||
(export "renamed_sub" (func $export/sub))
|
||||
(export "a" (global $export/a))
|
||||
(export "renamed_b" (global $export/b))
|
||||
(export "memory" (memory $0))
|
||||
(func $export/add (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(i32.add
|
||||
|
@ -8,8 +8,8 @@ function sub(a: i32, b: i32): i32 {
|
||||
|
||||
export { sub as renamed_sub };
|
||||
|
||||
export let a: i32 = 1;
|
||||
export const a: i32 = 1;
|
||||
|
||||
let b: i32 = 2;
|
||||
const b: i32 = 2;
|
||||
|
||||
export { b as renamed_b };
|
||||
|
@ -1,11 +1,13 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(global $export/a (mut i32) (i32.const 1))
|
||||
(global $export/b (mut i32) (i32.const 2))
|
||||
(global $export/a i32 (i32.const 1))
|
||||
(global $export/b i32 (i32.const 2))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "add" (func $export/add))
|
||||
(export "renamed_sub" (func $export/sub))
|
||||
(export "a" (global $export/a))
|
||||
(export "renamed_b" (global $export/b))
|
||||
(export "memory" (memory $0))
|
||||
(func $export/add (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(return
|
||||
|
@ -10,7 +10,7 @@
|
||||
(set_global $for/i
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue$1.1
|
||||
(loop $continue|1.1
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_global $for/i)
|
||||
@ -23,7 +23,7 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$1.1)
|
||||
(br $continue|1.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -37,7 +37,7 @@
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue$2.1
|
||||
(loop $continue|2.1
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $0)
|
||||
@ -50,11 +50,11 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$2.1)
|
||||
(br $continue|2.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue$3.1
|
||||
(loop $continue|3.1
|
||||
(if
|
||||
(i32.gt_s
|
||||
(get_global $for/i)
|
||||
@ -67,7 +67,7 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$3.1)
|
||||
(br $continue|3.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -75,9 +75,9 @@
|
||||
(get_global $for/i)
|
||||
(unreachable)
|
||||
)
|
||||
(block $break$4.1
|
||||
(loop $continue$4.1
|
||||
(br_if $break$4.1
|
||||
(block $break|4.1
|
||||
(loop $continue|4.1
|
||||
(br_if $break|4.1
|
||||
(i32.eq
|
||||
(get_global $for/i)
|
||||
(i32.const 10)
|
||||
@ -89,17 +89,17 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$4.1)
|
||||
(br $continue|4.1)
|
||||
)
|
||||
)
|
||||
(loop $continue$5.1
|
||||
(loop $continue|5.1
|
||||
(set_global $for/i
|
||||
(i32.sub
|
||||
(get_global $for/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br_if $continue$5.1
|
||||
(br_if $continue|5.1
|
||||
(get_global $for/i)
|
||||
)
|
||||
)
|
||||
|
@ -7,11 +7,11 @@
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(block $break$1.1
|
||||
(block $break|1.1
|
||||
(set_global $for/i
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue$1.1
|
||||
(loop $continue|1.1
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_global $for/i)
|
||||
@ -25,7 +25,7 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$1.1)
|
||||
(br $continue|1.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -39,13 +39,13 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(block $break$2.1
|
||||
(block $break|2.1
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(loop $continue$2.1
|
||||
(loop $continue|2.1
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $0)
|
||||
@ -59,14 +59,14 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$2.1)
|
||||
(br $continue|2.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break$3.1
|
||||
(block $break|3.1
|
||||
(nop)
|
||||
(loop $continue$3.1
|
||||
(loop $continue|3.1
|
||||
(if
|
||||
(i32.gt_s
|
||||
(get_global $for/i)
|
||||
@ -80,7 +80,7 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$3.1)
|
||||
(br $continue|3.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -94,9 +94,9 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(block $break$4.1
|
||||
(block $break|4.1
|
||||
(nop)
|
||||
(loop $continue$4.1
|
||||
(loop $continue|4.1
|
||||
(if
|
||||
(i32.const 1)
|
||||
(block
|
||||
@ -105,7 +105,7 @@
|
||||
(get_global $for/i)
|
||||
(i32.const 10)
|
||||
)
|
||||
(br $break$4.1)
|
||||
(br $break|4.1)
|
||||
)
|
||||
(set_global $for/i
|
||||
(i32.add
|
||||
@ -113,14 +113,14 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$4.1)
|
||||
(br $continue|4.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break$5.1
|
||||
(block $break|5.1
|
||||
(nop)
|
||||
(loop $continue$5.1
|
||||
(loop $continue|5.1
|
||||
(if
|
||||
(i32.const 1)
|
||||
(block
|
||||
@ -137,10 +137,10 @@
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(br $break$5.1)
|
||||
(br $break|5.1)
|
||||
)
|
||||
(nop)
|
||||
(br $continue$5.1)
|
||||
(br $continue|5.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(global $export/a (mut i32) (i32.const 1))
|
||||
(global $export/b (mut i32) (i32.const 2))
|
||||
(global $export/a i32 (i32.const 1))
|
||||
(global $export/b i32 (i32.const 2))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08")
|
||||
(export "memory" (memory $0))
|
||||
|
@ -1,8 +1,8 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(global $export/a (mut i32) (i32.const 1))
|
||||
(global $export/b (mut i32) (i32.const 2))
|
||||
(global $export/a i32 (i32.const 1))
|
||||
(global $export/b i32 (i32.const 2))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "memory" (memory $0))
|
||||
|
@ -1,10 +1,14 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(global $export/a i32 (i32.const 1))
|
||||
(global $export/b i32 (i32.const 2))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08")
|
||||
(export "add" (func $export/add))
|
||||
(export "renamed_sub" (func $export/sub))
|
||||
(export "renamed_a" (global $export/a))
|
||||
(export "rerenamed_b" (global $export/b))
|
||||
(export "renamed_add" (func $export/add))
|
||||
(export "rerenamed_sub" (func $export/sub))
|
||||
(export "memory" (memory $0))
|
||||
|
@ -1,4 +1,4 @@
|
||||
export { add, renamed_sub } from "./export";
|
||||
export { add, renamed_sub, a as renamed_a, renamed_b as rerenamed_b } from "./export";
|
||||
|
||||
import { add as imported_add, renamed_sub as imported_sub } from "./export";
|
||||
|
||||
|
@ -1,10 +1,14 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(global $export/a i32 (i32.const 1))
|
||||
(global $export/b i32 (i32.const 2))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "add" (func $export/add))
|
||||
(export "renamed_sub" (func $export/sub))
|
||||
(export "renamed_a" (global $export/a))
|
||||
(export "rerenamed_b" (global $export/b))
|
||||
(export "renamed_add" (func $export/add))
|
||||
(export "rerenamed_sub" (func $export/sub))
|
||||
(export "memory" (memory $0))
|
||||
@ -80,6 +84,8 @@
|
||||
export/renamed_b
|
||||
reexport/add
|
||||
reexport/renamed_sub
|
||||
reexport/renamed_a
|
||||
reexport/rerenamed_b
|
||||
reexport/renamed_add
|
||||
reexport/rerenamed_sub
|
||||
;)
|
||||
|
@ -7,15 +7,15 @@
|
||||
(export "doSwitchDefaultOmitted" (func $switch/doSwitchDefaultOmitted))
|
||||
(export "memory" (memory $0))
|
||||
(func $switch/doSwitch (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(block $case4$1.1
|
||||
(block $case2$1.1
|
||||
(block $case0$1.1
|
||||
(block $case4|1.1
|
||||
(block $case2|1.1
|
||||
(block $case0|1.1
|
||||
(block $tablify|0
|
||||
(br_table $case2$1.1 $case0$1.1 $case4$1.1 $case4$1.1 $tablify|0
|
||||
(br_table $case2|1.1 $case0|1.1 $case4|1.1 $case4|1.1 $tablify|0
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(br $case2$1.1)
|
||||
(br $case2|1.1)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
@ -28,10 +28,10 @@
|
||||
(i32.const 23)
|
||||
)
|
||||
(func $switch/doSwitchDefaultFirst (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(block $case3$1.1
|
||||
(block $case1$1.1
|
||||
(block $case3|1.1
|
||||
(block $case1|1.1
|
||||
(block $tablify|0
|
||||
(br_table $case1$1.1 $case3$1.1 $case3$1.1 $tablify|0
|
||||
(br_table $case1|1.1 $case3|1.1 $case3|1.1 $tablify|0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
@ -49,18 +49,18 @@
|
||||
(i32.const 23)
|
||||
)
|
||||
(func $switch/doSwitchDefaultOmitted (; 2 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(block $break$1.1
|
||||
(block $case2$1.1
|
||||
(block $case0$1.1
|
||||
(block $break|1.1
|
||||
(block $case2|1.1
|
||||
(block $case0|1.1
|
||||
(block $tablify|0
|
||||
(br_table $case0$1.1 $case2$1.1 $case2$1.1 $tablify|0
|
||||
(br_table $case0|1.1 $case2|1.1 $case2|1.1 $tablify|0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $break$1.1)
|
||||
(br $break|1.1)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
|
@ -8,40 +8,40 @@
|
||||
(export "memory" (memory $0))
|
||||
(func $switch/doSwitch (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(block $break$1.1
|
||||
(block $case4$1.1
|
||||
(block $case3$1.1
|
||||
(block $case2$1.1
|
||||
(block $case1$1.1
|
||||
(block $case0$1.1
|
||||
(block $break|1.1
|
||||
(block $case4|1.1
|
||||
(block $case3|1.1
|
||||
(block $case2|1.1
|
||||
(block $case1|1.1
|
||||
(block $case0|1.1
|
||||
(set_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(br_if $case0$1.1
|
||||
(br_if $case0|1.1
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br_if $case1$1.1
|
||||
(br_if $case1|1.1
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(br_if $case3$1.1
|
||||
(br_if $case3|1.1
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br_if $case4$1.1
|
||||
(br_if $case4|1.1
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(br $case2$1.1)
|
||||
(br $case2|1.1)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
@ -60,33 +60,33 @@
|
||||
)
|
||||
(func $switch/doSwitchDefaultFirst (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(block $break$1.1
|
||||
(block $case3$1.1
|
||||
(block $case2$1.1
|
||||
(block $case1$1.1
|
||||
(block $case0$1.1
|
||||
(block $break|1.1
|
||||
(block $case3|1.1
|
||||
(block $case2|1.1
|
||||
(block $case1|1.1
|
||||
(block $case0|1.1
|
||||
(set_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(br_if $case1$1.1
|
||||
(br_if $case1|1.1
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br_if $case2$1.1
|
||||
(br_if $case2|1.1
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br_if $case3$1.1
|
||||
(br_if $case3|1.1
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(br $case0$1.1)
|
||||
(br $case0|1.1)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
@ -104,32 +104,32 @@
|
||||
)
|
||||
(func $switch/doSwitchDefaultOmitted (; 2 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(block $break$1.1
|
||||
(block $case2$1.1
|
||||
(block $case1$1.1
|
||||
(block $case0$1.1
|
||||
(block $break|1.1
|
||||
(block $case2|1.1
|
||||
(block $case1|1.1
|
||||
(block $case0|1.1
|
||||
(set_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(br_if $case0$1.1
|
||||
(br_if $case0|1.1
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br_if $case1$1.1
|
||||
(br_if $case1|1.1
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br_if $case2$1.1
|
||||
(br_if $case2|1.1
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(br $break$1.1)
|
||||
(br $break|1.1)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
|
@ -6,7 +6,7 @@
|
||||
(export "loopWhileInWhile" (func $while/loopWhileInWhile))
|
||||
(export "memory" (memory $0))
|
||||
(func $while/loopWhile (; 0 ;) (type $iv) (param $0 i32)
|
||||
(loop $continue$1.1
|
||||
(loop $continue|1.1
|
||||
(if
|
||||
(get_local $0)
|
||||
(block
|
||||
@ -16,13 +16,13 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$1.1)
|
||||
(br $continue|1.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $while/loopWhileInWhile (; 1 ;) (type $iv) (param $0 i32)
|
||||
(loop $continue$1.1
|
||||
(loop $continue|1.1
|
||||
(if
|
||||
(get_local $0)
|
||||
(block
|
||||
@ -32,7 +32,7 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(loop $continue$1.2
|
||||
(loop $continue|1.2
|
||||
(if
|
||||
(get_local $0)
|
||||
(block
|
||||
@ -42,11 +42,11 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$1.2)
|
||||
(br $continue|1.2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue$1.1)
|
||||
(br $continue|1.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -6,8 +6,8 @@
|
||||
(export "loopWhileInWhile" (func $while/loopWhileInWhile))
|
||||
(export "memory" (memory $0))
|
||||
(func $while/loopWhile (; 0 ;) (type $iv) (param $0 i32)
|
||||
(block $break$1.1
|
||||
(loop $continue$1.1
|
||||
(block $break|1.1
|
||||
(loop $continue|1.1
|
||||
(if
|
||||
(get_local $0)
|
||||
(block
|
||||
@ -17,15 +17,15 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$1.1)
|
||||
(br $continue|1.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $while/loopWhileInWhile (; 1 ;) (type $iv) (param $0 i32)
|
||||
(block $break$1.1
|
||||
(loop $continue$1.1
|
||||
(block $break|1.1
|
||||
(loop $continue|1.1
|
||||
(if
|
||||
(get_local $0)
|
||||
(block
|
||||
@ -36,8 +36,8 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block $break$1.2
|
||||
(loop $continue$1.2
|
||||
(block $break|1.2
|
||||
(loop $continue|1.2
|
||||
(if
|
||||
(get_local $0)
|
||||
(block
|
||||
@ -47,13 +47,13 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue$1.2)
|
||||
(br $continue|1.2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue$1.1)
|
||||
(br $continue|1.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user