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