mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
API doc
This commit is contained in:
parent
69b8db16d1
commit
c44e24c373
@ -141,7 +141,16 @@ class StaticCodeBuilder {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScanState scan( FunctionName name, LinkedHashMap<String,FunctionName> constructors ) {
|
/**
|
||||||
|
* Scan for for references to other classes
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the name of the static constructor (class initializer)
|
||||||
|
* @param constructors
|
||||||
|
* all static constructors which have references or was not scanned
|
||||||
|
* @return the reference state
|
||||||
|
*/
|
||||||
|
private ScanState scan( FunctionName name, LinkedHashMap<String, FunctionName> constructors ) {
|
||||||
ScanState state = null;
|
ScanState state = null;
|
||||||
String className = name.className;
|
String className = name.className;
|
||||||
String sourceFile = null;
|
String sourceFile = null;
|
||||||
@ -195,12 +204,11 @@ class StaticCodeBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan a class initializer (static constructor). If it references another class with a static constructor which was
|
* Patch static constructor (class initializer)
|
||||||
* not called before then it patch the code and call it before the other class is access.
|
|
||||||
*
|
*
|
||||||
* @param name
|
* @param scan
|
||||||
* name of the static constructor
|
* the current scan
|
||||||
* @param queue
|
* @param scans
|
||||||
* a list with all static constructors which was not called
|
* a list with all static constructors which was not called
|
||||||
*/
|
*/
|
||||||
private void patch( ScanState scan, LinkedHashMap<String, ScanState> scans ) {
|
private void patch( ScanState scan, LinkedHashMap<String, ScanState> scans ) {
|
||||||
@ -230,10 +238,11 @@ class StaticCodeBuilder {
|
|||||||
continue; // field or method in own class
|
continue; // field or method in own class
|
||||||
}
|
}
|
||||||
|
|
||||||
// search if the other class has a static constructor
|
// search if the other class has a static constructor (class initializer)
|
||||||
ScanState otherScan = scans.remove( otherClassName );
|
ScanState otherScan = scans.remove( otherClassName );
|
||||||
|
//TODO if there references in other branches then it is not called because removed
|
||||||
if( otherScan != null ) {
|
if( otherScan != null ) {
|
||||||
// add a call to the other static consturctor
|
// add a call to the other static constructor (class initializer)
|
||||||
instructions.add( i, new WasmCallInstruction( otherScan.name, instr.getCodePosition(), instr.getLineNumber(), options.types, false ) );
|
instructions.add( i, new WasmCallInstruction( otherScan.name, instr.getCodePosition(), instr.getLineNumber(), options.types, false ) );
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
@ -248,6 +257,7 @@ class StaticCodeBuilder {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected WasmCodeBuilder getCodeBuilder( WatParser watParser ) {
|
protected WasmCodeBuilder getCodeBuilder( WatParser watParser ) {
|
||||||
WasmCodeBuilder codebuilder = watParser;
|
WasmCodeBuilder codebuilder = watParser;
|
||||||
watParser.reset( null, null, null );
|
watParser.reset( null, null, null );
|
||||||
|
@ -30,12 +30,16 @@ import de.inetsoftware.jwebassembly.wasm.ValueType;
|
|||||||
*/
|
*/
|
||||||
public class WasmOptions {
|
public class WasmOptions {
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
final FunctionManager functions = new FunctionManager();
|
final FunctionManager functions = new FunctionManager();
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public final TypeManager types = new TypeManager( this );
|
public final TypeManager types = new TypeManager( this );
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public final StringManager strings = new StringManager( this );
|
public final StringManager strings = new StringManager( this );
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
final CodeOptimizer optimizer = new CodeOptimizer();
|
final CodeOptimizer optimizer = new CodeOptimizer();
|
||||||
|
|
||||||
private final boolean debugNames;
|
private final boolean debugNames;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user