mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
Only ASCII strings as comment
This commit is contained in:
parent
fd27656b65
commit
7eb0406db8
@ -458,7 +458,11 @@ 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, (String)value ) );
|
||||
String comment = (String)value;
|
||||
if( !isAscii( comment ) ) {
|
||||
comment = null;
|
||||
}
|
||||
instructions.add( new WasmCallInstruction( name, javaCodePos, lineNumber, types, false, comment ) );
|
||||
} else if( value instanceof Number ) {
|
||||
instructions.add( new WasmConstInstruction( (Number)value, javaCodePos, lineNumber ) );
|
||||
} else if( value instanceof ConstantClass ) {
|
||||
@ -473,6 +477,25 @@ public abstract class WasmCodeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if the string contains only ASCCI characters
|
||||
*
|
||||
* @param str
|
||||
* the staring
|
||||
* @return true, if only ASCII
|
||||
*/
|
||||
private static boolean isAscii( String str ) {
|
||||
int length = str.length();
|
||||
for( int i = 0; i < length; i++ ) {
|
||||
int c = str.charAt( i );
|
||||
if( c >= 0x20 && c < 0x7F ) {
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a numeric operation instruction
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user