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
f1817d4f
Commit
f1817d4f
authored
Nov 11, 2014
by
Vinzenz Feenstra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implementation for parsing 'exec'
parent
4c7b796a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
0 deletions
+86
-0
src/codegen/parser.cpp
src/codegen/parser.cpp
+14
-0
src/codegen/pypa-parser.cpp
src/codegen/pypa-parser.cpp
+19
-0
src/core/ast.cpp
src/core/ast.cpp
+34
-0
src/core/ast.h
src/core/ast.h
+17
-0
src/core/cfg.cpp
src/core/cfg.cpp
+2
-0
No files found.
src/codegen/parser.cpp
View file @
f1817d4f
...
...
@@ -352,6 +352,18 @@ AST_ExceptHandler* read_excepthandler(BufferedReader* reader) {
return
rtn
;
}
AST_Exec
*
read_exec
(
BufferedReader
*
reader
)
{
AST_Exec
*
rtn
=
new
AST_Exec
();
rtn
->
expr
=
readASTExpr
(
reader
);
rtn
->
col_offset
=
readColOffset
(
reader
);
rtn
->
globals
=
readASTExpr
(
reader
);
rtn
->
lineno
=
reader
->
readULL
();
rtn
->
locals
=
readASTExpr
(
reader
);
return
rtn
;
}
AST_Expr
*
read_expr
(
BufferedReader
*
reader
)
{
AST_Expr
*
rtn
=
new
AST_Expr
();
...
...
@@ -813,6 +825,8 @@ AST_stmt* readASTStmt(BufferedReader* reader) {
return
read_continue
(
reader
);
case
AST_TYPE
:
:
Delete
:
return
read_delete
(
reader
);
case
AST_TYPE
:
:
Exec
:
return
read_exec
(
reader
);
case
AST_TYPE
:
:
Expr
:
return
read_expr
(
reader
);
case
AST_TYPE
:
:
For
:
...
...
src/codegen/pypa-parser.cpp
View file @
f1817d4f
...
...
@@ -440,6 +440,14 @@ struct expr_dispatcher {
return
ptr
;
}
ResultPtr
read
(
pypa
::
AstSetComp
&
l
)
{
AST_SetComp
*
ptr
=
new
AST_SetComp
();
location
(
ptr
,
l
);
readVector
(
ptr
->
generators
,
l
.
generators
);
ptr
->
elt
=
readItem
(
l
.
element
);
return
ptr
;
}
ResultPtr
read
(
pypa
::
AstName
&
a
)
{
AST_Name
*
ptr
=
new
AST_Name
();
location
(
ptr
,
a
);
...
...
@@ -613,6 +621,17 @@ struct stmt_dispatcher {
return
ptr
;
}
ResultPtr
read
(
pypa
::
AstExec
&
e
)
{
AST_Exec
*
ptr
=
new
AST_Exec
();
location
(
ptr
,
e
);
ptr
->
expr
=
readItem
(
e
.
body
);
if
(
e
.
globals
)
ptr
->
globals
=
readItem
(
e
.
globals
);
if
(
e
.
locals
)
ptr
->
locals
=
readItem
(
e
.
locals
);
return
ptr
;
}
ResultPtr
read
(
pypa
::
AstExpressionStatement
&
e
)
{
AST_Expr
*
ptr
=
new
AST_Expr
();
location
(
ptr
,
e
);
...
...
src/core/ast.cpp
View file @
f1817d4f
...
...
@@ -445,6 +445,19 @@ void AST_ExceptHandler::accept(ASTVisitor* v) {
visitVector
(
body
,
v
);
}
void
AST_Exec
::
accept
(
ASTVisitor
*
v
)
{
bool
skip
=
v
->
visit_exec
(
this
);
if
(
skip
)
return
;
if
(
expr
)
expr
->
accept
(
v
);
}
void
AST_Exec
::
accept_stmt
(
StmtVisitor
*
v
)
{
v
->
visit_exec
(
this
);
}
void
AST_Expr
::
accept
(
ASTVisitor
*
v
)
{
bool
skip
=
v
->
visit_expr
(
this
);
if
(
skip
)
...
...
@@ -1245,6 +1258,23 @@ bool PrintVisitor::visit_excepthandler(AST_ExceptHandler* node) {
return
true
;
}
bool
PrintVisitor
::
visit_exec
(
AST_Exec
*
node
)
{
printf
(
"exec "
);
node
->
expr
->
accept
(
this
);
if
(
node
->
globals
)
{
printf
(
" in "
);
node
->
globals
->
accept
(
this
);
if
(
node
->
locals
)
{
printf
(
", "
);
node
->
locals
->
accept
(
this
);
}
}
printf
(
"
\n
"
);
return
true
;
}
bool
PrintVisitor
::
visit_expr
(
AST_Expr
*
node
)
{
return
false
;
}
...
...
@@ -1853,6 +1883,10 @@ public:
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_exec
(
AST_Exec
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_expr
(
AST_Expr
*
node
)
{
output
->
push_back
(
node
);
return
false
;
...
...
src/core/ast.h
View file @
f1817d4f
...
...
@@ -435,6 +435,19 @@ public:
static
const
AST_TYPE
::
AST_TYPE
TYPE
=
AST_TYPE
::
ExceptHandler
;
};
class
AST_Exec
:
public
AST_stmt
{
public:
AST_expr
*
expr
;
AST_expr
*
globals
;
AST_expr
*
locals
;
virtual
void
accept
(
ASTVisitor
*
v
);
virtual
void
accept_stmt
(
StmtVisitor
*
v
);
AST_Exec
()
:
AST_stmt
(
AST_TYPE
::
Exec
)
{}
static
const
AST_TYPE
::
AST_TYPE
TYPE
=
AST_TYPE
::
Exec
;
};
class
AST_ExtSlice
:
public
AST_expr
{
public:
...
...
@@ -1007,6 +1020,7 @@ public:
virtual
bool
visit_dictcomp
(
AST_DictComp
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
bool
visit_ellipsis
(
AST_Ellipsis
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
bool
visit_excepthandler
(
AST_ExceptHandler
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
bool
visit_exec
(
AST_Exec
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
bool
visit_expr
(
AST_Expr
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
bool
visit_extslice
(
AST_ExtSlice
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
bool
visit_for
(
AST_For
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
...
...
@@ -1075,6 +1089,7 @@ public:
virtual
bool
visit_dictcomp
(
AST_DictComp
*
node
)
{
return
false
;
}
virtual
bool
visit_ellipsis
(
AST_Ellipsis
*
node
)
{
return
false
;
}
virtual
bool
visit_excepthandler
(
AST_ExceptHandler
*
node
)
{
return
false
;
}
virtual
bool
visit_exec
(
AST_Exec
*
node
)
{
return
false
;
}
virtual
bool
visit_expr
(
AST_Expr
*
node
)
{
return
false
;
}
virtual
bool
visit_extslice
(
AST_ExtSlice
*
node
)
{
return
false
;
}
virtual
bool
visit_for
(
AST_For
*
node
)
{
return
false
;
}
...
...
@@ -1164,6 +1179,7 @@ public:
virtual
void
visit_classdef
(
AST_ClassDef
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
void
visit_delete
(
AST_Delete
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
void
visit_continue
(
AST_Continue
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
void
visit_exec
(
AST_Exec
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
void
visit_expr
(
AST_Expr
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
void
visit_for
(
AST_For
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
void
visit_functiondef
(
AST_FunctionDef
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
...
...
@@ -1217,6 +1233,7 @@ public:
virtual
bool
visit_dictcomp
(
AST_DictComp
*
node
);
virtual
bool
visit_ellipsis
(
AST_Ellipsis
*
node
);
virtual
bool
visit_excepthandler
(
AST_ExceptHandler
*
node
);
virtual
bool
visit_exec
(
AST_Exec
*
node
);
virtual
bool
visit_expr
(
AST_Expr
*
node
);
virtual
bool
visit_extslice
(
AST_ExtSlice
*
node
);
virtual
bool
visit_for
(
AST_For
*
node
);
...
...
src/core/cfg.cpp
View file @
f1817d4f
...
...
@@ -1568,6 +1568,8 @@ public:
return
true
;
}
bool
visit_exec
(
AST_Exec
*
node
)
override
{
raiseExcHelper
(
SyntaxError
,
"'exec' currently not supported"
);
}
bool
visit_while
(
AST_While
*
node
)
override
{
if
(
!
curblock
)
return
true
;
...
...
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