Commit fabde965 authored by Kevin Modzelewski's avatar Kevin Modzelewski

got some more running

parent 2c20ac1d
...@@ -2654,6 +2654,7 @@ static int add_members(PyTypeObject* type, PyMemberDef* memb) noexcept { ...@@ -2654,6 +2654,7 @@ static int add_members(PyTypeObject* type, PyMemberDef* memb) noexcept {
return -1; return -1;
type->setattr(name, descr, NULL); type->setattr(name, descr, NULL);
Py_DECREF(descr); Py_DECREF(descr);
Py_DECREF(name);
} }
return 0; return 0;
} }
...@@ -2670,6 +2671,7 @@ static int add_getset(PyTypeObject* type, PyGetSetDef* gsp) noexcept { ...@@ -2670,6 +2671,7 @@ static int add_getset(PyTypeObject* type, PyGetSetDef* gsp) noexcept {
return -1; return -1;
type->setattr(name, descr, NULL); type->setattr(name, descr, NULL);
Py_DECREF(descr); Py_DECREF(descr);
Py_DECREF(name);
} }
return 0; return 0;
} }
......
This diff is collapsed.
...@@ -113,7 +113,7 @@ extern "C" int PyCode_GetArgCount(PyCodeObject* op) noexcept { ...@@ -113,7 +113,7 @@ extern "C" int PyCode_GetArgCount(PyCodeObject* op) noexcept {
void setupCode() { void setupCode() {
code_cls = BoxedClass::create(type_cls, object_cls, 0, 0, sizeof(BoxedCode), false, "code"); code_cls = BoxedClass::create(type_cls, object_cls, 0, 0, sizeof(BoxedCode), false, "code");
code_cls->giveAttr("__new__", None); // Hacky way of preventing users from instantiating this code_cls->giveAttrBorrowed("__new__", None); // Hacky way of preventing users from instantiating this
code_cls->giveAttr("co_name", new (pyston_getset_cls) BoxedGetsetDescriptor(BoxedCode::name, NULL, NULL)); code_cls->giveAttr("co_name", new (pyston_getset_cls) BoxedGetsetDescriptor(BoxedCode::name, NULL, NULL));
code_cls->giveAttr("co_filename", new (pyston_getset_cls) BoxedGetsetDescriptor(BoxedCode::filename, NULL, NULL)); code_cls->giveAttr("co_filename", new (pyston_getset_cls) BoxedGetsetDescriptor(BoxedCode::filename, NULL, NULL));
......
...@@ -272,7 +272,7 @@ void setupXrange() { ...@@ -272,7 +272,7 @@ void setupXrange() {
xrange_iterator_cls->giveAttr("next", new BoxedFunction(next)); xrange_iterator_cls->giveAttr("next", new BoxedFunction(next));
// TODO this is pretty hacky, but stuff the iterator cls into xrange to make sure it gets decref'd at the end // TODO this is pretty hacky, but stuff the iterator cls into xrange to make sure it gets decref'd at the end
xrange_cls->giveAttr("__iterator_cls__", xrange_iterator_cls); xrange_cls->giveAttrBorrowed("__iterator_cls__", xrange_iterator_cls);
xrange_cls->freeze(); xrange_cls->freeze();
xrange_cls->tp_iter = xrangeIter; xrange_cls->tp_iter = xrangeIter;
......
...@@ -373,7 +373,7 @@ BoxedBuiltinFunctionOrMethod::BoxedBuiltinFunctionOrMethod(FunctionMetadata* md, ...@@ -373,7 +373,7 @@ BoxedBuiltinFunctionOrMethod::BoxedBuiltinFunctionOrMethod(FunctionMetadata* md,
: BoxedBuiltinFunctionOrMethod(md, name, {}) { : BoxedBuiltinFunctionOrMethod(md, name, {}) {
Py_DECREF(this->doc); Py_DECREF(this->doc);
this->doc = doc ? boxString(doc) : None; this->doc = doc ? boxString(doc) : incref(None);
} }
BoxedBuiltinFunctionOrMethod::BoxedBuiltinFunctionOrMethod(FunctionMetadata* md, const char* name, BoxedBuiltinFunctionOrMethod::BoxedBuiltinFunctionOrMethod(FunctionMetadata* md, const char* name,
...@@ -3781,40 +3781,19 @@ void setupRuntime() { ...@@ -3781,40 +3781,19 @@ void setupRuntime() {
setupClassobj(); setupClassobj();
setupSuper(); setupSuper();
_PyUnicode_Init(); _PyUnicode_Init();
// XXX
PyType_ClearCache();
_Py_ReleaseInternedStrings();
_PyUnicode_Fini();
for (auto b : classes)
b->clearAttrs();
for (auto b : constants) {
b->clearAttrs();
Py_DECREF(b);
}
for (auto b : classes) {
if (b->tp_mro) {
Py_DECREF(b->tp_mro);
}
Py_DECREF(b);
}
PRINT_TOTAL_REFS();
exit(0);
// XXX
setupDescr(); setupDescr();
setupTraceback(); setupTraceback();
setupCode(); setupCode();
setupFrame(); setupFrame();
function_cls->giveAttr("__dict__", dict_descr); function_cls->giveAttrBorrowed("__dict__", dict_descr);
function_cls->giveAttr("__name__", new (pyston_getset_cls) BoxedGetsetDescriptor(funcName, funcSetName, NULL)); function_cls->giveAttr("__name__", new (pyston_getset_cls) BoxedGetsetDescriptor(funcName, funcSetName, NULL));
function_cls->giveAttr("__repr__", new BoxedFunction(FunctionMetadata::create((void*)functionRepr, STR, 1))); function_cls->giveAttr("__repr__", new BoxedFunction(FunctionMetadata::create((void*)functionRepr, STR, 1)));
function_cls->giveAttr("__module__", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, function_cls->giveAttr("__module__", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT,
offsetof(BoxedFunction, modname), false)); offsetof(BoxedFunction, modname), false));
function_cls->giveAttr( function_cls->giveAttr(
"__doc__", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedFunction, doc), false)); "__doc__", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedFunction, doc), false));
function_cls->giveAttr("func_doc", function_cls->getattr(internStringMortal("__doc__"))); function_cls->giveAttrBorrowed("func_doc", function_cls->getattr(getStaticString("__doc__")));
function_cls->giveAttr("__globals__", new (pyston_getset_cls) BoxedGetsetDescriptor(functionGlobals, NULL, NULL)); function_cls->giveAttr("__globals__", new (pyston_getset_cls) BoxedGetsetDescriptor(functionGlobals, NULL, NULL));
function_cls->giveAttr("__get__", new BoxedFunction(FunctionMetadata::create((void*)functionGet, UNKNOWN, 3))); function_cls->giveAttr("__get__", new BoxedFunction(FunctionMetadata::create((void*)functionGet, UNKNOWN, 3)));
function_cls->giveAttr("__call__", function_cls->giveAttr("__call__",
...@@ -3823,12 +3802,12 @@ void setupRuntime() { ...@@ -3823,12 +3802,12 @@ void setupRuntime() {
new BoxedFunction(FunctionMetadata::create((void*)functionNonzero, BOXED_BOOL, 1))); new BoxedFunction(FunctionMetadata::create((void*)functionNonzero, BOXED_BOOL, 1)));
function_cls->giveAttr("func_code", function_cls->giveAttr("func_code",
new (pyston_getset_cls) BoxedGetsetDescriptor(functionCode, functionSetCode, NULL)); new (pyston_getset_cls) BoxedGetsetDescriptor(functionCode, functionSetCode, NULL));
function_cls->giveAttr("__code__", function_cls->getattr(internStringMortal("func_code"))); function_cls->giveAttrBorrowed("__code__", function_cls->getattr(getStaticString("func_code")));
function_cls->giveAttr("func_name", function_cls->getattr(internStringMortal("__name__"))); function_cls->giveAttrBorrowed("func_name", function_cls->getattr(getStaticString("__name__")));
function_cls->giveAttr("func_defaults", function_cls->giveAttr("func_defaults",
new (pyston_getset_cls) BoxedGetsetDescriptor(functionDefaults, functionSetDefaults, NULL)); new (pyston_getset_cls) BoxedGetsetDescriptor(functionDefaults, functionSetDefaults, NULL));
function_cls->giveAttr("__defaults__", function_cls->getattr(internStringMortal("func_defaults"))); function_cls->giveAttrBorrowed("__defaults__", function_cls->getattr(getStaticString("func_defaults")));
function_cls->giveAttr("func_globals", function_cls->getattr(internStringMortal("__globals__"))); function_cls->giveAttrBorrowed("func_globals", function_cls->getattr(getStaticString("__globals__")));
function_cls->freeze(); function_cls->freeze();
function_cls->tp_descr_get = function_descr_get; function_cls->tp_descr_get = function_descr_get;
...@@ -3861,10 +3840,10 @@ void setupRuntime() { ...@@ -3861,10 +3840,10 @@ void setupRuntime() {
"__call__", new BoxedFunction(FunctionMetadata::create((void*)instancemethodCall, UNKNOWN, 1, true, true))); "__call__", new BoxedFunction(FunctionMetadata::create((void*)instancemethodCall, UNKNOWN, 1, true, true)));
instancemethod_cls->giveAttr( instancemethod_cls->giveAttr(
"im_func", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedInstanceMethod, func))); "im_func", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedInstanceMethod, func)));
instancemethod_cls->giveAttr("__func__", instancemethod_cls->getattr(internStringMortal("im_func"))); instancemethod_cls->giveAttrBorrowed("__func__", instancemethod_cls->getattr(getStaticString("im_func")));
instancemethod_cls->giveAttr( instancemethod_cls->giveAttr(
"im_self", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedInstanceMethod, obj))); "im_self", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedInstanceMethod, obj)));
instancemethod_cls->giveAttr("__self__", instancemethod_cls->getattr(internStringMortal("im_self"))); instancemethod_cls->giveAttrBorrowed("__self__", instancemethod_cls->getattr(getStaticString("im_self")));
instancemethod_cls->freeze(); instancemethod_cls->freeze();
instancemethod_cls->giveAttr("im_class", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, instancemethod_cls->giveAttr("im_class", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT,
...@@ -3943,12 +3922,32 @@ void setupRuntime() { ...@@ -3943,12 +3922,32 @@ void setupRuntime() {
attrwrapperiter_cls->tp_iternext = AttrWrapperIter::next_capi; attrwrapperiter_cls->tp_iternext = AttrWrapperIter::next_capi;
setupBuiltins(); setupBuiltins();
_PyExc_Init(); //_PyExc_Init();
setupThread(); //setupThread();
initgc(); //initgc();
setupImport(); //setupImport();
setupPyston(); //setupPyston();
setupAST(); //setupAST();
// XXX
PyType_ClearCache();
_Py_ReleaseInternedStrings();
_PyUnicode_Fini();
for (auto b : classes)
b->clearAttrs();
for (auto b : constants) {
b->clearAttrs();
Py_DECREF(b);
}
for (auto b : classes) {
if (b->tp_mro) {
Py_DECREF(b->tp_mro);
}
Py_DECREF(b);
}
PRINT_TOTAL_REFS();
exit(0);
// XXX
PyType_Ready(&PyByteArrayIter_Type); PyType_Ready(&PyByteArrayIter_Type);
PyType_Ready(&PyCapsule_Type); PyType_Ready(&PyCapsule_Type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment