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
c14215c5
Commit
c14215c5
authored
Dec 04, 2015
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some small bug fixing
parent
e3979f05
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+1
-1
src/runtime/float.cpp
src/runtime/float.cpp
+9
-0
src/runtime/int.cpp
src/runtime/int.cpp
+9
-0
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
c14215c5
...
@@ -95,7 +95,7 @@ extern "C" Box* abs_(Box* x) {
...
@@ -95,7 +95,7 @@ extern "C" Box* abs_(Box* x) {
return
boxInt
(
n
>=
0
?
n
:
-
n
);
return
boxInt
(
n
>=
0
?
n
:
-
n
);
}
else
if
(
x
->
cls
==
float_cls
)
{
}
else
if
(
x
->
cls
==
float_cls
)
{
double
d
=
static_cast
<
BoxedFloat
*>
(
x
)
->
d
;
double
d
=
static_cast
<
BoxedFloat
*>
(
x
)
->
d
;
return
boxFloat
(
d
>=
0
?
d
:
-
d
);
return
boxFloat
(
std
::
abs
(
d
)
);
}
else
if
(
x
->
cls
==
long_cls
)
{
}
else
if
(
x
->
cls
==
long_cls
)
{
return
longAbs
(
static_cast
<
BoxedLong
*>
(
x
));
return
longAbs
(
static_cast
<
BoxedLong
*>
(
x
));
}
else
{
}
else
{
...
...
src/runtime/float.cpp
View file @
c14215c5
...
@@ -760,6 +760,14 @@ Box* floatPos(BoxedFloat* self) {
...
@@ -760,6 +760,14 @@ Box* floatPos(BoxedFloat* self) {
return
PyFloat_FromDouble
(
self
->
d
);
return
PyFloat_FromDouble
(
self
->
d
);
}
}
Box
*
floatAbs
(
BoxedFloat
*
self
)
{
if
(
!
PyFloat_Check
(
self
))
raiseExcHelper
(
TypeError
,
"descriptor '__abs__' requires a 'float' object but received a '%s'"
,
getTypeName
(
self
));
double
res
=
std
::
abs
(
self
->
d
);
return
boxFloat
(
res
);
}
bool
floatNonzeroUnboxed
(
BoxedFloat
*
self
)
{
bool
floatNonzeroUnboxed
(
BoxedFloat
*
self
)
{
assert
(
self
->
cls
==
float_cls
);
assert
(
self
->
cls
==
float_cls
);
return
self
->
d
!=
0.0
;
return
self
->
d
!=
0.0
;
...
@@ -1614,6 +1622,7 @@ void setupFloat() {
...
@@ -1614,6 +1622,7 @@ void setupFloat() {
float_cls
->
giveAttr
(
"__gt__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
floatGt
,
UNKNOWN
,
2
)));
float_cls
->
giveAttr
(
"__gt__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
floatGt
,
UNKNOWN
,
2
)));
float_cls
->
giveAttr
(
"__neg__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
floatNeg
,
BOXED_FLOAT
,
1
)));
float_cls
->
giveAttr
(
"__neg__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
floatNeg
,
BOXED_FLOAT
,
1
)));
float_cls
->
giveAttr
(
"__pos__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
floatPos
,
BOXED_FLOAT
,
1
)));
float_cls
->
giveAttr
(
"__pos__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
floatPos
,
BOXED_FLOAT
,
1
)));
float_cls
->
giveAttr
(
"__abs__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
floatAbs
,
BOXED_FLOAT
,
1
)));
FunctionMetadata
*
nonzero
=
FunctionMetadata
::
create
((
void
*
)
floatNonzeroUnboxed
,
BOOL
,
1
);
FunctionMetadata
*
nonzero
=
FunctionMetadata
::
create
((
void
*
)
floatNonzeroUnboxed
,
BOOL
,
1
);
nonzero
->
addVersion
((
void
*
)
floatNonzero
,
UNKNOWN
);
nonzero
->
addVersion
((
void
*
)
floatNonzero
,
UNKNOWN
);
...
...
src/runtime/int.cpp
View file @
c14215c5
...
@@ -919,6 +919,14 @@ extern "C" Box* intInt(BoxedInt* self) {
...
@@ -919,6 +919,14 @@ extern "C" Box* intInt(BoxedInt* self) {
return
boxInt
(
self
->
n
);
return
boxInt
(
self
->
n
);
}
}
Box
*
intFloat
(
BoxedInt
*
self
)
{
if
(
!
PyInt_Check
(
self
))
raiseExcHelper
(
TypeError
,
"descriptor '__float__' requires a 'int' object but received a '%s'"
,
getTypeName
(
self
));
return
boxFloat
(
self
->
n
);
}
extern
"C"
Box
*
intIndex
(
BoxedInt
*
v
)
{
extern
"C"
Box
*
intIndex
(
BoxedInt
*
v
)
{
if
(
PyInt_CheckExact
(
v
))
if
(
PyInt_CheckExact
(
v
))
return
v
;
return
v
;
...
@@ -1205,6 +1213,7 @@ void setupInt() {
...
@@ -1205,6 +1213,7 @@ void setupInt() {
int_cls
->
giveAttr
(
"__trunc__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
intTrunc
,
BOXED_INT
,
1
)));
int_cls
->
giveAttr
(
"__trunc__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
intTrunc
,
BOXED_INT
,
1
)));
int_cls
->
giveAttr
(
"__index__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
intIndex
,
BOXED_INT
,
1
)));
int_cls
->
giveAttr
(
"__index__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
intIndex
,
BOXED_INT
,
1
)));
int_cls
->
giveAttr
(
"__int__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
intInt
,
BOXED_INT
,
1
)));
int_cls
->
giveAttr
(
"__int__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
intInt
,
BOXED_INT
,
1
)));
int_cls
->
giveAttr
(
"__float__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
intFloat
,
BOXED_FLOAT
,
1
)));
auto
int_new
=
FunctionMetadata
::
create
((
void
*
)
intNew
<
CXX
>
,
UNKNOWN
,
3
,
false
,
false
,
auto
int_new
=
FunctionMetadata
::
create
((
void
*
)
intNew
<
CXX
>
,
UNKNOWN
,
3
,
false
,
false
,
ParamNames
({
""
,
"x"
,
"base"
},
""
,
""
),
CXX
);
ParamNames
({
""
,
"x"
,
"base"
},
""
,
""
),
CXX
);
...
...
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