mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 10:44:47 +01:00
Class replacement need also StringManager.stringsMemoryOffset.
This commit is contained in:
parent
d3e3c4ff5d
commit
386c5adf28
@ -124,6 +124,21 @@ class FunctionManager {
|
||||
getOrCreate( name ).state = State.Written;
|
||||
}
|
||||
|
||||
/**
|
||||
* Same like markAsNeeded but it will replace the function name if already registered.
|
||||
*
|
||||
* @param name
|
||||
* the function name
|
||||
*/
|
||||
void markAsNeededAndReplaceIfExists( SyntheticFunctionName name ) {
|
||||
FunctionState state = states.get( name );
|
||||
if( state != null ) {
|
||||
states.remove( name );
|
||||
states.put( name, state );
|
||||
}
|
||||
markAsNeeded( name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a function as used/called and return the real name if there is an alias.
|
||||
*
|
||||
|
@ -474,6 +474,7 @@ public class ModuleGenerator {
|
||||
} else {
|
||||
FunctionName name = new FunctionName( method );
|
||||
if( "java/lang/Class.typeTableMemoryOffset()I".equals( name.signatureName ) ) {
|
||||
strings.getStringConstantFunction(); // we will need also the string constant function for the Class Name, in the other case a program with only new Object().getClass().getName() will fail to compile
|
||||
return types.getTypeTableMemoryOffsetFunctionName().getCodeBuilder( watParser );
|
||||
}
|
||||
throw new WasmException( "Abstract or native method can not be used: " + name.signatureName, -1 );
|
||||
|
@ -83,13 +83,13 @@ public class StringManager extends LinkedHashMap<String, Integer> {
|
||||
if( stringMemoryOffset < 0 ) {
|
||||
// register the function stringsMemoryOffset() as synthetic function
|
||||
stringMemoryOffset = 0;
|
||||
FunctionName offsetFunction =
|
||||
WatCodeSyntheticFunctionName offsetFunction =
|
||||
new WatCodeSyntheticFunctionName( "de/inetsoftware/jwebassembly/module/StringManager", "stringsMemoryOffset", "()I", "", null, ValueType.i32 ) {
|
||||
protected String getCode() {
|
||||
return "i32.const " + stringMemoryOffset;
|
||||
}
|
||||
};
|
||||
functions.markAsNeeded( offsetFunction );
|
||||
functions.markAsNeededAndReplaceIfExists( offsetFunction );
|
||||
}
|
||||
|
||||
return STRING_CONSTANT_FUNCTION;
|
||||
|
Loading…
x
Reference in New Issue
Block a user