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
47d6b1e6
Commit
47d6b1e6
authored
Aug 23, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make ScopingAnalysis a shared_ptr
parent
49502e91
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
20 deletions
+19
-20
src/codegen/codegen.cpp
src/codegen/codegen.cpp
+2
-1
src/codegen/irgen/hooks.cpp
src/codegen/irgen/hooks.cpp
+5
-6
src/core/cfg.cpp
src/core/cfg.cpp
+7
-9
src/core/types.h
src/core/types.h
+3
-2
test/unittests/analysis.cpp
test/unittests/analysis.cpp
+2
-2
No files found.
src/codegen/codegen.cpp
View file @
47d6b1e6
...
...
@@ -91,7 +91,8 @@ void FunctionMetadata::addVersion(CompiledFunction* compiled) {
}
}
SourceInfo
::
SourceInfo
(
BoxedModule
*
m
,
ScopingAnalysis
*
scoping
,
FutureFlags
future_flags
,
AST
*
ast
,
BoxedString
*
fn
)
SourceInfo
::
SourceInfo
(
BoxedModule
*
m
,
std
::
shared_ptr
<
ScopingAnalysis
>
scoping
,
FutureFlags
future_flags
,
AST
*
ast
,
BoxedString
*
fn
)
:
parent_module
(
m
),
scoping
(
scoping
),
scope_info
(
scoping
->
getScopeInfoForNode
(
ast
)),
...
...
src/codegen/irgen/hooks.cpp
View file @
47d6b1e6
...
...
@@ -369,11 +369,11 @@ void compileAndRunModule(AST_Module* m, BoxedModule* bm) {
RELEASE_ASSERT
(
fn
,
""
);
FutureFlags
future_flags
=
getFutureFlags
(
m
->
body
,
fn
);
ScopingAnalysis
*
scoping
=
new
ScopingAnalysis
(
m
,
true
);
std
::
shared_ptr
<
ScopingAnalysis
>
scoping
=
std
::
make_shared
<
ScopingAnalysis
>
(
m
,
true
);
auto
fn_str
=
boxString
(
fn
);
AUTO_DECREF
(
fn_str
);
std
::
unique_ptr
<
SourceInfo
>
si
(
new
SourceInfo
(
bm
,
s
coping
,
future_flags
,
m
,
fn_str
));
std
::
unique_ptr
<
SourceInfo
>
si
(
new
SourceInfo
(
bm
,
s
td
::
move
(
scoping
)
,
future_flags
,
m
,
fn_str
));
static
BoxedString
*
doc_str
=
getStaticString
(
"__doc__"
);
bm
->
setattr
(
doc_str
,
autoDecref
(
si
->
getDocString
()),
NULL
);
...
...
@@ -415,7 +415,7 @@ static FunctionMetadata* compileForEvalOrExec(AST* source, llvm::ArrayRef<AST_st
PyCompilerFlags
*
flags
)
{
Timer
_t
(
"for evalOrExec()"
);
ScopingAnalysis
*
scoping
=
new
ScopingAnalysis
(
source
,
false
);
auto
scoping
=
std
::
make_shared
<
ScopingAnalysis
>
(
source
,
false
);
// `my_future_flags` are the future flags enabled in the exec's code.
// `caller_future_flags` are the future flags of the source that the exec statement is in.
...
...
@@ -428,10 +428,9 @@ static FunctionMetadata* compileForEvalOrExec(AST* source, llvm::ArrayRef<AST_st
flags
->
cf_flags
=
future_flags
;
}
std
::
unique_ptr
<
SourceInfo
>
si
(
new
SourceInfo
(
getCurrentModule
(),
s
coping
,
future_flags
,
source
,
fn
));
std
::
unique_ptr
<
SourceInfo
>
si
(
new
SourceInfo
(
getCurrentModule
(),
s
td
::
move
(
scoping
)
,
future_flags
,
source
,
fn
));
FunctionMetadata
*
md
=
new
FunctionMetadata
(
0
,
false
,
false
,
std
::
move
(
si
));
return
md
;
return
new
FunctionMetadata
(
0
,
false
,
false
,
std
::
move
(
si
));
}
static
FunctionMetadata
*
compileExec
(
AST_Module
*
parsedModule
,
BoxedString
*
fn
,
PyCompilerFlags
*
flags
)
{
...
...
src/core/cfg.cpp
View file @
47d6b1e6
...
...
@@ -247,7 +247,7 @@ private:
FutureFlags
future_flags
;
CFG
*
cfg
;
CFGBlock
*
curblock
;
ScopingAnalysis
*
scoping_analysis
;
ScopingAnalysis
&
scoping_analysis
;
std
::
vector
<
ContInfo
>
continuations
;
std
::
vector
<
ExcBlockInfo
>
exc_handlers
;
...
...
@@ -257,7 +257,7 @@ private:
public:
CFGVisitor
(
SourceInfo
*
source
,
AST_TYPE
::
AST_TYPE
root_type
,
FutureFlags
future_flags
,
ScopingAnalysis
*
scoping_analysis
,
CFG
*
cfg
)
ScopingAnalysis
&
scoping_analysis
,
CFG
*
cfg
)
:
source
(
source
),
root_type
(
root_type
),
future_flags
(
future_flags
),
...
...
@@ -1039,7 +1039,7 @@ private:
func
->
args
=
new
AST_arguments
();
func
->
args
->
vararg
=
NULL
;
func
->
args
->
kwarg
=
NULL
;
scoping_analysis
->
registerScopeReplacement
(
node
,
func
);
// critical bit
scoping_analysis
.
registerScopeReplacement
(
node
,
func
);
// critical bit
return
new
AST_MakeFunction
(
func
);
}
...
...
@@ -1212,7 +1212,7 @@ private:
def
->
body
=
{
stmt
};
def
->
args
=
remapArguments
(
node
->
args
);
scoping_analysis
->
registerScopeReplacement
(
node
,
def
);
scoping_analysis
.
registerScopeReplacement
(
node
,
def
);
auto
tmp
=
nodeName
();
pushAssign
(
tmp
,
new
AST_MakeFunction
(
def
));
...
...
@@ -1651,7 +1651,7 @@ public:
for
(
auto
expr
:
node
->
bases
)
def
->
bases
.
push_back
(
remapExpr
(
expr
));
scoping_analysis
->
registerScopeReplacement
(
node
,
def
);
scoping_analysis
.
registerScopeReplacement
(
node
,
def
);
auto
tmp
=
nodeName
();
pushAssign
(
tmp
,
new
AST_MakeClass
(
def
));
...
...
@@ -1672,7 +1672,7 @@ public:
def
->
decorator_list
.
push_back
(
remapExpr
(
expr
));
def
->
args
=
remapArguments
(
node
->
args
);
scoping_analysis
->
registerScopeReplacement
(
node
,
def
);
scoping_analysis
.
registerScopeReplacement
(
node
,
def
);
auto
tmp
=
nodeName
();
pushAssign
(
tmp
,
new
AST_MakeFunction
(
def
));
...
...
@@ -2854,9 +2854,7 @@ CFG* computeCFG(SourceInfo* source, const ParamNames& param_names) {
CFG
*
rtn
=
new
CFG
();
ScopingAnalysis
*
scoping_analysis
=
source
->
scoping
;
CFGVisitor
visitor
(
source
,
source
->
ast
->
type
,
source
->
future_flags
,
scoping_analysis
,
rtn
);
CFGVisitor
visitor
(
source
,
source
->
ast
->
type
,
source
->
future_flags
,
*
source
->
scoping
,
rtn
);
bool
skip_first
=
false
;
...
...
src/core/types.h
View file @
47d6b1e6
...
...
@@ -442,7 +442,7 @@ private:
public:
BoxedModule
*
parent_module
;
ScopingAnalysis
*
scoping
;
std
::
shared_ptr
<
ScopingAnalysis
>
scoping
;
std
::
unique_ptr
<
ScopeInfo
>
scope_info
;
AST
*
ast
;
CFG
*
cfg
;
...
...
@@ -464,7 +464,8 @@ public:
Box
*
getDocString
();
SourceInfo
(
BoxedModule
*
m
,
ScopingAnalysis
*
scoping
,
FutureFlags
future_flags
,
AST
*
ast
,
BoxedString
*
fn
);
SourceInfo
(
BoxedModule
*
m
,
std
::
shared_ptr
<
ScopingAnalysis
>
scoping
,
FutureFlags
future_flags
,
AST
*
ast
,
BoxedString
*
fn
);
~
SourceInfo
();
};
...
...
test/unittests/analysis.cpp
View file @
47d6b1e6
...
...
@@ -31,7 +31,7 @@ TEST_F(AnalysisTest, augassign) {
AST_Module
*
module
=
caching_parse_file
(
fn
.
c_str
(),
0
);
assert
(
module
);
ScopingAnalysis
*
scoping
=
new
ScopingAnalysis
(
module
,
true
);
auto
scoping
=
std
::
make_shared
<
ScopingAnalysis
>
(
module
,
true
);
assert
(
module
->
body
[
0
]
->
type
==
AST_TYPE
::
FunctionDef
);
AST_FunctionDef
*
func
=
static_cast
<
AST_FunctionDef
*>
(
module
->
body
[
0
]);
...
...
@@ -65,7 +65,7 @@ void doOsrTest(bool is_osr, bool i_maybe_undefined) {
AST_Module
*
module
=
caching_parse_file
(
fn
.
c_str
(),
0
);
assert
(
module
);
ScopingAnalysis
*
scoping
=
new
ScopingAnalysis
(
module
,
true
);
auto
scoping
=
std
::
make_shared
<
ScopingAnalysis
>
(
module
,
true
);
assert
(
module
->
body
[
0
]
->
type
==
AST_TYPE
::
FunctionDef
);
AST_FunctionDef
*
func
=
static_cast
<
AST_FunctionDef
*>
(
module
->
body
[
0
]);
...
...
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