Skip to content

Commit

Permalink
[chore] Removed unused index from HostImports
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Jul 26, 2024
1 parent 3405d0a commit d9bd37b
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 62 deletions.
26 changes: 0 additions & 26 deletions runtime/src/main/java/com/dylibso/chicory/runtime/HostImports.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class HostImports {
private final HostGlobal[] globals;
private final HostMemory[] memories;
private final HostTable[] tables;
private FromHost[] index;

public HostImports() {
this.functions = NO_HOST_FUNCTIONS;
Expand Down Expand Up @@ -125,14 +124,6 @@ public HostTable table(int idx) {
return tables[idx];
}

public FromHost[] index() {
return index;
}

public void setIndex(FromHost[] index) {
this.index = index;
}

public static Builder builder() {
return new Builder();
}
Expand All @@ -142,7 +133,6 @@ public static final class Builder {
private List<HostGlobal> globals;
private List<HostMemory> memories;
private List<HostTable> tables;
private List<FromHost> index;

Builder() {}

Expand Down Expand Up @@ -198,19 +188,6 @@ public Builder addTable(HostTable... table) {
return this;
}

public Builder withIndex(List<FromHost> index) {
this.index = index;
return this;
}

public Builder addIndex(FromHost... i) {
if (this.index == null) {
this.index = new ArrayList<>();
}
Collections.addAll(this.index, i);
return this;
}

public HostImports build() {
final HostImports hostImports =
new HostImports(
Expand All @@ -224,9 +201,6 @@ public HostImports build() {
? new HostMemory[0]
: memories.toArray(new HostMemory[0]),
tables == null ? new HostTable[0] : tables.toArray(new HostTable[0]));
if (index != null) {
hostImports.setIndex(index.toArray(new FromHost[0]));
}
return hostImports;
}
}
Expand Down
6 changes: 0 additions & 6 deletions runtime/src/main/java/com/dylibso/chicory/runtime/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ private HostImports mapHostImports(Import[] imports, HostImports hostImports) {
var hostMemIdx = 0;
var hostTables = new HostTable[hostTableNum];
var hostTableIdx = 0;
var hostIndex = new FromHost[hostFuncNum + hostGlobalNum + hostMemNum + hostTableNum];
int cnt;
for (var impIdx = 0; impIdx < imports.length; impIdx++) {
var i = imports[impIdx];
Expand All @@ -390,7 +389,6 @@ private HostImports mapHostImports(Import[] imports, HostImports hostImports) {
&& i.name().equals(f.fieldName())) {
validateHostFunctionSignature((FunctionImport) i, f);
hostFuncs[hostFuncIdx] = f;
hostIndex[impIdx] = f;
found = true;
break;
}
Expand All @@ -405,7 +403,6 @@ private HostImports mapHostImports(Import[] imports, HostImports hostImports) {
&& i.name().equals(g.fieldName())) {
validateHostGlobalType((GlobalImport) i, g);
hostGlobals[hostGlobalIdx] = g;
hostIndex[impIdx] = g;
found = true;
break;
}
Expand All @@ -419,7 +416,6 @@ private HostImports mapHostImports(Import[] imports, HostImports hostImports) {
if (i.moduleName().equals(m.moduleName())
&& i.name().equals(m.fieldName())) {
hostMems[hostMemIdx] = m;
hostIndex[impIdx] = m;
found = true;
break;
}
Expand All @@ -434,7 +430,6 @@ private HostImports mapHostImports(Import[] imports, HostImports hostImports) {
&& i.name().equals(t.fieldName())) {
validateHostTableType((TableImport) i, t);
hostTables[hostTableIdx] = t;
hostIndex[impIdx] = t;
found = true;
break;
}
Expand All @@ -450,7 +445,6 @@ private HostImports mapHostImports(Import[] imports, HostImports hostImports) {
}

var result = new HostImports(hostFuncs, hostGlobals, hostMems, hostTables);
result.setIndex(hostIndex);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.dylibso.chicory.runtime;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import com.dylibso.chicory.wasm.types.Value;
import java.util.Arrays;
Expand All @@ -20,7 +19,6 @@ void empty() {
assertEquals(0, result.globalCount());
assertEquals(0, result.memoryCount());
assertEquals(0, result.tableCount());
assertNull(result.index());
}

@Nested
Expand Down Expand Up @@ -149,33 +147,5 @@ void addMemory() {
assertEquals(2, result.tableCount());
}
}

@Nested
class Index {

@Test
void withIndex() {
final HostImports result =
HostImports.builder()
.withIndex(
Arrays.asList(
new HostFunction(null, "", "", null, null),
new HostGlobal(
"spectest",
"global_i32",
new GlobalInstance(Value.i32(666)))))
.build();
assertEquals(2, result.index().length);
}

@Test
void addIndex() {
final HostImports result =
HostImports.builder()
.addIndex(new HostFunction(null, "", "", null, null))
.build();
assertEquals(1, result.index().length);
}
}
}
}

0 comments on commit d9bd37b

Please sign in to comment.