Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
fabde965
Commit
fabde965
authored
Nov 13, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
got some more running
parent
2c20ac1d
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
82 deletions
+86
-82
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+2
-0
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+47
-44
src/runtime/code.cpp
src/runtime/code.cpp
+1
-1
src/runtime/inline/xrange.cpp
src/runtime/inline/xrange.cpp
+1
-1
src/runtime/types.cpp
src/runtime/types.cpp
+35
-36
No files found.
src/capi/typeobject.cpp
View file @
fabde965
...
...
@@ -2654,6 +2654,7 @@ static int add_members(PyTypeObject* type, PyMemberDef* memb) noexcept {
return
-
1
;
type
->
setattr
(
name
,
descr
,
NULL
);
Py_DECREF
(
descr
);
Py_DECREF
(
name
);
}
return
0
;
}
...
...
@@ -2670,6 +2671,7 @@ static int add_getset(PyTypeObject* type, PyGetSetDef* gsp) noexcept {
return
-
1
;
type
->
setattr
(
name
,
descr
,
NULL
);
Py_DECREF
(
descr
);
Py_DECREF
(
name
);
}
return
0
;
}
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
fabde965
This diff is collapsed.
Click to expand it.
src/runtime/code.cpp
View file @
fabde965
...
...
@@ -113,7 +113,7 @@ extern "C" int PyCode_GetArgCount(PyCodeObject* op) noexcept {
void
setupCode
()
{
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
->
giveAttr
Borrowed
(
"__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_filename"
,
new
(
pyston_getset_cls
)
BoxedGetsetDescriptor
(
BoxedCode
::
filename
,
NULL
,
NULL
));
...
...
src/runtime/inline/xrange.cpp
View file @
fabde965
...
...
@@ -272,7 +272,7 @@ void setupXrange() {
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
xrange_cls
->
giveAttr
(
"__iterator_cls__"
,
xrange_iterator_cls
);
xrange_cls
->
giveAttr
Borrowed
(
"__iterator_cls__"
,
xrange_iterator_cls
);
xrange_cls
->
freeze
();
xrange_cls
->
tp_iter
=
xrangeIter
;
...
...
src/runtime/types.cpp
View file @
fabde965
...
...
@@ -373,7 +373,7 @@ BoxedBuiltinFunctionOrMethod::BoxedBuiltinFunctionOrMethod(FunctionMetadata* md,
:
BoxedBuiltinFunctionOrMethod
(
md
,
name
,
{})
{
Py_DECREF
(
this
->
doc
);
this
->
doc
=
doc
?
boxString
(
doc
)
:
None
;
this
->
doc
=
doc
?
boxString
(
doc
)
:
incref
(
None
)
;
}
BoxedBuiltinFunctionOrMethod
::
BoxedBuiltinFunctionOrMethod
(
FunctionMetadata
*
md
,
const
char
*
name
,
...
...
@@ -3781,40 +3781,19 @@ void setupRuntime() {
setupClassobj
();
setupSuper
();
_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
();
setupTraceback
();
setupCode
();
setupFrame
();
function_cls
->
giveAttr
(
"__dict__"
,
dict_descr
);
function_cls
->
giveAttr
Borrowed
(
"__dict__"
,
dict_descr
);
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
(
"__module__"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
offsetof
(
BoxedFunction
,
modname
),
false
));
function_cls
->
giveAttr
(
"__doc__"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
offsetof
(
BoxedFunction
,
doc
),
false
));
function_cls
->
giveAttr
(
"func_doc"
,
function_cls
->
getattr
(
internStringMortal
(
"__doc__"
)));
function_cls
->
giveAttr
Borrowed
(
"func_doc"
,
function_cls
->
getattr
(
getStaticString
(
"__doc__"
)));
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
(
"__call__"
,
...
...
@@ -3823,12 +3802,12 @@ void setupRuntime() {
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
functionNonzero
,
BOXED_BOOL
,
1
)));
function_cls
->
giveAttr
(
"func_code"
,
new
(
pyston_getset_cls
)
BoxedGetsetDescriptor
(
functionCode
,
functionSetCode
,
NULL
));
function_cls
->
giveAttr
(
"__code__"
,
function_cls
->
getattr
(
internStringMortal
(
"func_code"
)));
function_cls
->
giveAttr
(
"func_name"
,
function_cls
->
getattr
(
internStringMortal
(
"__name__"
)));
function_cls
->
giveAttr
Borrowed
(
"__code__"
,
function_cls
->
getattr
(
getStaticString
(
"func_code"
)));
function_cls
->
giveAttr
Borrowed
(
"func_name"
,
function_cls
->
getattr
(
getStaticString
(
"__name__"
)));
function_cls
->
giveAttr
(
"func_defaults"
,
new
(
pyston_getset_cls
)
BoxedGetsetDescriptor
(
functionDefaults
,
functionSetDefaults
,
NULL
));
function_cls
->
giveAttr
(
"__defaults__"
,
function_cls
->
getattr
(
internStringMortal
(
"func_defaults"
)));
function_cls
->
giveAttr
(
"func_globals"
,
function_cls
->
getattr
(
internStringMortal
(
"__globals__"
)));
function_cls
->
giveAttr
Borrowed
(
"__defaults__"
,
function_cls
->
getattr
(
getStaticString
(
"func_defaults"
)));
function_cls
->
giveAttr
Borrowed
(
"func_globals"
,
function_cls
->
getattr
(
getStaticString
(
"__globals__"
)));
function_cls
->
freeze
();
function_cls
->
tp_descr_get
=
function_descr_get
;
...
...
@@ -3861,10 +3840,10 @@ void setupRuntime() {
"__call__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
instancemethodCall
,
UNKNOWN
,
1
,
true
,
true
)));
instancemethod_cls
->
giveAttr
(
"im_func"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
offsetof
(
BoxedInstanceMethod
,
func
)));
instancemethod_cls
->
giveAttr
(
"__func__"
,
instancemethod_cls
->
getattr
(
internStringMortal
(
"im_func"
)));
instancemethod_cls
->
giveAttr
Borrowed
(
"__func__"
,
instancemethod_cls
->
getattr
(
getStaticString
(
"im_func"
)));
instancemethod_cls
->
giveAttr
(
"im_self"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
offsetof
(
BoxedInstanceMethod
,
obj
)));
instancemethod_cls
->
giveAttr
(
"__self__"
,
instancemethod_cls
->
getattr
(
internStringMortal
(
"im_self"
)));
instancemethod_cls
->
giveAttr
Borrowed
(
"__self__"
,
instancemethod_cls
->
getattr
(
getStaticString
(
"im_self"
)));
instancemethod_cls
->
freeze
();
instancemethod_cls
->
giveAttr
(
"im_class"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
...
...
@@ -3943,12 +3922,32 @@ void setupRuntime() {
attrwrapperiter_cls
->
tp_iternext
=
AttrWrapperIter
::
next_capi
;
setupBuiltins
();
_PyExc_Init
();
setupThread
();
initgc
();
setupImport
();
setupPyston
();
setupAST
();
//_PyExc_Init();
//setupThread();
//initgc();
//setupImport();
//setupPyston();
//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
(
&
PyCapsule_Type
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment