RIP tp::Strings

This commit is contained in:
IlyaShurupov 2024-03-22 14:44:26 +03:00 committed by Ilya Shurupov
parent fa2d0aaa92
commit 1756ca026d
90 changed files with 419 additions and 1475 deletions

View file

@ -9,7 +9,7 @@ namespace obj {
class ConstObject {
public:
obj::Object* mObj = NULL;
obj::Object* mObj = nullptr;
tp::alni mConstIdx = 0;
ConstObject();
@ -19,8 +19,8 @@ namespace obj {
class ConstObjectsPool {
public:
tp::Map<tp::String, ConstObject*> mMethods;
tp::Map<tp::String, ConstObject*> mStrings;
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;
@ -30,11 +30,11 @@ namespace obj {
tp::alni mTotalObjects = 0;
ConstObject* get(tp::alni val);
ConstObject* get(tp::String val);
ConstObject* get(const std::string& val);
ConstObject* get(tp::alnf val);
ConstObject* get(bool val);
ConstObject* addMethod(tp::String method_id, obj::Object* method);
ConstObject* addMethod(const std::string& method_id, obj::Object* method);
ConstObject* registerObject(obj::Object* obj);
void save(tp::Buffer<ConstData>& out);

View file

@ -1,7 +1,7 @@
#pragma once
#include "Strings.hpp"
#include <string>
#include "Buffer.hpp"
#include "interpreter/opcodes.h"
@ -28,7 +28,7 @@ namespace obj::BCgen {
explicit Expression(Type type);
virtual ~Expression() = default;
struct ExpressionChild* ExprChild(const tp::String& id);
struct ExpressionChild* ExprChild(const std::string& id);
struct ExpressionCall* ExprCall(class ExpressionList* args);
};
@ -39,28 +39,28 @@ namespace obj::BCgen {
};
struct ExpressionNew : public Expression {
tp::String mNewType;
explicit ExpressionNew(const tp::String& type);
std::string mNewType;
explicit ExpressionNew(const std::string& type);
~ExpressionNew() override;
};
struct ExpressionLocal : public Expression {
tp::String mLocalId;
explicit ExpressionLocal(const tp::String& id);
std::string mLocalId;
explicit ExpressionLocal(const std::string& id);
~ExpressionLocal() override;
};
struct ExpressionFunc : public Expression {
tp::String mFuncId;
explicit ExpressionFunc(const tp::String& id);
std::string mFuncId;
explicit ExpressionFunc(const std::string& id);
~ExpressionFunc() override;
};
struct ExpressionChild : public Expression {
Expression* mParent = nullptr;
tp::String mLocalId;
std::string mLocalId;
bool mMethod = false;
ExpressionChild(Expression* mParent, const tp::String& id);
ExpressionChild(Expression* mParent, const std::string& id);
~ExpressionChild() override;
};
@ -102,12 +102,12 @@ namespace obj::BCgen {
struct ExpressionConst : public Expression {
enum ConstType { STR, INT, BOOL, FLT } mConstType;
tp::String str;
std::string str;
tp::alni integer = 0;
tp::alnf floating = 0;
bool boolean = false;
explicit ExpressionConst(const tp::String& val);
explicit ExpressionConst(const std::string& val);
explicit ExpressionConst(const char* val);
explicit ExpressionConst(tp::alni val);
explicit ExpressionConst(tp::int4 val);

View file

@ -1,7 +1,7 @@
#pragma once
#include "Strings.hpp"
#include <string>
#include "List.hpp"
#include "Map.hpp"
@ -16,17 +16,17 @@ namespace obj {
struct FunctionDefinition {
FunctionDefinition* mPrnt = NULL;
FunctionDefinition* mPrnt = nullptr;
// signature
tp::String mFunctionId;
std::string mFunctionId;
tp::List<ConstObject*> mArgsOrder;
ConstObjectsPool mConstants;
tp::Map<tp::String, ConstObject*> mLocals;
tp::Map<std::string, ConstObject*> mLocals;
tp::List<Instruction> mInstructions;
FunctionDefinition(tp::String function_id, tp::Buffer<tp::String> args, FunctionDefinition* prnt);
FunctionDefinition(const std::string& function_id, tp::Buffer<std::string> args, FunctionDefinition* prnt);
FunctionDefinition() {}
void generateByteCode(ByteCode& out);
@ -36,7 +36,7 @@ namespace obj {
void EvalExpr(Expression* expr);
void EvalStatement(Statement* expr);
ConstObject* defineLocal(tp::String id);
ConstObject* defineLocal(const std::string& id);
};
void init();

View file

@ -35,11 +35,11 @@ namespace obj {
tp::alni mParam = 0;
tp::alni mParamBytes = 1;
ConstObject* mConstData = NULL;
ConstObject* mConstData2 = NULL;
ConstObject* mConstData = nullptr;
ConstObject* mConstData2 = nullptr;
tp::alni mInstIdx = 0;
Instruction* mInstTarget = NULL;
Instruction* mInstTarget = nullptr;
Instruction();
Instruction(ConstObject* constData);

View file

@ -36,21 +36,21 @@ namespace obj::BCgen {
};
struct StatementFuncDef : public Statement {
tp::Buffer<tp::String> mArgs;
tp::String mFunctionId;
tp::Buffer<std::string> mArgs;
std::string mFunctionId;
StatementScope* mStatements = nullptr;
explicit StatementFuncDef(const tp::String& function_id);
explicit StatementFuncDef(const std::string& function_id);
~StatementFuncDef() override;
};
struct StatementLocalDef : public Statement {
tp::String mLocalId;
std::string mLocalId;
Expression* mNewExpr = nullptr;
ExpressionConst* mConstExpr = nullptr;
bool mIsConstExpr = false;
StatementLocalDef(const tp::String& id, Expression* value);
StatementLocalDef(const std::string& id, Expression* value);
~StatementLocalDef() override;
};
@ -102,10 +102,10 @@ namespace obj::BCgen {
};
struct StatementClassDef : public Statement {
tp::String mClassId;
std::string mClassId;
StatementScope* mScope = nullptr;
StatementClassDef(const tp::String& class_id, StatementScope* scope);
StatementClassDef(const std::string& class_id, StatementScope* scope);
~StatementClassDef() override;
};
}