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
688a6117
Commit
688a6117
authored
Apr 27, 2015
by
Travis Hance
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use future flags constants from cpython
parent
7cce54f1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
18 deletions
+18
-18
from_cpython/Include/Python.h
from_cpython/Include/Python.h
+2
-0
src/codegen/irgen/future.cpp
src/codegen/irgen/future.cpp
+11
-7
src/codegen/irgen/future.h
src/codegen/irgen/future.h
+0
-8
src/core/cfg.cpp
src/core/cfg.cpp
+5
-3
No files found.
from_cpython/Include/Python.h
View file @
688a6117
...
...
@@ -111,6 +111,8 @@
#include "pyfpe.h"
#include "code.h"
#define Py_single_input 256
#define Py_file_input 257
#define Py_eval_input 258
...
...
src/codegen/irgen/future.cpp
View file @
688a6117
...
...
@@ -16,6 +16,8 @@
#include <map>
#include "Python.h"
#include "core/ast.h"
namespace
pyston
{
...
...
@@ -27,13 +29,15 @@ struct FutureOption {
};
const
std
::
map
<
std
::
string
,
FutureOption
>
future_options
=
{
{
"absolute_import"
,
{
version_hex
(
2
,
5
,
0
),
version_hex
(
3
,
0
,
0
),
FF_ABSOLUTE_IMPORT
}
},
{
"division"
,
{
version_hex
(
2
,
2
,
0
),
version_hex
(
3
,
0
,
0
),
FF_DIVISION
}
},
{
"generators"
,
{
version_hex
(
2
,
2
,
0
),
version_hex
(
3
,
0
,
0
),
FF_GENERATOR
}
},
{
"unicode_literals"
,
{
version_hex
(
2
,
6
,
0
),
version_hex
(
3
,
0
,
0
),
FF_UNICODE_LITERALS
}
},
{
"print_function"
,
{
version_hex
(
2
,
6
,
0
),
version_hex
(
3
,
0
,
0
),
FF_PRINT_FUNCTION
}
},
{
"nested_scopes"
,
{
version_hex
(
2
,
1
,
0
),
version_hex
(
2
,
2
,
0
),
FF_NESTED_SCOPES
}
},
{
"with_statement"
,
{
version_hex
(
2
,
5
,
0
),
version_hex
(
3
,
6
,
0
),
FF_WITH_STATEMENT
}
}
};
=
{
{
"absolute_import"
,
{
version_hex
(
2
,
5
,
0
),
version_hex
(
3
,
0
,
0
),
CO_FUTURE_ABSOLUTE_IMPORT
}
},
{
"division"
,
{
version_hex
(
2
,
2
,
0
),
version_hex
(
3
,
0
,
0
),
CO_FUTURE_DIVISION
}
},
{
"unicode_literals"
,
{
version_hex
(
2
,
6
,
0
),
version_hex
(
3
,
0
,
0
),
CO_FUTURE_UNICODE_LITERALS
}
},
{
"print_function"
,
{
version_hex
(
2
,
6
,
0
),
version_hex
(
3
,
0
,
0
),
CO_FUTURE_PRINT_FUNCTION
}
},
{
"with_statement"
,
{
version_hex
(
2
,
5
,
0
),
version_hex
(
3
,
6
,
0
),
CO_FUTURE_WITH_STATEMENT
}
},
// These are mandatory in all versions we care about (>= 2.3)
{
"generators"
,
{
version_hex
(
2
,
2
,
0
),
version_hex
(
3
,
0
,
0
),
CO_GENERATOR
}
},
{
"nested_scopes"
,
{
version_hex
(
2
,
1
,
0
),
version_hex
(
2
,
2
,
0
),
CO_NESTED
}
}
};
void
raiseFutureImportErrorNotFound
(
const
char
*
file
,
AST
*
node
,
const
char
*
name
)
{
raiseSyntaxErrorHelper
(
file
,
""
,
node
,
"future feature %s is not defined"
,
name
);
...
...
src/codegen/irgen/future.h
View file @
688a6117
...
...
@@ -21,14 +21,6 @@
namespace
pyston
{
#define FF_ABSOLUTE_IMPORT 0x01
#define FF_DIVISION 0x02
#define FF_GENERATOR 0x04
#define FF_UNICODE_LITERALS 0x08
#define FF_PRINT_FUNCTION 0x10
#define FF_NESTED_SCOPES 0x20
#define FF_WITH_STATEMENT 0x40
// Loop through import statements to find __future__ imports throwing errors for
// bad __future__ imports. Returns the futures that are turned on. This is used
// for irgeneration; the parser still has to handle some futures on its own,
...
...
src/core/cfg.cpp
View file @
688a6117
...
...
@@ -19,6 +19,8 @@
#include <cstdio>
#include <cstdlib>
#include "Python.h"
#include "analysis/scoping_analysis.h"
#include "core/ast.h"
#include "core/options.h"
...
...
@@ -1481,7 +1483,7 @@ public:
// level == -1 means check both sys path and relative for imports.
// so if `from __future__ import absolute_import` was used in the file, set level to 0
int
level
;
if
(
!
(
future_flags
&
FF
_ABSOLUTE_IMPORT
))
if
(
!
(
future_flags
&
CO_FUTURE
_ABSOLUTE_IMPORT
))
level
=
-
1
;
else
level
=
0
;
...
...
@@ -1532,7 +1534,7 @@ public:
// level == -1 means check both sys path and relative for imports.
// so if `from __future__ import absolute_import` was used in the file, set level to 0
int
level
;
if
(
node
->
level
==
0
&&
!
(
future_flags
&
FF
_ABSOLUTE_IMPORT
))
if
(
node
->
level
==
0
&&
!
(
future_flags
&
CO_FUTURE
_ABSOLUTE_IMPORT
))
level
=
-
1
;
else
level
=
node
->
level
;
...
...
@@ -1729,7 +1731,7 @@ public:
}
AST_TYPE
::
AST_TYPE
remapBinOpType
(
AST_TYPE
::
AST_TYPE
op_type
)
{
if
(
op_type
==
AST_TYPE
::
Div
&&
(
future_flags
&
(
FF
_DIVISION
)))
{
if
(
op_type
==
AST_TYPE
::
Div
&&
(
future_flags
&
(
CO_FUTURE
_DIVISION
)))
{
return
AST_TYPE
::
TrueDiv
;
}
else
{
return
op_type
;
...
...
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