mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
More normalize of names for SpiderMonkey
This commit is contained in:
parent
2cf6214d56
commit
efa65bb377
@ -79,6 +79,9 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
debugNames = Boolean.parseBoolean( properties.get( JWebAssembly.DEBUG_NAMES ) );
|
debugNames = Boolean.parseBoolean( properties.get( JWebAssembly.DEBUG_NAMES ) );
|
||||||
output.append( "(module" );
|
output.append( "(module" );
|
||||||
inset++;
|
inset++;
|
||||||
|
if( spiderMonkey ) {
|
||||||
|
output.append( " (gc_feature_opt_in 3)" ); // enable GcFeatureOptIn for SpiderMonkey https://github.com/lars-t-hansen/moz-gc-experiments/blob/master/version2.md
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,7 +103,7 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
int oldInset = inset;
|
int oldInset = inset;
|
||||||
inset = 1;
|
inset = 1;
|
||||||
newline( output );
|
newline( output );
|
||||||
output.append( "(type $" ).append( typeName ).append( " (struct" );
|
output.append( "(type $" ).append( normalizeName( typeName ) ).append( " (struct" );
|
||||||
inset++;
|
inset++;
|
||||||
for( NamedStorageType field : fields ) {
|
for( NamedStorageType field : fields ) {
|
||||||
newline( output );
|
newline( output );
|
||||||
@ -113,7 +116,7 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
if( type.getCode() < 0 ) {
|
if( type.getCode() < 0 ) {
|
||||||
output.append( type.toString() );
|
output.append( type.toString() );
|
||||||
} else {
|
} else {
|
||||||
output.append( "(ref " ).append( type.toString() ).append( ')' );
|
output.append( "(ref " ).append( normalizeName( type.toString() ) ).append( ')' );
|
||||||
}
|
}
|
||||||
output.append( "))" );
|
output.append( "))" );
|
||||||
}
|
}
|
||||||
@ -160,11 +163,22 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private String normalizeName( FunctionName name ) {
|
private String normalizeName( FunctionName name ) {
|
||||||
String fullName = name.fullName;
|
return normalizeName( name.fullName );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize the function name for the text format
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the name
|
||||||
|
* @return the normalized name
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
private String normalizeName( String name ) {
|
||||||
if( spiderMonkey ) {
|
if( spiderMonkey ) {
|
||||||
fullName = fullName.replace( '/', '.' ); // TODO HACK for https://bugzilla.mozilla.org/show_bug.cgi?id=1511485
|
name = name.replace( '/', '.' ).replace( '<', '_' ).replace( '>', '_' ); // TODO HACK for https://bugzilla.mozilla.org/show_bug.cgi?id=1511485
|
||||||
}
|
}
|
||||||
return fullName;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,7 +216,7 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
methodParamNames.add( name );
|
methodParamNames.add( name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
methodOutput.append( ' ' ).append( valueType.toString() ).append( ')' );
|
methodOutput.append( ' ' ).append( normalizeName( valueType.toString() ) ).append( ')' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,11 +320,11 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
op += "_s";
|
op += "_s";
|
||||||
break;
|
break;
|
||||||
case ifnonnull:
|
case ifnonnull:
|
||||||
methodOutput.append( "ref.isnull" );
|
methodOutput.append( "ref.is_null" );
|
||||||
writeNumericOperator( NumericOperator.eqz, ValueType.i32 );
|
writeNumericOperator( NumericOperator.eqz, ValueType.i32 );
|
||||||
return;
|
return;
|
||||||
case ifnull:
|
case ifnull:
|
||||||
methodOutput.append( "ref.isnull" );
|
methodOutput.append( "ref.is_null" );
|
||||||
return;
|
return;
|
||||||
case ref_ne:
|
case ref_ne:
|
||||||
methodOutput.append( "ref.eq" );
|
methodOutput.append( "ref.eq" );
|
||||||
@ -550,7 +564,7 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
newline( methodOutput );
|
newline( methodOutput );
|
||||||
methodOutput.append( operation );
|
methodOutput.append( operation );
|
||||||
if( type != null ) {
|
if( type != null ) {
|
||||||
methodOutput.append( ' ' ).append( type );
|
methodOutput.append( ' ' ).append( normalizeName( type.toString() ) );
|
||||||
}
|
}
|
||||||
if( fieldName != null ) {
|
if( fieldName != null ) {
|
||||||
methodOutput.append( " $" ).append( fieldName );
|
methodOutput.append( " $" ).append( fieldName );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user