mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 10:44:47 +01:00
pass compiler properties to the module writers
This commit is contained in:
parent
cd50b9c203
commit
a10d029e00
@ -48,6 +48,8 @@ public class JWebAssembly {
|
||||
|
||||
private final HashMap<String, String> properties = new HashMap<>();
|
||||
|
||||
public static final String DEBUG_NAMES = "DebugNames";
|
||||
|
||||
/**
|
||||
* Create a instance.
|
||||
*/
|
||||
@ -123,8 +125,8 @@ public class JWebAssembly {
|
||||
* if any conversion error occurs
|
||||
*/
|
||||
public void compileToText( File file ) throws WasmException {
|
||||
try (TextModuleWriter writer = new TextModuleWriter( new OutputStreamWriter( new FileOutputStream( file ), StandardCharsets.UTF_8 ) )) {
|
||||
compile( writer );
|
||||
try (OutputStreamWriter output = new OutputStreamWriter( new FileOutputStream( file ), StandardCharsets.UTF_8 )) {
|
||||
compileToText( output );
|
||||
} catch( Exception ex ) {
|
||||
throw WasmException.create( ex );
|
||||
}
|
||||
@ -139,7 +141,7 @@ public class JWebAssembly {
|
||||
* if any conversion error occurs
|
||||
*/
|
||||
public void compileToText( Appendable output ) throws WasmException {
|
||||
try (TextModuleWriter writer = new TextModuleWriter( output )) {
|
||||
try (TextModuleWriter writer = new TextModuleWriter( output, properties )) {
|
||||
compile( writer );
|
||||
} catch( Exception ex ) {
|
||||
throw WasmException.create( ex );
|
||||
@ -184,7 +186,7 @@ public class JWebAssembly {
|
||||
* if any conversion error occurs
|
||||
*/
|
||||
public void compileToBinary( OutputStream output ) throws WasmException {
|
||||
try (BinaryModuleWriter writer = new BinaryModuleWriter( output )) {
|
||||
try (BinaryModuleWriter writer = new BinaryModuleWriter( output, properties )) {
|
||||
compile( writer );
|
||||
} catch( Exception ex ) {
|
||||
throw WasmException.create( ex );
|
||||
|
@ -20,6 +20,7 @@ import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -28,6 +29,7 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.inetsoftware.classparser.ConstantRef;
|
||||
import de.inetsoftware.jwebassembly.JWebAssembly;
|
||||
import de.inetsoftware.jwebassembly.WasmException;
|
||||
import de.inetsoftware.jwebassembly.module.FunctionName;
|
||||
import de.inetsoftware.jwebassembly.module.ModuleWriter;
|
||||
@ -49,6 +51,8 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
|
||||
private WasmOutputStream wasm;
|
||||
|
||||
private final boolean debugNames;
|
||||
|
||||
private WasmOutputStream codeStream = new WasmOutputStream();
|
||||
|
||||
private WasmOutputStream functionsStream = new WasmOutputStream();
|
||||
@ -74,11 +78,14 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
*
|
||||
* @param output
|
||||
* the target for the module data.
|
||||
* @param properties
|
||||
* compiler properties
|
||||
* @throws IOException
|
||||
* if any I/O error occur
|
||||
*/
|
||||
public BinaryModuleWriter( OutputStream output ) throws IOException {
|
||||
public BinaryModuleWriter( OutputStream output, HashMap<String, String> properties ) throws IOException {
|
||||
wasm = new WasmOutputStream( output );
|
||||
debugNames = Boolean.parseBoolean( properties.get( JWebAssembly.DEBUG_NAMES ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@
|
||||
package de.inetsoftware.jwebassembly.text;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@ -53,10 +54,12 @@ public class TextModuleWriter extends ModuleWriter {
|
||||
*
|
||||
* @param output
|
||||
* target for the result
|
||||
* @param properties
|
||||
* compiler properties
|
||||
* @throws IOException
|
||||
* if any I/O error occur
|
||||
*/
|
||||
public TextModuleWriter( Appendable output ) throws IOException {
|
||||
public TextModuleWriter( Appendable output, HashMap<String, String> properties ) throws IOException {
|
||||
this.output = output;
|
||||
output.append( "(module" );
|
||||
inset++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user