improve error message

This commit is contained in:
Volker Berlin 2020-02-25 14:57:11 +01:00
parent 2f2c39a07a
commit 742eb6e128

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 - 2019 Volker Berlin (i-net software) Copyright 2018 - 2020 Volker Berlin (i-net software)
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -202,15 +202,19 @@ public class WatParser extends WasmCodeBuilder {
addTableInstruction( false, getInt( tokens, ++i), javaCodePos, lineNumber ); addTableInstruction( false, getInt( tokens, ++i), javaCodePos, lineNumber );
break; break;
case "call": case "call":
StringBuilder builder = new StringBuilder( get( tokens, ++i ) ); try {
String str; StringBuilder builder = new StringBuilder( get( tokens, ++i ) );
do { String str;
str = get( tokens, ++i ); do {
builder.append( str ); str = get( tokens, ++i );
} while ( !")".equals( str ) ); builder.append( str );
builder.append( get( tokens, ++i ) ); } while ( !")".equals( str ) );
FunctionName name = new FunctionName( builder.substring( 1 ) ); builder.append( get( tokens, ++i ) );
addCallInstruction( name, javaCodePos, lineNumber ); FunctionName name = new FunctionName( builder.substring( 1 ) );
addCallInstruction( name, javaCodePos, lineNumber );
} catch( Exception ex ) {
throw new WasmException( "The syntax for a function name is $package.ClassName.methodName(paramSignature)returnSignature", lineNumber );
}
break; break;
case "return": case "return":
addBlockInstruction( WasmBlockOperator.RETURN, null, javaCodePos, lineNumber ); addBlockInstruction( WasmBlockOperator.RETURN, null, javaCodePos, lineNumber );