| 272 | } |
| 273 | |
| 274 | bool ASContext::LoadScript(const Path &path) { |
| 275 | // Compile the script code |
| 276 | int r = CompileScript(path); |
| 277 | if (r < 0) { |
| 278 | DisplayFormatError(_ok, true, "Error", "Could not compile script: %s", path.GetFullPath()); |
| 279 | return false; |
| 280 | } |
| 281 | |
| 282 | if (LoadExpectedFunctions() == false) { |
| 283 | std::stringstream ss; |
| 284 | for (unsigned i = 0; i < expected_functions.size(); i++) { |
| 285 | if (expected_functions[i].mandatory && expected_functions[i].func_ptr == NULL) { |
| 286 | ss << expected_functions[i].definition << std::endl; |
| 287 | } |
| 288 | } |
| 289 | DisplayFormatError(_ok_cancel, true, "Error", "Could not initialize script %s, missing expected functions:\n%s", path.GetFullPath(), ss.str().c_str()); |
| 290 | return false; |
| 291 | } |
| 292 | |
| 293 | if (kDebugLineCallback) { |
| 294 | ctx->SetLineCallback(asFUNCTION(DebugLineCallback), &module, asCALL_CDECL); |
| 295 | } |
| 296 | |
| 297 | current_script = path; |
| 298 | if (asdebugger_enabled) |
| 299 | ASDebugger::AddContext(this); |
| 300 | if (asprofiler_enabled) { |
| 301 | ASProfiler::AddContext(this); |
| 302 | profiler.SetContext(this); |
| 303 | } |
| 304 | |
| 305 | return true; |
| 306 | } |
| 307 | |
| 308 | void ASContext::LoadScriptFromText(const std::string &text) { |
| 309 | // Compile the script code |
no test coverage detected