Skip to content

Commit

Permalink
closer
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Oct 7, 2023
1 parent a6ba4db commit a356d1b
Show file tree
Hide file tree
Showing 19 changed files with 273 additions and 48 deletions.
3 changes: 3 additions & 0 deletions runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
</goals>
</execution>
</executions>
<configuration>
<wastToProcess>i32.wast,i64.wast,local_get.wast,memory.wast,return.wast</wastToProcess>
</configuration>
</plugin>
</plugins>
</build>
Expand Down

This file was deleted.

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

import com.dylibso.chicory.runtime.exceptions.ChicoryException;
import com.dylibso.chicory.wasm.types.Value;

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

import com.dylibso.chicory.runtime.exceptions.ChicoryException;
import com.dylibso.chicory.wasm.types.*;

import java.util.*;
Expand Down
13 changes: 12 additions & 1 deletion runtime/src/main/java/com/dylibso/chicory/runtime/Module.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.dylibso.chicory.runtime;

import com.dylibso.chicory.runtime.exceptions.ChicoryException;
import com.dylibso.chicory.runtime.exceptions.InvalidException;
import com.dylibso.chicory.wasm.Parser;
import com.dylibso.chicory.wasm.types.*;

import java.util.HashMap;
import java.util.Map;

public class Module {
private com.dylibso.chicory.wasm.Module module;
Expand All @@ -15,6 +16,16 @@ public static Module build(String wasmFile) {
return new Module(parser.parseModule());
}

public static Module build(String wasmFile, ModuleType type) {
switch (type) {
case TEXT:
return build(wasmFile);
default:
// TODO: implement me
throw new InvalidException("type mismatch");
}
}

protected Module(com.dylibso.chicory.wasm.Module module) {
this.module = module;
this.exports = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.dylibso.chicory.runtime;

public enum ModuleType {
TEXT,
BINARY
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.dylibso.chicory.runtime;

import com.dylibso.chicory.runtime.exceptions.ChicoryException;

import java.util.List;
import java.util.Stack;

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

public class ChicoryException extends RuntimeException {
public ChicoryException(String msg) {
super(msg);
}
public ChicoryException(Throwable cause) {
super(cause);
}
public ChicoryException(String msg, Throwable cause) {
super(msg, cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.dylibso.chicory.runtime.exceptions;

public class InvalidException extends ChicoryException {
public InvalidException(String msg) {
super(msg);
}
public InvalidException(Throwable cause) {
super(cause);
}
public InvalidException(String msg, Throwable cause) {
super(msg, cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.dylibso.chicory.runtime.exceptions;

public class MalformedException extends ChicoryException {
public MalformedException(String msg) {
super(msg);
}
public MalformedException(Throwable cause) {
super(cause);
}
public MalformedException(String msg, Throwable cause) {
super(msg, cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.dylibso.chicory.runtime.exceptions;

public class WASMRuntimeException extends ChicoryException {
public WASMRuntimeException(String msg) {
super(msg);
}
public WASMRuntimeException(Throwable cause) {
super(cause);
}
public WASMRuntimeException(String msg, Throwable cause) {
super(msg, cause);
}
}
Loading

0 comments on commit a356d1b

Please sign in to comment.