mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
share the LocaleVariableManager between multiple WasmCodeBuilder
This commit is contained in:
parent
9680ba6445
commit
3fd3c63351
@ -50,6 +50,16 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
|
|||||||
|
|
||||||
private BranchManager branchManager;
|
private BranchManager branchManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance
|
||||||
|
*
|
||||||
|
* @param codeBuilder
|
||||||
|
* other code builder for shred references
|
||||||
|
*/
|
||||||
|
JavaMethodWasmCodeBuilder( @Nonnull WasmCodeBuilder codeBuilder ) {
|
||||||
|
super( codeBuilder );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -91,8 +91,8 @@ public class ModuleGenerator {
|
|||||||
* libraries
|
* libraries
|
||||||
*/
|
*/
|
||||||
public ModuleGenerator( @Nonnull ModuleWriter writer, WasmTarget target, @Nonnull List<URL> libraries ) {
|
public ModuleGenerator( @Nonnull ModuleWriter writer, WasmTarget target, @Nonnull List<URL> libraries ) {
|
||||||
this.javaCodeBuilder = new JavaMethodWasmCodeBuilder();
|
|
||||||
this.watParser = new WatParser();
|
this.watParser = new WatParser();
|
||||||
|
this.javaCodeBuilder = new JavaMethodWasmCodeBuilder( watParser );
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
this.javaScript = new JavaScriptWriter( target );
|
this.javaScript = new JavaScriptWriter( target );
|
||||||
this.classFileLoader = new ClassFileLoader( new URLClassLoader( libraries.toArray( new URL[libraries.size()] ) ) );
|
this.classFileLoader = new ClassFileLoader( new URLClassLoader( libraries.toArray( new URL[libraries.size()] ) ) );
|
||||||
|
@ -57,9 +57,9 @@ import de.inetsoftware.jwebassembly.wasm.WasmBlockOperator;
|
|||||||
*/
|
*/
|
||||||
public abstract class WasmCodeBuilder {
|
public abstract class WasmCodeBuilder {
|
||||||
|
|
||||||
private final LocaleVariableManager localVariables = new LocaleVariableManager();
|
private final LocaleVariableManager localVariables;
|
||||||
|
|
||||||
private final List<WasmInstruction> instructions = new ArrayList<>();
|
private final List<WasmInstruction> instructions;
|
||||||
|
|
||||||
private TypeManager types;
|
private TypeManager types;
|
||||||
|
|
||||||
@ -71,6 +71,25 @@ public abstract class WasmCodeBuilder {
|
|||||||
|
|
||||||
private ClassFileLoader classFileLoader;
|
private ClassFileLoader classFileLoader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance of CodeBuilder
|
||||||
|
*/
|
||||||
|
protected WasmCodeBuilder() {
|
||||||
|
localVariables = new LocaleVariableManager();
|
||||||
|
instructions = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance with shared resources
|
||||||
|
*
|
||||||
|
* @param codeBuilder
|
||||||
|
* other instance of CodeBuilder
|
||||||
|
*/
|
||||||
|
WasmCodeBuilder( @Nonnull WasmCodeBuilder codeBuilder ) {
|
||||||
|
localVariables = codeBuilder.localVariables;
|
||||||
|
instructions = codeBuilder.instructions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the code builder;
|
* Initialize the code builder;
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user