Skip to content

Commit

Permalink
Fix spotless config (#14)
Browse files Browse the repository at this point in the history
* Fix spotless configuration

* Bulk reformatting
  • Loading branch information
andreaTP authored Oct 9, 2023
1 parent feffc29 commit 2c64c71
Show file tree
Hide file tree
Showing 62 changed files with 2,155 additions and 1,796 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,11 @@ sh scripts/compile-tests.sh

# This pulls down the wasm-testsuite in /tmp and copies over some needed
# files to our src/test/resources directory. We only need to run
# this is if we need to update the v1 spec data
# this is if we need to update the v1 spec data
sh scripts/sync-test-suite.sh

# This takes the wasm test suite data and generates Junit tests
# in src/test/java/com/dylibso/chicory/runtime/. Only need to be re-run
# If we are updating the specs or changing the code generator
ruby scripts/generate-java.rb
```

52 changes: 30 additions & 22 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.dylibso.chickory</groupId>
<artifactId>chicory</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>chicory</name>
<url>http://www.example.com</url>
<packaging>pom</packaging>

<modules>
<module>test-gen-plugin</module>
<module>wasm</module>
<module>runtime</module>
</modules>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -24,12 +27,6 @@
<spotless.version>2.40.0</spotless.version>
</properties>

<modules>
<module>test-gen-plugin</module>
<module>wasm</module>
<module>runtime</module>
</modules>

<dependencyManagement>
<dependencies>
<dependency>
Expand All @@ -54,9 +51,9 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<release>${maven.compiler.target}</release>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<release>${maven.compiler.target}</release>
</configuration>
</plugin>
<plugin>
Expand All @@ -77,11 +74,11 @@
<formats>
<format>
<includes>
<include>**/src/main/java/**/*.java</include>
<include>**/src/test/java/**/*.java</include>
<include>*.md</include>
<include>.gitignore</include>
</includes>
<trimTrailingWhitespace/>
<endWithNewline/>
<trimTrailingWhitespace></trimTrailingWhitespace>
<endWithNewline></endWithNewline>
<indent>
<spaces>true</spaces>
<spacesPerTab>2</spacesPerTab>
Expand All @@ -93,18 +90,29 @@
<include>**/src/main/java/**/*.java</include>
<include>**/src/test/java/**/*.java</include>
</includes>
<importOrder />
<removeUnusedImports />
<googleJavaFormat>
<version>1.18.1</version>
<style>AOSP</style>
<reflowLongStrings>true</reflowLongStrings>
<formatJavadoc>false</formatJavadoc>
</googleJavaFormat>
<importOrder></importOrder>
<removeUnusedImports></removeUnusedImports>
</java>
<pom>
<includes>
<include>**/pom.xml</include>
</includes>
<sortPom></sortPom>
</pom>
</configuration>
<executions>
<execution>
<id>format</id>
<phase>process-sources</phase>
<goals>
<goal>check</goal>
<goal>apply</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>
Expand Down
32 changes: 12 additions & 20 deletions runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -18,41 +15,36 @@
<groupId>com.dylibso.chickory</groupId>
<artifactId>wasm</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>


<build>
<plugins>
<plugin>
<groupId>com.dylibso.chickory</groupId>
<artifactId>test-gen-plugin</artifactId>
<version>${project.version}</version>
<configuration>
<wastToProcess>i32.wast,
i64.wast,
return.wast</wastToProcess>
<excludedTests>SpecV1ReturnTest.test6,
SpecV1ReturnTest.test7,
SpecV1ReturnTest.test9,
SpecV1ReturnTest.test49,
SpecV1ReturnTest.test55</excludedTests>
</configuration>
<executions>
<execution>
<goals>
<goal>wasm-test-gen</goal>
</goals>
</execution>
</executions>
<configuration>
<wastToProcess>
i32.wast,
i64.wast,
return.wast
</wastToProcess>
<excludedTests>
SpecV1ReturnTest.test6,
SpecV1ReturnTest.test7,
SpecV1ReturnTest.test9,
SpecV1ReturnTest.test49,
SpecV1ReturnTest.test55
</excludedTests>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
73 changes: 38 additions & 35 deletions runtime/src/main/java/com/dylibso/chicory/runtime/HostFunction.java
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
package com.dylibso.chicory.runtime;

import com.dylibso.chicory.wasm.types.ValueType;

import java.util.List;

public class HostFunction {
private final WasmFunctionHandle handle;
private final String moduleName;
private final String fieldName;
private final List<ValueType> paramTypes;
private final List<ValueType> returnTypes;

HostFunction(WasmFunctionHandle handle, String moduleName, String fieldName, List<ValueType> paramTypes, List<ValueType> returnTypes) {
this.handle = handle;
this.moduleName = moduleName;
this.fieldName = fieldName;
this.paramTypes = paramTypes;
this.returnTypes = returnTypes;
}

public WasmFunctionHandle getHandle() {
return handle;
}

public String getModuleName() {
return moduleName;
}

public String getFieldName() {
return fieldName;
}

public List<ValueType> getParamTypes() {
return paramTypes;
}

public List<ValueType> getReturnTypes() {
return returnTypes;
}

private final WasmFunctionHandle handle;
private final String moduleName;
private final String fieldName;
private final List<ValueType> paramTypes;
private final List<ValueType> returnTypes;

HostFunction(
WasmFunctionHandle handle,
String moduleName,
String fieldName,
List<ValueType> paramTypes,
List<ValueType> returnTypes) {
this.handle = handle;
this.moduleName = moduleName;
this.fieldName = fieldName;
this.paramTypes = paramTypes;
this.returnTypes = returnTypes;
}

public WasmFunctionHandle getHandle() {
return handle;
}

public String getModuleName() {
return moduleName;
}

public String getFieldName() {
return fieldName;
}

public List<ValueType> getParamTypes() {
return paramTypes;
}

public List<ValueType> getReturnTypes() {
return returnTypes;
}
}
24 changes: 11 additions & 13 deletions runtime/src/main/java/com/dylibso/chicory/runtime/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.dylibso.chicory.wasm.types.*;

import java.util.Arrays;

public class Instance {
private Module module;
private Machine machine;
Expand All @@ -13,17 +11,17 @@ public class Instance {
private Value[] globals;
private FunctionType[] types;
private int[] functionTypes;
private HostFunction[] imports;
private HostFunction[] imports;

public Instance(Module module,
Global[] globalInitalizers,
Value[] globals,
Memory memory,
FunctionBody[] functions,
FunctionType[] types,
int[] functionTypes,
HostFunction[] imports
) {
public Instance(
Module module,
Global[] globalInitalizers,
Value[] globals,
Memory memory,
FunctionBody[] functions,
FunctionType[] types,
int[] functionTypes,
HostFunction[] imports) {
this.module = module;
this.globalInitalizers = globalInitalizers;
this.globals = globals;
Expand All @@ -39,7 +37,7 @@ public ExportFunction getExport(String name) {
var export = module.getExport(name);
var funcId = (int) export.getDesc().getIndex();
return (args) -> {
//System.out.println("Args: " + Arrays.toString(args));
// System.out.println("Args: " + Arrays.toString(args));
try {
return machine.call(funcId, args, true);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.dylibso.chicory.runtime;
import com.dylibso.chicory.wasm.types.Value;

import com.dylibso.chicory.wasm.types.Value;
import java.util.Stack;


/**
* A temporary class that gives us a little more control over the interface.
* It allows us to assert non-nulls as well as throw stack under and overflow exceptions
Expand Down
Loading

0 comments on commit 2c64c71

Please sign in to comment.