28 Star 110 Fork 86

hinus/pythonvm

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
generator.cpp 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
hinus 提交于 2018-10-10 10:27 +08:00 . Summary: generator
#include "runtime/generator.hpp"
#include "runtime/functionObject.hpp"
#include "runtime/frameObject.hpp"
#include "runtime/interpreter.hpp"
#include "code/codeObject.hpp"
#include "object/hiDict.hpp"
#include "object/hiList.hpp"
#include "memory/oopClosure.hpp"
GeneratorKlass* GeneratorKlass::instance = NULL;
GeneratorKlass::GeneratorKlass() {
}
GeneratorKlass* GeneratorKlass::get_instance() {
if (instance == NULL)
instance = new GeneratorKlass();
return instance;
}
HiObject* GeneratorKlass::iter(HiObject* obj) {
return obj;
}
HiObject* GeneratorKlass::next(HiObject* obj) {
assert(obj->klass() == (Klass*) this);
Generator* g = (Generator*) obj;
return Interpreter::get_instance()->eval_generator(g);
}
size_t GeneratorKlass::size() {
return sizeof(Generator);
}
void GeneratorKlass::oops_do(OopClosure* f, HiObject* obj) {
Generator* g = (Generator*)obj;
assert(g->klass() == (Klass*)this);
if (g->frame())
g->frame()->oops_do(f);
}
Generator::Generator(FunctionObject* func, ArrayList<HiObject*>* args, int arg_cnt) {
_frame = new FrameObject(func, args, arg_cnt);
set_klass(GeneratorKlass::get_instance());
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/hinus/pythonvm.git
git@gitee.com:hinus/pythonvm.git
hinus
pythonvm
pythonvm
master

搜索帮助