write string constant in the text format for easer reading

This commit is contained in:
Volker Berlin 2020-03-22 12:36:01 +01:00
parent 548d701444
commit b3bef1570a
3 changed files with 5 additions and 4 deletions

View File

@ -90,6 +90,7 @@ public class StringManager extends LinkedHashMap<String, Integer> {
}
};
functions.markAsNeededAndReplaceIfExists( offsetFunction );
functions.markAsNeeded( STRING_CONSTANT_FUNCTION );
}
return STRING_CONSTANT_FUNCTION;

View File

@ -398,7 +398,7 @@ public abstract class WasmCodeBuilder {
Integer id = strings.get( value );
FunctionName name = strings.getStringConstantFunction();
instructions.add( new WasmConstInstruction( id, ValueType.i32, javaCodePos, lineNumber ) );
instructions.add( new WasmCallInstruction( name, javaCodePos, lineNumber, types, false, "\"" + value + "\"" ) );
instructions.add( new WasmCallInstruction( name, javaCodePos, lineNumber, types, false, (String)value ) );
} else if( value instanceof Number ) {
instructions.add( new WasmConstInstruction( (Number)value, javaCodePos, lineNumber ) );
} else if( value instanceof ConstantClass ) {

View File

@ -685,11 +685,11 @@ public class TextModuleWriter extends ModuleWriter {
* {@inheritDoc}
*/
@Override
protected void writeFunctionCall( FunctionName name, String comments ) throws IOException {
protected void writeFunctionCall( FunctionName name, String comment ) throws IOException {
newline( methodOutput );
methodOutput.append( "call $" ).append( normalizeName( name ) );
if( comments != null ) {
methodOutput.append( ") ;; " ).append( comments );
if( comment != null ) {
methodOutput.append( " ;; \"" ).append( comment.replace( "\n", "\\n" ).replace( "\r", "\\r" ) ).append( '"' );
}
}