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
3b413f50
Commit
3b413f50
authored
Sep 06, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up some dead code from the cfg changes
And make BST_arguments a bit safer by removing misleading fields.
parent
763cc656
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
90 deletions
+6
-90
src/analysis/function_analysis.cpp
src/analysis/function_analysis.cpp
+1
-10
src/core/bst.cpp
src/core/bst.cpp
+3
-12
src/core/bst.h
src/core/bst.h
+1
-3
src/core/cfg.cpp
src/core/cfg.cpp
+1
-65
No files found.
src/analysis/function_analysis.cpp
View file @
3b413f50
...
...
@@ -340,16 +340,7 @@ public:
return
true
;
}
virtual
bool
visit_arguments
(
BST_arguments
*
node
)
{
if
(
node
->
kwarg
)
_doSet
(
node
->
kwarg
);
if
(
node
->
vararg
)
_doSet
(
node
->
vararg
);
for
(
int
i
=
0
;
i
<
node
->
args
.
size
();
i
++
)
{
_doSet
(
node
->
args
[
i
]);
}
return
true
;
}
virtual
bool
visit_arguments
(
BST_arguments
*
node
)
{
RELEASE_ASSERT
(
0
,
"this shouldn't get hit"
);
}
virtual
bool
visit_exec
(
BST_Exec
*
node
)
{
return
true
;
}
...
...
src/core/bst.cpp
View file @
3b413f50
...
...
@@ -61,11 +61,6 @@ void BST_arguments::accept(BSTVisitor* v) {
return
;
visitVector
(
defaults
,
v
);
visitVector
(
args
,
v
);
if
(
kwarg
)
kwarg
->
accept
(
v
);
if
(
vararg
)
vararg
->
accept
(
v
);
}
void
BST_Assert
::
accept
(
BSTVisitor
*
v
)
{
...
...
@@ -883,17 +878,13 @@ bool PrintVisitor::visit_alias(BST_alias* node) {
}
bool
PrintVisitor
::
visit_arguments
(
BST_arguments
*
node
)
{
int
nargs
=
node
->
args
.
size
();
int
ndefault
=
node
->
defaults
.
size
();
for
(
int
i
=
0
;
i
<
n
args
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n
default
;
i
++
)
{
if
(
i
>
0
)
stream
<<
", "
;
node
->
args
[
i
]
->
accept
(
this
);
if
(
i
>=
nargs
-
ndefault
)
{
stream
<<
"="
;
node
->
defaults
[
i
-
(
nargs
-
ndefault
)]
->
accept
(
this
);
}
stream
<<
"<default "
<<
i
<<
">="
;
node
->
defaults
[
i
]
->
accept
(
this
);
}
return
true
;
}
...
...
src/core/bst.h
View file @
3b413f50
...
...
@@ -232,9 +232,7 @@ class BST_Name;
class
BST_arguments
:
public
BST
{
public:
// no lineno, col_offset attributes
std
::
vector
<
BST_expr
*>
args
,
defaults
;
BST_Name
*
kwarg
=
NULL
,
*
vararg
=
NULL
;
std
::
vector
<
BST_expr
*>
defaults
;
virtual
void
accept
(
BSTVisitor
*
v
);
...
...
src/core/cfg.cpp
View file @
3b413f50
...
...
@@ -150,42 +150,6 @@ static int getLastLineno(llvm::ArrayRef<AST_stmt*> body, int default_lineno) {
return
default_lineno
;
return
getLastLinenoSub
(
body
.
back
());
}
#if 0
int getLastLineno(AST* ast) {
switch (ast->type) {
case AST_TYPE::Lambda: {
auto lambda = ast_cast<AST_Lambda>(ast);
return getLastLinenoSub(lambda->body);
}
case AST_TYPE::Expression: {
auto expr = ast_cast<AST_Expression>(ast);
return getLastLinenoSub(expr->body);
}
case AST_TYPE::ClassDef: {
auto classdef = ast_cast<AST_ClassDef>(ast);
if (classdef->body.size() == 0)
return classdef->lineno;
return getLastLinenoSub(classdef->body.back());
}
case AST_TYPE::Module: {
auto module = ast_cast<AST_Module>(ast);
if (module->body.size() == 0) {
assert(module->lineno == 0);
return 1;
}
return getLastLinenoSub(module->body.back());
}
case AST_TYPE::FunctionDef: {
auto funcdef = ast_cast<AST_FunctionDef>(ast);
if (funcdef->body.size() == 0)
return funcdef->lineno;
return getLastLinenoSub(funcdef->body.back());
}
default:
RELEASE_ASSERT(0, "%d", ast->type);
}
}
#endif
void
CFGBlock
::
connectTo
(
CFGBlock
*
successor
,
bool
allow_backedge
)
{
assert
(
successors
.
size
()
<=
1
);
...
...
@@ -846,7 +810,6 @@ private:
return
subscript
;
}
// void pushAssign(BST_expr* target, BST_expr* val);
// We need this both on asts (ex assigning to the element name in a for loop), and
// for bsts (desugaring an augassign)
// TODO: we should get rid of this bst one, or at least not call it the same thing?
...
...
@@ -1259,25 +1222,6 @@ private:
return
rtn
;
}
// This is a helper function used for generators expressions and comprehensions.
//
// Generates a FunctionDef which produces scope for `node'. The function produced is empty, so you'd better fill it.
// `node' had better be a kind of node that scoping_analysis thinks can carry scope (see the switch (node->type)
// block in ScopingAnalysis::processNameUsages in analysis/scoping_analysis.cpp); e.g. a Lambda or GeneratorExp.
AST_MakeFunction
*
makeFunctionForScope
(
AST
*
node
)
{
AST_FunctionDef
*
func
=
new
AST_FunctionDef
();
func
->
lineno
=
node
->
lineno
;
func
->
col_offset
=
node
->
col_offset
;
// TODO this should be set off the type of the comprehension (ie <setcomp> or <dictcomp> or <genexpr>)
InternedString
func_name
=
internString
(
"<comprehension>"
);
func
->
name
=
func_name
;
func
->
args
=
new
AST_arguments
();
func
->
args
->
vararg
=
NULL
;
func
->
args
->
kwarg
=
NULL
;
RELEASE_ASSERT
(
0
,
"should this just be the bare functiondef?"
);
return
new
AST_MakeFunction
(
func
);
}
// This is a helper function used for generator expressions and comprehensions.
// TODO(rntz): use this to handle unscoped (i.e. list) comprehensions as well?
void
emitComprehensionLoops
(
int
lineno
,
std
::
vector
<
AST_stmt
*>*
insert_point
,
...
...
@@ -1308,7 +1252,7 @@ private:
}
do_yield
(
insert_point
);
//
RELEASE_ASSERT(0, "have to delete these new ast nodes");
//
TODO: have to delete these new ast nodes
}
BST_expr
*
remapGeneratorExp
(
AST_GeneratorExp
*
node
)
{
...
...
@@ -1449,12 +1393,7 @@ private:
}
BST_arguments
*
remapArguments
(
AST_arguments
*
args
)
{
// TODO: once in BST we don't need the arguments struct except for evaluating defaults.
auto
rtn
=
new
BST_arguments
();
// for (auto a : args->args)
// rtn->args.push_back(remapExpr(a));
// rtn->kwarg = remapName(args->kwarg);
// rtn->vararg = remapName(args->vararg);
for
(
auto
expr
:
args
->
defaults
)
rtn
->
defaults
.
push_back
(
remapExpr
(
expr
));
return
rtn
;
...
...
@@ -1470,7 +1409,6 @@ private:
auto
bdef
=
new
BST_FunctionDef
();
bdef
->
lineno
=
node
->
lineno
;
bdef
->
col_offset
=
node
->
col_offset
;
// bdef->name = name;
bdef
->
args
=
remapArguments
(
node
->
args
);
...
...
@@ -1605,8 +1543,6 @@ private:
rtn
=
remapExtSlice
(
ast_cast
<
AST_ExtSlice
>
(
node
));
break
;
case
AST_TYPE
:
:
Index
:
// if (ast_cast<AST_Index>(node)->value->type == AST_TYPE::Num)
// return node;
rtn
=
remapIndex
(
ast_cast
<
AST_Index
>
(
node
));
break
;
case
AST_TYPE
:
:
Slice
:
...
...
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