diff --git a/source/Base/ScriptSrc.cpp b/source/Base/ScriptSrc.cpp index 209b1b49..0e0ad54f 100644 --- a/source/Base/ScriptSrc.cpp +++ b/source/Base/ScriptSrc.cpp @@ -136,27 +136,31 @@ void ScriptSrc::Process() { mLine.push_back(line); } + // Specify that this script contains line information + mInfo = true; } // ------------------------------------------------------------------------------------------------ -ScriptSrc::ScriptSrc(HSQUIRRELVM vm, const String & path, bool info) +ScriptSrc::ScriptSrc(HSQUIRRELVM vm, String && path, bool delay, bool info) : mExec(vm) - , mPath(path) + , mPath(std::move(path)) , mData() , mLine() + , mInfo(info) + , mDelay(delay) { - // Is the specified path empty? - if (mPath.empty()) - { - throw std::runtime_error("Invalid or empty script path"); - } // Is the specified virtual machine invalid? - else if (!vm) + if (!vm) { throw std::runtime_error("Invalid virtual machine pointer"); } + // Is the specified path empty? + else if (mPath.empty()) + { + throw std::runtime_error("Invalid or empty script path"); + } // Should we load the file contents for debugging purposes? - else if (info) + else if (mInfo) { Process(); } diff --git a/source/Base/ScriptSrc.hpp b/source/Base/ScriptSrc.hpp index 2820a6d4..0fd7d592 100644 --- a/source/Base/ScriptSrc.hpp +++ b/source/Base/ScriptSrc.hpp @@ -29,6 +29,8 @@ public: String mPath; // Path to the script file. String mData; // The contents of the script file. Line mLine; // List of lines of code in the data. + bool mInfo; // Whether this script contains line information. + bool mDelay; // Don't execute immediately after compilation. /* -------------------------------------------------------------------------------------------- * Read file contents and calculate information about the lines of code. @@ -36,9 +38,18 @@ public: void Process(); /* -------------------------------------------------------------------------------------------- - * Default constructor. + * Base constructor. */ - ScriptSrc(HSQUIRRELVM vm, const String & path, bool info = false); + ScriptSrc(HSQUIRRELVM vm, const String & path, bool delay = false, bool info = false) + : ScriptSrc(vm, String(path), delay, info) + { + /* ... */ + } + + /* -------------------------------------------------------------------------------------------- + * Base constructor. + */ + ScriptSrc(HSQUIRRELVM vm, String && path, bool delay = false, bool info = false); /* -------------------------------------------------------------------------------------------- * Copy constructor.