RIP tp::Strings

This commit is contained in:
IlyaShurupov 2024-03-22 14:44:26 +03:00
parent aa53a4addb
commit 893a07e924
90 changed files with 419 additions and 1475 deletions

View file

@ -3,8 +3,6 @@
#include "primitives/primitives.h"
#include "Logging.hpp"
#include "Timing.hpp"
using namespace obj;
@ -224,9 +222,9 @@ void Interpreter::stepBytecodeIn() {
auto obj = mOperandsStack.getOperand();
if (obj->type->convesions && obj->type->convesions->to_string) {
auto str = NDO->toString(obj);
gLogger->write(str, true);
printf("%s\n", str.c_str());
} else {
gLogger->write(String(obj->type->name), true);
printf("Object with type '%s' has no string representation.\n", obj->type->name);
}
break;
}

View file

@ -12,9 +12,9 @@ Scope::~Scope() {
}
}
obj::Object* ScopeStack::getLocalUtil(Scope& scope, tp::String* id) {
obj::Object* ScopeStack::getLocalUtil(Scope& scope, const std::string& id) {
auto idx = scope.mLocals.presents(*id);
auto idx = scope.mLocals.presents(id);
if (idx) {
return scope.mLocals.getSlotVal(idx);
@ -62,7 +62,7 @@ void ScopeStack::addTempReturn(obj::Object* ret) {
}
}
void ScopeStack::addLocal(obj::Object* local, tp::String id) {
void ScopeStack::addLocal(obj::Object* local, const std::string& id) {
DEBUG_ASSERT(mIdx != 0 && "No scope given");
Scope::ObjDict& locals = mBuff[mIdx - 1].mLocals;
auto idx = locals.presents(id);
@ -73,9 +73,9 @@ void ScopeStack::addLocal(obj::Object* local, tp::String id) {
locals.put(id, local);
}
obj::Object* ScopeStack::getLocal(tp::String& str) {
obj::Object* ScopeStack::getLocal(const std::string& str) {
mIterIdx = mIdx - 1;
return getLocalUtil(mBuff[mIdx - 1], &str);
return getLocalUtil(mBuff[mIdx - 1], str);
}
Scope* ScopeStack::getCurrentScope() { return &mBuff[mIdx - 1]; }