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
916a2dcf
Commit
916a2dcf
authored
Apr 18, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
2a3b70eb
' into refcounting
parents
73ab425f
2a3b70eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
7 deletions
+39
-7
src/runtime/int.cpp
src/runtime/int.cpp
+7
-7
test/tests/float.py
test/tests/float.py
+32
-0
No files found.
src/runtime/int.cpp
View file @
916a2dcf
...
@@ -491,7 +491,7 @@ extern "C" Box* intAdd(BoxedInt* lhs, Box* rhs) {
...
@@ -491,7 +491,7 @@ extern "C" Box* intAdd(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
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
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
return
boxFloat
(
lhs
->
n
+
rhs_float
->
d
);
return
boxFloat
(
lhs
->
n
+
rhs_float
->
d
);
}
else
{
}
else
{
...
@@ -620,7 +620,7 @@ extern "C" Box* intDiv(BoxedInt* lhs, Box* rhs) {
...
@@ -620,7 +620,7 @@ extern "C" Box* intDiv(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
return
intDivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
return
intDivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
}
else
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
return
intDivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
return
intDivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
}
else
{
}
else
{
return
incref
(
NotImplemented
);
return
incref
(
NotImplemented
);
...
@@ -662,7 +662,7 @@ extern "C" Box* intFloordiv(BoxedInt* lhs, Box* rhs) {
...
@@ -662,7 +662,7 @@ extern "C" Box* intFloordiv(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
return
intFloordivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
return
intFloordivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
}
else
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
return
intFloordivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
return
intFloordivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
}
else
{
}
else
{
return
incref
(
NotImplemented
);
return
incref
(
NotImplemented
);
...
@@ -708,7 +708,7 @@ extern "C" Box* intTruediv(BoxedInt* lhs, Box* rhs) {
...
@@ -708,7 +708,7 @@ extern "C" Box* intTruediv(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
return
intTruedivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
return
intTruedivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
}
else
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
return
intTruedivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
return
intTruedivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
}
else
{
}
else
{
return
incref
(
NotImplemented
);
return
incref
(
NotImplemented
);
...
@@ -855,7 +855,7 @@ extern "C" Box* intMul(BoxedInt* lhs, Box* rhs) {
...
@@ -855,7 +855,7 @@ extern "C" Box* intMul(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
intMulInt
(
lhs
,
rhs_int
);
return
intMulInt
(
lhs
,
rhs_int
);
}
else
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
return
intMulFloat
(
lhs
,
rhs_float
);
return
intMulFloat
(
lhs
,
rhs_float
);
}
else
{
}
else
{
...
@@ -907,7 +907,7 @@ extern "C" Box* intPow(BoxedInt* lhs, Box* rhs, Box* mod) {
...
@@ -907,7 +907,7 @@ extern "C" Box* intPow(BoxedInt* lhs, Box* rhs, Box* mod) {
if
(
PyLong_Check
(
rhs
))
if
(
PyLong_Check
(
rhs
))
return
intPowLong
(
lhs
,
static_cast
<
BoxedLong
*>
(
rhs
),
mod
);
return
intPowLong
(
lhs
,
static_cast
<
BoxedLong
*>
(
rhs
),
mod
);
else
if
(
PyFloat_Check
(
rhs
))
else
if
(
PyFloat_Check
Exact
(
rhs
))
return
intPowFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
),
mod
);
return
intPowFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
),
mod
);
else
if
(
!
PyInt_Check
(
rhs
))
else
if
(
!
PyInt_Check
(
rhs
))
return
incref
(
NotImplemented
);
return
incref
(
NotImplemented
);
...
@@ -1002,7 +1002,7 @@ extern "C" Box* intSub(BoxedInt* lhs, Box* rhs) {
...
@@ -1002,7 +1002,7 @@ extern "C" Box* intSub(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
intSubInt
(
lhs
,
rhs_int
);
return
intSubInt
(
lhs
,
rhs_int
);
}
else
if
(
PyFloat_Check
(
rhs
))
{
}
else
if
(
PyFloat_Check
Exact
(
rhs
))
{
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
return
intSubFloat
(
lhs
,
rhs_float
);
return
intSubFloat
(
lhs
,
rhs_float
);
}
else
{
}
else
{
...
...
test/tests/float.py
View file @
916a2dcf
...
@@ -141,3 +141,35 @@ for x in data:
...
@@ -141,3 +141,35 @@ for x in data:
arg2
=
y
)))
arg2
=
y
)))
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
.
message
)
print
(
e
.
message
)
class
Foo1
(
float
):
def
__rdiv__
(
self
,
other
):
print
(
"float custom operation called"
)
return
self
/
other
class
Foo2
(
long
):
def
__rdiv__
(
self
,
other
):
print
(
"long custom operation called"
)
return
self
/
other
class
Foo3
(
int
):
def
__rdiv__
(
self
,
other
):
print
(
"int custom operation called"
)
return
self
/
other
a
=
Foo1
(
1.5
)
b
=
Foo2
(
1L
)
c
=
Foo3
(
1
)
print
(
1.5
/
a
)
print
(
1.5
/
b
)
print
(
1.5
/
c
)
print
(
1
/
a
)
print
(
1
/
b
)
print
(
1
/
c
)
print
(
1L
/
a
)
print
(
1L
/
b
)
print
(
1L
/
c
)
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