From c2e6fe8a13d4a4de4971bd68e34034e29f8ccebc Mon Sep 17 00:00:00 2001 From: Nathanne Isip Date: Sat, 30 Nov 2024 07:34:14 +0800 Subject: [PATCH] Updated UseStatement class implementation for Emscripten target. --- src/n8/ast/statement/UseStatement.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/n8/ast/statement/UseStatement.cpp b/src/n8/ast/statement/UseStatement.cpp index 34a8718..ba4ab71 100644 --- a/src/n8/ast/statement/UseStatement.cpp +++ b/src/n8/ast/statement/UseStatement.cpp @@ -20,6 +20,7 @@ #include #include #include +#include DynamicObject UseStatement::visit( SymbolTable& symbols @@ -27,12 +28,20 @@ DynamicObject UseStatement::visit( __attribute__((unused)) #endif ) { + #ifndef __EMSCRIPTEN__ DynamicObject libName = this->libraryName->visit(symbols), libVer = this->libraryVersion->visit(symbols); std::string lName = libName.toString(), lVersion = libVer.toString(); + if(!N8Util::SemVer::validateSemVer(lVersion)) + throw ASTNodeException( + std::move(address), + "Invalid semantic version '" + lVersion + + "' for library " + lName + ); + if(!N8Util::PathHelper::isLibraryInstalled( lName, lVersion )) throw ASTNodeException( @@ -45,6 +54,12 @@ DynamicObject UseStatement::visit( lName, lVersion )); + #else + throw ASTNodeException( + std::move(address), + "The 'use' statement is not allowed on WebAssembly build type." + ); + #endif return DynamicObject(); }