The update enhances object management by involving scope-based reference counting. The change affects loading and destruction operations in the Object and several other classes, ensuring the release or retention of objects adhere to their usage context. A function for logging type data has also been introduced to provide better clarity during debugging. Also, tests in script & interpreter have been altered to run in separate module initializations to avoid cross-test interference. Overall, it provides better memory management and dependable tests.
40 lines
No EOL
882 B
C++
40 lines
No EOL
882 B
C++
|
|
#include "NewPlacement.hpp"
|
|
|
|
#include "Testing.hpp"
|
|
|
|
#include "core/object.h"
|
|
#include "primitives/methodobject.h"
|
|
#include "primitives/interpreterobject.h"
|
|
#include "primitives/linkobject.h"
|
|
#include "compiler/function.h"
|
|
#include "interpreter/interpreter.h"
|
|
|
|
using namespace tp;
|
|
using namespace obj;
|
|
|
|
TEST_DEF_STATIC(Simple) {
|
|
|
|
auto method = NDO_CAST(MethodObject, NDO->create("method"));
|
|
auto interpreter = NDO_CAST(InterpreterObject, NDO->create("interpreter"));
|
|
|
|
interpreter->getMember<LinkObject>("target method")->setLink(method);
|
|
|
|
method->mScript->mReadable->val = "<< 3;";
|
|
method->compile();
|
|
|
|
interpreter->exec();
|
|
|
|
NDO->save(interpreter, "interp.o");
|
|
|
|
auto interpreterLoaded = NDO_CAST(InterpreterObject, NDO->load("interp.o"));
|
|
|
|
interpreterLoaded->exec();
|
|
|
|
NDO->destroy(interpreterLoaded);
|
|
NDO->destroy(interpreter);
|
|
}
|
|
|
|
TEST_DEF(Interpreter) {
|
|
testSimple();
|
|
} |