Skip to content

Commit 5f0c24f

Browse files
VolkerVolker
authored andcommitted
Fix "import" in the text format
1 parent 80a8b5d commit 5f0c24f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/de/inetsoftware/jwebassembly/text/TextModuleWriter.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public class TextModuleWriter extends ModuleWriter {
4444

4545
private int inset;
4646

47+
private boolean isImport;
48+
4749
private HashSet<String> globals = new HashSet<>();
4850

4951
/**
@@ -77,7 +79,8 @@ public void close() throws IOException {
7779
protected void prepareImport( FunctionName name, String importModule, String importName ) throws IOException {
7880
if( importName != null ) {
7981
newline( output );
80-
output.append( "(import \"" ).append( importModule ).append( "\" \"" ).append( importName ).append( "\" (func $" ).append( name.fullName ).append( "))" );
82+
output.append( "(import \"" ).append( importModule ).append( "\" \"" ).append( importName ).append( "\" (func $" ).append( name.fullName );
83+
isImport = true;
8184
}
8285
}
8386

@@ -114,7 +117,12 @@ protected void writeMethodParam( String kind, ValueType valueType ) throws IOExc
114117
* {@inheritDoc}
115118
*/
116119
@Override
117-
protected void writeMethodParamFinish() throws IOException {}
120+
protected void writeMethodParamFinish() throws IOException {
121+
if( isImport ) {
122+
isImport = false;
123+
output.append( "))" );
124+
}
125+
}
118126

119127
/**
120128
* {@inheritDoc}

0 commit comments

Comments
 (0)