mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 15:37:52 +01:00
pass the compiler properties to sub classes
This commit is contained in:
parent
9faeb626a9
commit
5883adc2af
@ -320,7 +320,7 @@ public class JWebAssembly {
|
|||||||
* if any conversion error occurs
|
* if any conversion error occurs
|
||||||
*/
|
*/
|
||||||
private void compile( ModuleWriter writer, WasmTarget target ) throws IOException, WasmException {
|
private void compile( ModuleWriter writer, WasmTarget target ) throws IOException, WasmException {
|
||||||
ModuleGenerator generator = new ModuleGenerator( writer, target, libraries );
|
ModuleGenerator generator = new ModuleGenerator( writer, target, libraries, properties );
|
||||||
for( URL url : classFiles ) {
|
for( URL url : classFiles ) {
|
||||||
ClassFile classFile = new ClassFile( new BufferedInputStream( url.openStream() ) );
|
ClassFile classFile = new ClassFile( new BufferedInputStream( url.openStream() ) );
|
||||||
generator.prepare( classFile );
|
generator.prepare( classFile );
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package de.inetsoftware.jwebassembly.module;
|
package de.inetsoftware.jwebassembly.module;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -44,6 +45,16 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
|
|||||||
|
|
||||||
private BranchManger branchManager = new BranchManger( getInstructions() );
|
private BranchManger branchManager = new BranchManger( getInstructions() );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new code builder.
|
||||||
|
*
|
||||||
|
* @param properties
|
||||||
|
* compiler properties
|
||||||
|
*/
|
||||||
|
public JavaMethodWasmCodeBuilder( HashMap<String, String> properties ) {
|
||||||
|
super( properties );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the wasm instructions
|
* Build the wasm instructions
|
||||||
*
|
*
|
||||||
|
@ -22,6 +22,7 @@ import java.net.URL;
|
|||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -59,9 +60,9 @@ public class ModuleGenerator {
|
|||||||
|
|
||||||
private final URLClassLoader libraries;
|
private final URLClassLoader libraries;
|
||||||
|
|
||||||
private final JavaMethodWasmCodeBuilder javaCodeBuilder = new JavaMethodWasmCodeBuilder();
|
private final JavaMethodWasmCodeBuilder javaCodeBuilder;
|
||||||
|
|
||||||
private final WatParser watParser = new WatParser();
|
private final WatParser watParser;
|
||||||
|
|
||||||
private String sourceFile;
|
private String sourceFile;
|
||||||
|
|
||||||
@ -82,8 +83,12 @@ public class ModuleGenerator {
|
|||||||
* the target for the module data
|
* the target for the module data
|
||||||
* @param libraries
|
* @param libraries
|
||||||
* libraries
|
* libraries
|
||||||
|
* @param properties
|
||||||
|
* compiler properties
|
||||||
*/
|
*/
|
||||||
public ModuleGenerator( @Nonnull ModuleWriter writer, WasmTarget target, @Nonnull List<URL> libraries ) {
|
public ModuleGenerator( @Nonnull ModuleWriter writer, WasmTarget target, @Nonnull List<URL> libraries, HashMap<String, String> properties ) {
|
||||||
|
this.javaCodeBuilder = new JavaMethodWasmCodeBuilder( properties );
|
||||||
|
this.watParser = new WatParser( properties );
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
this.javaScript = new JavaScriptWriter( target );
|
this.javaScript = new JavaScriptWriter( target );
|
||||||
this.libraries = new URLClassLoader( libraries.toArray( new URL[libraries.size()] ) );
|
this.libraries = new URLClassLoader( libraries.toArray( new URL[libraries.size()] ) );
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package de.inetsoftware.jwebassembly.module;
|
package de.inetsoftware.jwebassembly.module;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nonnegative;
|
import javax.annotation.Nonnegative;
|
||||||
@ -48,6 +49,15 @@ public abstract class WasmCodeBuilder {
|
|||||||
|
|
||||||
private TypeManager types;
|
private TypeManager types;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new code builder.
|
||||||
|
*
|
||||||
|
* @param properties
|
||||||
|
* compiler properties
|
||||||
|
*/
|
||||||
|
public WasmCodeBuilder( HashMap<String, String> properties ) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of instructions
|
* Get the list of instructions
|
||||||
*
|
*
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package de.inetsoftware.jwebassembly.watparser;
|
package de.inetsoftware.jwebassembly.watparser;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nonnegative;
|
import javax.annotation.Nonnegative;
|
||||||
@ -37,6 +38,16 @@ import de.inetsoftware.jwebassembly.wasm.WasmBlockOperator;
|
|||||||
*/
|
*/
|
||||||
public class WatParser extends WasmCodeBuilder {
|
public class WatParser extends WasmCodeBuilder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new code builder.
|
||||||
|
*
|
||||||
|
* @param properties
|
||||||
|
* compiler properties
|
||||||
|
*/
|
||||||
|
public WatParser( HashMap<String, String> properties ) {
|
||||||
|
super( properties );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the given wasm text format and generate a list of WasmInstuctions
|
* Parse the given wasm text format and generate a list of WasmInstuctions
|
||||||
*
|
*
|
||||||
|
@ -36,7 +36,7 @@ import de.inetsoftware.jwebassembly.watparser.WatParser;
|
|||||||
public class WatParserTest {
|
public class WatParserTest {
|
||||||
|
|
||||||
private void test( String wat ) throws IOException {
|
private void test( String wat ) throws IOException {
|
||||||
WatParser parser = new WatParser();
|
WatParser parser = new WatParser( new HashMap<>() );
|
||||||
parser.parse( wat, 100 );
|
parser.parse( wat, 100 );
|
||||||
WasmCodeBuilder codeBuilder = parser;
|
WasmCodeBuilder codeBuilder = parser;
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user