Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make type validation use Module instead of Instance #465

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions runtime/src/main/java/com/dylibso/chicory/runtime/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE;

import com.dylibso.chicory.wasm.Module;
import com.dylibso.chicory.wasm.TypeValidator;
import com.dylibso.chicory.wasm.exceptions.ChicoryException;
import com.dylibso.chicory.wasm.exceptions.InvalidException;
import com.dylibso.chicory.wasm.exceptions.MalformedException;
Expand Down Expand Up @@ -273,7 +274,7 @@ public Instance initialize(boolean start) {
+ funcType);
}
}
new TypeValidator().validate(i, this.function(i), this.types[funcType], this);
new TypeValidator(module).validate(i, function(i), types[funcType]);
}
}
}
Expand Down Expand Up @@ -358,31 +359,13 @@ public Value readGlobal(int idx) {
return globals[idx - importedGlobalsOffset].getValue();
}

public Global globalInitializer(int idx) {
if (idx < importedGlobalsOffset) {
return null;
}
if ((idx - importedGlobalsOffset) >= globalInitializers.length) {
throw new InvalidException("unknown global " + idx);
}
return globalInitializers[idx - importedGlobalsOffset];
}

public int globalCount() {
return globals.length;
}

public FunctionType type(int idx) {
if (idx >= types.length) {
throw new InvalidException("unknown type " + idx);
}
return types[idx];
}

public int typeCount() {
return types.length;
}

public int functionType(int idx) {
if (idx >= functionTypes.length) {
throw new InvalidException("unknown function " + idx);
Expand All @@ -408,10 +391,6 @@ public TableInstance table(int idx) {
return tables[idx - importedTablesOffset];
}

public DataSegment[] dataSegments() {
return dataSegments;
}

public Element element(int idx) {
if (idx < 0 || idx >= elements.length) {
throw new InvalidException("unknown elem segment " + idx);
Expand Down
Loading
Loading