mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
write the class name of all classes in the wasm file for later use
This commit is contained in:
parent
62b16ac07e
commit
5eed2c2e79
@ -57,6 +57,21 @@ class StringManager extends LinkedHashMap<String, Integer> {
|
||||
this.functions = options.functions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the positive id for the string.
|
||||
*
|
||||
* @param str
|
||||
* the string
|
||||
* @return the id
|
||||
*/
|
||||
public Integer get( @Nonnull Object str ) {
|
||||
Integer id = super.get( str );
|
||||
if( id == null ) {
|
||||
put( (String)str, id = size() );
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the function name object for the {@link #stringConstant(int)}.
|
||||
*
|
||||
|
@ -57,7 +57,7 @@ public class TypeManager {
|
||||
* <li>offset of interface call table (itable)
|
||||
* <li>offset of instanceof list
|
||||
*/
|
||||
private static final int VTABLE_FIRST_FUNCTION_INDEX = 2;
|
||||
private static final int VTABLE_FIRST_FUNCTION_INDEX = 3;
|
||||
|
||||
private Map<String, StructType> structTypes = new LinkedHashMap<>();
|
||||
|
||||
@ -220,7 +220,7 @@ public class TypeManager {
|
||||
*
|
||||
* @author Volker Berlin
|
||||
*/
|
||||
public static class StructType implements AnyType {
|
||||
public class StructType implements AnyType {
|
||||
|
||||
private final String name;
|
||||
|
||||
@ -446,6 +446,9 @@ public class TypeManager {
|
||||
data.writeInt32( type.getClassIndex() );
|
||||
}
|
||||
|
||||
int classNameIdx = options.strings.get( getName().replace( '/', '.' ) );
|
||||
header.writeInt32( classNameIdx ); // string id of the className
|
||||
|
||||
data.writeTo( dataStream );
|
||||
}
|
||||
|
||||
|
@ -395,9 +395,6 @@ public abstract class WasmCodeBuilder {
|
||||
protected void addConstInstruction( Object value, int javaCodePos, int lineNumber ) {
|
||||
if( value.getClass() == String.class ) {
|
||||
Integer id = strings.get( value );
|
||||
if( id == null ) {
|
||||
strings.put( (String)value, id = strings.size() );
|
||||
}
|
||||
FunctionName name = strings.getStringConstantFunction();
|
||||
instructions.add( new WasmConstInstruction( id, ValueType.i32, javaCodePos, lineNumber ) );
|
||||
addCallInstruction( name, javaCodePos, lineNumber );
|
||||
|
Loading…
x
Reference in New Issue
Block a user