Skip to content

Commit

Permalink
Rebase on master
Browse files Browse the repository at this point in the history
  • Loading branch information
titzer committed Oct 10, 2023
1 parent 40399d6 commit 238f182
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
18 changes: 9 additions & 9 deletions src/engine/BinParser.v3
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class BinParser(extensions: Extension.set, limits: Limits, filename: string) ext
if (extensions.TYPE_IMPORTS && kind == BpImportExportKind.Args.code) {
var count = parser.readU32_i("import arg count", limits.max_num_exports);
if (!err.ok()) return;
args = Array<Decl>.new(count);
args = Array<Decl2>.new(count);
for (i < count) args[i] = readExportWithoutName();
kind = parser.readByte("import kind", BpConstants.renderImportKind);
}
Expand Down Expand Up @@ -539,17 +539,17 @@ class BinParser(extensions: Extension.set, limits: Limits, filename: string) ext
var decl = readExportWithoutName();
module.exports.put(name, decl);
}
def readExportWithoutName() -> Decl {
def readExportWithoutName() -> Decl2 {
var pt = decoder.pos;
var kind = parser.readByte("export kind", BpConstants.renderImportKind);
var decl: Decl;
var decl: Decl2;
match (kind) {
BpImportExportKind.Function.code => decl = parser.readFuncRef();
BpImportExportKind.Table.code => decl = parser.readTableRef();
BpImportExportKind.Memory.code => decl = parser.readMemoryRef();
BpImportExportKind.Global.code => decl = parser.readGlobalRef();
BpImportExportKind.Tag.code => decl = parser.readTagRef();
BpImportExportKind.AbsType.code => decl = parser.readAbsTypeRef();
BpImportExportKind.Function.code => decl = Decl2.Func(parser.readFuncIndex());
BpImportExportKind.Table.code => decl = Decl2.Table(parser.readTableIndex());
BpImportExportKind.Memory.code => decl = Decl2.Memory(parser.readMemoryIndex());
BpImportExportKind.Global.code => decl = Decl2.Global(parser.readGlobalIndex());
BpImportExportKind.Tag.code => decl = Decl2.Tag(parser.readTagIndex());
BpImportExportKind.AbsType.code => decl = Decl2.AbsType(parser.readAbsTypeIndex());
_ => err.rel(decoder, pt).InvalidExportKind(kind);
}
return decl;
Expand Down
3 changes: 3 additions & 0 deletions src/engine/Instantiator.v3
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ class Instantiator(extensions: Extension.set, module: Module, var imports: Array
var nsig = Canon.sigPR(p, r);
return nsig;
}
def mapHeapType(decl: HeapTypeDecl) -> HeapTypeDecl {
return decl; // TODO: substitute and canonicalize
}
def mapStruct(decl: StructDecl) -> StructDecl {
return decl; // TODO: substitute and canonicalize
}
Expand Down
9 changes: 9 additions & 0 deletions src/engine/WasmParser.v3
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,21 @@ class WasmParser(extensions: Extension.set, limits: Limits, module: Module,
def readGlobalRef() -> GlobalDecl {
return readIndex("global", module.globals);
}
def readGlobalIndex() -> u31 {
return readAndCheckIndex("global", module.globals.length).1;
}
def readTagRef() -> TagDecl {
return readIndex("tag", module.tags);
}
def readTagIndex() -> u31 {
return readAndCheckIndex("tag", module.tags.length).1;
}
def readAbsTypeRef() -> AbsTypeDecl {
return readIndex("abstract type", module.abstypes);
}
def readAbsTypeIndex() -> u31 {
return readAndCheckIndex("abstract type", module.abstypes.length).1;
}
def readIndex<T>(quantity: string, space: Vector<T>) -> T {
var t = readAndCheckIndex(quantity, space.length);
return if(t.0, space[t.1]);
Expand Down
7 changes: 4 additions & 3 deletions src/objdump.main.v3
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ def renderImportExportDecl(out: StringBuilder, decl: Decl) {
}
def renderImportExportDecl2(out: StringBuilder, decl: Decl2) {
match (decl) {
Sig(index) => out.put1(": sig #%d", index);
Struct(index) => out.put1(": struct #%d", index);
Array(index) => out.put1(": array #%d", index);
RecGroup(abstract, index, length) => out.put2(": recgrp %d %d", index, length);
Sig(abstract, index) => out.put1(": sig #%d", index);
Struct(abstract, index) => out.put1(": struct #%d", index);
Array(abstract, index) => out.put1(": array #%d", index);
AbsType(index) => out.put1(": abstype #%d", index);
Func(index) => out.put1(": func #%d", index);
Table(index) => out.put1(": table #%d", index);
Expand Down

0 comments on commit 238f182

Please sign in to comment.