This commit is contained in:
blueloveTH 2023-04-04 22:55:57 +08:00
parent 22e909d7e1
commit a187e5bcdb
2 changed files with 8 additions and 5 deletions

View File

@ -60,6 +60,7 @@ struct CodeObject {
std::set<StrName> global_names; std::set<StrName> global_names;
std::vector<CodeBlock> blocks = { CodeBlock{NO_BLOCK, -1} }; std::vector<CodeBlock> blocks = { CodeBlock{NO_BLOCK, -1} };
std::map<StrName, int> labels; std::map<StrName, int> labels;
std::vector<FunctionDecl> functions;
// may be.. just use a large NameDict? // may be.. just use a large NameDict?
uint32_t perfect_locals_capacity = 2; uint32_t perfect_locals_capacity = 2;

View File

@ -24,7 +24,7 @@ struct NativeFunc {
PyObject* operator()(VM* vm, Args& args) const; PyObject* operator()(VM* vm, Args& args) const;
}; };
struct Function { struct FunctionDecl {
StrName name; StrName name;
CodeObject_ code; CodeObject_ code;
std::vector<StrName> args; std::vector<StrName> args;
@ -32,10 +32,6 @@ struct Function {
NameDict kwargs; // empty if no k=v NameDict kwargs; // empty if no k=v
std::vector<StrName> kwargs_order; std::vector<StrName> kwargs_order;
// runtime settings
PyObject* _module = nullptr;
NameDict_ _closure = nullptr;
bool has_name(StrName val) const { bool has_name(StrName val) const {
bool _0 = std::find(args.begin(), args.end(), val) != args.end(); bool _0 = std::find(args.begin(), args.end(), val) != args.end();
bool _1 = starred_arg == val; bool _1 = starred_arg == val;
@ -44,6 +40,12 @@ struct Function {
} }
}; };
struct Function{
const FunctionDecl* decl;
PyObject* _module = nullptr;
NameDict_ _closure = nullptr;
};
struct BoundMethod { struct BoundMethod {
PyObject* obj; PyObject* obj;
PyObject* method; PyObject* method;