From 20d2b7f44ef6d944c76012f3cac5f32f11a39fb4 Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Thu, 8 Aug 2019 17:47:57 +0200 Subject: [PATCH] improve error messages --- .../jwebassembly/module/ModuleGenerator.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java index 1e865e2..4ea7ef9 100644 --- a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java +++ b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java @@ -216,11 +216,17 @@ public class ModuleGenerator { functions.markAsWritten( name ); Map importAnannotation = functions.getImportAnannotation( name ); - String impoarModule = (String)importAnannotation.get( "module" ); + String importModule = (String)importAnannotation.get( "module" ); + if( importModule == null || importModule.isEmpty() ) { + throw new WasmException( "Module not set for import function: " + name.signatureName, -1 ); + } String importName = (String)importAnannotation.get( "name" ); - writer.prepareImport( name, impoarModule, importName ); + if( importName == null || importName.isEmpty() ) { + throw new WasmException( "Name not set for import function: " + name.signatureName, -1 ); + } + writer.prepareImport( name, importModule, importName ); writeMethodSignature( name, true, null ); - javaScript.addImport( impoarModule, importName, importAnannotation ); + javaScript.addImport( importModule, importName, importAnannotation ); } // init/write the function types @@ -404,7 +410,9 @@ public class ModuleGenerator { private WasmCodeBuilder createInstructions( MethodInfo method ) throws IOException { Code code = null; try { - if( method.getAnnotation( JWebAssembly.IMPORT_ANNOTATION ) != null ) { + Map annotationValues; + if( (annotationValues = method.getAnnotation( JWebAssembly.IMPORT_ANNOTATION )) != null ) { + functions.markAsImport( new FunctionName( method ), annotationValues ); return null; } code = method.getCode();