mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
some more replace
This commit is contained in:
parent
cbe8945d37
commit
ffee64655e
@ -71,7 +71,7 @@ struct CodeObject {
|
|||||||
std::vector<int> iblocks; // block index for each bytecode
|
std::vector<int> iblocks; // block index for each bytecode
|
||||||
std::vector<LineInfo> lines;
|
std::vector<LineInfo> lines;
|
||||||
|
|
||||||
small_vector<PyObject*, 8> consts;
|
small_vector_no_copy_and_move<PyObject*, 8> consts;
|
||||||
|
|
||||||
pod_vector<StrName> varnames; // local variables
|
pod_vector<StrName> varnames; // local variables
|
||||||
NameDictInt varnames_inv;
|
NameDictInt varnames_inv;
|
||||||
@ -97,8 +97,10 @@ struct FuncDecl {
|
|||||||
PyObject* value; // default value
|
PyObject* value; // default value
|
||||||
};
|
};
|
||||||
CodeObject_ code; // code object of this function
|
CodeObject_ code; // code object of this function
|
||||||
pod_vector<int> args; // indices in co->varnames
|
|
||||||
pod_vector<KwArg> kwargs; // indices in co->varnames
|
small_vector_no_copy_and_move<int, 6> args; // indices in co->varnames
|
||||||
|
small_vector_no_copy_and_move<KwArg, 6> kwargs; // indices in co->varnames
|
||||||
|
|
||||||
int starred_arg = -1; // index in co->varnames, -1 if no *arg
|
int starred_arg = -1; // index in co->varnames, -1 if no *arg
|
||||||
int starred_kwarg = -1; // index in co->varnames, -1 if no **kwarg
|
int starred_kwarg = -1; // index in co->varnames, -1 if no **kwarg
|
||||||
bool nested = false; // whether this function is nested
|
bool nested = false; // whether this function is nested
|
||||||
|
@ -22,7 +22,7 @@ class Compiler {
|
|||||||
inline static PrattRule rules[kTokenCount];
|
inline static PrattRule rules[kTokenCount];
|
||||||
|
|
||||||
Lexer lexer;
|
Lexer lexer;
|
||||||
stack<CodeEmitContext> contexts;
|
stack_no_copy<CodeEmitContext> contexts;
|
||||||
VM* vm;
|
VM* vm;
|
||||||
bool unknown_global_scope; // for eval/exec() call
|
bool unknown_global_scope; // for eval/exec() call
|
||||||
bool used;
|
bool used;
|
||||||
|
@ -126,7 +126,7 @@ struct Frame {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using CallstackContainer = small_vector<Frame, 16>;
|
using CallstackContainer = small_vector_no_copy_and_move<Frame, 16>;
|
||||||
|
|
||||||
struct FrameId{
|
struct FrameId{
|
||||||
CallstackContainer* data;
|
CallstackContainer* data;
|
||||||
|
@ -104,7 +104,7 @@ struct Lexer {
|
|||||||
const char* curr_char;
|
const char* curr_char;
|
||||||
int current_line = 1;
|
int current_line = 1;
|
||||||
std::vector<Token> nexts;
|
std::vector<Token> nexts;
|
||||||
stack_no_copy<int, pod_vector<int>> indents;
|
stack_no_copy<int, small_vector_no_copy_and_move<int, 8>> indents;
|
||||||
int brackets_level = 0;
|
int brackets_level = 0;
|
||||||
bool used = false;
|
bool used = false;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ struct _FrameRecord{
|
|||||||
struct LineProfiler{
|
struct LineProfiler{
|
||||||
// filename -> records
|
// filename -> records
|
||||||
std::map<std::string_view, std::vector<_LineRecord>> records;
|
std::map<std::string_view, std::vector<_LineRecord>> records;
|
||||||
stack<_FrameRecord> frames;
|
stack_no_copy<_FrameRecord> frames;
|
||||||
std::set<FuncDecl*> functions;
|
std::set<FuncDecl*> functions;
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
|
@ -393,4 +393,17 @@ namespace pkpy
|
|||||||
m_end = m_begin;
|
m_end = m_begin;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// small_vector_no_copy_and_move
|
||||||
|
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
class small_vector_no_copy_and_move: public small_vector<T, N>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
small_vector_no_copy_and_move() = default;
|
||||||
|
small_vector_no_copy_and_move(const small_vector_no_copy_and_move& other) = delete;
|
||||||
|
small_vector_no_copy_and_move& operator=(const small_vector_no_copy_and_move& other) = delete;
|
||||||
|
small_vector_no_copy_and_move(small_vector_no_copy_and_move&& other) = delete;
|
||||||
|
small_vector_no_copy_and_move& operator=(small_vector_no_copy_and_move&& other) = delete;
|
||||||
|
};
|
||||||
} // namespace pkpy
|
} // namespace pkpy
|
@ -120,7 +120,7 @@ public:
|
|||||||
|
|
||||||
struct{
|
struct{
|
||||||
PyObject* error;
|
PyObject* error;
|
||||||
stack<ArgsView> s_view;
|
stack_no_copy<ArgsView> s_view;
|
||||||
} _c;
|
} _c;
|
||||||
|
|
||||||
PyObject* None;
|
PyObject* None;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user