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
a3dbaa95
Commit
a3dbaa95
authored
Nov 04, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
passes initialization
parent
f1a3d284
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
117 additions
and
73 deletions
+117
-73
src/capi/abstract.cpp
src/capi/abstract.cpp
+1
-0
src/core/types.h
src/core/types.h
+2
-0
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+4
-4
src/runtime/builtin_modules/thread.cpp
src/runtime/builtin_modules/thread.cpp
+2
-2
src/runtime/classobj.cpp
src/runtime/classobj.cpp
+1
-1
src/runtime/dict.cpp
src/runtime/dict.cpp
+6
-6
src/runtime/file.cpp
src/runtime/file.cpp
+11
-0
src/runtime/import.cpp
src/runtime/import.cpp
+1
-1
src/runtime/inline/list.cpp
src/runtime/inline/list.cpp
+1
-1
src/runtime/inline/list.h
src/runtime/inline/list.h
+1
-0
src/runtime/iterobject.cpp
src/runtime/iterobject.cpp
+6
-6
src/runtime/list.cpp
src/runtime/list.cpp
+7
-2
src/runtime/long.cpp
src/runtime/long.cpp
+2
-2
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+3
-0
src/runtime/set.cpp
src/runtime/set.cpp
+9
-9
src/runtime/str.cpp
src/runtime/str.cpp
+27
-27
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+6
-3
src/runtime/types.cpp
src/runtime/types.cpp
+4
-2
src/runtime/types.h
src/runtime/types.h
+23
-7
No files found.
src/capi/abstract.cpp
View file @
a3dbaa95
...
@@ -2387,6 +2387,7 @@ extern "C" PyObject* PyNumber_Index(PyObject* o) noexcept {
...
@@ -2387,6 +2387,7 @@ extern "C" PyObject* PyNumber_Index(PyObject* o) noexcept {
if
(
o
==
NULL
)
if
(
o
==
NULL
)
return
null_error
();
return
null_error
();
if
(
PyInt_Check
(
o
)
||
PyLong_Check
(
o
))
{
if
(
PyInt_Check
(
o
)
||
PyLong_Check
(
o
))
{
Py_INCREF
(
o
);
return
o
;
return
o
;
}
}
...
...
src/core/types.h
View file @
a3dbaa95
...
@@ -750,6 +750,7 @@ extern "C" PyObject* PystonType_GenericAlloc(BoxedClass* cls, Py_ssize_t nitems)
...
@@ -750,6 +750,7 @@ extern "C" PyObject* PystonType_GenericAlloc(BoxedClass* cls, Py_ssize_t nitems)
Box* rtn = static_cast<Box*>(mem); \
Box* rtn = static_cast<Box*>(mem); \
\
\
rtn->cls = default_cls; \
rtn->cls = default_cls; \
_Py_NewReference(rtn); \
return rtn; \
return rtn; \
/* TODO: there should be a way to not have to do this nested inlining by hand */
\
/* TODO: there should be a way to not have to do this nested inlining by hand */
\
}
}
...
@@ -809,6 +810,7 @@ static_assert(offsetof(BoxVar, ob_size) == offsetof(struct _varobject, ob_size),
...
@@ -809,6 +810,7 @@ static_assert(offsetof(BoxVar, ob_size) == offsetof(struct _varobject, ob_size),
\
\
BoxVar* rtn = static_cast<BoxVar*>(mem); \
BoxVar* rtn = static_cast<BoxVar*>(mem); \
rtn->cls = default_cls; \
rtn->cls = default_cls; \
_Py_NewReference(rtn); \
rtn->ob_size = nitems; \
rtn->ob_size = nitems; \
return rtn; \
return rtn; \
}
}
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
a3dbaa95
...
@@ -617,7 +617,7 @@ Box* setattrFunc(Box* obj, Box* _str, Box* value) {
...
@@ -617,7 +617,7 @@ Box* setattrFunc(Box* obj, Box* _str, Box* value) {
static
Box
*
hasattrFuncHelper
(
Box
*
return_val
)
noexcept
{
static
Box
*
hasattrFuncHelper
(
Box
*
return_val
)
noexcept
{
if
(
return_val
)
if
(
return_val
)
return
True
;
Py_RETURN_TRUE
;
if
(
PyErr_Occurred
())
{
if
(
PyErr_Occurred
())
{
if
(
!
PyErr_ExceptionMatches
(
PyExc_Exception
))
if
(
!
PyErr_ExceptionMatches
(
PyExc_Exception
))
...
@@ -625,7 +625,7 @@ static Box* hasattrFuncHelper(Box* return_val) noexcept {
...
@@ -625,7 +625,7 @@ static Box* hasattrFuncHelper(Box* return_val) noexcept {
PyErr_Clear
();
PyErr_Clear
();
}
}
return
False
;
Py_RETURN_FALSE
;
}
}
template
<
ExceptionStyle
S
>
template
<
ExceptionStyle
S
>
...
@@ -1636,12 +1636,12 @@ Return the absolute value of the argument.");
...
@@ -1636,12 +1636,12 @@ Return the absolute value of the argument.");
PyDoc_STRVAR
(
all_doc
,
"all(iterable) -> bool
\n
\
PyDoc_STRVAR
(
all_doc
,
"all(iterable) -> bool
\n
\
\n
\
\n
\
Return True if bool(x) is True for all values x in the iterable.
\n
\
Return True if bool(x) is True for all values x in the iterable.
\n
\
If the iterable is empty,
return True
."
);
If the iterable is empty,
Py_RETURN_TRUE
."
);
PyDoc_STRVAR
(
any_doc
,
"any(iterable) -> bool
\n
\
PyDoc_STRVAR
(
any_doc
,
"any(iterable) -> bool
\n
\
\n
\
\n
\
Return True if bool(x) is True for any x in the iterable.
\n
\
Return True if bool(x) is True for any x in the iterable.
\n
\
If the iterable is empty,
return False
."
);
If the iterable is empty,
Py_RETURN_FALSE
."
);
PyDoc_STRVAR
(
apply_doc
,
"apply(object[, args[, kwargs]]) -> value
\n
\
PyDoc_STRVAR
(
apply_doc
,
"apply(object[, args[, kwargs]]) -> value
\n
\
\n
\
\n
\
...
...
src/runtime/builtin_modules/thread.cpp
View file @
a3dbaa95
...
@@ -176,9 +176,9 @@ public:
...
@@ -176,9 +176,9 @@ 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
);
return
False
;
Py_RETURN_FALSE
;
}
}
return
True
;
Py_RETURN_TRUE
;
}
}
};
};
...
...
src/runtime/classobj.cpp
View file @
a3dbaa95
...
@@ -666,7 +666,7 @@ Box* instanceNonzero(Box* _inst) {
...
@@ -666,7 +666,7 @@ Box* instanceNonzero(Box* _inst) {
if
(
nonzero_func
)
{
if
(
nonzero_func
)
{
return
runtimeCall
(
nonzero_func
,
ArgPassSpec
(
0
),
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
return
runtimeCall
(
nonzero_func
,
ArgPassSpec
(
0
),
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
}
else
{
}
else
{
return
True
;
Py_RETURN_TRUE
;
}
}
}
}
...
...
src/runtime/dict.cpp
View file @
a3dbaa95
...
@@ -588,17 +588,17 @@ Box* dictEq(BoxedDict* self, Box* _rhs) {
...
@@ -588,17 +588,17 @@ Box* dictEq(BoxedDict* self, Box* _rhs) {
BoxedDict
*
rhs
=
static_cast
<
BoxedDict
*>
(
_rhs
);
BoxedDict
*
rhs
=
static_cast
<
BoxedDict
*>
(
_rhs
);
if
(
self
->
d
.
size
()
!=
rhs
->
d
.
size
())
if
(
self
->
d
.
size
()
!=
rhs
->
d
.
size
())
return
False
;
Py_RETURN_FALSE
;
for
(
const
auto
&
p
:
self
->
d
)
{
for
(
const
auto
&
p
:
self
->
d
)
{
auto
it
=
rhs
->
d
.
find
(
p
.
first
);
auto
it
=
rhs
->
d
.
find
(
p
.
first
);
if
(
it
==
rhs
->
d
.
end
())
if
(
it
==
rhs
->
d
.
end
())
return
False
;
Py_RETURN_FALSE
;
if
(
!
PyEq
()(
p
.
second
,
it
->
second
))
if
(
!
PyEq
()(
p
.
second
,
it
->
second
))
return
False
;
Py_RETURN_FALSE
;
}
}
return
True
;
Py_RETURN_TRUE
;
}
}
Box
*
dictNe
(
BoxedDict
*
self
,
Box
*
_rhs
)
{
Box
*
dictNe
(
BoxedDict
*
self
,
Box
*
_rhs
)
{
...
@@ -606,8 +606,8 @@ Box* dictNe(BoxedDict* self, Box* _rhs) {
...
@@ -606,8 +606,8 @@ Box* dictNe(BoxedDict* self, Box* _rhs) {
if
(
eq
==
NotImplemented
)
if
(
eq
==
NotImplemented
)
return
eq
;
return
eq
;
if
(
eq
==
True
)
if
(
eq
==
True
)
return
False
;
Py_RETURN_FALSE
;
return
True
;
Py_RETURN_TRUE
;
}
}
...
...
src/runtime/file.cpp
View file @
a3dbaa95
...
@@ -287,6 +287,16 @@ BoxedFile::BoxedFile(FILE* f, std::string fname, const char* fmode, int (*close)
...
@@ -287,6 +287,16 @@ BoxedFile::BoxedFile(FILE* f, std::string fname, const char* fmode, int (*close)
f_bufptr
(
0
),
f_bufptr
(
0
),
f_setbuf
(
0
),
f_setbuf
(
0
),
unlocked_count
(
0
)
{
unlocked_count
(
0
)
{
static
BoxedString
*
not_yet_string
=
internStringImmortal
(
"<uninitialized file>"
);
Py_INCREF
(
not_yet_string
);
this
->
f_name
=
not_yet_string
;
Py_INCREF
(
not_yet_string
);
this
->
f_mode
=
not_yet_string
;
Py_INCREF
(
None
);
this
->
f_encoding
=
None
;
Py_INCREF
(
None
);
this
->
f_errors
=
None
;
Box
*
r
=
fill_file_fields
(
this
,
f
,
boxString
(
fname
),
fmode
,
close
);
Box
*
r
=
fill_file_fields
(
this
,
f
,
boxString
(
fname
),
fmode
,
close
);
checkAndThrowCAPIException
();
checkAndThrowCAPIException
();
assert
(
r
==
this
);
assert
(
r
==
this
);
...
@@ -1062,6 +1072,7 @@ Box* fileNew(BoxedClass* cls, Box* s, Box* m, Box** args) {
...
@@ -1062,6 +1072,7 @@ Box* fileNew(BoxedClass* cls, Box* s, Box* m, Box** args) {
auto
file
=
new
BoxedFile
(
f
,
fn
->
s
(),
PyString_AsString
(
m
));
auto
file
=
new
BoxedFile
(
f
,
fn
->
s
(),
PyString_AsString
(
m
));
PyFile_SetBufSize
(
file
,
buffering
->
n
);
PyFile_SetBufSize
(
file
,
buffering
->
n
);
return
file
;
return
file
;
}
}
...
...
src/runtime/import.cpp
View file @
a3dbaa95
...
@@ -960,7 +960,7 @@ Box* impIsBuiltin(Box* _name) {
...
@@ -960,7 +960,7 @@ Box* impIsBuiltin(Box* _name) {
Box
*
impIsFrozen
(
Box
*
name
)
{
Box
*
impIsFrozen
(
Box
*
name
)
{
if
(
!
PyString_Check
(
name
))
if
(
!
PyString_Check
(
name
))
raiseExcHelper
(
TypeError
,
"must be string, not %s"
,
getTypeName
(
name
));
raiseExcHelper
(
TypeError
,
"must be string, not %s"
,
getTypeName
(
name
));
return
False
;
Py_RETURN_FALSE
;
}
}
PyDoc_STRVAR
(
find_module_doc
,
"find_module(name, [path]) -> (file, filename, (suffix, mode, type))
\n
\
PyDoc_STRVAR
(
find_module_doc
,
"find_module(name, [path]) -> (file, filename, (suffix, mode, type))
\n
\
...
...
src/runtime/inline/list.cpp
View file @
a3dbaa95
...
@@ -40,7 +40,7 @@ Box* listiterHasnext(Box* s) {
...
@@ -40,7 +40,7 @@ Box* listiterHasnext(Box* s) {
BoxedListIterator
*
self
=
static_cast
<
BoxedListIterator
*>
(
s
);
BoxedListIterator
*
self
=
static_cast
<
BoxedListIterator
*>
(
s
);
if
(
!
self
->
l
)
{
if
(
!
self
->
l
)
{
return
False
;
Py_RETURN_FALSE
;
}
}
bool
ans
=
(
self
->
pos
<
self
->
l
->
size
);
bool
ans
=
(
self
->
pos
<
self
->
l
->
size
);
...
...
src/runtime/inline/list.h
View file @
a3dbaa95
...
@@ -52,6 +52,7 @@ extern "C" inline void listAppendInternal(Box* s, Box* v) {
...
@@ -52,6 +52,7 @@ extern "C" inline void listAppendInternal(Box* s, Box* v) {
self
->
ensure
(
1
);
self
->
ensure
(
1
);
assert
(
self
->
size
<
self
->
capacity
);
assert
(
self
->
size
<
self
->
capacity
);
Py_INCREF
(
v
);
self
->
elts
->
elts
[
self
->
size
]
=
v
;
self
->
elts
->
elts
[
self
->
size
]
=
v
;
self
->
size
++
;
self
->
size
++
;
}
}
...
...
src/runtime/iterobject.cpp
View file @
a3dbaa95
...
@@ -45,7 +45,7 @@ static Box* seqiterHasnext_capi(Box* s) noexcept {
...
@@ -45,7 +45,7 @@ static Box* seqiterHasnext_capi(Box* s) noexcept {
BoxedSeqIter
*
self
=
static_cast
<
BoxedSeqIter
*>
(
s
);
BoxedSeqIter
*
self
=
static_cast
<
BoxedSeqIter
*>
(
s
);
if
(
!
self
->
b
)
{
if
(
!
self
->
b
)
{
return
False
;
Py_RETURN_FALSE
;
}
}
Box
*
next
=
PySequence_GetItem
(
self
->
b
,
self
->
idx
);
Box
*
next
=
PySequence_GetItem
(
self
->
b
,
self
->
idx
);
...
@@ -53,14 +53,14 @@ static Box* seqiterHasnext_capi(Box* s) noexcept {
...
@@ -53,14 +53,14 @@ static Box* seqiterHasnext_capi(Box* s) noexcept {
if
(
PyErr_ExceptionMatches
(
IndexError
)
||
PyErr_ExceptionMatches
(
StopIteration
))
{
if
(
PyErr_ExceptionMatches
(
IndexError
)
||
PyErr_ExceptionMatches
(
StopIteration
))
{
PyErr_Clear
();
PyErr_Clear
();
self
->
b
=
NULL
;
self
->
b
=
NULL
;
return
False
;
Py_RETURN_FALSE
;
}
}
return
NULL
;
return
NULL
;
}
}
self
->
idx
++
;
self
->
idx
++
;
self
->
next
=
next
;
self
->
next
=
next
;
return
True
;
Py_RETURN_TRUE
;
}
}
Box
*
seqiterHasnext
(
Box
*
s
)
{
Box
*
seqiterHasnext
(
Box
*
s
)
{
...
@@ -79,20 +79,20 @@ Box* seqreviterHasnext_capi(Box* s) noexcept {
...
@@ -79,20 +79,20 @@ Box* seqreviterHasnext_capi(Box* s) noexcept {
BoxedSeqIter
*
self
=
static_cast
<
BoxedSeqIter
*>
(
s
);
BoxedSeqIter
*
self
=
static_cast
<
BoxedSeqIter
*>
(
s
);
if
(
self
->
idx
==
-
1
||
!
self
->
b
)
if
(
self
->
idx
==
-
1
||
!
self
->
b
)
return
False
;
Py_RETURN_FALSE
;
Box
*
next
=
PySequence_GetItem
(
self
->
b
,
self
->
idx
);
Box
*
next
=
PySequence_GetItem
(
self
->
b
,
self
->
idx
);
if
(
!
next
)
{
if
(
!
next
)
{
if
(
PyErr_ExceptionMatches
(
IndexError
)
||
PyErr_ExceptionMatches
(
StopIteration
))
{
if
(
PyErr_ExceptionMatches
(
IndexError
)
||
PyErr_ExceptionMatches
(
StopIteration
))
{
PyErr_Clear
();
PyErr_Clear
();
self
->
b
=
NULL
;
self
->
b
=
NULL
;
return
False
;
Py_RETURN_FALSE
;
}
}
return
NULL
;
return
NULL
;
}
}
self
->
idx
--
;
self
->
idx
--
;
self
->
next
=
next
;
self
->
next
=
next
;
return
True
;
Py_RETURN_TRUE
;
}
}
Box
*
seqreviterHasnext
(
Box
*
s
)
{
Box
*
seqreviterHasnext
(
Box
*
s
)
{
...
...
src/runtime/list.cpp
View file @
a3dbaa95
...
@@ -756,6 +756,8 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
...
@@ -756,6 +756,8 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
memcpy
(
self
->
elts
->
elts
+
s1
,
rhs
->
elts
->
elts
,
sizeof
(
rhs
->
elts
->
elts
[
0
])
*
s2
);
memcpy
(
self
->
elts
->
elts
+
s1
,
rhs
->
elts
->
elts
,
sizeof
(
rhs
->
elts
->
elts
[
0
])
*
s2
);
self
->
size
=
s1
+
s2
;
self
->
size
=
s1
+
s2
;
Py_INCREF
(
self
);
return
self
;
return
self
;
}
}
...
@@ -772,6 +774,8 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
...
@@ -772,6 +774,8 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
memcpy
(
self
->
elts
->
elts
+
s1
,
rhs
->
elts
,
sizeof
(
self
->
elts
->
elts
[
0
])
*
s2
);
memcpy
(
self
->
elts
->
elts
+
s1
,
rhs
->
elts
,
sizeof
(
self
->
elts
->
elts
[
0
])
*
s2
);
self
->
size
=
s1
+
s2
;
self
->
size
=
s1
+
s2
;
Py_INCREF
(
self
);
return
self
;
return
self
;
}
}
...
@@ -780,6 +784,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
...
@@ -780,6 +784,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
for
(
auto
*
b
:
_rhs
->
pyElements
())
for
(
auto
*
b
:
_rhs
->
pyElements
())
listAppendInternal
(
self
,
b
);
listAppendInternal
(
self
,
b
);
Py_INCREF
(
self
);
return
self
;
return
self
;
}
}
...
@@ -1120,9 +1125,9 @@ Box* _listCmp(BoxedList* lhs, BoxedList* rhs, AST_TYPE::AST_TYPE op_type) {
...
@@ -1120,9 +1125,9 @@ Box* _listCmp(BoxedList* lhs, BoxedList* rhs, AST_TYPE::AST_TYPE op_type) {
if
(
lsz
!=
rsz
)
{
if
(
lsz
!=
rsz
)
{
if
(
op_type
==
AST_TYPE
::
Eq
)
if
(
op_type
==
AST_TYPE
::
Eq
)
return
False
;
Py_RETURN_FALSE
;
if
(
op_type
==
AST_TYPE
::
NotEq
)
if
(
op_type
==
AST_TYPE
::
NotEq
)
return
True
;
Py_RETURN_TRUE
;
}
}
int
n
=
std
::
min
(
lsz
,
rsz
);
int
n
=
std
::
min
(
lsz
,
rsz
);
...
...
src/runtime/long.cpp
View file @
a3dbaa95
...
@@ -1376,8 +1376,8 @@ Box* longNonzero(BoxedLong* self) {
...
@@ -1376,8 +1376,8 @@ Box* longNonzero(BoxedLong* self) {
getTypeName
(
self
));
getTypeName
(
self
));
if
(
mpz_sgn
(
self
->
n
)
==
0
)
if
(
mpz_sgn
(
self
->
n
)
==
0
)
return
False
;
Py_RETURN_FALSE
;
return
True
;
Py_RETURN_TRUE
;
}
}
bool
longNonzeroUnboxed
(
BoxedLong
*
self
)
{
bool
longNonzeroUnboxed
(
BoxedLong
*
self
)
{
...
...
src/runtime/objmodel.cpp
View file @
a3dbaa95
...
@@ -773,6 +773,9 @@ template Box* Box::getattr<REWRITABLE>(BoxedString*, GetattrRewriteArgs*);
...
@@ -773,6 +773,9 @@ template Box* Box::getattr<REWRITABLE>(BoxedString*, GetattrRewriteArgs*);
template
Box
*
Box
::
getattr
<
NOT_REWRITABLE
>(
BoxedString
*
,
GetattrRewriteArgs
*
);
template
Box
*
Box
::
getattr
<
NOT_REWRITABLE
>(
BoxedString
*
,
GetattrRewriteArgs
*
);
void
Box
::
appendNewHCAttr
(
Box
*
new_attr
,
SetattrRewriteArgs
*
rewrite_args
)
{
void
Box
::
appendNewHCAttr
(
Box
*
new_attr
,
SetattrRewriteArgs
*
rewrite_args
)
{
assert
(
!
rewrite_args
);
// need to emit incref
Py_INCREF
(
new_attr
);
assert
(
cls
->
instancesHaveHCAttrs
());
assert
(
cls
->
instancesHaveHCAttrs
());
HCAttrs
*
attrs
=
getHCAttrsPtr
();
HCAttrs
*
attrs
=
getHCAttrsPtr
();
HiddenClass
*
hcls
=
attrs
->
hcls
;
HiddenClass
*
hcls
=
attrs
->
hcls
;
...
...
src/runtime/set.cpp
View file @
a3dbaa95
...
@@ -508,13 +508,13 @@ static Box* setIssubset(BoxedSet* self, Box* container) {
...
@@ -508,13 +508,13 @@ static Box* setIssubset(BoxedSet* self, Box* container) {
BoxedSet
*
rhs
=
static_cast
<
BoxedSet
*>
(
container
);
BoxedSet
*
rhs
=
static_cast
<
BoxedSet
*>
(
container
);
if
(
self
->
s
.
size
()
>
rhs
->
s
.
size
())
if
(
self
->
s
.
size
()
>
rhs
->
s
.
size
())
return
False
;
Py_RETURN_FALSE
;
for
(
auto
e
:
self
->
s
)
{
for
(
auto
e
:
self
->
s
)
{
if
(
rhs
->
s
.
find
(
e
)
==
rhs
->
s
.
end
())
if
(
rhs
->
s
.
find
(
e
)
==
rhs
->
s
.
end
())
return
False
;
Py_RETURN_FALSE
;
}
}
return
True
;
Py_RETURN_TRUE
;
}
}
static
Box
*
setIssuperset
(
BoxedSet
*
self
,
Box
*
container
)
{
static
Box
*
setIssuperset
(
BoxedSet
*
self
,
Box
*
container
)
{
...
@@ -532,9 +532,9 @@ static Box* setIsdisjoint(BoxedSet* self, Box* container) {
...
@@ -532,9 +532,9 @@ static Box* setIsdisjoint(BoxedSet* self, Box* container) {
for
(
auto
e
:
container
->
pyElements
())
{
for
(
auto
e
:
container
->
pyElements
())
{
if
(
self
->
s
.
find
(
e
)
!=
self
->
s
.
end
())
if
(
self
->
s
.
find
(
e
)
!=
self
->
s
.
end
())
return
False
;
Py_RETURN_FALSE
;
}
}
return
True
;
Py_RETURN_TRUE
;
}
}
static
Box
*
setIntersection
(
BoxedSet
*
self
,
BoxedTuple
*
args
)
{
static
Box
*
setIntersection
(
BoxedSet
*
self
,
BoxedTuple
*
args
)
{
...
@@ -590,10 +590,10 @@ Box* setPop(BoxedSet* self) {
...
@@ -590,10 +590,10 @@ Box* setPop(BoxedSet* self) {
Box
*
setEq
(
BoxedSet
*
self
,
BoxedSet
*
rhs
)
{
Box
*
setEq
(
BoxedSet
*
self
,
BoxedSet
*
rhs
)
{
RELEASE_ASSERT
(
PyAnySet_Check
(
self
),
""
);
RELEASE_ASSERT
(
PyAnySet_Check
(
self
),
""
);
if
(
!
PyAnySet_Check
(
rhs
))
if
(
!
PyAnySet_Check
(
rhs
))
return
False
;
Py_RETURN_FALSE
;
if
(
self
->
s
.
size
()
!=
rhs
->
s
.
size
())
if
(
self
->
s
.
size
()
!=
rhs
->
s
.
size
())
return
False
;
Py_RETURN_FALSE
;
return
setIssubset
(
self
,
rhs
);
return
setIssubset
(
self
,
rhs
);
}
}
...
@@ -618,7 +618,7 @@ Box* setLt(BoxedSet* self, BoxedSet* rhs) {
...
@@ -618,7 +618,7 @@ Box* setLt(BoxedSet* self, BoxedSet* rhs) {
raiseExcHelper
(
TypeError
,
"can only compare to a set"
);
raiseExcHelper
(
TypeError
,
"can only compare to a set"
);
if
(
self
->
s
.
size
()
>=
rhs
->
s
.
size
())
if
(
self
->
s
.
size
()
>=
rhs
->
s
.
size
())
return
False
;
Py_RETURN_FALSE
;
return
setIssubset
(
self
,
rhs
);
return
setIssubset
(
self
,
rhs
);
}
}
...
@@ -637,7 +637,7 @@ Box* setGt(BoxedSet* self, BoxedSet* rhs) {
...
@@ -637,7 +637,7 @@ Box* setGt(BoxedSet* self, BoxedSet* rhs) {
raiseExcHelper
(
TypeError
,
"can only compare to a set"
);
raiseExcHelper
(
TypeError
,
"can only compare to a set"
);
if
(
self
->
s
.
size
()
<=
rhs
->
s
.
size
())
if
(
self
->
s
.
size
()
<=
rhs
->
s
.
size
())
return
False
;
Py_RETURN_FALSE
;
return
setIssuperset
(
self
,
rhs
);
return
setIssuperset
(
self
,
rhs
);
}
}
...
...
src/runtime/str.cpp
View file @
a3dbaa95
...
@@ -1704,14 +1704,14 @@ Box* strIsAlpha(BoxedString* self) {
...
@@ -1704,14 +1704,14 @@ Box* strIsAlpha(BoxedString* self) {
llvm
::
StringRef
str
(
self
->
s
());
llvm
::
StringRef
str
(
self
->
s
());
if
(
str
.
empty
())
if
(
str
.
empty
())
return
False
;
Py_RETURN_FALSE
;
for
(
const
auto
&
c
:
str
)
{
for
(
const
auto
&
c
:
str
)
{
if
(
!
std
::
isalpha
(
c
))
if
(
!
std
::
isalpha
(
c
))
return
False
;
Py_RETURN_FALSE
;
}
}
return
True
;
Py_RETURN_TRUE
;
}
}
Box
*
strIsDigit
(
BoxedString
*
self
)
{
Box
*
strIsDigit
(
BoxedString
*
self
)
{
...
@@ -1719,14 +1719,14 @@ Box* strIsDigit(BoxedString* self) {
...
@@ -1719,14 +1719,14 @@ Box* strIsDigit(BoxedString* self) {
llvm
::
StringRef
str
(
self
->
s
());
llvm
::
StringRef
str
(
self
->
s
());
if
(
str
.
empty
())
if
(
str
.
empty
())
return
False
;
Py_RETURN_FALSE
;
for
(
const
auto
&
c
:
str
)
{
for
(
const
auto
&
c
:
str
)
{
if
(
!
std
::
isdigit
(
c
))
if
(
!
std
::
isdigit
(
c
))
return
False
;
Py_RETURN_FALSE
;
}
}
return
True
;
Py_RETURN_TRUE
;
}
}
Box
*
strIsAlnum
(
BoxedString
*
self
)
{
Box
*
strIsAlnum
(
BoxedString
*
self
)
{
...
@@ -1734,14 +1734,14 @@ Box* strIsAlnum(BoxedString* self) {
...
@@ -1734,14 +1734,14 @@ Box* strIsAlnum(BoxedString* self) {
llvm
::
StringRef
str
(
self
->
s
());
llvm
::
StringRef
str
(
self
->
s
());
if
(
str
.
empty
())
if
(
str
.
empty
())
return
False
;
Py_RETURN_FALSE
;
for
(
const
auto
&
c
:
str
)
{
for
(
const
auto
&
c
:
str
)
{
if
(
!
std
::
isalnum
(
c
))
if
(
!
std
::
isalnum
(
c
))
return
False
;
Py_RETURN_FALSE
;
}
}
return
True
;
Py_RETURN_TRUE
;
}
}
Box
*
strIsLower
(
BoxedString
*
self
)
{
Box
*
strIsLower
(
BoxedString
*
self
)
{
...
@@ -1751,13 +1751,13 @@ Box* strIsLower(BoxedString* self) {
...
@@ -1751,13 +1751,13 @@ Box* strIsLower(BoxedString* self) {
bool
lowered
=
false
;
bool
lowered
=
false
;
if
(
str
.
empty
())
if
(
str
.
empty
())
return
False
;
Py_RETURN_FALSE
;
for
(
const
auto
&
c
:
str
)
{
for
(
const
auto
&
c
:
str
)
{
if
(
std
::
isspace
(
c
)
||
std
::
isdigit
(
c
))
{
if
(
std
::
isspace
(
c
)
||
std
::
isdigit
(
c
))
{
continue
;
continue
;
}
else
if
(
!
std
::
islower
(
c
))
{
}
else
if
(
!
std
::
islower
(
c
))
{
return
False
;
Py_RETURN_FALSE
;
}
else
{
}
else
{
lowered
=
true
;
lowered
=
true
;
}
}
...
@@ -1772,12 +1772,12 @@ Box* strIsUpper(BoxedString* self) {
...
@@ -1772,12 +1772,12 @@ Box* strIsUpper(BoxedString* self) {
llvm
::
StringRef
str
(
self
->
s
());
llvm
::
StringRef
str
(
self
->
s
());
if
(
str
.
empty
())
if
(
str
.
empty
())
return
False
;
Py_RETURN_FALSE
;
bool
cased
=
false
;
bool
cased
=
false
;
for
(
const
auto
&
c
:
str
)
{
for
(
const
auto
&
c
:
str
)
{
if
(
std
::
islower
(
c
))
if
(
std
::
islower
(
c
))
return
False
;
Py_RETURN_FALSE
;
else
if
(
!
cased
&&
isupper
(
c
))
else
if
(
!
cased
&&
isupper
(
c
))
cased
=
true
;
cased
=
true
;
}
}
...
@@ -1790,14 +1790,14 @@ Box* strIsSpace(BoxedString* self) {
...
@@ -1790,14 +1790,14 @@ Box* strIsSpace(BoxedString* self) {
llvm
::
StringRef
str
(
self
->
s
());
llvm
::
StringRef
str
(
self
->
s
());
if
(
str
.
empty
())
if
(
str
.
empty
())
return
False
;
Py_RETURN_FALSE
;
for
(
const
auto
&
c
:
str
)
{
for
(
const
auto
&
c
:
str
)
{
if
(
!
std
::
isspace
(
c
))
if
(
!
std
::
isspace
(
c
))
return
False
;
Py_RETURN_FALSE
;
}
}
return
True
;
Py_RETURN_TRUE
;
}
}
Box
*
strIsTitle
(
BoxedString
*
self
)
{
Box
*
strIsTitle
(
BoxedString
*
self
)
{
...
@@ -1806,7 +1806,7 @@ Box* strIsTitle(BoxedString* self) {
...
@@ -1806,7 +1806,7 @@ Box* strIsTitle(BoxedString* self) {
llvm
::
StringRef
str
(
self
->
s
());
llvm
::
StringRef
str
(
self
->
s
());
if
(
str
.
empty
())
if
(
str
.
empty
())
return
False
;
Py_RETURN_FALSE
;
if
(
str
.
size
()
==
1
)
if
(
str
.
size
()
==
1
)
return
boxBool
(
std
::
isupper
(
str
[
0
]));
return
boxBool
(
std
::
isupper
(
str
[
0
]));
...
@@ -1815,14 +1815,14 @@ Box* strIsTitle(BoxedString* self) {
...
@@ -1815,14 +1815,14 @@ Box* strIsTitle(BoxedString* self) {
for
(
const
auto
&
c
:
str
)
{
for
(
const
auto
&
c
:
str
)
{
if
(
std
::
isupper
(
c
))
{
if
(
std
::
isupper
(
c
))
{
if
(
!
start_of_word
)
{
if
(
!
start_of_word
)
{
return
False
;
Py_RETURN_FALSE
;
}
}
start_of_word
=
false
;
start_of_word
=
false
;
cased
=
true
;
cased
=
true
;
}
else
if
(
std
::
islower
(
c
))
{
}
else
if
(
std
::
islower
(
c
))
{
if
(
start_of_word
)
{
if
(
start_of_word
)
{
return
False
;
Py_RETURN_FALSE
;
}
}
start_of_word
=
false
;
start_of_word
=
false
;
...
@@ -2131,9 +2131,9 @@ Box* strStartswith(BoxedString* self, Box* elt, Box* start, Box** _args) {
...
@@ -2131,9 +2131,9 @@ Box* strStartswith(BoxedString* self, Box* elt, Box* start, Box** _args) {
auto
b
=
strStartswith
(
self
,
e
,
start
,
_args
);
auto
b
=
strStartswith
(
self
,
e
,
start
,
_args
);
assert
(
b
->
cls
==
bool_cls
);
assert
(
b
->
cls
==
bool_cls
);
if
(
b
==
True
)
if
(
b
==
True
)
return
True
;
Py_RETURN_TRUE
;
}
}
return
False
;
Py_RETURN_FALSE
;
}
}
if
(
isSubclass
(
elt
->
cls
,
unicode_cls
))
{
if
(
isSubclass
(
elt
->
cls
,
unicode_cls
))
{
...
@@ -2163,9 +2163,9 @@ Box* strStartswith(BoxedString* self, Box* elt, Box* start, Box** _args) {
...
@@ -2163,9 +2163,9 @@ Box* strStartswith(BoxedString* self, Box* elt, Box* start, Box** _args) {
Py_ssize_t
compare_len
=
iend
-
istart
;
Py_ssize_t
compare_len
=
iend
-
istart
;
if
(
compare_len
<
0
)
if
(
compare_len
<
0
)
return
False
;
Py_RETURN_FALSE
;
if
(
sub
->
size
()
>
compare_len
)
if
(
sub
->
size
()
>
compare_len
)
return
False
;
Py_RETURN_FALSE
;
return
boxBool
(
compareStringRefs
(
self
->
s
(),
istart
,
sub
->
size
(),
sub
->
s
())
==
0
);
return
boxBool
(
compareStringRefs
(
self
->
s
(),
istart
,
sub
->
size
(),
sub
->
s
())
==
0
);
}
}
...
@@ -2202,9 +2202,9 @@ Box* strEndswith(BoxedString* self, Box* elt, Box* start, Box** _args) {
...
@@ -2202,9 +2202,9 @@ Box* strEndswith(BoxedString* self, Box* elt, Box* start, Box** _args) {
auto
b
=
strEndswith
(
self
,
e
,
start
,
_args
);
auto
b
=
strEndswith
(
self
,
e
,
start
,
_args
);
assert
(
b
->
cls
==
bool_cls
);
assert
(
b
->
cls
==
bool_cls
);
if
(
b
==
True
)
if
(
b
==
True
)
return
True
;
Py_RETURN_TRUE
;
}
}
return
False
;
Py_RETURN_FALSE
;
}
}
if
(
!
PyString_Check
(
elt
))
if
(
!
PyString_Check
(
elt
))
...
@@ -2226,9 +2226,9 @@ Box* strEndswith(BoxedString* self, Box* elt, Box* start, Box** _args) {
...
@@ -2226,9 +2226,9 @@ Box* strEndswith(BoxedString* self, Box* elt, Box* start, Box** _args) {
Py_ssize_t
compare_len
=
iend
-
istart
;
Py_ssize_t
compare_len
=
iend
-
istart
;
if
(
compare_len
<
0
)
if
(
compare_len
<
0
)
return
False
;
Py_RETURN_FALSE
;
if
(
sub
->
size
()
>
compare_len
)
if
(
sub
->
size
()
>
compare_len
)
return
False
;
Py_RETURN_FALSE
;
// XXX: this line is the only difference between startswith and endswith:
// XXX: this line is the only difference between startswith and endswith:
istart
+=
compare_len
-
sub
->
size
();
istart
+=
compare_len
-
sub
->
size
();
return
boxBool
(
compareStringRefs
(
self
->
s
(),
istart
,
sub
->
size
(),
sub
->
s
())
==
0
);
return
boxBool
(
compareStringRefs
(
self
->
s
(),
istart
,
sub
->
size
(),
sub
->
s
())
==
0
);
...
...
src/runtime/tuple.cpp
View file @
a3dbaa95
...
@@ -61,6 +61,7 @@ Box* tupleGetitemUnboxed(BoxedTuple* self, i64 n) {
...
@@ -61,6 +61,7 @@ Box* tupleGetitemUnboxed(BoxedTuple* self, i64 n) {
raiseExcHelper
(
IndexError
,
"tuple index out of range"
);
raiseExcHelper
(
IndexError
,
"tuple index out of range"
);
Box
*
rtn
=
self
->
elts
[
n
];
Box
*
rtn
=
self
->
elts
[
n
];
Py_INCREF
(
rtn
);
return
rtn
;
return
rtn
;
}
}
...
@@ -269,9 +270,9 @@ Box* tupleContains(BoxedTuple* self, Box* elt) {
...
@@ -269,9 +270,9 @@ Box* tupleContains(BoxedTuple* self, Box* elt) {
throwCAPIException
();
throwCAPIException
();
if
(
r
)
if
(
r
)
return
True
;
Py_RETURN_TRUE
;
}
}
return
False
;
Py_RETURN_FALSE
;
}
}
Box
*
tupleIndex
(
BoxedTuple
*
self
,
Box
*
elt
,
Box
*
startBox
,
Box
**
args
)
{
Box
*
tupleIndex
(
BoxedTuple
*
self
,
Box
*
elt
,
Box
*
startBox
,
Box
**
args
)
{
...
@@ -409,8 +410,10 @@ extern "C" PyObject* PyTuple_Pack(Py_ssize_t n, ...) noexcept {
...
@@ -409,8 +410,10 @@ extern "C" PyObject* PyTuple_Pack(Py_ssize_t n, ...) noexcept {
extern
"C"
PyObject
*
PyTuple_New
(
Py_ssize_t
size
)
noexcept
{
extern
"C"
PyObject
*
PyTuple_New
(
Py_ssize_t
size
)
noexcept
{
RELEASE_ASSERT
(
size
>=
0
,
""
);
RELEASE_ASSERT
(
size
>=
0
,
""
);
if
(
size
==
0
)
if
(
size
==
0
)
{
Py_INCREF
(
EmptyTuple
);
return
EmptyTuple
;
return
EmptyTuple
;
}
return
BoxedTuple
::
create
(
size
);
return
BoxedTuple
::
create
(
size
);
}
}
...
...
src/runtime/types.cpp
View file @
a3dbaa95
...
@@ -1632,7 +1632,7 @@ extern "C" Box* none_repr(Box* v) noexcept {
...
@@ -1632,7 +1632,7 @@ extern "C" Box* none_repr(Box* v) noexcept {
}
}
extern
"C"
Box
*
noneNonzero
(
Box
*
v
)
{
extern
"C"
Box
*
noneNonzero
(
Box
*
v
)
{
return
False
;
Py_RETURN_FALSE
;
}
}
extern
"C"
BoxedString
*
builtinFunctionOrMethodRepr
(
BoxedBuiltinFunctionOrMethod
*
v
)
{
extern
"C"
BoxedString
*
builtinFunctionOrMethodRepr
(
BoxedBuiltinFunctionOrMethod
*
v
)
{
...
@@ -1794,7 +1794,7 @@ static void functionSetDefaults(Box* b, Box* v, void*) {
...
@@ -1794,7 +1794,7 @@ static void functionSetDefaults(Box* b, Box* v, void*) {
}
}
static
Box
*
functionNonzero
(
BoxedFunction
*
self
)
{
static
Box
*
functionNonzero
(
BoxedFunction
*
self
)
{
return
True
;
Py_RETURN_TRUE
;
}
}
extern
"C"
{
extern
"C"
{
...
@@ -3313,6 +3313,7 @@ extern "C" PyVarObject* PyObject_InitVar(PyVarObject* op, PyTypeObject* tp, Py_s
...
@@ -3313,6 +3313,7 @@ extern "C" PyVarObject* PyObject_InitVar(PyVarObject* op, PyTypeObject* tp, Py_s
Py_TYPE
(
op
)
=
tp
;
Py_TYPE
(
op
)
=
tp
;
op
->
ob_size
=
size
;
op
->
ob_size
=
size
;
_Py_NewReference
(
op
);
gc
::
registerPythonObject
(
op
);
gc
::
registerPythonObject
(
op
);
...
@@ -3329,6 +3330,7 @@ extern "C" PyObject* PyObject_Init(PyObject* op, PyTypeObject* tp) noexcept {
...
@@ -3329,6 +3330,7 @@ extern "C" PyObject* PyObject_Init(PyObject* op, PyTypeObject* tp) noexcept {
assert
(
gc
::
isValidGCObject
(
tp
));
assert
(
gc
::
isValidGCObject
(
tp
));
Py_TYPE
(
op
)
=
tp
;
Py_TYPE
(
op
)
=
tp
;
_Py_NewReference
(
op
);
gc
::
registerPythonObject
(
op
);
gc
::
registerPythonObject
(
op
);
...
...
src/runtime/types.h
View file @
a3dbaa95
...
@@ -129,11 +129,14 @@ extern BoxedModule* sys_module, *builtins_module, *math_module, *time_module, *t
...
@@ -129,11 +129,14 @@ extern BoxedModule* sys_module, *builtins_module, *math_module, *time_module, *t
extern
"C"
inline
Box
*
boxBool
(
bool
b
)
__attribute__
((
visibility
(
"default"
)));
extern
"C"
inline
Box
*
boxBool
(
bool
b
)
__attribute__
((
visibility
(
"default"
)));
extern
"C"
inline
Box
*
boxBool
(
bool
b
)
{
extern
"C"
inline
Box
*
boxBool
(
bool
b
)
{
return
b
?
True
:
False
;
if
(
b
)
Py_RETURN_TRUE
;
else
Py_RETURN_FALSE
;
}
}
extern
"C"
inline
Box
*
boxBoolNegated
(
bool
b
)
__attribute__
((
visibility
(
"default"
)));
extern
"C"
inline
Box
*
boxBoolNegated
(
bool
b
)
__attribute__
((
visibility
(
"default"
)));
extern
"C"
inline
Box
*
boxBoolNegated
(
bool
b
)
{
extern
"C"
inline
Box
*
boxBoolNegated
(
bool
b
)
{
return
b
?
False
:
True
;
return
b
oxBool
(
!
b
)
;
}
}
extern
"C"
Box
*
boxInt
(
i64
)
__attribute__
((
visibility
(
"default"
)));
extern
"C"
Box
*
boxInt
(
i64
)
__attribute__
((
visibility
(
"default"
)));
extern
"C"
i64
unboxInt
(
Box
*
);
extern
"C"
i64
unboxInt
(
Box
*
);
...
@@ -424,6 +427,7 @@ public:
...
@@ -424,6 +427,7 @@ public:
BoxVar
*
rtn
=
static_cast
<
BoxVar
*>
(
mem
);
BoxVar
*
rtn
=
static_cast
<
BoxVar
*>
(
mem
);
rtn
->
cls
=
str_cls
;
rtn
->
cls
=
str_cls
;
rtn
->
ob_size
=
nitems
;
rtn
->
ob_size
=
nitems
;
_Py_NewReference
(
rtn
);
return
rtn
;
return
rtn
;
}
}
...
@@ -516,15 +520,19 @@ static_assert(offsetof(BoxedList, capacity) == offsetof(PyListObject, allocated)
...
@@ -516,15 +520,19 @@ static_assert(offsetof(BoxedList, capacity) == offsetof(PyListObject, allocated)
class
BoxedTuple
:
public
BoxVar
{
class
BoxedTuple
:
public
BoxVar
{
public:
public:
static
BoxedTuple
*
create
(
int64_t
size
)
{
static
BoxedTuple
*
create
(
int64_t
size
)
{
if
(
size
==
0
)
if
(
size
==
0
)
{
Py_INCREF
(
EmptyTuple
);
return
EmptyTuple
;
return
EmptyTuple
;
}
BoxedTuple
*
rtn
=
new
(
size
)
BoxedTuple
();
BoxedTuple
*
rtn
=
new
(
size
)
BoxedTuple
();
memset
(
rtn
->
elts
,
0
,
size
*
sizeof
(
Box
*
));
// TODO not all callers want this (but some do)
memset
(
rtn
->
elts
,
0
,
size
*
sizeof
(
Box
*
));
// TODO not all callers want this (but some do)
return
rtn
;
return
rtn
;
}
}
static
BoxedTuple
*
create
(
int64_t
nelts
,
Box
**
elts
)
{
static
BoxedTuple
*
create
(
int64_t
nelts
,
Box
**
elts
)
{
if
(
nelts
==
0
)
if
(
nelts
==
0
)
{
Py_INCREF
(
EmptyTuple
);
return
EmptyTuple
;
return
EmptyTuple
;
}
BoxedTuple
*
rtn
=
new
(
nelts
)
BoxedTuple
();
BoxedTuple
*
rtn
=
new
(
nelts
)
BoxedTuple
();
for
(
int
i
=
0
;
i
<
nelts
;
i
++
)
for
(
int
i
=
0
;
i
<
nelts
;
i
++
)
assert
(
gc
::
isValidGCObject
(
elts
[
i
]));
assert
(
gc
::
isValidGCObject
(
elts
[
i
]));
...
@@ -652,6 +660,7 @@ public:
...
@@ -652,6 +660,7 @@ public:
BoxVar
*
rtn
=
static_cast
<
BoxVar
*>
(
mem
);
BoxVar
*
rtn
=
static_cast
<
BoxVar
*>
(
mem
);
rtn
->
cls
=
tuple_cls
;
rtn
->
cls
=
tuple_cls
;
rtn
->
ob_size
=
nitems
;
rtn
->
ob_size
=
nitems
;
_Py_NewReference
(
rtn
);
return
rtn
;
return
rtn
;
}
}
...
@@ -996,6 +1005,7 @@ public:
...
@@ -996,6 +1005,7 @@ public:
=
static_cast
<
BoxedClosure
*>
(
gc_alloc
(
sizeof
(
BoxedClosure
)
+
nelts
*
sizeof
(
Box
*
),
gc
::
GCKind
::
PYTHON
));
=
static_cast
<
BoxedClosure
*>
(
gc_alloc
(
sizeof
(
BoxedClosure
)
+
nelts
*
sizeof
(
Box
*
),
gc
::
GCKind
::
PYTHON
));
rtn
->
nelts
=
nelts
;
rtn
->
nelts
=
nelts
;
rtn
->
cls
=
closure_cls
;
rtn
->
cls
=
closure_cls
;
_Py_NewReference
(
rtn
);
memset
((
void
*
)
rtn
->
elts
,
0
,
sizeof
(
Box
*
)
*
nelts
);
memset
((
void
*
)
rtn
->
elts
,
0
,
sizeof
(
Box
*
)
*
nelts
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1128,9 +1138,13 @@ Box* getFrame(int depth);
...
@@ -1128,9 +1138,13 @@ Box* getFrame(int depth);
inline
BoxedString
*
boxString
(
llvm
::
StringRef
s
)
{
inline
BoxedString
*
boxString
(
llvm
::
StringRef
s
)
{
if
(
s
.
size
()
<=
1
)
{
if
(
s
.
size
()
<=
1
)
{
BoxedString
*
r
;
if
(
s
.
size
()
==
0
)
if
(
s
.
size
()
==
0
)
return
EmptyString
;
r
=
EmptyString
;
return
characters
[
s
.
data
()[
0
]
&
UCHAR_MAX
];
else
r
=
characters
[
s
.
data
()[
0
]
&
UCHAR_MAX
];
Py_INCREF
(
r
);
return
r
;
}
}
return
new
(
s
.
size
())
BoxedString
(
s
);
return
new
(
s
.
size
())
BoxedString
(
s
);
}
}
...
@@ -1139,7 +1153,9 @@ inline BoxedString* boxString(llvm::StringRef s) {
...
@@ -1139,7 +1153,9 @@ inline BoxedString* boxString(llvm::StringRef s) {
extern
BoxedInt
*
interned_ints
[
NUM_INTERNED_INTS
];
extern
BoxedInt
*
interned_ints
[
NUM_INTERNED_INTS
];
extern
"C"
inline
Box
*
boxInt
(
int64_t
n
)
{
extern
"C"
inline
Box
*
boxInt
(
int64_t
n
)
{
if
(
0
<=
n
&&
n
<
NUM_INTERNED_INTS
)
{
if
(
0
<=
n
&&
n
<
NUM_INTERNED_INTS
)
{
return
interned_ints
[
n
];
auto
r
=
interned_ints
[
n
];
Py_INCREF
(
r
);
return
r
;
}
}
return
new
BoxedInt
(
n
);
return
new
BoxedInt
(
n
);
}
}
...
...
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