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
586ceed6
Commit
586ceed6
authored
Feb 26, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
9216f615
' into refcounting
parents
bb191d97
9216f615
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
771 additions
and
150 deletions
+771
-150
from_cpython/Objects/floatobject.c
from_cpython/Objects/floatobject.c
+6
-3
src/runtime/float.cpp
src/runtime/float.cpp
+134
-12
src/runtime/frame.cpp
src/runtime/frame.cpp
+11
-3
src/runtime/int.cpp
src/runtime/int.cpp
+260
-12
src/runtime/long.cpp
src/runtime/long.cpp
+242
-118
src/runtime/long.h
src/runtime/long.h
+2
-2
test/tests/float.py
test/tests/float.py
+26
-0
test/tests/intmethods.py
test/tests/intmethods.py
+50
-0
test/tests/long.py
test/tests/long.py
+40
-0
No files found.
from_cpython/Objects/floatobject.c
View file @
586ceed6
...
...
@@ -747,7 +747,8 @@ float_rem(PyObject *v, PyObject *w)
return
PyFloat_FromDouble
(
mod
);
}
static
PyObject
*
// pyston change: make this not static
PyObject
*
float_divmod
(
PyObject
*
v
,
PyObject
*
w
)
{
double
vx
,
wx
;
...
...
@@ -987,7 +988,8 @@ float_nonzero(PyFloatObject *v)
return
v
->
ob_fval
!=
0
.
0
;
}
static
int
// pyston change: make not static
int
float_coerce
(
PyObject
**
pv
,
PyObject
**
pw
)
{
if
(
PyInt_Check
(
*
pw
))
{
...
...
@@ -1949,7 +1951,8 @@ PyDoc_STRVAR(float_getformat_doc,
"'unknown', 'IEEE, big-endian' or 'IEEE, little-endian' best describes the
\n
"
"format of floating point numbers used by the C type named by typestr."
);
static
PyObject
*
// pyston change: make not static
PyObject
*
float_setformat
(
PyTypeObject
*
v
,
PyObject
*
args
)
{
char
*
typestr
;
...
...
src/runtime/float.cpp
View file @
586ceed6
This diff is collapsed.
Click to expand it.
src/runtime/frame.cpp
View file @
586ceed6
...
...
@@ -154,9 +154,17 @@ Box* getFrame(int depth) {
return
BoxedFrame
::
boxFrame
(
std
::
move
(
it
));
}
extern
"C"
int
PyFrame_GetLineNumber
(
PyFrameObject
*
f
)
noexcept
{
BoxedInt
*
lineno
=
(
BoxedInt
*
)
BoxedFrame
::
lineno
((
Box
*
)
f
,
NULL
);
return
lineno
->
n
;
extern
"C"
int
PyFrame_GetLineNumber
(
PyFrameObject
*
_f
)
noexcept
{
// TODO remove this when we are able to introspect exited frames:
// We check if the frame exited and only return the correct line number when it is still available.
// Because of a limitation in out current frame introspection we can also not inspect OSRed frames.
BoxedFrame
*
f
=
(
BoxedFrame
*
)
_f
;
PythonFrameIterator
new_it
=
f
->
it
.
getCurrentVersion
();
if
(
new_it
.
exists
()
&&
new_it
.
getFrameInfo
()
->
frame_obj
==
f
)
{
BoxedInt
*
lineno
=
(
BoxedInt
*
)
BoxedFrame
::
lineno
((
Box
*
)
f
,
NULL
);
return
lineno
->
n
;
}
return
-
1
;
}
extern
"C"
PyObject
*
PyFrame_GetGlobals
(
PyFrameObject
*
f
)
noexcept
{
...
...
src/runtime/int.cpp
View file @
586ceed6
This diff is collapsed.
Click to expand it.
src/runtime/long.cpp
View file @
586ceed6
This diff is collapsed.
Click to expand it.
src/runtime/long.h
View file @
586ceed6
...
...
@@ -49,8 +49,8 @@ Box* longSub(BoxedLong* lhs, Box* rhs);
Box
*
longMul
(
BoxedLong
*
lhs
,
Box
*
rhs
);
Box
*
longDiv
(
BoxedLong
*
lhs
,
Box
*
rhs
);
Box
*
longPow
(
BoxedLong
*
lhs
,
Box
*
rhs
,
Box
*
mod
=
None
);
Box
*
longL
shift
(
BoxedLong
*
lhs
,
Box
*
rhs
);
Box
*
longR
shift
(
BoxedLong
*
lhs
,
Box
*
rhs
);
Box
*
longL
ShiftLong
(
BoxedLong
*
lhs
,
Box
*
_
rhs
);
Box
*
longR
ShiftLong
(
BoxedLong
*
lhs
,
Box
*
_
rhs
);
Box
*
longHex
(
BoxedLong
*
v
);
Box
*
longOct
(
BoxedLong
*
v
);
...
...
test/tests/float.py
View file @
586ceed6
...
...
@@ -111,3 +111,29 @@ print sys.float_info
if
1
:
x
=
-
2.0
print
(
float
.
__long__
(
sys
.
float_info
.
max
))
print
(
float
.
__int__
(
sys
.
float_info
.
max
))
data
=
[
"-1.0"
,
"0.0"
,
"1.0"
,
"5.0"
,
"-5.0"
,
"5"
,
"5L"
,
"0L"
,
"5+5j"
,
"
\
"
5
\
"
"
,
"None"
,
]
operations
=
[
"__rpow__"
,
"__ridv__"
,
"__divmod__"
,
"__rdivmod__"
,
"__rtruediv__"
,
"__coerce__"
]
for
x
in
data
:
for
y
in
data
:
for
operation
in
operations
:
try
:
print
(
eval
(
"float.{op}({arg1}, {arg2})"
.
format
(
op
=
operation
,
arg1
=
x
,
arg2
=
y
)))
except
Exception
as
e
:
print
(
e
.
message
)
test/tests/intmethods.py
View file @
586ceed6
...
...
@@ -178,3 +178,53 @@ if sys.version_info >= (2, 7, 6):
print
(
e
.
message
)
else
:
print
(
"int() missing string argument"
)
pow_test_data
=
[
42
,
3
,
3L
,
4.5
,
"x"
,
0
,
-
42
,
None
]
for
rhs
in
pow_test_data
:
for
lhs
in
pow_test_data
:
for
mod
in
pow_test_data
:
try
:
print
(
int
.
__rpow__
(
rhs
,
lhs
,
mod
))
except
Exception
as
e
:
print
(
e
.
message
)
unary_test_data
=
[
-
42
,
-
0
,
0
,
42
,
max_int
,
min_int
]
for
i
in
unary_test_data
:
print
(
int
.
__abs__
(
i
))
print
(
int
.
__long__
(
i
))
print
(
int
.
__float__
(
i
))
data
=
[
"-1"
,
"0"
,
"1"
,
"5"
,
"-5"
,
"5.0"
,
"5L"
,
"0L"
,
"5+5j"
,
"0.0"
,
"
\
"
5
\
"
"
,
"None"
,
]
operations
=
[
"__radd__"
,
"__rand__"
,
"__ror__"
,
"__rxor__"
,
"__rsub__"
,
"__rmul__"
,
"__rdiv__"
,
"__rfloordiv__"
,
"__rpow__"
,
"__rmod__"
,
"__rdivmod__"
,
"__rtruediv__"
,
"__rrshift__"
,
"__rlshift__"
,
"__coerce__"
,
]
for
x
in
data
:
for
y
in
data
:
for
operation
in
operations
:
try
:
print
(
eval
(
"int.{op}({arg1}, {arg2})"
.
format
(
op
=
operation
,
arg1
=
x
,
arg2
=
y
)))
except
Exception
as
e
:
print
(
e
.
message
)
test/tests/long.py
View file @
586ceed6
...
...
@@ -162,3 +162,43 @@ for i in range(-10, 10):
for
i
in
xrange
(
100
):
for
j
in
xrange
(
100
):
print
i
,
j
,
hash
((
1
<<
i
)
-
(
1
<<
j
))
pow_test_data
=
[
42L
,
3
,
4.5
,
"x"
,
0
,
-
42
,
None
]
for
rhs
in
pow_test_data
:
for
lhs
in
pow_test_data
:
for
mod
in
pow_test_data
:
try
:
print
(
long
.
__rpow__
(
rhs
,
lhs
,
mod
))
except
Exception
as
e
:
print
(
e
.
message
)
unary_test_data
=
[
-
42
,
-
0
,
0
,
42
]
for
i
in
unary_test_data
:
print
(
int
.
__abs__
(
i
))
print
(
int
.
__long__
(
i
))
data
=
[
"-1L"
,
"0L"
,
"1L"
,
"42L"
,
"-42L"
,
"42.0"
,
"5"
,
"0"
,
"5+5j"
,
"0.0"
,
"
\
"
42
\
"
"
,
"None"
,
]
operations
=
[
"__rpow__"
,
"__rshift__"
,
"__lshift__"
,
"__rrshift__"
,
"__rlshift__"
,
"__coerce__"
,
]
for
x
in
data
:
for
y
in
data
:
for
operation
in
operations
:
try
:
print
(
eval
(
"long.{op}({arg1}, {arg2})"
.
format
(
op
=
operation
,
arg1
=
x
,
arg2
=
y
)))
except
Exception
as
e
:
print
(
e
.
message
)
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