clean up object module
This commit is contained in:
parent
e78885d452
commit
f8c82b7e29
68 changed files with 1223 additions and 1229 deletions
|
|
@ -1,45 +1,42 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "interpreter/ByteCode.hpp"
|
||||
#include "core/Object.hpp"
|
||||
#include "interpreter/ByteCode.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace BCgen {
|
||||
namespace tp::obj {
|
||||
|
||||
class ConstObject {
|
||||
public:
|
||||
obj::Object* mObj = nullptr;
|
||||
tp::alni mConstIdx = 0;
|
||||
class ConstObject {
|
||||
public:
|
||||
Object* mObj = nullptr;
|
||||
alni mConstIdx = 0;
|
||||
|
||||
ConstObject();
|
||||
ConstObject(obj::Object* mObj);
|
||||
};
|
||||
|
||||
|
||||
class ConstObjectsPool {
|
||||
public:
|
||||
tp::Map<std::string, ConstObject*> mMethods;
|
||||
tp::Map<std::string, ConstObject*> mStrings;
|
||||
tp::Map<tp::alni, ConstObject*> mIntegers;
|
||||
tp::Map<tp::alnf, ConstObject*> mFloats;
|
||||
ConstObject mBoolTrue;
|
||||
ConstObject mBoolFalse;
|
||||
|
||||
bool mDelete = true;
|
||||
tp::alni mTotalObjects = 0;
|
||||
|
||||
ConstObject* get(tp::alni val);
|
||||
ConstObject* get(const std::string& val);
|
||||
ConstObject* get(tp::alnf val);
|
||||
ConstObject* get(bool val);
|
||||
|
||||
ConstObject* addMethod(const std::string& method_id, obj::Object* method);
|
||||
ConstObject* registerObject(obj::Object* obj);
|
||||
void save(tp::Buffer<ConstData>& out);
|
||||
|
||||
ConstObjectsPool() = default;
|
||||
~ConstObjectsPool();
|
||||
};
|
||||
ConstObject();
|
||||
ConstObject(Object* mObj);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
class ConstObjectsPool {
|
||||
public:
|
||||
Map<std::string, ConstObject*> mMethods;
|
||||
Map<std::string, ConstObject*> mStrings;
|
||||
Map<alni, ConstObject*> mIntegers;
|
||||
Map<alnf, ConstObject*> mFloats;
|
||||
ConstObject mBoolTrue;
|
||||
ConstObject mBoolFalse;
|
||||
|
||||
bool mDelete = true;
|
||||
alni mTotalObjects = 0;
|
||||
|
||||
ConstObject* get(alni val);
|
||||
ConstObject* get(const std::string& val);
|
||||
ConstObject* get(alnf val);
|
||||
ConstObject* get(bool val);
|
||||
|
||||
ConstObject* addMethod(const std::string& method_id, Object* method);
|
||||
ConstObject* registerObject(Object* obj);
|
||||
void save(Buffer<ConstData>& out);
|
||||
|
||||
ConstObjectsPool() = default;
|
||||
~ConstObjectsPool();
|
||||
};
|
||||
}
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "Buffer.hpp"
|
||||
|
||||
#include "interpreter/OperatoinCodes.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace obj::BCgen {
|
||||
namespace tp::obj {
|
||||
|
||||
struct Expression {
|
||||
enum class Type {
|
||||
|
|
@ -33,26 +31,26 @@ namespace obj::BCgen {
|
|||
};
|
||||
|
||||
struct ExpressionList : public Expression {
|
||||
tp::Buffer<Expression*> mItems;
|
||||
Buffer<Expression*> mItems;
|
||||
ExpressionList();
|
||||
~ExpressionList() override;
|
||||
};
|
||||
|
||||
struct ExpressionNew : public Expression {
|
||||
std::string mNewType;
|
||||
explicit ExpressionNew(const std::string& type);
|
||||
explicit ExpressionNew(std::string type);
|
||||
~ExpressionNew() override;
|
||||
};
|
||||
|
||||
struct ExpressionLocal : public Expression {
|
||||
std::string mLocalId;
|
||||
explicit ExpressionLocal(const std::string& id);
|
||||
explicit ExpressionLocal(std::string id);
|
||||
~ExpressionLocal() override;
|
||||
};
|
||||
|
||||
struct ExpressionFunc : public Expression {
|
||||
std::string mFuncId;
|
||||
explicit ExpressionFunc(const std::string& id);
|
||||
explicit ExpressionFunc(std::string id);
|
||||
~ExpressionFunc() override;
|
||||
};
|
||||
|
||||
|
|
@ -60,7 +58,7 @@ namespace obj::BCgen {
|
|||
Expression* mParent = nullptr;
|
||||
std::string mLocalId;
|
||||
bool mMethod = false;
|
||||
ExpressionChild(Expression* mParent, const std::string& id);
|
||||
ExpressionChild(Expression* mParent, std::string id);
|
||||
~ExpressionChild() override;
|
||||
};
|
||||
|
||||
|
|
@ -83,7 +81,7 @@ namespace obj::BCgen {
|
|||
Expression* mLeft = nullptr;
|
||||
Expression* mRight = nullptr;
|
||||
|
||||
enum class BoolType : tp::uint1 {
|
||||
enum class BoolType : uint1 {
|
||||
AND = 24U,
|
||||
OR,
|
||||
EQUAL,
|
||||
|
|
@ -103,16 +101,16 @@ namespace obj::BCgen {
|
|||
struct ExpressionConst : public Expression {
|
||||
enum ConstType { STR, INT, BOOL, FLT } mConstType;
|
||||
std::string str;
|
||||
tp::alni integer = 0;
|
||||
tp::alnf floating = 0;
|
||||
alni integer = 0;
|
||||
alnf floating = 0;
|
||||
bool boolean = false;
|
||||
|
||||
explicit ExpressionConst(const std::string& val);
|
||||
explicit ExpressionConst(std::string val);
|
||||
explicit ExpressionConst(const char* val);
|
||||
explicit ExpressionConst(tp::alni val);
|
||||
explicit ExpressionConst(tp::int4 val);
|
||||
explicit ExpressionConst(tp::flt4 val);
|
||||
explicit ExpressionConst(tp::alnf val);
|
||||
explicit ExpressionConst(alni val);
|
||||
explicit ExpressionConst(int4 val);
|
||||
explicit ExpressionConst(flt4 val);
|
||||
explicit ExpressionConst(alnf val);
|
||||
explicit ExpressionConst(bool val);
|
||||
|
||||
~ExpressionConst() override;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "List.hpp"
|
||||
#include "Map.hpp"
|
||||
|
||||
|
|
@ -9,39 +7,38 @@
|
|||
#include "Statements.hpp"
|
||||
#include "Constants.hpp"
|
||||
|
||||
namespace obj {
|
||||
#include <string>
|
||||
|
||||
namespace tp::obj {
|
||||
struct MethodObject;
|
||||
|
||||
namespace BCgen {
|
||||
struct FunctionDefinition {
|
||||
|
||||
struct FunctionDefinition {
|
||||
|
||||
FunctionDefinition* mPrnt = nullptr;
|
||||
FunctionDefinition* mPrnt = nullptr;
|
||||
|
||||
// signature
|
||||
std::string mFunctionId;
|
||||
tp::List<ConstObject*> mArgsOrder;
|
||||
// signature
|
||||
std::string mFunctionId;
|
||||
List<ConstObject*> mArgsOrder;
|
||||
|
||||
ConstObjectsPool mConstants;
|
||||
tp::Map<std::string, ConstObject*> mLocals;
|
||||
tp::List<Instruction> mInstructions;
|
||||
ConstObjectsPool mConstants;
|
||||
Map<std::string, ConstObject*> mLocals;
|
||||
List<Instruction> mInstructions;
|
||||
|
||||
FunctionDefinition(const std::string& function_id, tp::Buffer<std::string> args, FunctionDefinition* prnt);
|
||||
FunctionDefinition() {}
|
||||
FunctionDefinition(const std::string& function_id, const Buffer<std::string>& args, FunctionDefinition* prnt);
|
||||
FunctionDefinition() {}
|
||||
|
||||
void generateByteCode(ByteCode& out);
|
||||
void generateByteCode(ByteCode& out);
|
||||
|
||||
tp::List<Instruction>::Node* inst(Instruction inst);
|
||||
|
||||
void EvalExpr(Expression* expr);
|
||||
void EvalStatement(Statement* expr);
|
||||
List<Instruction>::Node* inst(Instruction inst);
|
||||
|
||||
ConstObject* defineLocal(const std::string& id);
|
||||
};
|
||||
void EvalExpr(Expression* expr);
|
||||
void EvalStatement(Statement* expr);
|
||||
|
||||
void init();
|
||||
void deinit();
|
||||
void Genereate(ByteCode& out, StatementScope* body);
|
||||
bool Compile(MethodObject* obj);
|
||||
ConstObject* defineLocal(const std::string& id);
|
||||
};
|
||||
};
|
||||
|
||||
void initialize();
|
||||
void finalize();
|
||||
void Generate(ByteCode& out, StatementScope* body);
|
||||
bool Compile(MethodObject* obj);
|
||||
}
|
||||
|
|
@ -2,52 +2,47 @@
|
|||
#pragma once
|
||||
|
||||
#include "interpreter/OperatoinCodes.hpp"
|
||||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
#include "List.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace BCgen {
|
||||
namespace tp::obj {
|
||||
class ConstObject;
|
||||
|
||||
class ConstObject;
|
||||
class Instruction {
|
||||
public:
|
||||
|
||||
class Instruction {
|
||||
public:
|
||||
OpCode mOp = OpCode::NONE;
|
||||
|
||||
OpCode mOp = OpCode::NONE;
|
||||
enum class ArgType : ualni {
|
||||
NO_ARG,
|
||||
PARAM,
|
||||
CONST_ARG,
|
||||
} mArgType = ArgType::NO_ARG;
|
||||
|
||||
enum class ArgType : tp::ualni {
|
||||
NO_ARG,
|
||||
PARAM,
|
||||
CONST_ARG,
|
||||
} mArgType = ArgType::NO_ARG;
|
||||
enum class InstType : ualni {
|
||||
NONE,
|
||||
JUMP,
|
||||
JUMP_IF,
|
||||
JUMP_IF_NOT,
|
||||
EXEC,
|
||||
PURE_CONST,
|
||||
} mInstType = InstType::NONE;
|
||||
|
||||
enum class InstType : tp::ualni {
|
||||
NONE,
|
||||
JUMP,
|
||||
JUMP_IF,
|
||||
JUMP_IF_NOT,
|
||||
EXEC,
|
||||
PURE_CONST,
|
||||
} mInstType = InstType::NONE;
|
||||
alni mParam = 0;
|
||||
alni mParamBytes = 1;
|
||||
|
||||
tp::alni mParam = 0;
|
||||
tp::alni mParamBytes = 1;
|
||||
ConstObject* mConstData = nullptr;
|
||||
ConstObject* mConstData2 = nullptr;
|
||||
|
||||
ConstObject* mConstData = nullptr;
|
||||
ConstObject* mConstData2 = nullptr;
|
||||
alni mInstIdx = 0;
|
||||
Instruction* mInstTarget = nullptr;
|
||||
|
||||
tp::alni mInstIdx = 0;
|
||||
Instruction* mInstTarget = nullptr;
|
||||
|
||||
Instruction();
|
||||
Instruction(ConstObject* constData);
|
||||
Instruction(OpCode op);
|
||||
Instruction(OpCode op, ConstObject* constData);
|
||||
Instruction(OpCode op, ConstObject* constData, ConstObject* constData2);
|
||||
Instruction(OpCode op, tp::alni param, tp::alni nBytes);
|
||||
Instruction(Instruction* inst, InstType jump_type);
|
||||
};
|
||||
Instruction();
|
||||
Instruction(ConstObject* constData);
|
||||
Instruction(OpCode op);
|
||||
Instruction(OpCode op, ConstObject* constData);
|
||||
Instruction(OpCode op, ConstObject* constData, ConstObject* constData2);
|
||||
Instruction(OpCode op, alni param, alni nBytes);
|
||||
Instruction(Instruction* inst, InstType jump_type);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "Expressions.hpp"
|
||||
|
||||
namespace obj::BCgen {
|
||||
namespace tp::obj {
|
||||
struct Statement {
|
||||
|
||||
enum class Type {
|
||||
|
|
@ -28,15 +28,15 @@ namespace obj::BCgen {
|
|||
};
|
||||
|
||||
struct StatementScope : public Statement {
|
||||
tp::Buffer<Statement*> mStatements;
|
||||
Buffer<Statement*> mStatements;
|
||||
bool mPushToScopeStack = false;
|
||||
|
||||
StatementScope(tp::InitialierList<Statement*> statements, bool aPushToScopeStack);
|
||||
StatementScope(InitialierList<Statement*> statements, bool aPushToScopeStack);
|
||||
~StatementScope() override;
|
||||
};
|
||||
|
||||
struct StatementFuncDef : public Statement {
|
||||
tp::Buffer<std::string> mArgs;
|
||||
Buffer<std::string> mArgs;
|
||||
std::string mFunctionId;
|
||||
StatementScope* mStatements = nullptr;
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ namespace obj::BCgen {
|
|||
ExpressionConst* mConstExpr = nullptr;
|
||||
bool mIsConstExpr = false;
|
||||
|
||||
StatementLocalDef(const std::string& id, Expression* value);
|
||||
StatementLocalDef(std::string id, Expression* value);
|
||||
~StatementLocalDef() override;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
#include "core/TypeGroups.hpp"
|
||||
#include "core/TypeMethods.hpp"
|
||||
|
||||
#include "Archiver.hpp"
|
||||
#include "ObjectArchiver.hpp"
|
||||
#include "SizeCounter.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
//#include "interpreter/interpreter.h"
|
||||
#include "core/ObjectArchiver.hpp"
|
||||
|
||||
/* Steps to create custom Object:
|
||||
define name of object
|
||||
|
|
@ -37,80 +37,29 @@ implement construct, destruct and copy methods */
|
|||
#define NDO_MEMH_FROM_NDO(ndo_ptr) (((ObjectMemHead*)ndo_ptr) - 1)
|
||||
#define NDO_FROM_MEMH(ndo_ptr) ((Object*)(ndo_ptr + 1))
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
|
||||
template<bool tRead>
|
||||
class Archiver : public tp::ArchiverTemplate<tRead> {
|
||||
tp::LocalConnection mConnection;
|
||||
tp::ualni mAddress = 0;
|
||||
tp::ualni mFirstNotWritten = 0;
|
||||
|
||||
public:
|
||||
Archiver() = default;
|
||||
explicit Archiver(const char* location) {
|
||||
mConnection.connect(tp::LocalConnection::Location(location), tp::LocalConnection::Type(tRead));
|
||||
};
|
||||
|
||||
void writeBytes(const tp::int1* val, tp::ualni size) override {
|
||||
mConnection.setPointer(mAddress);
|
||||
mConnection.writeBytes(val, size);
|
||||
incrementAddresses(size);
|
||||
}
|
||||
|
||||
void readBytes(tp::int1* val, tp::ualni size) override {
|
||||
mConnection.setPointer(mAddress);
|
||||
mConnection.readBytes(val, size);
|
||||
incrementAddresses(size);
|
||||
}
|
||||
|
||||
tp::ualni getAddress() { return mAddress; }
|
||||
|
||||
void setAddress(tp::ualni addr) { mAddress = addr; }
|
||||
|
||||
tp::ualni getFreeAddress() { return mFirstNotWritten; }
|
||||
|
||||
void setFreeAddress(tp::ualni addr) { mFirstNotWritten = addr; }
|
||||
|
||||
bool isOpened() { return mConnection.getConnectionStatus().isOpened(); }
|
||||
|
||||
tp::ualni getSize() { return mConnection.size(); }
|
||||
|
||||
private:
|
||||
void incrementAddresses(tp::ualni size) {
|
||||
// if (mAddress + size > mFirstNotWritten) mFirstNotWritten = mAddress + size;
|
||||
mAddress += size;
|
||||
}
|
||||
};
|
||||
|
||||
using ArchiverIn = Archiver<true>;
|
||||
using ArchiverOut = Archiver<false>;
|
||||
|
||||
void save_string(ArchiverOut& file, const std::string& string);
|
||||
tp::ualni save_string_size(const std::string& string);
|
||||
void load_string(ArchiverIn& file, std::string& out);
|
||||
|
||||
extern tp::ModuleManifest gModuleObjects;
|
||||
extern ModuleManifest gModuleObjects;
|
||||
|
||||
extern struct objects_api* NDO;
|
||||
|
||||
struct ObjectMemHead {
|
||||
ObjectMemHead* up;
|
||||
ObjectMemHead* down;
|
||||
tp::alni flags;
|
||||
tp::alni refc;
|
||||
alni flags;
|
||||
alni refc;
|
||||
};
|
||||
|
||||
struct Object {
|
||||
const struct ObjectType* type;
|
||||
};
|
||||
|
||||
typedef void (*object_from_int)(Object* self, tp::alni in);
|
||||
typedef void (*object_from_float)(Object* self, tp::alnf in);
|
||||
typedef void (*object_from_int)(Object* self, alni in);
|
||||
typedef void (*object_from_float)(Object* self, alnf in);
|
||||
typedef void (*object_from_string)(Object* self, const std::string& in);
|
||||
typedef std::string(*object_to_string)(Object* self);
|
||||
typedef tp::alni(*object_to_int)(Object* self);
|
||||
typedef tp::alnf(*object_to_float)(Object* self);
|
||||
typedef alni(*object_to_int)(Object* self);
|
||||
typedef alnf(*object_to_float)(Object* self);
|
||||
|
||||
struct ObjectTypeConversions {
|
||||
object_from_int from_int;
|
||||
|
|
@ -137,22 +86,22 @@ namespace obj {
|
|||
typedef void (*object_destructor)(Object* self);
|
||||
typedef void (*object_copy)(Object* self, const Object* target);
|
||||
|
||||
typedef tp::alni(*object_save_size)(Object* self);
|
||||
typedef alni(*object_save_size)(Object* self);
|
||||
typedef void (*object_save)(Object*, ArchiverOut&);
|
||||
typedef void (*object_load)(ArchiverIn&, Object*);
|
||||
|
||||
typedef bool (*object_compare)(Object*, Object*);
|
||||
|
||||
typedef tp::Buffer<Object*> (*object_debug_all_childs_retrival)(Object*);
|
||||
typedef tp::alni (*object_allocated_size)(Object*); // default value = type->size - sizeof(ObjectType*)
|
||||
typedef tp::alni (*object_allocated_size_recursive)(Object*); // default value = object_allocated_size
|
||||
typedef Buffer<Object*> (*object_debug_all_childs_retrival)(Object*);
|
||||
typedef alni (*object_allocated_size)(Object*); // default value = type->size - sizeof(ObjectType*)
|
||||
typedef alni (*object_allocated_size_recursive)(Object*); // default value = object_allocated_size
|
||||
|
||||
struct ObjectType {
|
||||
const ObjectType* base = nullptr;
|
||||
object_constructor constructor = nullptr;
|
||||
object_destructor destructor = nullptr;
|
||||
object_copy copy = nullptr;
|
||||
tp::alni size = 0;
|
||||
alni size = 0;
|
||||
const char* name;
|
||||
const ObjectTypeConversions* convesions = nullptr;
|
||||
const ObjectTypeAriphmetics* ariphmetics = nullptr;
|
||||
|
|
@ -174,7 +123,7 @@ namespace obj {
|
|||
typedef void (pre_load_callback)(void* self, ArchiverIn&);
|
||||
typedef void (post_save_callback)(void* self, ArchiverOut&);
|
||||
typedef void (post_load_callback)(void* self, ArchiverIn&);
|
||||
typedef tp::alni (slcb_size_callback)(void* self, ArchiverOut&);
|
||||
typedef alni (slcb_size_callback)(void* self, ArchiverOut&);
|
||||
|
||||
struct save_load_callbacks {
|
||||
void* self;
|
||||
|
|
@ -188,8 +137,8 @@ namespace obj {
|
|||
|
||||
struct objects_api {
|
||||
|
||||
tp::Map<std::string, const ObjectType*> types;
|
||||
obj::TypeGroups type_groups;
|
||||
Map<std::string, const ObjectType*> types;
|
||||
TypeGroups type_groups;
|
||||
Interpreter* interp = nullptr;
|
||||
|
||||
objects_api();
|
||||
|
|
@ -197,54 +146,54 @@ namespace obj {
|
|||
|
||||
void define(ObjectType* type);
|
||||
Object* create(const std::string& name);
|
||||
Object* copy(Object* self, const Object* in);
|
||||
bool compare(Object* first, Object* second);
|
||||
Object* instatiate(Object*);
|
||||
void set(Object* self, tp::alni val);
|
||||
void set(Object* self, tp::alnf val);
|
||||
void set(Object* self, const std::string& val);
|
||||
static Object* copy(Object* self, const Object* in);
|
||||
static bool compare(Object* first, Object* second);
|
||||
static Object* instantiate(Object*);
|
||||
static void set(Object* self, alni val);
|
||||
static void set(Object* self, alnf val);
|
||||
static void set(Object* self, const std::string& val);
|
||||
|
||||
tp::alni toInt(Object* self);
|
||||
tp::alnf toFloat(Object* self);
|
||||
bool toBool(Object* self);
|
||||
std::string toString(Object* self);
|
||||
static alni toInt(Object* self);
|
||||
static alnf toFloat(Object* self);
|
||||
static bool toBool(Object* self);
|
||||
static std::string toString(Object* self);
|
||||
|
||||
void clear_object_flags();
|
||||
|
||||
void destroy(Object* in);
|
||||
void destroy(Object* in) const;
|
||||
|
||||
void refinc(Object* in);
|
||||
tp::halni getrefc(Object* in);
|
||||
static void increaseReferenceCount(Object* in);
|
||||
static halni getReferenceCount(Object* in);
|
||||
private:
|
||||
void setrefc(Object* in, tp::halni refc);
|
||||
static void setReferenceCount(Object* in, halni count);
|
||||
public:
|
||||
|
||||
save_load_callbacks* sl_callbacks[SAVE_LOAD_MAX_CALLBACK_SLOTS];
|
||||
tp::alni sl_callbacks_load_idx = 0;
|
||||
save_load_callbacks* sl_callbacks[SAVE_LOAD_MAX_CALLBACK_SLOTS]{};
|
||||
alni sl_callbacks_load_idx = 0;
|
||||
|
||||
void add_sl_callbacks(save_load_callbacks*);
|
||||
|
||||
tp::alni objsize_file(Object* self);
|
||||
tp::alni objsize_file_recursive(Object* self);
|
||||
alni objsize_file(Object* self);
|
||||
alni objsize_file_recursive(Object* self);
|
||||
|
||||
tp::alni objsize_ram(Object* self);
|
||||
tp::alni objsize_ram_recursive_util(Object* self, const ObjectType* type, bool different_object = true);
|
||||
tp::alni objsize_ram_recursive(Object* self);
|
||||
alni objsize_ram(Object* self);
|
||||
alni objsize_ram_recursive_util(Object* self, const ObjectType* type, bool different_object = true);
|
||||
alni objsize_ram_recursive(Object* self);
|
||||
|
||||
bool save(Object*, const std::string& path, bool compressed = true);
|
||||
Object* load(const std::string& path);
|
||||
tp::alni save(ArchiverOut&, Object*);
|
||||
Object* load(ArchiverIn&, tp::alni file_adress);
|
||||
alni save(ArchiverOut&, Object*);
|
||||
Object* load(ArchiverIn&, alni file_adress);
|
||||
};
|
||||
|
||||
void logTypeData(const ObjectType* type);
|
||||
void assertNoLeaks();
|
||||
tp::ualni getObjCount();
|
||||
ualni getObjCount();
|
||||
|
||||
Object* ndo_cast(const Object* in, const ObjectType* to_type);
|
||||
|
||||
template <typename Type>
|
||||
Type* create() {
|
||||
return (Type*)obj::NDO->create(Type::TypeData.name);
|
||||
return (Type*)NDO->create(Type::TypeData.name);
|
||||
}
|
||||
};
|
||||
}
|
||||
56
Objects/public/core/ObjectArchiver.hpp
Normal file
56
Objects/public/core/ObjectArchiver.hpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#pragma once
|
||||
|
||||
#include "ObjectArchiver.hpp"
|
||||
#include "LocalConnection.hpp"
|
||||
|
||||
namespace tp::obj {
|
||||
template<bool tRead>
|
||||
class Archiver : public ArchiverTemplate<tRead> {
|
||||
LocalConnection mConnection;
|
||||
ualni mAddress = 0;
|
||||
ualni mFirstNotWritten = 0;
|
||||
|
||||
public:
|
||||
Archiver() = default;
|
||||
explicit Archiver(const char* location) {
|
||||
mConnection.connect(LocalConnection::Location(location), LocalConnection::Type(tRead));
|
||||
};
|
||||
|
||||
void writeBytes(const int1* val, ualni size) override {
|
||||
mConnection.setPointer(mAddress);
|
||||
mConnection.writeBytes(val, size);
|
||||
incrementAddresses(size);
|
||||
}
|
||||
|
||||
void readBytes(int1* val, ualni size) override {
|
||||
mConnection.setPointer(mAddress);
|
||||
mConnection.readBytes(val, size);
|
||||
incrementAddresses(size);
|
||||
}
|
||||
|
||||
ualni getAddress() { return mAddress; }
|
||||
|
||||
void setAddress(ualni addr) { mAddress = addr; }
|
||||
|
||||
ualni getFreeAddress() { return mFirstNotWritten; }
|
||||
|
||||
void setFreeAddress(ualni addr) { mFirstNotWritten = addr; }
|
||||
|
||||
bool isOpened() { return mConnection.getConnectionStatus().isOpened(); }
|
||||
|
||||
ualni getSize() { return mConnection.size(); }
|
||||
|
||||
private:
|
||||
void incrementAddresses(ualni size) {
|
||||
// if (mAddress + size > mFirstNotWritten) mFirstNotWritten = mAddress + size;
|
||||
mAddress += size;
|
||||
}
|
||||
};
|
||||
|
||||
using ArchiverIn = Archiver<true>;
|
||||
using ArchiverOut = Archiver<false>;
|
||||
|
||||
void save_string(ArchiverOut& file, const std::string& string);
|
||||
ualni save_string_size(const std::string& string);
|
||||
void load_string(ArchiverIn& file, std::string& out);
|
||||
}
|
||||
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
#include "primitives/MethodObject.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
// global singleton API for method object to manage the script
|
||||
struct ScriptSection {
|
||||
|
||||
tp::List<Script*> mScripts;
|
||||
List<Script*> mScripts;
|
||||
|
||||
Script* createScript();
|
||||
void changeScript(Script** current_script, Script** new_script);
|
||||
void abandonScript(Script* script);
|
||||
|
||||
tp::alni get_script_file_adress(Script* in);
|
||||
Script* get_scritp_from_file_adress(tp::alni file_adress);
|
||||
alni get_script_file_adress(Script* in);
|
||||
Script* get_scritp_from_file_adress(alni file_adress);
|
||||
|
||||
~ScriptSection();
|
||||
|
||||
|
|
@ -31,6 +31,6 @@ namespace obj {
|
|||
|
||||
static void save_script_table_to_file(ScriptSection* self, ArchiverOut& file);
|
||||
static void load_script_table_from_file(ScriptSection* self, ArchiverIn& file);
|
||||
static tp::alni save_script_table_to_file_size(ScriptSection* self, ArchiverOut& file);
|
||||
static alni save_script_table_to_file_size(ScriptSection* self, ArchiverOut& file);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
#include "Map.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct ObjectType;
|
||||
struct objects_api;
|
||||
|
|
@ -13,15 +13,15 @@ namespace obj {
|
|||
|
||||
public:
|
||||
|
||||
typedef tp::Map<std::string, obj::TypeGroups*> Dict;
|
||||
typedef Map<std::string, TypeGroups*> Dict;
|
||||
|
||||
TypeGroups();
|
||||
|
||||
friend struct obj::objects_api;
|
||||
friend struct objects_api;
|
||||
|
||||
explicit TypeGroups(bool is_group);
|
||||
|
||||
void addType(ObjectType* type, tp::InitialierList<const char*> path, tp::alni cur_arg = 0);
|
||||
void addType(ObjectType* type, InitialierList<const char*> path, alni cur_arg = 0);
|
||||
void setType(ObjectType* type);
|
||||
bool isGroup();
|
||||
Dict* getChilds();
|
||||
|
|
@ -36,5 +36,4 @@ namespace obj {
|
|||
const obj::ObjectType* type;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
#include "Buffer.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct Interpreter;
|
||||
struct Object;
|
||||
|
|
@ -23,7 +23,7 @@ namespace obj {
|
|||
mutable Object* self = nullptr;
|
||||
Arg args[MAX_ARGS];
|
||||
|
||||
tp::int1 mNargs = 0;
|
||||
int1 mNargs = 0;
|
||||
|
||||
void (*exec)(const TypeMethod* tm) = nullptr;
|
||||
|
||||
|
|
@ -37,14 +37,14 @@ namespace obj {
|
|||
extern TypeMethod gDefaultTypeMethods[3];
|
||||
|
||||
struct TypeMethods {
|
||||
enum : tp::int2 { MAX_TYPE_METHODS = 128 };
|
||||
enum : int2 { MAX_TYPE_METHODS = 128 };
|
||||
|
||||
TypeMethod* methods[MAX_TYPE_METHODS];
|
||||
tp::halni mNMethods = 0;
|
||||
halni mNMethods = 0;
|
||||
|
||||
struct LookupKey {
|
||||
tp::int2 key = -1;
|
||||
tp::int2 type_depth = -1;
|
||||
int2 key = -1;
|
||||
int2 type_depth = -1;
|
||||
operator bool() { return key != -1; }
|
||||
};
|
||||
|
||||
|
|
@ -53,11 +53,10 @@ namespace obj {
|
|||
|
||||
void init();
|
||||
|
||||
tp::halni nMethods() const;
|
||||
halni nMethods() const;
|
||||
|
||||
private:
|
||||
tp::int2 presents(const std::string&) const;
|
||||
const TypeMethod* getMethod(tp::int2) const;
|
||||
int2 presents(const std::string&) const;
|
||||
const TypeMethod* getMethod(int2) const;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -9,15 +9,15 @@
|
|||
#include "Buffer.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
typedef Object* ConstData;
|
||||
|
||||
struct ByteCode {
|
||||
tp::Buffer<ConstData> mConstants;
|
||||
tp::Buffer<OpCode> mInstructions;
|
||||
tp::ualni mInstructionIdx = 0;
|
||||
tp::ualni mArgumentsLoaded = 0;
|
||||
Buffer<ConstData> mConstants;
|
||||
Buffer<OpCode> mInstructions;
|
||||
ualni mInstructionIdx = 0;
|
||||
ualni mArgumentsLoaded = 0;
|
||||
|
||||
~ByteCode() {
|
||||
for (auto const_obj : mConstants) {
|
||||
|
|
@ -25,4 +25,4 @@ namespace obj {
|
|||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -5,11 +5,8 @@
|
|||
|
||||
#include "Map.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
struct MethodObject;
|
||||
};
|
||||
|
||||
namespace obj {
|
||||
|
||||
struct ByteCode;
|
||||
|
||||
|
|
@ -17,16 +14,16 @@ namespace obj {
|
|||
|
||||
struct CallFrame {
|
||||
enum { CALL_DEPTH = 1024 };
|
||||
obj::Object* mSelf = nullptr;
|
||||
obj::MethodObject* mMethod = nullptr;
|
||||
tp::ualni mIp = 0;
|
||||
Object* mSelf = nullptr;
|
||||
MethodObject* mMethod = nullptr;
|
||||
ualni mIp = 0;
|
||||
};
|
||||
|
||||
void enter(const CallFrame& frame);
|
||||
void leave();
|
||||
ByteCode* getBytecode();
|
||||
[[nodiscard]] tp::halni len() const;
|
||||
[[nodiscard]] halni len() const;
|
||||
|
||||
tp::ConstSizeBuffer<CallFrame, CallFrame::CALL_DEPTH> mStack;
|
||||
ConstSizeBuffer<CallFrame, CallFrame::CALL_DEPTH> mStack;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -4,19 +4,19 @@
|
|||
#include "ScopeStack.hpp"
|
||||
#include "CallStack.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
struct Interpreter {
|
||||
OperandStack mOperandsStack;
|
||||
ScopeStack mScopeStack;
|
||||
CallStack mCallStack;
|
||||
|
||||
obj::Object* mLastParent = nullptr;
|
||||
Object* mLastParent = nullptr;
|
||||
bool mIsTypeMethod = false;
|
||||
const TypeMethod* mTypeMethod = nullptr;
|
||||
|
||||
typedef struct { obj::Object* obj; std::string id; } GlobalDef;
|
||||
typedef struct { Object* obj; std::string id; } GlobalDef;
|
||||
|
||||
void exec(obj::MethodObject* method, obj::ClassObject* self = nullptr, obj::DictObject* globals = nullptr, tp::InitialierList<GlobalDef> globals2 = {});
|
||||
void exec(MethodObject* method, ClassObject* self = nullptr, DictObject* globals = nullptr, InitialierList<GlobalDef> globals2 = {});
|
||||
|
||||
void stepBytecode();
|
||||
void stepBytecodeIn();
|
||||
|
|
@ -24,6 +24,6 @@ namespace obj {
|
|||
|
||||
bool finished();
|
||||
|
||||
void execAll(obj::MethodObject* method, obj::ClassObject* self = nullptr, obj::DictObject* globals = nullptr, tp::InitialierList<GlobalDef> globals2 = {});
|
||||
void execAll(MethodObject* method, ClassObject* self = nullptr, DictObject* globals = nullptr, InitialierList<GlobalDef> globals2 = {});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -3,21 +3,21 @@
|
|||
#include "ByteCode.hpp"
|
||||
#include "core/Object.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
// can be other aligned value as well
|
||||
typedef obj::Object* Operand;
|
||||
typedef Object* Operand;
|
||||
|
||||
class OperandStack {
|
||||
|
||||
enum : tp::alni {
|
||||
enum : alni {
|
||||
MAX_STACK_SIZE = 512
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
Operand* mBuff;
|
||||
tp::ualni mIdx;
|
||||
ualni mIdx;
|
||||
|
||||
OperandStack();
|
||||
void push(Operand operand);
|
||||
|
|
@ -35,5 +35,4 @@ namespace obj {
|
|||
|
||||
~OperandStack();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -12,11 +12,11 @@
|
|||
// 2) Index of bytecode->ConstData from bytecode->Instruction (ConstData)
|
||||
// 3) Raw Bytes from bytecode->Instruction (Param)
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
extern struct OpcodeInfos gOpcodeInfos;
|
||||
|
||||
enum class OpCode : tp::uint1 {
|
||||
enum class OpCode : uint1 {
|
||||
|
||||
NONE = 0x00,
|
||||
HALT,
|
||||
|
|
@ -118,24 +118,24 @@ namespace obj {
|
|||
|
||||
enum { MAX_OPERANDS = 5 };
|
||||
Operand buff[MAX_OPERANDS];
|
||||
tp::halni len = 0;
|
||||
halni len = 0;
|
||||
|
||||
OperandsInfo();
|
||||
OperandsInfo(tp::InitialierList<Operand> list);
|
||||
OperandsInfo(InitialierList<Operand> list);
|
||||
};
|
||||
|
||||
struct ParamsInfo {
|
||||
struct Param {
|
||||
const char* desc = nullptr;
|
||||
tp::halni bytes = 1;
|
||||
halni bytes = 1;
|
||||
};
|
||||
|
||||
enum { MAX_PARAMS = 5 };
|
||||
Param buff[MAX_PARAMS];
|
||||
tp::halni len = 0;
|
||||
halni len = 0;
|
||||
|
||||
ParamsInfo();
|
||||
ParamsInfo(tp::InitialierList<Param> list);
|
||||
ParamsInfo(InitialierList<Param> list);
|
||||
};
|
||||
|
||||
struct OpInfo {
|
||||
|
|
@ -144,14 +144,14 @@ namespace obj {
|
|||
OperandsInfo operands;
|
||||
ParamsInfo params;
|
||||
|
||||
tp::uint1 opsize();
|
||||
uint1 opsize();
|
||||
};
|
||||
|
||||
OpcodeInfos();
|
||||
OpInfo fetch(OpCode code);
|
||||
|
||||
private:
|
||||
OpInfo buff[(tp::alni)OpCode::END_OPCODES];
|
||||
OpInfo buff[(alni)OpCode::END_OPCODES];
|
||||
|
||||
void add(OpCode code, const OpInfo& info);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
#include "core/Object.hpp"
|
||||
#include "Map.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct Scope {
|
||||
typedef tp::Map<std::string, obj::Object*> ObjDict;
|
||||
typedef tp::List<obj::Object*> ObjList;
|
||||
typedef Map<std::string, Object*> ObjDict;
|
||||
typedef List<Object*> ObjList;
|
||||
|
||||
ObjDict mLocals;
|
||||
ObjList mTemps;
|
||||
|
|
@ -18,29 +18,28 @@ namespace obj {
|
|||
|
||||
class ScopeStack {
|
||||
|
||||
enum : tp::alni {
|
||||
enum : alni {
|
||||
MAX_STACK_SIZE = 1024 * 4
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
Scope* mBuff;
|
||||
tp::ualni mIdx;
|
||||
tp::ualni mIterIdx;
|
||||
ualni mIdx;
|
||||
ualni mIterIdx;
|
||||
|
||||
ScopeStack();
|
||||
void enterScope(bool aChildReachable);
|
||||
void leaveScope();
|
||||
void addLocal(obj::Object* local, const std::string& id);
|
||||
void addTemp(obj::Object* tmp);
|
||||
void addLocal(Object* local, const std::string& id);
|
||||
void addTemp(Object* tmp);
|
||||
void popTemp();
|
||||
void addTempReturn(obj::Object* ret);
|
||||
obj::Object* getLocal(const std::string& str);
|
||||
void addTempReturn(Object* ret);
|
||||
Object* getLocal(const std::string& str);
|
||||
Scope* getCurrentScope();
|
||||
~ScopeStack();
|
||||
|
||||
private:
|
||||
obj::Object* getLocalUtil(Scope& scope, const std::string& id);
|
||||
Object* getLocalUtil(Scope& scope, const std::string& id);
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
#include "interpreter/ByteCode.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
struct Script {
|
||||
obj::StringObject* mReadable;
|
||||
StringObject* mReadable;
|
||||
ByteCode mBytecode;
|
||||
|
||||
void compile();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -3,20 +3,20 @@
|
|||
#include "compiler/Statements.hpp"
|
||||
#include "compiler/Expressions.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
class Parser {
|
||||
public:
|
||||
Parser() = default;
|
||||
|
||||
struct Result {
|
||||
obj::BCgen::StatementScope* scope = nullptr;
|
||||
StatementScope* scope = nullptr;
|
||||
bool isError = false;
|
||||
std::string description;
|
||||
tp::halni line = 0;
|
||||
tp::halni column = 0;
|
||||
halni line = 0;
|
||||
halni column = 0;
|
||||
};
|
||||
|
||||
Result parse(const std::string& stream);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct BoolObject : Object {
|
||||
tp::alni val;
|
||||
alni val;
|
||||
|
||||
static ObjectType TypeData;
|
||||
static void constructor(BoolObject* self);
|
||||
|
|
@ -14,11 +14,11 @@ namespace obj {
|
|||
|
||||
static BoolObject* create(bool in);
|
||||
|
||||
static void from_int(BoolObject* self, tp::alni in);
|
||||
static void from_float(BoolObject* self, tp::alnf in);
|
||||
static void from_int(BoolObject* self, alni in);
|
||||
static void from_float(BoolObject* self, alnf in);
|
||||
static void from_string(BoolObject* self, const std::string& in);
|
||||
static std::string to_string(BoolObject* self);
|
||||
static tp::alni to_int(BoolObject* self);
|
||||
static tp::alnf to_float(BoolObject* self);
|
||||
static alni to_int(BoolObject* self);
|
||||
static alnf to_float(BoolObject* self);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "primitives/DictObject.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct ClassObject : Object {
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ namespace obj {
|
|||
static void copy(ClassObject* self, const ClassObject* in);
|
||||
static void destructor(ClassObject* self);
|
||||
static void constructor(ClassObject* self);
|
||||
static tp::alni save_size(ClassObject* self);
|
||||
static alni save_size(ClassObject* self);
|
||||
static void save(ClassObject* self, ArchiverOut& file_self);
|
||||
static void load(ArchiverIn& file_self, ClassObject* self);
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ namespace obj {
|
|||
Type* getMember(const std::string& id) {
|
||||
auto idx = members->presents(id);
|
||||
if (bool(idx)) {
|
||||
return ((Type*)obj::ndo_cast(members->getSlotVal(idx), &Type::TypeData));
|
||||
return ((Type*)ndo_cast(members->getSlotVal(idx), &Type::TypeData));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -43,4 +43,4 @@ namespace obj {
|
|||
return out;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -4,10 +4,10 @@
|
|||
#include "core/Object.hpp"
|
||||
#include "Color.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct ColorObject : Object {
|
||||
tp::RGBA mCol;
|
||||
RGBA mCol;
|
||||
|
||||
static ObjectType TypeData;
|
||||
static ObjectTypeAriphmetics TypeAriphm;
|
||||
|
|
@ -15,10 +15,10 @@ namespace obj {
|
|||
static void constructor(Object* self);
|
||||
static void copy(ColorObject* self, const ColorObject* in);
|
||||
|
||||
static void from_int(ColorObject* self, tp::alni in);
|
||||
static void from_float(ColorObject* self, tp::alnf in);
|
||||
static void from_int(ColorObject* self, alni in);
|
||||
static void from_float(ColorObject* self, alnf in);
|
||||
static std::string to_string(ColorObject* self);
|
||||
|
||||
static ColorObject* create(tp::RGBA in);
|
||||
static ColorObject* create(RGBA in);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct DictObject : Object {
|
||||
static ObjectType TypeData;
|
||||
|
|
@ -10,22 +10,22 @@ namespace obj {
|
|||
static void destructor(Object* self);
|
||||
static void constructor(Object* self);
|
||||
|
||||
static tp::alni save_size(DictObject* self);
|
||||
static alni save_size(DictObject* self);
|
||||
static void save(DictObject* self, ArchiverOut& file_self);
|
||||
static void load(ArchiverIn& file_self, DictObject* self);
|
||||
static tp::Buffer<Object*> childs_retrival(DictObject* self);
|
||||
static tp::alni allocated_size(DictObject* self);
|
||||
static tp::alni allocated_size_recursive(DictObject* self);
|
||||
static Buffer<Object*> childs_retrival(DictObject* self);
|
||||
static alni allocated_size(DictObject* self);
|
||||
static alni allocated_size_recursive(DictObject* self);
|
||||
|
||||
void put(const std::string&, Object*);
|
||||
void remove(const std::string&);
|
||||
Object* get(const std::string&);
|
||||
tp::Map<std::string, Object*>::Idx presents(const std::string&);
|
||||
Object* getSlotVal(tp::Map<std::string, Object*>::Idx);
|
||||
Map<std::string, Object*>::Idx presents(const std::string&);
|
||||
Object* getSlotVal(Map<std::string, Object*>::Idx);
|
||||
|
||||
[[nodiscard]] const tp::Map<std::string, Object*>& getItems() const;
|
||||
[[nodiscard]] const Map<std::string, Object*>& getItems() const;
|
||||
|
||||
private:
|
||||
tp::Map<std::string, Object*> items;
|
||||
Map<std::string, Object*> items;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -3,32 +3,32 @@
|
|||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct EnumObject : Object {
|
||||
|
||||
// one entry is 2 * sizeof(alni) in size
|
||||
tp::uhalni active;
|
||||
tp::uhalni nentries;
|
||||
tp::alni* entries;
|
||||
uhalni active;
|
||||
uhalni nentries;
|
||||
alni* entries;
|
||||
|
||||
static ObjectType TypeData;
|
||||
static void constructor(EnumObject* self);
|
||||
static void destructor(EnumObject* self);
|
||||
static void copy(EnumObject* self, const EnumObject* in);
|
||||
|
||||
void init(tp::InitialierList<const char*> list);
|
||||
void init(InitialierList<const char*> list);
|
||||
const char* getActiveName();
|
||||
const char* getItemName(tp::uhalni idx);
|
||||
const char* getItemName(uhalni idx);
|
||||
|
||||
static void from_int(EnumObject* self, tp::alni in);
|
||||
static void from_float(EnumObject* self, tp::alnf in);
|
||||
static void from_int(EnumObject* self, alni in);
|
||||
static void from_float(EnumObject* self, alnf in);
|
||||
static void from_string(EnumObject* self, const std::string& in);
|
||||
static std::string to_string(EnumObject* self);
|
||||
static tp::alni to_int(EnumObject* self);
|
||||
static tp::alnf to_float(EnumObject* self);
|
||||
static alni to_int(EnumObject* self);
|
||||
static alnf to_float(EnumObject* self);
|
||||
|
||||
static bool compare(EnumObject* first, EnumObject* second);
|
||||
static EnumObject* create(tp::InitialierList<const char*> list);
|
||||
static EnumObject* create(InitialierList<const char*> list);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct FloatObject : Object {
|
||||
tp::alnf val;
|
||||
alnf val;
|
||||
|
||||
static ObjectType TypeData;
|
||||
static ObjectTypeAriphmetics TypeAriphm;
|
||||
|
|
@ -14,13 +14,13 @@ namespace obj {
|
|||
|
||||
static void constructor(FloatObject* self);
|
||||
static void copy(FloatObject* self, const FloatObject* in);
|
||||
static FloatObject* create(tp::alnf in);
|
||||
static FloatObject* create(alnf in);
|
||||
|
||||
static void from_int(FloatObject* self, tp::alni in);
|
||||
static void from_float(FloatObject* self, tp::alnf in);
|
||||
static void from_int(FloatObject* self, alni in);
|
||||
static void from_float(FloatObject* self, alnf in);
|
||||
static void from_string(FloatObject* self, const std::string& in);
|
||||
static std::string to_string(FloatObject* self);
|
||||
static tp::alni to_int(FloatObject* self);
|
||||
static tp::alnf to_float(FloatObject* self);
|
||||
static alni to_int(FloatObject* self);
|
||||
static alnf to_float(FloatObject* self);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -3,23 +3,23 @@
|
|||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct IntObject : Object {
|
||||
tp::alni val;
|
||||
alni val;
|
||||
|
||||
static ObjectType TypeData;
|
||||
static ObjectTypeAriphmetics TypeAriphm;
|
||||
|
||||
static void constructor(Object* self);
|
||||
static void copy(IntObject* self, const IntObject* in);
|
||||
static IntObject* create(tp::alni in);
|
||||
static IntObject* create(alni in);
|
||||
|
||||
static void from_int(Object* self, tp::alni in);
|
||||
static void from_float(Object* self, tp::alnf in);
|
||||
static void from_int(Object* self, alni in);
|
||||
static void from_float(Object* self, alnf in);
|
||||
static void from_string(Object* self, const std::string& in);
|
||||
static std::string to_string(Object* self);
|
||||
static tp::alni to_int(Object* self);
|
||||
static tp::alnf to_float(Object* self);
|
||||
static alni to_int(Object* self);
|
||||
static alnf to_float(Object* self);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
#include "interpreter/Interpreter.hpp"
|
||||
#include "primitives/ClassObject.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
struct InterpreterObject : ClassObject {
|
||||
static ObjectType TypeData;
|
||||
Interpreter mInterpreter;
|
||||
|
|
@ -12,8 +12,8 @@ namespace obj {
|
|||
static void constructor(InterpreterObject* self);
|
||||
static void load(ArchiverIn& file_self, InterpreterObject* self);
|
||||
|
||||
void exec(obj::ClassObject* self = nullptr, tp::InitialierList<Interpreter::GlobalDef> globals = {});
|
||||
void exec(obj::ClassObject* self = nullptr, InitialierList<Interpreter::GlobalDef> globals = {});
|
||||
void debug();
|
||||
bool running();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct LinkObject : Object {
|
||||
static ObjectType TypeData;
|
||||
|
|
@ -12,12 +12,12 @@ namespace obj {
|
|||
static void copy(Object* self, const Object* in);
|
||||
static LinkObject* create(Object* in);
|
||||
|
||||
static tp::alni save_size(LinkObject* self);
|
||||
static alni save_size(LinkObject* self);
|
||||
static void save(LinkObject* self, ArchiverOut& file_self);
|
||||
static void load(ArchiverIn& file_self, LinkObject* self);
|
||||
static tp::alni allocated_size(LinkObject* self);
|
||||
static tp::alni allocated_size_recursive(LinkObject* self);
|
||||
static tp::Buffer<Object*> childs_retrival(LinkObject* self);
|
||||
static alni allocated_size(LinkObject* self);
|
||||
static alni allocated_size_recursive(LinkObject* self);
|
||||
static Buffer<Object*> childs_retrival(LinkObject* self);
|
||||
|
||||
Object* getLink();
|
||||
void setLink(Object* obj);
|
||||
|
|
@ -25,5 +25,4 @@ namespace obj {
|
|||
private:
|
||||
Object* link;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
enum ListMethods {
|
||||
LISTOBJECT_PUSH_BACK,
|
||||
|
|
@ -16,21 +16,21 @@ namespace obj {
|
|||
static void copy(Object* self, const Object* in);
|
||||
static void destructor(Object* self);
|
||||
|
||||
static tp::alni allocated_size_recursive(ListObject* self);
|
||||
static tp::alni allocated_size(ListObject* self);
|
||||
static tp::Buffer<Object*> childs_retrival(ListObject* self);
|
||||
static alni allocated_size_recursive(ListObject* self);
|
||||
static alni allocated_size(ListObject* self);
|
||||
static Buffer<Object*> childs_retrival(ListObject* self);
|
||||
static void load(ArchiverIn& file_self, ListObject* self);
|
||||
static void save(ListObject* self, ArchiverOut& file_self);
|
||||
static tp::alni save_size(ListObject* self);
|
||||
static alni save_size(ListObject* self);
|
||||
|
||||
[[nodiscard]] const tp::List<Object*>& getItems() const;
|
||||
[[nodiscard]] const List<Object*>& getItems() const;
|
||||
|
||||
void pushBack(Object* obj);
|
||||
void pushFront(Object* obj);
|
||||
void popBack();
|
||||
void delNode(tp::List<Object*>::Node*);
|
||||
void delNode(List<Object*>::Node*);
|
||||
|
||||
private:
|
||||
tp::List<Object*> items;
|
||||
List<Object*> items;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
#include "primitives/StringObject.hpp"
|
||||
#include "interpreter/Script.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct MethodObject : Object {
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ namespace obj {
|
|||
static void constructor(MethodObject* self);
|
||||
static void copy(MethodObject* self, MethodObject* in);
|
||||
static void destructor(MethodObject* self);
|
||||
static tp::alni save_size(MethodObject* self);
|
||||
static alni save_size(MethodObject* self);
|
||||
static void save(MethodObject* self, ArchiverOut& file_self);
|
||||
static void load(ArchiverIn& file_self, obj::MethodObject* self);
|
||||
|
||||
|
|
@ -25,4 +25,4 @@ namespace obj {
|
|||
|
||||
static MethodObject* create(const std::string& script);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
extern struct NullObject* NdoNull_globalInstance;
|
||||
|
||||
|
|
@ -15,18 +15,18 @@ namespace obj {
|
|||
static Object* null_return() {
|
||||
if (!NdoNull_globalInstance) {
|
||||
NdoNull_globalInstance = (NullObject*) NDO->create("null");
|
||||
obj::NDO->refinc(NdoNull_globalInstance);
|
||||
NDO->increaseReferenceCount(NdoNull_globalInstance);
|
||||
}
|
||||
return (Object*) NdoNull_globalInstance;
|
||||
}
|
||||
|
||||
static Object* null_return_ref() {
|
||||
obj::NDO->refinc(null_return());
|
||||
NDO->increaseReferenceCount(null_return());
|
||||
return NdoNull_globalInstance;
|
||||
}
|
||||
};
|
||||
|
||||
#define NDO_NULL obj::NullObject::null_return()
|
||||
#define NDO_NULL_REF obj::NullObject::null_return_ref()
|
||||
#define NDO_NULL NullObject::null_return()
|
||||
#define NDO_NULL_REF NullObject::null_return_ref()
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
namespace obj {
|
||||
namespace tp::obj {
|
||||
|
||||
struct StringObject : Object {
|
||||
std::string val;
|
||||
|
|
@ -14,11 +14,11 @@ namespace obj {
|
|||
static void copy(Object* self, const Object* in);
|
||||
static StringObject* create(const std::string& in);
|
||||
|
||||
static void from_int(StringObject* self, tp::alni in);
|
||||
static void from_float(StringObject* self, tp::alnf in);
|
||||
static void from_int(StringObject* self, alni in);
|
||||
static void from_float(StringObject* self, alnf in);
|
||||
static void from_string(StringObject* self, const std::string& in);
|
||||
static std::string to_string(StringObject* self);
|
||||
static tp::alni to_int(StringObject* self);
|
||||
static tp::alnf to_float(StringObject* self);
|
||||
static alni to_int(StringObject* self);
|
||||
static alnf to_float(StringObject* self);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
namespace obj {
|
||||
|
||||
namespace tp::obj {
|
||||
struct TypeObject : Object {
|
||||
static ObjectType TypeData;
|
||||
const ObjectType* mTypeRef;
|
||||
static TypeObject* create(const ObjectType* type);
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue