Objects Initial
This commit is contained in:
parent
0f639ba3b1
commit
94057d2a66
76 changed files with 7895 additions and 17 deletions
46
Objects/public/interpreter/scopestack.h
Normal file
46
Objects/public/interpreter/scopestack.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#pragma once
|
||||
|
||||
#include "core/object.h"
|
||||
#include "Map.hpp"
|
||||
|
||||
namespace obj {
|
||||
|
||||
struct Scope {
|
||||
typedef tp::Map<tp::String, obj::Object*> ObjDict;
|
||||
typedef tp::List<obj::Object*> ObjList;
|
||||
|
||||
ObjDict mLocals;
|
||||
ObjList mTemps;
|
||||
bool mChildReachable = true;
|
||||
|
||||
~Scope();
|
||||
};
|
||||
|
||||
class ScopeStack {
|
||||
|
||||
enum : tp::alni {
|
||||
MAX_STACK_SIZE = 1024 * 4
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
Scope* mBuff;
|
||||
tp::ualni mIdx;
|
||||
tp::ualni mIterIdx;
|
||||
|
||||
ScopeStack();
|
||||
void enterScope(bool aChildReachable);
|
||||
void leaveScope();
|
||||
void addLocal(obj::Object* local, tp::String id);
|
||||
void addTemp(obj::Object* tmp);
|
||||
void popTemp();
|
||||
void addTempReturn(obj::Object* ret);
|
||||
obj::Object* getLocal(tp::String& str);
|
||||
Scope* getCurrentScope();
|
||||
~ScopeStack();
|
||||
|
||||
private:
|
||||
obj::Object* getLocalUtil(Scope& scope, tp::String* id);
|
||||
};
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue