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
440a3d62
Commit
440a3d62
authored
Aug 25, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit 'pr/861' into class_gc
parents
440d8927
60131ac6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
6 deletions
+55
-6
from_cpython/Python/dtoa.c
from_cpython/Python/dtoa.c
+3
-0
src/analysis/type_analysis.cpp
src/analysis/type_analysis.cpp
+12
-4
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+29
-2
test/tests/float.py
test/tests/float.py
+3
-0
test/tests/str_functions.py
test/tests/str_functions.py
+8
-0
No files found.
from_cpython/Python/dtoa.c
View file @
440a3d62
...
...
@@ -118,6 +118,9 @@
#include "Python.h"
// Pyston change: disable custom memory managment because it confuses our GC
#define Py_USING_MEMORY_DEBUGGER 1
/* if PY_NO_SHORT_FLOAT_REPR is defined, then don't even try to compile
the following code */
#ifndef PY_NO_SHORT_FLOAT_REPR
...
...
src/analysis/type_analysis.cpp
View file @
440a3d62
...
...
@@ -222,7 +222,7 @@ private:
return
rtn
;
}
bool
hasFixed
Bino
ps
(
CompilerType
*
type
)
{
bool
hasFixed
O
ps
(
CompilerType
*
type
)
{
// This is non-exhaustive:
return
type
==
STR
||
type
==
INT
||
type
==
FLOAT
||
type
==
LIST
||
type
==
DICT
;
}
...
...
@@ -230,7 +230,7 @@ private:
void
*
visit_augbinop
(
AST_AugBinOp
*
node
)
override
{
CompilerType
*
left
=
getType
(
node
->
left
);
CompilerType
*
right
=
getType
(
node
->
right
);
if
(
!
hasFixed
Binops
(
left
)
||
!
hasFixedBino
ps
(
right
))
if
(
!
hasFixed
Ops
(
left
)
||
!
hasFixedO
ps
(
right
))
return
UNKNOWN
;
// TODO this isn't the exact behavior
...
...
@@ -259,7 +259,7 @@ private:
void
*
visit_binop
(
AST_BinOp
*
node
)
override
{
CompilerType
*
left
=
getType
(
node
->
left
);
CompilerType
*
right
=
getType
(
node
->
right
);
if
(
!
hasFixed
Binops
(
left
)
||
!
hasFixedBino
ps
(
right
))
if
(
!
hasFixed
Ops
(
left
)
||
!
hasFixedO
ps
(
right
))
return
UNKNOWN
;
// TODO this isn't the exact behavior
...
...
@@ -505,12 +505,20 @@ private:
void
*
visit_unaryop
(
AST_UnaryOp
*
node
)
override
{
CompilerType
*
operand
=
getType
(
node
->
operand
);
if
(
!
hasFixedOps
(
operand
))
return
UNKNOWN
;
// TODO this isn't the exact behavior
BoxedString
*
name
=
getOpName
(
node
->
op_type
);
CompilerType
*
attr_type
=
operand
->
getattrType
(
name
,
true
);
if
(
attr_type
==
UNDEF
)
attr_type
=
UNKNOWN
;
std
::
vector
<
CompilerType
*>
arg_types
;
return
attr_type
->
callType
(
ArgPassSpec
(
0
),
arg_types
,
NULL
);
CompilerType
*
rtn_type
=
attr_type
->
callType
(
ArgPassSpec
(
0
),
arg_types
,
NULL
);
rtn_type
=
unboxedType
(
rtn_type
->
getConcreteType
());
return
rtn_type
;
}
void
*
visit_yield
(
AST_Yield
*
)
override
{
return
UNKNOWN
;
}
...
...
src/codegen/compvars.cpp
View file @
440a3d62
...
...
@@ -824,7 +824,9 @@ public:
struct
Sig
{
std
::
vector
<
ConcreteCompilerType
*>
arg_types
;
CompilerType
*
rtn_type
;
int
ndefaults
;
int
ndefaults
=
0
;
bool
takes_varargs
=
false
;
bool
takes_kwargs
=
false
;
};
private:
...
...
@@ -847,14 +849,20 @@ public:
RELEASE_ASSERT
(
!
argspec
.
has_starargs
,
""
);
RELEASE_ASSERT
(
!
argspec
.
has_kwargs
,
""
);
RELEASE_ASSERT
(
argspec
.
num_keywords
==
0
,
""
);
RELEASE_ASSERT
(
!
keyword_names
||
keyword_names
->
empty
()
==
0
,
""
);
for
(
int
i
=
0
;
i
<
sigs
.
size
();
i
++
)
{
Sig
*
sig
=
sigs
[
i
];
if
(
arg_types
.
size
()
<
sig
->
arg_types
.
size
()
-
sig
->
ndefaults
||
arg_types
.
size
()
>
sig
->
arg_types
.
size
())
int
num_normal_args
=
sig
->
arg_types
.
size
()
-
((
sig
->
takes_varargs
?
1
:
0
)
+
(
sig
->
takes_kwargs
?
1
:
0
));
if
(
arg_types
.
size
()
<
num_normal_args
-
sig
->
ndefaults
)
continue
;
if
(
!
sig
->
takes_varargs
&&
arg_types
.
size
()
>
sig
->
arg_types
.
size
())
continue
;
bool
works
=
true
;
for
(
int
j
=
0
;
j
<
arg_types
.
size
();
j
++
)
{
if
(
j
==
num_normal_args
)
break
;
if
(
!
arg_types
[
j
]
->
canConvertTo
(
sig
->
arg_types
[
j
]))
{
works
=
false
;
break
;
...
...
@@ -883,6 +891,8 @@ public:
Sig
*
type_sig
=
new
Sig
();
type_sig
->
rtn_type
=
fspec
->
rtn_type
;
type_sig
->
ndefaults
=
clf
->
paramspec
.
num_defaults
;
type_sig
->
takes_varargs
=
clf
->
paramspec
.
takes_varargs
;
type_sig
->
takes_kwargs
=
clf
->
paramspec
.
takes_kwargs
;
if
(
stripfirst
)
{
assert
(
fspec
->
arg_types
.
size
()
>=
1
);
...
...
@@ -1294,6 +1304,14 @@ public:
return
boolFromI1
(
emitter
,
cmp
);
}
ConcreteCompilerVariable
*
unaryop
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
AST_TYPE
::
AST_TYPE
op_type
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
auto
rtn
=
converted
->
unaryop
(
emitter
,
info
,
op_type
);
converted
->
decvref
(
emitter
);
return
rtn
;
}
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
...
...
@@ -1885,6 +1903,15 @@ public:
ConcreteCompilerVariable
*
unaryop
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
AST_TYPE
::
AST_TYPE
op_type
)
override
{
BoxedString
*
attr
=
getOpName
(
op_type
);
bool
no_attribute
=
false
;
ConcreteCompilerVariable
*
called_constant
=
tryCallattrConstant
(
emitter
,
info
,
var
,
attr
,
true
,
ArgPassSpec
(
0
,
0
,
0
,
0
),
{},
NULL
,
&
no_attribute
);
if
(
called_constant
&&
!
no_attribute
)
return
called_constant
;
return
UNKNOWN
->
unaryop
(
emitter
,
info
,
var
,
op_type
);
}
...
...
test/tests/float.py
View file @
440a3d62
...
...
@@ -108,3 +108,6 @@ for lhs in all_args:
import
sys
print
sys
.
float_info
if
1
:
x
=
-
2.0
test/tests/str_functions.py
View file @
440a3d62
...
...
@@ -173,3 +173,11 @@ class C(object):
def
__str__
(
self
):
return
"my class"
print
"{0}"
.
format
(
C
())
def
irgen_error
():
for
i
in
range
(
1
):
fail
=
"test"
.
format
()
print
fail
fail
=
"test {0} {1} {2}"
.
format
(
1
,
2
,
3
)
print
fail
irgen_error
()
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