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
eb8815b4
Commit
eb8815b4
authored
Jun 11, 2016
by
Marius Wachtler
Committed by
GitHub
Jun 11, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1245 from c-rhodes/1097
Improve REPL support
parents
74ee55c8
24a5b0c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
18 deletions
+12
-18
src/codegen/cpython_ast.cpp
src/codegen/cpython_ast.cpp
+12
-1
src/core/ast.cpp
src/core/ast.cpp
+0
-13
src/core/ast.h
src/core/ast.h
+0
-4
No files found.
src/codegen/cpython_ast.cpp
View file @
eb8815b4
...
...
@@ -61,6 +61,8 @@ private:
InternedStringPool
*
pool
=
NULL
;
int
loop_depth
=
0
;
int
in_finally
=
0
;
int
interactive
=
0
;
int
nestlevel
=
0
;
llvm
::
StringRef
fn
;
public:
...
...
@@ -511,7 +513,9 @@ public:
auto
v
=
stmt
->
v
.
FunctionDef
;
r
->
name
=
convert
(
v
.
name
);
r
->
args
=
convert
(
v
.
args
,
r
);
nestlevel
++
;
r
->
body
=
convert
<
stmt_ty
,
AST_stmt
*>
(
v
.
body
);
nestlevel
--
;
r
->
decorator_list
=
convert
<
expr_ty
,
AST_expr
*>
(
v
.
decorator_list
);
return
r
;
}
...
...
@@ -520,7 +524,9 @@ public:
auto
v
=
stmt
->
v
.
ClassDef
;
r
->
name
=
convert
(
v
.
name
);
r
->
bases
=
convert
<
expr_ty
,
AST_expr
*>
(
v
.
bases
);
nestlevel
++
;
r
->
body
=
convert
<
stmt_ty
,
AST_stmt
*>
(
v
.
body
);
nestlevel
--
;
r
->
decorator_list
=
convert
<
expr_ty
,
AST_expr
*>
(
v
.
decorator_list
);
return
r
;
}
...
...
@@ -666,6 +672,11 @@ public:
auto
r
=
new
AST_Expr
();
auto
v
=
stmt
->
v
.
Expr
;
r
->
value
=
convert
(
v
.
value
);
if
(
interactive
&&
nestlevel
<=
0
)
{
auto
print_expr
=
new
AST_LangPrimitive
(
AST_LangPrimitive
::
PRINT_EXPR
);
print_expr
->
args
.
push_back
(
r
->
value
);
r
->
value
=
print_expr
;
}
return
r
;
}
case
Pass_kind
:
...
...
@@ -704,11 +715,11 @@ public:
return
rtn
;
}
case
Interactive_kind
:
{
this
->
interactive
=
1
;
AST_Module
*
rtn
=
new
AST_Module
(
llvm
::
make_unique
<
InternedStringPool
>
());
assert
(
!
this
->
pool
);
this
->
pool
=
rtn
->
interned_strings
.
get
();
convertAll
<
stmt_ty
>
(
mod
->
v
.
Interactive
.
body
,
rtn
->
body
);
makeModuleInteractive
(
rtn
);
return
rtn
;
}
case
Expression_kind
:
{
...
...
src/core/ast.cpp
View file @
eb8815b4
...
...
@@ -2236,17 +2236,4 @@ void flatten(AST_expr* root, std::vector<AST*>& output, bool expand_scopes) {
root
->
accept
(
&
visitor
);
}
void
makeModuleInteractive
(
AST_Module
*
m
)
{
for
(
int
i
=
0
;
i
<
m
->
body
.
size
();
++
i
)
{
AST_stmt
*
s
=
m
->
body
[
i
];
if
(
s
->
type
!=
AST_TYPE
::
Expr
)
continue
;
AST_Expr
*
expr
=
(
AST_Expr
*
)
s
;
AST_LangPrimitive
*
print_expr
=
new
AST_LangPrimitive
(
AST_LangPrimitive
::
PRINT_EXPR
);
print_expr
->
args
.
push_back
(
expr
->
value
);
expr
->
value
=
print_expr
;
}
}
}
src/core/ast.h
View file @
eb8815b4
...
...
@@ -1444,10 +1444,6 @@ template <class T, class R> void findNodes(const R& roots, std::vector<T*>& outp
}
}
// Take a normally-parsed module, and convert it (inplace) to a form that will print out any bare expressions.
// This is used for "single" mode or the repl.
void
makeModuleInteractive
(
AST_Module
*
m
);
llvm
::
StringRef
getOpSymbol
(
int
op_type
);
BORROWED
(
BoxedString
*
)
getOpName
(
int
op_type
);
int
getReverseCmpOp
(
int
op_type
,
bool
&
success
);
...
...
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