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
f1428058
Commit
f1428058
authored
Mar 18, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
I guess I missed the subdirectories of runtime/
parent
5078c462
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
88 additions
and
51 deletions
+88
-51
src/capi/modsupport.cpp
src/capi/modsupport.cpp
+1
-1
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+35
-4
src/runtime/builtin_modules/pyston.cpp
src/runtime/builtin_modules/pyston.cpp
+3
-3
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+15
-9
src/runtime/builtin_modules/thread.cpp
src/runtime/builtin_modules/thread.cpp
+3
-3
src/runtime/classobj.cpp
src/runtime/classobj.cpp
+3
-3
src/runtime/descr.cpp
src/runtime/descr.cpp
+1
-1
src/runtime/float.cpp
src/runtime/float.cpp
+3
-3
src/runtime/inline/dict.cpp
src/runtime/inline/dict.cpp
+3
-3
src/runtime/inline/list.cpp
src/runtime/inline/list.cpp
+1
-1
src/runtime/inline/tuple.cpp
src/runtime/inline/tuple.cpp
+1
-1
src/runtime/inline/xrange.cpp
src/runtime/inline/xrange.cpp
+1
-1
src/runtime/int.cpp
src/runtime/int.cpp
+14
-14
src/runtime/iterators.cpp
src/runtime/iterators.cpp
+1
-1
src/runtime/list.cpp
src/runtime/list.cpp
+2
-2
src/runtime/types.cpp
src/runtime/types.cpp
+1
-1
No files found.
src/capi/modsupport.cpp
View file @
f1428058
...
@@ -372,7 +372,7 @@ static PyObject* va_build_value(const char* fmt, va_list va, int flags) noexcept
...
@@ -372,7 +372,7 @@ static PyObject* va_build_value(const char* fmt, va_list va, int flags) noexcept
return
NULL
;
return
NULL
;
if
(
n
==
0
)
if
(
n
==
0
)
return
None
;
return
incref
(
None
)
;
va_list
lva
;
va_list
lva
;
__va_copy
(
lva
,
va
);
__va_copy
(
lva
,
va
);
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
f1428058
...
@@ -140,6 +140,7 @@ extern "C" Box* octFunc(Box* x) {
...
@@ -140,6 +140,7 @@ extern "C" Box* octFunc(Box* x) {
extern
"C"
Box
*
all
(
Box
*
container
)
{
extern
"C"
Box
*
all
(
Box
*
container
)
{
for
(
Box
*
e
:
container
->
pyElements
())
{
for
(
Box
*
e
:
container
->
pyElements
())
{
AUTO_DECREF
(
e
);
if
(
!
nonzero
(
e
))
{
if
(
!
nonzero
(
e
))
{
return
boxBool
(
false
);
return
boxBool
(
false
);
}
}
...
@@ -149,6 +150,7 @@ extern "C" Box* all(Box* container) {
...
@@ -149,6 +150,7 @@ extern "C" Box* all(Box* container) {
extern
"C"
Box
*
any
(
Box
*
container
)
{
extern
"C"
Box
*
any
(
Box
*
container
)
{
for
(
Box
*
e
:
container
->
pyElements
())
{
for
(
Box
*
e
:
container
->
pyElements
())
{
AUTO_DECREF
(
e
);
if
(
nonzero
(
e
))
{
if
(
nonzero
(
e
))
{
return
boxBool
(
true
);
return
boxBool
(
true
);
}
}
...
@@ -157,6 +159,7 @@ extern "C" Box* any(Box* container) {
...
@@ -157,6 +159,7 @@ extern "C" Box* any(Box* container) {
}
}
Box
*
min_max
(
Box
*
arg0
,
BoxedTuple
*
args
,
BoxedDict
*
kwargs
,
int
opid
)
{
Box
*
min_max
(
Box
*
arg0
,
BoxedTuple
*
args
,
BoxedDict
*
kwargs
,
int
opid
)
{
assert
(
0
&&
"check refcounting"
);
assert
(
args
->
cls
==
tuple_cls
);
assert
(
args
->
cls
==
tuple_cls
);
if
(
kwargs
)
if
(
kwargs
)
assert
(
kwargs
->
cls
==
dict_cls
);
assert
(
kwargs
->
cls
==
dict_cls
);
...
@@ -222,6 +225,7 @@ Box* min_max(Box* arg0, BoxedTuple* args, BoxedDict* kwargs, int opid) {
...
@@ -222,6 +225,7 @@ Box* min_max(Box* arg0, BoxedTuple* args, BoxedDict* kwargs, int opid) {
}
}
extern
"C"
Box
*
min
(
Box
*
arg0
,
BoxedTuple
*
args
,
BoxedDict
*
kwargs
)
{
extern
"C"
Box
*
min
(
Box
*
arg0
,
BoxedTuple
*
args
,
BoxedDict
*
kwargs
)
{
assert
(
0
&&
"check refcounting"
);
if
(
arg0
==
None
&&
args
->
size
()
==
0
)
{
if
(
arg0
==
None
&&
args
->
size
()
==
0
)
{
raiseExcHelper
(
TypeError
,
"min expected 1 arguments, got 0"
);
raiseExcHelper
(
TypeError
,
"min expected 1 arguments, got 0"
);
}
}
...
@@ -235,6 +239,7 @@ extern "C" Box* min(Box* arg0, BoxedTuple* args, BoxedDict* kwargs) {
...
@@ -235,6 +239,7 @@ extern "C" Box* min(Box* arg0, BoxedTuple* args, BoxedDict* kwargs) {
}
}
extern
"C"
Box
*
max
(
Box
*
arg0
,
BoxedTuple
*
args
,
BoxedDict
*
kwargs
)
{
extern
"C"
Box
*
max
(
Box
*
arg0
,
BoxedTuple
*
args
,
BoxedDict
*
kwargs
)
{
assert
(
0
&&
"check refcounting"
);
if
(
arg0
==
None
&&
args
->
size
()
==
0
)
{
if
(
arg0
==
None
&&
args
->
size
()
==
0
)
{
raiseExcHelper
(
TypeError
,
"max expected 1 arguments, got 0"
);
raiseExcHelper
(
TypeError
,
"max expected 1 arguments, got 0"
);
}
}
...
@@ -248,6 +253,7 @@ extern "C" Box* max(Box* arg0, BoxedTuple* args, BoxedDict* kwargs) {
...
@@ -248,6 +253,7 @@ extern "C" Box* max(Box* arg0, BoxedTuple* args, BoxedDict* kwargs) {
}
}
extern
"C"
Box
*
next
(
Box
*
iterator
,
Box
*
_default
)
noexcept
{
extern
"C"
Box
*
next
(
Box
*
iterator
,
Box
*
_default
)
noexcept
{
assert
(
0
&&
"check refcounting"
);
if
(
!
PyIter_Check
(
iterator
))
{
if
(
!
PyIter_Check
(
iterator
))
{
PyErr_Format
(
PyExc_TypeError
,
"%.200s object is not an iterator"
,
iterator
->
cls
->
tp_name
);
PyErr_Format
(
PyExc_TypeError
,
"%.200s object is not an iterator"
,
iterator
->
cls
->
tp_name
);
return
NULL
;
return
NULL
;
...
@@ -280,6 +286,7 @@ extern "C" Box* next(Box* iterator, Box* _default) noexcept {
...
@@ -280,6 +286,7 @@ extern "C" Box* next(Box* iterator, Box* _default) noexcept {
}
}
extern
"C"
Box
*
sum
(
Box
*
container
,
Box
*
initial
)
{
extern
"C"
Box
*
sum
(
Box
*
container
,
Box
*
initial
)
{
assert
(
0
&&
"check refcounting"
);
if
(
initial
->
cls
==
str_cls
)
if
(
initial
->
cls
==
str_cls
)
raiseExcHelper
(
TypeError
,
"sum() can't sum strings [use ''.join(seq) instead]"
);
raiseExcHelper
(
TypeError
,
"sum() can't sum strings [use ''.join(seq) instead]"
);
...
@@ -307,6 +314,7 @@ Box* open(Box* arg1, Box* arg2, Box* arg3) {
...
@@ -307,6 +314,7 @@ Box* open(Box* arg1, Box* arg2, Box* arg3) {
}
}
extern
"C"
Box
*
chr
(
Box
*
arg
)
{
extern
"C"
Box
*
chr
(
Box
*
arg
)
{
assert
(
0
&&
"check refcounting"
);
i64
n
=
PyInt_AsLong
(
arg
);
i64
n
=
PyInt_AsLong
(
arg
);
if
(
n
==
-
1
&&
PyErr_Occurred
())
if
(
n
==
-
1
&&
PyErr_Occurred
())
throwCAPIException
();
throwCAPIException
();
...
@@ -320,6 +328,7 @@ extern "C" Box* chr(Box* arg) {
...
@@ -320,6 +328,7 @@ extern "C" Box* chr(Box* arg) {
}
}
extern
"C"
Box
*
unichr
(
Box
*
arg
)
{
extern
"C"
Box
*
unichr
(
Box
*
arg
)
{
assert
(
0
&&
"check refcounting"
);
int
n
=
-
1
;
int
n
=
-
1
;
if
(
!
PyArg_ParseSingle
(
arg
,
0
,
"unichr"
,
"i"
,
&
n
))
if
(
!
PyArg_ParseSingle
(
arg
,
0
,
"unichr"
,
"i"
,
&
n
))
throwCAPIException
();
throwCAPIException
();
...
@@ -331,6 +340,7 @@ extern "C" Box* unichr(Box* arg) {
...
@@ -331,6 +340,7 @@ extern "C" Box* unichr(Box* arg) {
}
}
Box
*
coerceFunc
(
Box
*
vv
,
Box
*
ww
)
{
Box
*
coerceFunc
(
Box
*
vv
,
Box
*
ww
)
{
assert
(
0
&&
"check refcounting"
);
Box
*
res
;
Box
*
res
;
if
(
PyErr_WarnPy3k
(
"coerce() not supported in 3.x"
,
1
)
<
0
)
if
(
PyErr_WarnPy3k
(
"coerce() not supported in 3.x"
,
1
)
<
0
)
...
@@ -343,6 +353,7 @@ Box* coerceFunc(Box* vv, Box* ww) {
...
@@ -343,6 +353,7 @@ Box* coerceFunc(Box* vv, Box* ww) {
}
}
extern
"C"
Box
*
ord
(
Box
*
obj
)
{
extern
"C"
Box
*
ord
(
Box
*
obj
)
{
assert
(
0
&&
"check refcounting"
);
long
ord
;
long
ord
;
Py_ssize_t
size
;
Py_ssize_t
size
;
...
@@ -422,6 +433,7 @@ Box* notimplementedRepr(Box* self) {
...
@@ -422,6 +433,7 @@ Box* notimplementedRepr(Box* self) {
}
}
Box
*
sorted
(
Box
*
obj
,
Box
*
cmp
,
Box
*
key
,
Box
**
args
)
{
Box
*
sorted
(
Box
*
obj
,
Box
*
cmp
,
Box
*
key
,
Box
**
args
)
{
assert
(
0
&&
"check refcounting"
);
Box
*
reverse
=
args
[
0
];
Box
*
reverse
=
args
[
0
];
BoxedList
*
rtn
=
new
BoxedList
();
BoxedList
*
rtn
=
new
BoxedList
();
...
@@ -448,8 +460,10 @@ Box* issubclass_func(Box* child, Box* parent) {
...
@@ -448,8 +460,10 @@ Box* issubclass_func(Box* child, Box* parent) {
}
}
Box
*
intern_func
(
Box
*
str
)
{
Box
*
intern_func
(
Box
*
str
)
{
assert
(
0
&&
"check refcounting"
);
if
(
!
PyString_CheckExact
(
str
))
// have to use exact check!
if
(
!
PyString_CheckExact
(
str
))
// have to use exact check!
raiseExcHelper
(
TypeError
,
"can't intern subclass of string"
);
raiseExcHelper
(
TypeError
,
"can't intern subclass of string"
);
Py_INCREF
(
str
);
PyString_InternInPlace
(
&
str
);
PyString_InternInPlace
(
&
str
);
checkAndThrowCAPIException
();
checkAndThrowCAPIException
();
return
str
;
return
str
;
...
@@ -482,6 +496,7 @@ Box* bltinImport(Box* name, Box* globals, Box* locals, Box** args) {
...
@@ -482,6 +496,7 @@ Box* bltinImport(Box* name, Box* globals, Box* locals, Box** args) {
}
}
Box
*
delattrFunc
(
Box
*
obj
,
Box
*
_str
)
{
Box
*
delattrFunc
(
Box
*
obj
,
Box
*
_str
)
{
assert
(
0
&&
"check refcounting"
);
_str
=
coerceUnicodeToStr
<
CXX
>
(
_str
);
_str
=
coerceUnicodeToStr
<
CXX
>
(
_str
);
if
(
_str
->
cls
!=
str_cls
)
if
(
_str
->
cls
!=
str_cls
)
...
@@ -490,7 +505,7 @@ Box* delattrFunc(Box* obj, Box* _str) {
...
@@ -490,7 +505,7 @@ Box* delattrFunc(Box* obj, Box* _str) {
internStringMortalInplace
(
str
);
internStringMortalInplace
(
str
);
delattr
(
obj
,
str
);
delattr
(
obj
,
str
);
return
None
;
return
incref
(
None
)
;
}
}
static
Box
*
getattrFuncHelper
(
STOLEN
(
Box
*
)
return_val
,
Box
*
obj
,
BoxedString
*
str
,
Box
*
default_val
)
noexcept
{
static
Box
*
getattrFuncHelper
(
STOLEN
(
Box
*
)
return_val
,
Box
*
obj
,
BoxedString
*
str
,
Box
*
default_val
)
noexcept
{
...
@@ -617,6 +632,7 @@ Box* getattrFuncInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args,
...
@@ -617,6 +632,7 @@ Box* getattrFuncInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args,
}
}
Box
*
setattrFunc
(
Box
*
obj
,
Box
*
_str
,
Box
*
value
)
{
Box
*
setattrFunc
(
Box
*
obj
,
Box
*
_str
,
Box
*
value
)
{
assert
(
0
&&
"check refcounting"
);
_str
=
coerceUnicodeToStr
<
CXX
>
(
_str
);
_str
=
coerceUnicodeToStr
<
CXX
>
(
_str
);
if
(
_str
->
cls
!=
str_cls
)
{
if
(
_str
->
cls
!=
str_cls
)
{
...
@@ -627,7 +643,7 @@ Box* setattrFunc(Box* obj, Box* _str, Box* value) {
...
@@ -627,7 +643,7 @@ Box* setattrFunc(Box* obj, Box* _str, Box* value) {
internStringMortalInplace
(
str
);
internStringMortalInplace
(
str
);
setattr
(
obj
,
str
,
value
);
setattr
(
obj
,
str
,
value
);
return
None
;
return
incref
(
None
)
;
}
}
static
Box
*
hasattrFuncHelper
(
Box
*
return_val
)
noexcept
{
static
Box
*
hasattrFuncHelper
(
Box
*
return_val
)
noexcept
{
...
@@ -742,6 +758,7 @@ Box* hasattrFuncInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args,
...
@@ -742,6 +758,7 @@ Box* hasattrFuncInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args,
}
}
Box
*
map2
(
Box
*
f
,
Box
*
container
)
{
Box
*
map2
(
Box
*
f
,
Box
*
container
)
{
assert
(
0
&&
"check refcounting"
);
Box
*
rtn
=
new
BoxedList
();
Box
*
rtn
=
new
BoxedList
();
bool
use_identity_func
=
f
==
None
;
bool
use_identity_func
=
f
==
None
;
for
(
Box
*
e
:
container
->
pyElements
())
{
for
(
Box
*
e
:
container
->
pyElements
())
{
...
@@ -756,6 +773,7 @@ Box* map2(Box* f, Box* container) {
...
@@ -756,6 +773,7 @@ Box* map2(Box* f, Box* container) {
}
}
Box
*
map
(
Box
*
f
,
BoxedTuple
*
args
)
{
Box
*
map
(
Box
*
f
,
BoxedTuple
*
args
)
{
assert
(
0
&&
"check refcounting"
);
assert
(
args
->
cls
==
tuple_cls
);
assert
(
args
->
cls
==
tuple_cls
);
auto
num_iterable
=
args
->
size
();
auto
num_iterable
=
args
->
size
();
if
(
num_iterable
<
1
)
if
(
num_iterable
<
1
)
...
@@ -811,6 +829,7 @@ Box* map(Box* f, BoxedTuple* args) {
...
@@ -811,6 +829,7 @@ Box* map(Box* f, BoxedTuple* args) {
}
}
Box
*
reduce
(
Box
*
f
,
Box
*
container
,
Box
*
initial
)
{
Box
*
reduce
(
Box
*
f
,
Box
*
container
,
Box
*
initial
)
{
assert
(
0
&&
"check refcounting"
);
Box
*
current
=
initial
;
Box
*
current
=
initial
;
for
(
Box
*
e
:
container
->
pyElements
())
{
for
(
Box
*
e
:
container
->
pyElements
())
{
...
@@ -831,6 +850,7 @@ Box* reduce(Box* f, Box* container, Box* initial) {
...
@@ -831,6 +850,7 @@ Box* reduce(Box* f, Box* container, Box* initial) {
// from cpython, bltinmodule.c
// from cpython, bltinmodule.c
PyObject
*
filterstring
(
PyObject
*
func
,
BoxedString
*
strobj
)
{
PyObject
*
filterstring
(
PyObject
*
func
,
BoxedString
*
strobj
)
{
assert
(
0
&&
"check refcounting"
);
PyObject
*
result
;
PyObject
*
result
;
Py_ssize_t
i
,
j
;
Py_ssize_t
i
,
j
;
Py_ssize_t
len
=
PyString_Size
(
strobj
);
Py_ssize_t
len
=
PyString_Size
(
strobj
);
...
@@ -950,6 +970,7 @@ Fail_1:
...
@@ -950,6 +970,7 @@ Fail_1:
}
}
static
PyObject
*
filterunicode
(
PyObject
*
func
,
PyObject
*
strobj
)
{
static
PyObject
*
filterunicode
(
PyObject
*
func
,
PyObject
*
strobj
)
{
assert
(
0
&&
"check refcounting"
);
PyObject
*
result
;
PyObject
*
result
;
Py_ssize_t
i
,
j
;
Py_ssize_t
i
,
j
;
Py_ssize_t
len
=
PyUnicode_GetSize
(
strobj
);
Py_ssize_t
len
=
PyUnicode_GetSize
(
strobj
);
...
@@ -1055,6 +1076,7 @@ Fail_1:
...
@@ -1055,6 +1076,7 @@ Fail_1:
}
}
static
PyObject
*
filtertuple
(
PyObject
*
func
,
PyObject
*
tuple
)
{
static
PyObject
*
filtertuple
(
PyObject
*
func
,
PyObject
*
tuple
)
{
assert
(
0
&&
"check refcounting"
);
PyObject
*
result
;
PyObject
*
result
;
Py_ssize_t
i
,
j
;
Py_ssize_t
i
,
j
;
Py_ssize_t
len
=
PyTuple_Size
(
tuple
);
Py_ssize_t
len
=
PyTuple_Size
(
tuple
);
...
@@ -1121,6 +1143,7 @@ Fail_1:
...
@@ -1121,6 +1143,7 @@ Fail_1:
}
}
Box
*
filter2
(
Box
*
f
,
Box
*
container
)
{
Box
*
filter2
(
Box
*
f
,
Box
*
container
)
{
assert
(
0
&&
"check refcounting"
);
// If the filter-function argument is None, filter() works by only returning
// If the filter-function argument is None, filter() works by only returning
// the elements that are truthy. This is equivalent to using the bool() constructor.
// the elements that are truthy. This is equivalent to using the bool() constructor.
// - actually since we call nonzero() afterwards, we could use an ident() function
// - actually since we call nonzero() afterwards, we could use an ident() function
...
@@ -1165,6 +1188,7 @@ Box* filter2(Box* f, Box* container) {
...
@@ -1165,6 +1188,7 @@ Box* filter2(Box* f, Box* container) {
}
}
Box
*
zip
(
BoxedTuple
*
containers
)
{
Box
*
zip
(
BoxedTuple
*
containers
)
{
assert
(
0
&&
"check refcounting"
);
assert
(
containers
->
cls
==
tuple_cls
);
assert
(
containers
->
cls
==
tuple_cls
);
BoxedList
*
rtn
=
new
BoxedList
();
BoxedList
*
rtn
=
new
BoxedList
();
...
@@ -1216,6 +1240,7 @@ public:
...
@@ -1216,6 +1240,7 @@ public:
};
};
Box
*
exceptionNew
(
BoxedClass
*
cls
,
BoxedTuple
*
args
)
{
Box
*
exceptionNew
(
BoxedClass
*
cls
,
BoxedTuple
*
args
)
{
assert
(
0
&&
"check refcounting"
);
if
(
!
PyType_Check
(
cls
))
if
(
!
PyType_Check
(
cls
))
raiseExcHelper
(
TypeError
,
"exceptions.__new__(X): X is not a type object (%s)"
,
getTypeName
(
cls
));
raiseExcHelper
(
TypeError
,
"exceptions.__new__(X): X is not a type object (%s)"
,
getTypeName
(
cls
));
...
@@ -1234,6 +1259,7 @@ Box* exceptionNew(BoxedClass* cls, BoxedTuple* args) {
...
@@ -1234,6 +1259,7 @@ Box* exceptionNew(BoxedClass* cls, BoxedTuple* args) {
}
}
Box
*
exceptionStr
(
Box
*
b
)
{
Box
*
exceptionStr
(
Box
*
b
)
{
assert
(
0
&&
"check refcounting"
);
// TODO In CPython __str__ and __repr__ pull from an internalized message field, but for now do this:
// TODO In CPython __str__ and __repr__ pull from an internalized message field, but for now do this:
static
BoxedString
*
message_str
=
getStaticString
(
"message"
);
static
BoxedString
*
message_str
=
getStaticString
(
"message"
);
Box
*
message
=
b
->
getattr
(
message_str
);
Box
*
message
=
b
->
getattr
(
message_str
);
...
@@ -1245,6 +1271,7 @@ Box* exceptionStr(Box* b) {
...
@@ -1245,6 +1271,7 @@ Box* exceptionStr(Box* b) {
}
}
Box
*
exceptionRepr
(
Box
*
b
)
{
Box
*
exceptionRepr
(
Box
*
b
)
{
assert
(
0
&&
"check refcounting"
);
// TODO In CPython __str__ and __repr__ pull from an internalized message field, but for now do this:
// TODO In CPython __str__ and __repr__ pull from an internalized message field, but for now do this:
static
BoxedString
*
message_str
=
getStaticString
(
"message"
);
static
BoxedString
*
message_str
=
getStaticString
(
"message"
);
Box
*
message
=
b
->
getattr
(
message_str
);
Box
*
message
=
b
->
getattr
(
message_str
);
...
@@ -1257,6 +1284,7 @@ Box* exceptionRepr(Box* b) {
...
@@ -1257,6 +1284,7 @@ Box* exceptionRepr(Box* b) {
}
}
static
BoxedClass
*
makeBuiltinException
(
BoxedClass
*
base
,
const
char
*
name
,
int
size
=
0
)
{
static
BoxedClass
*
makeBuiltinException
(
BoxedClass
*
base
,
const
char
*
name
,
int
size
=
0
)
{
assert
(
0
&&
"check refcounting"
);
if
(
size
==
0
)
if
(
size
==
0
)
size
=
base
->
tp_basicsize
;
size
=
base
->
tp_basicsize
;
...
@@ -1503,6 +1531,7 @@ static PyObject* builtin_reload(PyObject* self, PyObject* v) noexcept {
...
@@ -1503,6 +1531,7 @@ static PyObject* builtin_reload(PyObject* self, PyObject* v) noexcept {
}
}
Box
*
getreversed
(
Box
*
o
)
{
Box
*
getreversed
(
Box
*
o
)
{
assert
(
0
&&
"check refcounting"
);
static
BoxedString
*
reversed_str
=
getStaticString
(
"__reversed__"
);
static
BoxedString
*
reversed_str
=
getStaticString
(
"__reversed__"
);
// common case:
// common case:
...
@@ -1527,7 +1556,7 @@ Box* getreversed(Box* o) {
...
@@ -1527,7 +1556,7 @@ Box* getreversed(Box* o) {
Box
*
pydump
(
Box
*
p
,
BoxedInt
*
level
)
{
Box
*
pydump
(
Box
*
p
,
BoxedInt
*
level
)
{
dumpEx
(
p
,
level
->
n
);
dumpEx
(
p
,
level
->
n
);
return
None
;
return
incref
(
None
)
;
}
}
Box
*
pydumpAddr
(
Box
*
p
)
{
Box
*
pydumpAddr
(
Box
*
p
)
{
...
@@ -1535,7 +1564,7 @@ Box* pydumpAddr(Box* p) {
...
@@ -1535,7 +1564,7 @@ Box* pydumpAddr(Box* p) {
raiseExcHelper
(
TypeError
,
"Requires an int"
);
raiseExcHelper
(
TypeError
,
"Requires an int"
);
dump
((
void
*
)
static_cast
<
BoxedInt
*>
(
p
)
->
n
);
dump
((
void
*
)
static_cast
<
BoxedInt
*>
(
p
)
->
n
);
return
None
;
return
incref
(
None
)
;
}
}
Box
*
builtinIter
(
Box
*
obj
,
Box
*
sentinel
)
{
Box
*
builtinIter
(
Box
*
obj
,
Box
*
sentinel
)
{
...
@@ -1624,6 +1653,7 @@ Box* rawInput(Box* prompt) {
...
@@ -1624,6 +1653,7 @@ Box* rawInput(Box* prompt) {
}
}
Box
*
input
(
Box
*
prompt
)
{
Box
*
input
(
Box
*
prompt
)
{
assert
(
0
&&
"check refcounting"
);
PyObject
*
line
=
rawInput
(
prompt
);
PyObject
*
line
=
rawInput
(
prompt
);
char
*
str
=
NULL
;
char
*
str
=
NULL
;
...
@@ -1698,6 +1728,7 @@ Box* builtinCmp(Box* a, Box* b) {
...
@@ -1698,6 +1728,7 @@ Box* builtinCmp(Box* a, Box* b) {
}
}
Box
*
builtinApply
(
Box
*
func
,
Box
*
args
,
Box
*
keywords
)
{
Box
*
builtinApply
(
Box
*
func
,
Box
*
args
,
Box
*
keywords
)
{
assert
(
0
&&
"check refcounting"
);
if
(
!
PyTuple_Check
(
args
))
{
if
(
!
PyTuple_Check
(
args
))
{
if
(
!
PySequence_Check
(
args
))
if
(
!
PySequence_Check
(
args
))
raiseExcHelper
(
TypeError
,
"apply() arg 2 expected sequence, found %s"
,
getTypeName
(
args
));
raiseExcHelper
(
TypeError
,
"apply() arg 2 expected sequence, found %s"
,
getTypeName
(
args
));
...
...
src/runtime/builtin_modules/pyston.cpp
View file @
f1428058
...
@@ -48,12 +48,12 @@ static Box* setOption(Box* option, Box* value) {
...
@@ -48,12 +48,12 @@ static Box* setOption(Box* option, Box* value) {
else
CHECK
(
LAZY_SCOPING_ANALYSIS
);
else
CHECK
(
LAZY_SCOPING_ANALYSIS
);
else
raiseExcHelper
(
ValueError
,
"unknown option name '%s"
,
option_string
->
data
());
else
raiseExcHelper
(
ValueError
,
"unknown option name '%s"
,
option_string
->
data
());
return
None
;
Py_RETURN_NONE
;
}
}
static
Box
*
clearStats
()
{
static
Box
*
clearStats
()
{
Stats
::
clear
();
Stats
::
clear
();
return
None
;
Py_RETURN_NONE
;
}
}
static
Box
*
dumpStats
(
Box
*
includeZeros
)
{
static
Box
*
dumpStats
(
Box
*
includeZeros
)
{
...
@@ -61,7 +61,7 @@ static Box* dumpStats(Box* includeZeros) {
...
@@ -61,7 +61,7 @@ static Box* dumpStats(Box* includeZeros) {
raiseExcHelper
(
TypeError
,
"includeZeros must be a 'bool' object but received a '%s'"
,
raiseExcHelper
(
TypeError
,
"includeZeros must be a 'bool' object but received a '%s'"
,
getTypeName
(
includeZeros
));
getTypeName
(
includeZeros
));
Stats
::
dump
(((
BoxedBool
*
)
includeZeros
)
->
n
!=
0
);
Stats
::
dump
(((
BoxedBool
*
)
includeZeros
)
->
n
!=
0
);
return
None
;
Py_RETURN_NONE
;
}
}
void
setupPyston
()
{
void
setupPyston
()
{
...
...
src/runtime/builtin_modules/sys.cpp
View file @
f1428058
...
@@ -58,18 +58,24 @@ Box* sysExcClear() {
...
@@ -58,18 +58,24 @@ Box* sysExcClear() {
assert
(
exc
->
value
);
assert
(
exc
->
value
);
assert
(
exc
->
traceback
);
assert
(
exc
->
traceback
);
exc
->
type
=
None
;
Box
*
old_type
=
exc
->
type
;
exc
->
value
=
None
;
Box
*
old_value
=
exc
->
value
;
exc
->
traceback
=
None
;
Box
*
old_tracebck
=
exc
->
traceback
;
exc
->
type
=
incref
(
None
);
exc
->
value
=
incref
(
None
);
exc
->
traceback
=
incref
(
None
);
Py_DECREF
(
old_type
);
Py_DECREF
(
old_value
);
Py_DECREF
(
old_traceback
);
return
None
;
Py_RETURN_NONE
;
}
}
static
Box
*
sysExit
(
Box
*
arg
)
{
static
Box
*
sysExit
(
Box
*
arg
)
{
assert
(
arg
);
assert
(
arg
);
Box
*
exc
=
runtimeCall
(
SystemExit
,
ArgPassSpec
(
1
),
arg
,
NULL
,
NULL
,
NULL
,
NULL
);
Box
*
exc
=
runtimeCall
(
SystemExit
,
ArgPassSpec
(
1
),
arg
,
NULL
,
NULL
,
NULL
,
NULL
);
// TODO this should be handled by the SystemExit constructor
// TODO this should be handled by the SystemExit constructor
exc
->
giveAttr
(
"code"
,
arg
);
exc
->
giveAttr
Borrowed
(
"code"
,
arg
);
raiseExc
(
exc
);
raiseExc
(
exc
);
}
}
...
@@ -85,7 +91,7 @@ BORROWED(BoxedDict*) getSysModulesDict() {
...
@@ -85,7 +91,7 @@ BORROWED(BoxedDict*) getSysModulesDict() {
return
sys_modules_dict
;
return
sys_modules_dict
;
}
}
B
oxedList
*
getSysPath
()
{
B
ORROWED
(
BoxedList
*
)
getSysPath
()
{
// Unlike sys.modules, CPython handles sys.path by fetching it each time:
// Unlike sys.modules, CPython handles sys.path by fetching it each time:
auto
path_str
=
getStaticString
(
"path"
);
auto
path_str
=
getStaticString
(
"path"
);
...
@@ -130,7 +136,7 @@ Box* sysGetDefaultEncoding() {
...
@@ -130,7 +136,7 @@ Box* sysGetDefaultEncoding() {
Box
*
sysGetFilesystemEncoding
()
{
Box
*
sysGetFilesystemEncoding
()
{
if
(
Py_FileSystemDefaultEncoding
)
if
(
Py_FileSystemDefaultEncoding
)
return
boxString
(
Py_FileSystemDefaultEncoding
);
return
boxString
(
Py_FileSystemDefaultEncoding
);
return
None
;
Py_RETURN_NONE
;
}
}
Box
*
sysGetRecursionLimit
()
{
Box
*
sysGetRecursionLimit
()
{
...
@@ -211,12 +217,12 @@ void addToSysArgv(const char* str) {
...
@@ -211,12 +217,12 @@ void addToSysArgv(const char* str) {
Box
*
sys_argv
=
sys_module
->
getattr
(
argv_str
);
Box
*
sys_argv
=
sys_module
->
getattr
(
argv_str
);
assert
(
sys_argv
);
assert
(
sys_argv
);
assert
(
sys_argv
->
cls
==
list_cls
);
assert
(
sys_argv
->
cls
==
list_cls
);
listAppendInternal
(
sys_argv
,
autoDecref
(
boxString
(
str
)
));
listAppendInternal
Stolen
(
sys_argv
,
boxString
(
str
));
}
}
void
appendToSysPath
(
llvm
::
StringRef
path
)
{
void
appendToSysPath
(
llvm
::
StringRef
path
)
{
BoxedList
*
sys_path
=
getSysPath
();
BoxedList
*
sys_path
=
getSysPath
();
listAppendInternal
(
sys_path
,
autoDecref
(
boxString
(
path
)
));
listAppendInternal
Stolen
(
sys_path
,
boxString
(
path
));
}
}
void
prependToSysPath
(
llvm
::
StringRef
path
)
{
void
prependToSysPath
(
llvm
::
StringRef
path
)
{
...
...
src/runtime/builtin_modules/thread.cpp
View file @
f1428058
...
@@ -73,7 +73,7 @@ static void* thread_start(Box* target, Box* varargs, Box* kwargs) {
...
@@ -73,7 +73,7 @@ static void* thread_start(Box* target, Box* varargs, Box* kwargs) {
++
nb_threads
;
++
nb_threads
;
try
{
try
{
runtimeCall
(
target
,
ArgPassSpec
(
0
,
0
,
true
,
kwargs
!=
NULL
),
varargs
,
kwargs
,
NULL
,
NULL
,
NULL
);
autoDecref
(
runtimeCall
(
target
,
ArgPassSpec
(
0
,
0
,
true
,
kwargs
!=
NULL
),
varargs
,
kwargs
,
NULL
,
NULL
,
NULL
)
);
}
catch
(
ExcInfo
e
)
{
}
catch
(
ExcInfo
e
)
{
e
.
printExcAndTraceback
();
e
.
printExcAndTraceback
();
}
}
...
@@ -147,11 +147,11 @@ public:
...
@@ -147,11 +147,11 @@ public:
if
(
PyThread_acquire_lock
(
self
->
lock_lock
,
0
))
{
if
(
PyThread_acquire_lock
(
self
->
lock_lock
,
0
))
{
PyThread_release_lock
(
self
->
lock_lock
);
PyThread_release_lock
(
self
->
lock_lock
);
raiseExcHelper
(
ThreadError
,
"release unlocked lock"
);
raiseExcHelper
(
ThreadError
,
"release unlocked lock"
);
return
None
;
return
incref
(
None
)
;
}
}
PyThread_release_lock
(
self
->
lock_lock
);
PyThread_release_lock
(
self
->
lock_lock
);
return
None
;
return
incref
(
None
)
;
}
}
static
Box
*
exit
(
Box
*
_self
,
Box
*
arg1
,
Box
*
arg2
,
Box
**
args
)
{
return
release
(
_self
);
}
static
Box
*
exit
(
Box
*
_self
,
Box
*
arg1
,
Box
*
arg2
,
Box
**
args
)
{
return
release
(
_self
);
}
...
...
src/runtime/classobj.cpp
View file @
f1428058
...
@@ -297,12 +297,12 @@ static Box* classobjSetattr(Box* _cls, Box* _attr, Box* _value) {
...
@@ -297,12 +297,12 @@ static Box* classobjSetattr(Box* _cls, Box* _attr, Box* _value) {
assert
(
_value
);
assert
(
_value
);
_classobjSetattr
(
_cls
,
_attr
,
_value
);
_classobjSetattr
(
_cls
,
_attr
,
_value
);
return
None
;
return
incref
(
None
)
;
}
}
static
Box
*
classobjDelattr
(
Box
*
_cls
,
Box
*
_attr
)
{
static
Box
*
classobjDelattr
(
Box
*
_cls
,
Box
*
_attr
)
{
_classobjSetattr
(
_cls
,
_attr
,
NULL
);
_classobjSetattr
(
_cls
,
_attr
,
NULL
);
return
None
;
return
incref
(
None
)
;
}
}
static
int
classobj_setattro
(
Box
*
cls
,
Box
*
attr
,
Box
*
value
)
noexcept
{
static
int
classobj_setattro
(
Box
*
cls
,
Box
*
attr
,
Box
*
value
)
noexcept
{
...
@@ -608,7 +608,7 @@ Box* instanceDelattr(Box* _inst, Box* _attr) {
...
@@ -608,7 +608,7 @@ Box* instanceDelattr(Box* _inst, Box* _attr) {
raiseExcHelper
(
AttributeError
,
"%.50s instance has no attribute '%.400s'"
,
clsobj
->
name
->
c_str
(),
raiseExcHelper
(
AttributeError
,
"%.50s instance has no attribute '%.400s'"
,
clsobj
->
name
->
c_str
(),
attr
->
c_str
());
attr
->
c_str
());
}
}
return
None
;
return
incref
(
None
)
;
}
}
int
instance_setattro
(
Box
*
inst
,
Box
*
attr
,
Box
*
value
)
noexcept
{
int
instance_setattro
(
Box
*
inst
,
Box
*
attr
,
Box
*
value
)
noexcept
{
...
...
src/runtime/descr.cpp
View file @
f1428058
...
@@ -88,7 +88,7 @@ static Box* propertyInit(Box* _self, Box* fget, Box* fset, Box** args) {
...
@@ -88,7 +88,7 @@ static Box* propertyInit(Box* _self, Box* fget, Box* fset, Box** args) {
propertyDocCopy
(
self
,
fget
);
propertyDocCopy
(
self
,
fget
);
}
}
return
None
;
return
incref
(
None
)
;
}
}
static
Box
*
propertyGet
(
Box
*
self
,
Box
*
obj
,
Box
*
type
)
{
static
Box
*
propertyGet
(
Box
*
self
,
Box
*
obj
,
Box
*
type
)
{
...
...
src/runtime/float.cpp
View file @
f1428058
...
@@ -219,7 +219,7 @@ extern "C" Box* floatRDiv(BoxedFloat* lhs, Box* rhs) {
...
@@ -219,7 +219,7 @@ extern "C" Box* floatRDiv(BoxedFloat* lhs, Box* rhs) {
raiseDivZeroExcIfZero
(
lhs
->
d
);
raiseDivZeroExcIfZero
(
lhs
->
d
);
return
boxFloat
(
rhs_f
/
lhs
->
d
);
return
boxFloat
(
rhs_f
/
lhs
->
d
);
}
else
{
}
else
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
}
}
...
@@ -271,7 +271,7 @@ extern "C" Box* floatFloorDiv(BoxedFloat* lhs, Box* rhs) {
...
@@ -271,7 +271,7 @@ extern "C" Box* floatFloorDiv(BoxedFloat* lhs, Box* rhs) {
}
}
return
floatFloorDivFloat
(
lhs
,
new
BoxedFloat
(
rhs_f
));
return
floatFloorDivFloat
(
lhs
,
new
BoxedFloat
(
rhs_f
));
}
else
{
}
else
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
}
}
...
@@ -1032,7 +1032,7 @@ Box* floatCoerce(BoxedFloat* _self, Box* other) {
...
@@ -1032,7 +1032,7 @@ Box* floatCoerce(BoxedFloat* _self, Box* other) {
if
(
result
==
0
)
if
(
result
==
0
)
return
BoxedTuple
::
create
({
self
,
other
});
return
BoxedTuple
::
create
({
self
,
other
});
else
if
(
result
==
1
)
else
if
(
result
==
1
)
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
else
else
throwCAPIException
();
throwCAPIException
();
}
}
...
...
src/runtime/inline/dict.cpp
View file @
f1428058
...
@@ -45,7 +45,7 @@ Box* dictIterItems(Box* s) {
...
@@ -45,7 +45,7 @@ Box* dictIterItems(Box* s) {
}
}
Box
*
dictIterIter
(
Box
*
s
)
{
Box
*
dictIterIter
(
Box
*
s
)
{
return
s
;
return
incref
(
s
)
;
}
}
llvm_compat_bool
dictIterHasnextUnboxed
(
Box
*
s
)
{
llvm_compat_bool
dictIterHasnextUnboxed
(
Box
*
s
)
{
...
@@ -66,9 +66,9 @@ Box* dictiter_next(Box* s) noexcept {
...
@@ -66,9 +66,9 @@ Box* dictiter_next(Box* s) noexcept {
Box
*
rtn
=
nullptr
;
Box
*
rtn
=
nullptr
;
if
(
self
->
cls
==
&
PyDictIterKey_Type
)
{
if
(
self
->
cls
==
&
PyDictIterKey_Type
)
{
rtn
=
self
->
it
->
first
.
value
;
rtn
=
incref
(
self
->
it
->
first
.
value
)
;
}
else
if
(
self
->
cls
==
&
PyDictIterValue_Type
)
{
}
else
if
(
self
->
cls
==
&
PyDictIterValue_Type
)
{
rtn
=
self
->
it
->
second
;
rtn
=
incref
(
self
->
it
->
second
)
;
}
else
if
(
self
->
cls
==
&
PyDictIterItem_Type
)
{
}
else
if
(
self
->
cls
==
&
PyDictIterItem_Type
)
{
rtn
=
BoxedTuple
::
create
({
self
->
it
->
first
.
value
,
self
->
it
->
second
});
rtn
=
BoxedTuple
::
create
({
self
->
it
->
first
.
value
,
self
->
it
->
second
});
}
else
{
}
else
{
...
...
src/runtime/inline/list.cpp
View file @
f1428058
...
@@ -116,7 +116,7 @@ Box* listreviter_next(Box* s) noexcept {
...
@@ -116,7 +116,7 @@ Box* listreviter_next(Box* s) noexcept {
Box
*
rtn
=
self
->
l
->
elts
->
elts
[
self
->
pos
];
Box
*
rtn
=
self
->
l
->
elts
->
elts
[
self
->
pos
];
self
->
pos
--
;
self
->
pos
--
;
return
rtn
;
return
incref
(
rtn
)
;
}
}
Box
*
listreviterNext
(
Box
*
s
)
{
Box
*
listreviterNext
(
Box
*
s
)
{
...
...
src/runtime/inline/tuple.cpp
View file @
f1428058
...
@@ -24,7 +24,7 @@ BoxedTupleIterator::BoxedTupleIterator(BoxedTuple* t) : t(t), pos(0) {
...
@@ -24,7 +24,7 @@ BoxedTupleIterator::BoxedTupleIterator(BoxedTuple* t) : t(t), pos(0) {
}
}
Box
*
tupleIterIter
(
Box
*
s
)
{
Box
*
tupleIterIter
(
Box
*
s
)
{
return
s
;
return
incref
(
s
)
;
}
}
Box
*
tupleIter
(
Box
*
s
)
noexcept
{
Box
*
tupleIter
(
Box
*
s
)
noexcept
{
...
...
src/runtime/inline/xrange.cpp
View file @
f1428058
...
@@ -243,7 +243,7 @@ Box* xrangeRepr(BoxedXrange* self) {
...
@@ -243,7 +243,7 @@ Box* xrangeRepr(BoxedXrange* self) {
Box
*
xrangeReduce
(
Box
*
self
)
{
Box
*
xrangeReduce
(
Box
*
self
)
{
if
(
!
self
)
{
if
(
!
self
)
{
return
None
;
return
incref
(
None
)
;
}
}
BoxedXrange
*
r
=
static_cast
<
BoxedXrange
*>
(
self
);
BoxedXrange
*
r
=
static_cast
<
BoxedXrange
*>
(
self
);
BoxedTuple
*
range
=
BoxedTuple
::
create
(
BoxedTuple
*
range
=
BoxedTuple
::
create
(
...
...
src/runtime/int.cpp
View file @
f1428058
...
@@ -515,7 +515,7 @@ Box* intRAdd(BoxedInt* lhs, Box* rhs) {
...
@@ -515,7 +515,7 @@ Box* intRAdd(BoxedInt* lhs, Box* rhs) {
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
add_i64_i64
(
lhs
->
n
,
rhs_int
->
n
);
return
add_i64_i64
(
lhs
->
n
,
rhs_int
->
n
);
}
else
{
}
else
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
}
}
...
@@ -542,7 +542,7 @@ Box* intRAnd(BoxedInt* lhs, Box* rhs) {
...
@@ -542,7 +542,7 @@ Box* intRAnd(BoxedInt* lhs, Box* rhs) {
getTypeName
(
lhs
));
getTypeName
(
lhs
));
if
(
!
PyInt_Check
(
rhs
))
{
if
(
!
PyInt_Check
(
rhs
))
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
boxInt
(
lhs
->
n
&
rhs_int
->
n
);
return
boxInt
(
lhs
->
n
&
rhs_int
->
n
);
...
@@ -570,7 +570,7 @@ Box* intROr(BoxedInt* lhs, Box* rhs) {
...
@@ -570,7 +570,7 @@ Box* intROr(BoxedInt* lhs, Box* rhs) {
raiseExcHelper
(
TypeError
,
"descriptor '__ror__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
raiseExcHelper
(
TypeError
,
"descriptor '__ror__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
if
(
!
PyInt_Check
(
rhs
))
{
if
(
!
PyInt_Check
(
rhs
))
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
boxInt
(
lhs
->
n
|
rhs_int
->
n
);
return
boxInt
(
lhs
->
n
|
rhs_int
->
n
);
...
@@ -599,7 +599,7 @@ Box* intRXor(BoxedInt* lhs, Box* rhs) {
...
@@ -599,7 +599,7 @@ Box* intRXor(BoxedInt* lhs, Box* rhs) {
getTypeName
(
lhs
));
getTypeName
(
lhs
));
if
(
!
PyInt_Check
(
rhs
))
{
if
(
!
PyInt_Check
(
rhs
))
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
boxInt
(
lhs
->
n
^
rhs_int
->
n
);
return
boxInt
(
lhs
->
n
^
rhs_int
->
n
);
...
@@ -642,7 +642,7 @@ Box* intRDiv(BoxedInt* lhs, Box* rhs) {
...
@@ -642,7 +642,7 @@ Box* intRDiv(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
return
div_i64_i64
(
static_cast
<
BoxedInt
*>
(
rhs
)
->
n
,
lhs
->
n
);
return
div_i64_i64
(
static_cast
<
BoxedInt
*>
(
rhs
)
->
n
,
lhs
->
n
);
}
else
{
}
else
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
}
}
...
@@ -682,7 +682,7 @@ Box* intRFloordiv(BoxedInt* lhs, Box* rhs) {
...
@@ -682,7 +682,7 @@ Box* intRFloordiv(BoxedInt* lhs, Box* rhs) {
getTypeName
(
lhs
));
getTypeName
(
lhs
));
if
(
!
PyInt_Check
(
rhs
))
{
if
(
!
PyInt_Check
(
rhs
))
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
return
div_i64_i64
(
static_cast
<
BoxedInt
*>
(
rhs
)
->
n
,
lhs
->
n
);
return
div_i64_i64
(
static_cast
<
BoxedInt
*>
(
rhs
)
->
n
,
lhs
->
n
);
...
@@ -730,7 +730,7 @@ Box* intRTruediv(BoxedInt* lhs, Box* rhs) {
...
@@ -730,7 +730,7 @@ Box* intRTruediv(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
return
intTruedivInt
(
static_cast
<
BoxedInt
*>
(
rhs
),
lhs
);
return
intTruedivInt
(
static_cast
<
BoxedInt
*>
(
rhs
),
lhs
);
}
else
{
}
else
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
}
}
...
@@ -772,7 +772,7 @@ Box* intRLShift(BoxedInt* lhs, Box* rhs) {
...
@@ -772,7 +772,7 @@ Box* intRLShift(BoxedInt* lhs, Box* rhs) {
if
(
!
PyInt_Check
(
rhs
))
{
if
(
!
PyInt_Check
(
rhs
))
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
intLShiftInt
(
rhs_int
,
lhs
);
return
intLShiftInt
(
rhs_int
,
lhs
);
...
@@ -801,7 +801,7 @@ Box* intRMod(BoxedInt* lhs, Box* rhs) {
...
@@ -801,7 +801,7 @@ Box* intRMod(BoxedInt* lhs, Box* rhs) {
getTypeName
(
lhs
));
getTypeName
(
lhs
));
if
(
!
PyInt_Check
(
rhs
))
{
if
(
!
PyInt_Check
(
rhs
))
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
mod_i64_i64
(
rhs_int
->
n
,
lhs
->
n
);
return
mod_i64_i64
(
rhs_int
->
n
,
lhs
->
n
);
...
@@ -838,7 +838,7 @@ Box* intRDivmod(BoxedInt* lhs, Box* rhs) {
...
@@ -838,7 +838,7 @@ Box* intRDivmod(BoxedInt* lhs, Box* rhs) {
getTypeName
(
lhs
));
getTypeName
(
lhs
));
if
(
!
PyInt_Check
(
rhs
))
{
if
(
!
PyInt_Check
(
rhs
))
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
return
intDivmod
(
static_cast
<
BoxedInt
*>
(
rhs
),
lhs
);
return
intDivmod
(
static_cast
<
BoxedInt
*>
(
rhs
),
lhs
);
}
}
...
@@ -876,7 +876,7 @@ Box* intRMul(BoxedInt* lhs, Box* rhs) {
...
@@ -876,7 +876,7 @@ Box* intRMul(BoxedInt* lhs, Box* rhs) {
getTypeName
(
lhs
));
getTypeName
(
lhs
));
if
(
!
PyInt_Check
(
rhs
))
if
(
!
PyInt_Check
(
rhs
))
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
return
intMul
(
lhs
,
rhs
);
return
intMul
(
lhs
,
rhs
);
}
}
...
@@ -938,7 +938,7 @@ Box* intRPow(BoxedInt* lhs, Box* rhs, Box* mod) {
...
@@ -938,7 +938,7 @@ Box* intRPow(BoxedInt* lhs, Box* rhs, Box* mod) {
getTypeName
(
lhs
));
getTypeName
(
lhs
));
if
(
!
PyInt_Check
(
rhs
))
if
(
!
PyInt_Check
(
rhs
))
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
if
(
mod
!=
None
)
{
if
(
mod
!=
None
)
{
if
(
lhs
->
n
<
0
)
if
(
lhs
->
n
<
0
)
...
@@ -984,7 +984,7 @@ Box* intRRShift(BoxedInt* lhs, Box* rhs) {
...
@@ -984,7 +984,7 @@ Box* intRRShift(BoxedInt* lhs, Box* rhs) {
getTypeName
(
lhs
));
getTypeName
(
lhs
));
if
(
!
PyInt_Check
(
rhs
))
{
if
(
!
PyInt_Check
(
rhs
))
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
intRShiftInt
(
rhs_int
,
lhs
);
return
intRShiftInt
(
rhs_int
,
lhs
);
...
@@ -1026,7 +1026,7 @@ Box* intRSub(BoxedInt* lhs, Box* rhs) {
...
@@ -1026,7 +1026,7 @@ Box* intRSub(BoxedInt* lhs, Box* rhs) {
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
sub_i64_i64
(
rhs_int
->
n
,
lhs
->
n
);
return
sub_i64_i64
(
rhs_int
->
n
,
lhs
->
n
);
}
else
{
}
else
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
}
}
}
...
...
src/runtime/iterators.cpp
View file @
f1428058
...
@@ -91,7 +91,7 @@ private:
...
@@ -91,7 +91,7 @@ private:
static
Box
*
getValue
(
BoxedString
*
o
,
uint64_t
i
)
{
return
boxString
(
llvm
::
StringRef
(
o
->
data
()
+
i
,
1
));
}
static
Box
*
getValue
(
BoxedString
*
o
,
uint64_t
i
)
{
return
boxString
(
llvm
::
StringRef
(
o
->
data
()
+
i
,
1
));
}
public:
public:
BoxIteratorIndex
(
T
*
obj
)
:
obj
(
obj
),
index
(
0
)
{
explicit
BoxIteratorIndex
(
T
*
obj
)
:
obj
(
obj
),
index
(
0
)
{
Py_XINCREF
(
obj
);
Py_XINCREF
(
obj
);
if
(
obj
&&
!
hasnext
(
obj
,
index
))
{
if
(
obj
&&
!
hasnext
(
obj
,
index
))
{
Py_CLEAR
(
obj
);
Py_CLEAR
(
obj
);
...
...
src/runtime/list.cpp
View file @
f1428058
...
@@ -833,8 +833,8 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
...
@@ -833,8 +833,8 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
}
}
Box
*
listExtend
(
BoxedList
*
self
,
Box
*
_rhs
)
{
Box
*
listExtend
(
BoxedList
*
self
,
Box
*
_rhs
)
{
listIAdd
(
self
,
_rhs
);
autoDecref
(
listIAdd
(
self
,
_rhs
)
);
return
None
;
return
incref
(
None
)
;
}
}
Box
*
listAdd
(
BoxedList
*
self
,
Box
*
_rhs
)
{
Box
*
listAdd
(
BoxedList
*
self
,
Box
*
_rhs
)
{
...
...
src/runtime/types.cpp
View file @
f1428058
...
@@ -2752,7 +2752,7 @@ Box* objectSetattr(Box* obj, Box* attr, Box* value) {
...
@@ -2752,7 +2752,7 @@ Box* objectSetattr(Box* obj, Box* attr, Box* value) {
BoxedString
*
attr_str
=
static_cast
<
BoxedString
*>
(
attr
);
BoxedString
*
attr_str
=
static_cast
<
BoxedString
*>
(
attr
);
setattrGeneric
<
NOT_REWRITABLE
>
(
obj
,
attr_str
,
value
,
NULL
);
setattrGeneric
<
NOT_REWRITABLE
>
(
obj
,
attr_str
,
value
,
NULL
);
return
None
;
return
incref
(
None
)
;
}
}
Box
*
objectSubclasshook
(
Box
*
cls
,
Box
*
a
)
{
Box
*
objectSubclasshook
(
Box
*
cls
,
Box
*
a
)
{
...
...
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