| 687 | } |
| 688 | |
| 689 | bool Squirrel::LoadScript(HSQUIRRELVM vm, const std::string &script, bool in_root) |
| 690 | { |
| 691 | ScriptAllocatorScope alloc_scope(this); |
| 692 | |
| 693 | /* Make sure we are always in the root-table */ |
| 694 | if (in_root) sq_pushroottable(vm); |
| 695 | |
| 696 | SQInteger ops_left = vm->_ops_till_suspend; |
| 697 | /* Load and run the script */ |
| 698 | if (SQ_SUCCEEDED(LoadFile(vm, script, SQTrue))) { |
| 699 | sq_push(vm, -2); |
| 700 | if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue, 100000))) { |
| 701 | sq_pop(vm, 1); |
| 702 | /* After compiling the file we want to reset the amount of opcodes. */ |
| 703 | vm->_ops_till_suspend = ops_left; |
| 704 | return true; |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | vm->_ops_till_suspend = ops_left; |
| 709 | Debug(misc, 0, "[squirrel] Failed to compile '{}'", script); |
| 710 | return false; |
| 711 | } |
| 712 | |
| 713 | bool Squirrel::LoadScript(const std::string &script) |
| 714 | { |
no test coverage detected