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
b4d71529
Commit
b4d71529
authored
Jan 20, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set the frame-local ExcInfo from the ast interpreter
Seems like it kinda works
parent
a9fe6120
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
1 deletion
+26
-1
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+12
-0
src/core/ast.cpp
src/core/ast.cpp
+3
-0
src/core/ast.h
src/core/ast.h
+1
-0
src/core/cfg.cpp
src/core/cfg.cpp
+10
-1
No files found.
src/codegen/ast_interpreter.cpp
View file @
b4d71529
...
...
@@ -598,6 +598,18 @@ Value ASTInterpreter::visit_langPrimitive(AST_LangPrimitive* node) {
assert
(
node
->
args
.
size
()
==
1
);
Value
obj
=
visit_expr
(
node
->
args
[
0
]);
v
=
boxBool
(
nonzero
(
obj
.
o
));
}
else
if
(
node
->
opcode
==
AST_LangPrimitive
::
SET_EXC_INFO
)
{
assert
(
node
->
args
.
size
()
==
3
);
Value
type
=
visit_expr
(
node
->
args
[
0
]);
assert
(
type
.
o
);
Value
value
=
visit_expr
(
node
->
args
[
1
]);
assert
(
value
.
o
);
Value
traceback
=
visit_expr
(
node
->
args
[
2
]);
assert
(
traceback
.
o
);
getFrameInfo
()
->
exc
=
ExcInfo
(
type
.
o
,
value
.
o
,
traceback
.
o
);
v
=
None
;
}
else
RELEASE_ASSERT
(
0
,
"not implemented"
);
return
v
;
...
...
src/core/ast.cpp
View file @
b4d71529
...
...
@@ -1455,6 +1455,9 @@ bool PrintVisitor::visit_langprimitive(AST_LangPrimitive* node) {
case
AST_LangPrimitive
:
:
NONZERO
:
printf
(
"NONZERO"
);
break
;
case
AST_LangPrimitive
:
:
SET_EXC_INFO
:
printf
(
"SET_EXC_INFO"
);
break
;
default:
RELEASE_ASSERT
(
0
,
"%d"
,
node
->
opcode
);
}
...
...
src/core/ast.h
View file @
b4d71529
...
...
@@ -977,6 +977,7 @@ public:
IMPORT_STAR
,
NONE
,
NONZERO
,
SET_EXC_INFO
,
}
opcode
;
std
::
vector
<
AST_expr
*>
args
;
...
...
src/core/cfg.cpp
View file @
b4d71529
...
...
@@ -968,6 +968,8 @@ private:
rtn
=
remapIfExp
(
ast_cast
<
AST_IfExp
>
(
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
:
:
Lambda
:
...
...
@@ -1851,7 +1853,7 @@ public:
cfg
->
placeBlock
(
exc_handler_block
);
curblock
=
exc_handler_block
;
// TODO
: this should be an EXCEPTION_MATCHES(exc_type_name
)
// TODO
This is supposed to be exc_type_name (value doesn't matter for checking matches
)
AST_expr
*
exc_obj
=
makeName
(
exc_value_name
,
AST_TYPE
::
Load
,
node
->
lineno
);
bool
caught_all
=
false
;
...
...
@@ -1862,6 +1864,7 @@ public:
if
(
exc_handler
->
type
)
{
AST_expr
*
handled_type
=
remapExpr
(
exc_handler
->
type
);
// TODO: this should be an EXCEPTION_MATCHES(exc_type_name)
AST_LangPrimitive
*
is_caught_here
=
new
AST_LangPrimitive
(
AST_LangPrimitive
::
ISINSTANCE
);
is_caught_here
->
args
.
push_back
(
_dup
(
exc_obj
));
is_caught_here
->
args
.
push_back
(
handled_type
);
...
...
@@ -1883,6 +1886,12 @@ public:
caught_all
=
true
;
}
AST_LangPrimitive
*
set_exc_info
=
new
AST_LangPrimitive
(
AST_LangPrimitive
::
SET_EXC_INFO
);
set_exc_info
->
args
.
push_back
(
makeName
(
exc_type_name
,
AST_TYPE
::
Load
,
node
->
lineno
));
set_exc_info
->
args
.
push_back
(
makeName
(
exc_value_name
,
AST_TYPE
::
Load
,
node
->
lineno
));
set_exc_info
->
args
.
push_back
(
makeName
(
exc_traceback_name
,
AST_TYPE
::
Load
,
node
->
lineno
));
push_back
(
makeExpr
(
set_exc_info
));
if
(
exc_handler
->
name
)
{
pushAssign
(
exc_handler
->
name
,
_dup
(
exc_obj
));
}
...
...
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