diff --git a/.idea/misc.xml b/.idea/misc.xml index f1c67dfa..443605b5 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,7 @@ + + \ No newline at end of file diff --git a/include/lib.hpp b/include/lib.hpp index e3df285b..67da72e0 100644 --- a/include/lib.hpp +++ b/include/lib.hpp @@ -275,6 +275,10 @@ namespace encoding { } +namespace regex { + void match(WrenVM* vm); + void contains(WrenVM* vm); +} } // namespace lib diff --git a/include/vm.hpp b/include/vm.hpp index 8b2734e0..38eef5b0 100644 --- a/include/vm.hpp +++ b/include/vm.hpp @@ -5,6 +5,14 @@ #include #include +#ifndef NDEBUG + #include + #define DEBUG_PRINT(...) std::cout << rang::fg::blue << "DEBUG " << rang::fg::reset << __VA_ARGS__ << std::endl; +#else + #define DEBUG_PRINT(...) +#endif + + namespace vm { size_t createVmMap(WrenVM* vm, const int& slot, const std::unordered_map& entries); diff --git a/src/vm/config.cpp b/src/vm/config.cpp index 0f1d21cc..c19ed2ae 100644 --- a/src/vm/config.cpp +++ b/src/vm/config.cpp @@ -2,7 +2,6 @@ #include "vm.hpp" #include -#include #include #include #include @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -149,13 +149,10 @@ static void errorFn(WrenVM* vm, const WrenErrorType errorType, const char* modul } else { std::cerr << rang::fg::red << "Error: " << rang::fg::reset << msg << std::endl; if (std::getenv("FAN_LIB") == nullptr) { - std::cerr << rang::fg::blue << "\nHELP: " << rang::fg::reset - << "Fan requires the " << rang::fg::yellow << "FAN_LIB " << rang::fg::reset - << "environment variable to be set with the path to Fan's standard library.\n" - << "This is typically found in the " << rang::fg::yellow << "lang/ " << rang::fg::reset - << "directory included in your installation.\n\n" - << "export FAN_LIB=\"" << rang::fg::yellow << "/fake/path/to/replace" - << rang::fg::reset << "/fan/lang\"" << std::endl; + std::cerr << rang::fg::blue << "\nHELP: " << rang::fg::reset << "Fan requires the " << rang::fg::yellow << "FAN_LIB " << rang::fg::reset + << "environment variable to be set with the path to Fan's standard library.\n" + << "This is typically found in the " << rang::fg::yellow << "lang/ " << rang::fg::reset << "directory included in your installation.\n\n" + << "export FAN_LIB=\"" << rang::fg::yellow << "/fake/path/to/replace" << rang::fg::reset << "/fan/lang\"" << std::endl; } } // Need to find a way to keep track of user source to print actual file name. @@ -419,10 +416,18 @@ WrenForeignMethodFn bindForeignMethodFn(WrenVM* vm, const char* module, const ch return lib::encoding::md_to_html; } } + } - // if (std::strcmp(className, "JSON") == 0) { - // - // } + if (std::strcmp(module, "std/regex") == 0) { + if (std::strcmp(className, "Regex") == 0) { + if (isStatic && std::strcmp(signature, "match(_,_,_)") == 0) { + return lib::regex::match; + } + + if (isStatic && std::strcmp(signature, "contains(_,_,_)") == 0) { + return lib::regex::contains; + } + } } return nullptr;