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
52fe1669
Commit
52fe1669
authored
Mar 27, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get some basic eval() cases working
parent
66200ef5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
14 deletions
+11
-14
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+4
-5
src/codegen/irgen/hooks.cpp
src/codegen/irgen/hooks.cpp
+5
-7
src/codegen/unwinding.cpp
src/codegen/unwinding.cpp
+1
-1
src/codegen/unwinding.h
src/codegen/unwinding.h
+1
-1
No files found.
src/codegen/ast_interpreter.cpp
View file @
52fe1669
...
@@ -153,8 +153,6 @@ private:
...
@@ -153,8 +153,6 @@ private:
public:
public:
~
ASTInterpreter
()
{
~
ASTInterpreter
()
{
Py_XDECREF
(
frame_info
.
boxedLocals
);
Py_DECREF
(
frame_info
.
globals
);
Py_XDECREF
(
this
->
created_closure
);
Py_XDECREF
(
this
->
created_closure
);
}
}
...
@@ -186,7 +184,7 @@ public:
...
@@ -186,7 +184,7 @@ public:
void
setGenerator
(
Box
*
gen
);
void
setGenerator
(
Box
*
gen
);
void
setPassedClosure
(
Box
*
closure
);
void
setPassedClosure
(
Box
*
closure
);
void
setCreatedClosure
(
Box
*
closure
);
void
setCreatedClosure
(
Box
*
closure
);
void
setBoxedLocals
(
Box
*
);
void
setBoxedLocals
(
STOLEN
(
Box
*
)
);
void
setFrameInfo
(
const
FrameInfo
*
frame_info
);
void
setFrameInfo
(
const
FrameInfo
*
frame_info
);
void
setGlobals
(
Box
*
globals
);
void
setGlobals
(
Box
*
globals
);
...
@@ -219,6 +217,7 @@ void ASTInterpreter::setCreatedClosure(Box* closure) {
...
@@ -219,6 +217,7 @@ void ASTInterpreter::setCreatedClosure(Box* closure) {
}
}
void
ASTInterpreter
::
setBoxedLocals
(
Box
*
boxedLocals
)
{
void
ASTInterpreter
::
setBoxedLocals
(
Box
*
boxedLocals
)
{
assert
(
!
this
->
frame_info
.
boxedLocals
);
this
->
frame_info
.
boxedLocals
=
boxedLocals
;
this
->
frame_info
.
boxedLocals
=
boxedLocals
;
}
}
...
@@ -230,7 +229,7 @@ void ASTInterpreter::setFrameInfo(const FrameInfo* frame_info) {
...
@@ -230,7 +229,7 @@ void ASTInterpreter::setFrameInfo(const FrameInfo* frame_info) {
void
ASTInterpreter
::
setGlobals
(
Box
*
globals
)
{
void
ASTInterpreter
::
setGlobals
(
Box
*
globals
)
{
assert
(
!
this
->
frame_info
.
globals
);
assert
(
!
this
->
frame_info
.
globals
);
this
->
frame_info
.
globals
=
incref
(
globals
)
;
this
->
frame_info
.
globals
=
globals
;
}
}
ASTInterpreter
::
ASTInterpreter
(
FunctionMetadata
*
md
,
Box
**
vregs
,
int
num_vregs
)
ASTInterpreter
::
ASTInterpreter
(
FunctionMetadata
*
md
,
Box
**
vregs
,
int
num_vregs
)
...
@@ -1951,7 +1950,7 @@ Box* astInterpretFunctionEval(FunctionMetadata* md, Box* globals, Box* boxedLoca
...
@@ -1951,7 +1950,7 @@ Box* astInterpretFunctionEval(FunctionMetadata* md, Box* globals, Box* boxedLoca
ASTInterpreter
interpreter
(
md
,
vregs
,
num_vregs
);
ASTInterpreter
interpreter
(
md
,
vregs
,
num_vregs
);
interpreter
.
initArguments
(
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
interpreter
.
initArguments
(
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
interpreter
.
setBoxedLocals
(
boxedLocals
);
interpreter
.
setBoxedLocals
(
incref
(
boxedLocals
)
);
assert
(
!
md
->
source
->
scoping
->
areGlobalsFromModule
());
assert
(
!
md
->
source
->
scoping
->
areGlobalsFromModule
());
assert
(
globals
);
assert
(
globals
);
...
...
src/codegen/irgen/hooks.cpp
View file @
52fe1669
...
@@ -356,6 +356,8 @@ Box* evalOrExec(FunctionMetadata* md, Box* globals, Box* boxedLocals) {
...
@@ -356,6 +356,8 @@ Box* evalOrExec(FunctionMetadata* md, Box* globals, Box* boxedLocals) {
if
(
doc_string
!=
None
)
{
if
(
doc_string
!=
None
)
{
static
BoxedString
*
doc_box
=
getStaticString
(
"__doc__"
);
static
BoxedString
*
doc_box
=
getStaticString
(
"__doc__"
);
setGlobal
(
boxedLocals
,
doc_box
,
doc_string
);
setGlobal
(
boxedLocals
,
doc_box
,
doc_string
);
}
else
{
Py_DECREF
(
doc_string
);
}
}
return
astInterpretFunctionEval
(
md
,
globals
,
boxedLocals
);
return
astInterpretFunctionEval
(
md
,
globals
,
boxedLocals
);
...
@@ -413,13 +415,13 @@ extern "C" PyCodeObject* PyAST_Compile(struct _mod* _mod, const char* filename,
...
@@ -413,13 +415,13 @@ extern "C" PyCodeObject* PyAST_Compile(struct _mod* _mod, const char* filename,
if
(
parsed
->
type
!=
AST_TYPE
::
Module
)
{
if
(
parsed
->
type
!=
AST_TYPE
::
Module
)
{
raiseExcHelper
(
TypeError
,
"expected Module node, got %s"
,
AST_TYPE
::
stringify
(
parsed
->
type
));
raiseExcHelper
(
TypeError
,
"expected Module node, got %s"
,
AST_TYPE
::
stringify
(
parsed
->
type
));
}
}
md
=
compileExec
(
static_cast
<
AST_Module
*>
(
parsed
),
boxString
(
filename
),
flags
);
md
=
compileExec
(
static_cast
<
AST_Module
*>
(
parsed
),
autoDecref
(
boxString
(
filename
)
),
flags
);
break
;
break
;
case
Expression_kind
:
case
Expression_kind
:
if
(
parsed
->
type
!=
AST_TYPE
::
Expression
)
{
if
(
parsed
->
type
!=
AST_TYPE
::
Expression
)
{
raiseExcHelper
(
TypeError
,
"expected Expression node, got %s"
,
AST_TYPE
::
stringify
(
parsed
->
type
));
raiseExcHelper
(
TypeError
,
"expected Expression node, got %s"
,
AST_TYPE
::
stringify
(
parsed
->
type
));
}
}
md
=
compileEval
(
static_cast
<
AST_Expression
*>
(
parsed
),
boxString
(
filename
),
flags
);
md
=
compileEval
(
static_cast
<
AST_Expression
*>
(
parsed
),
autoDecref
(
boxString
(
filename
)
),
flags
);
break
;
break
;
case
Suite_kind
:
case
Suite_kind
:
PyErr_SetString
(
PyExc_SystemError
,
"suite should not be possible"
);
PyErr_SetString
(
PyExc_SystemError
,
"suite should not be possible"
);
...
@@ -469,7 +471,6 @@ extern "C" int PyEval_MergeCompilerFlags(PyCompilerFlags* cf) noexcept {
...
@@ -469,7 +471,6 @@ extern "C" int PyEval_MergeCompilerFlags(PyCompilerFlags* cf) noexcept {
}
}
static
void
pickGlobalsAndLocals
(
Box
*&
globals
,
Box
*&
locals
)
{
static
void
pickGlobalsAndLocals
(
Box
*&
globals
,
Box
*&
locals
)
{
assert
(
0
&&
"check refcounting"
);
if
(
globals
==
None
)
if
(
globals
==
None
)
globals
=
NULL
;
globals
=
NULL
;
...
@@ -502,9 +503,7 @@ static void pickGlobalsAndLocals(Box*& globals, Box*& locals) {
...
@@ -502,9 +503,7 @@ static void pickGlobalsAndLocals(Box*& globals, Box*& locals) {
if
(
globals
->
cls
==
module_cls
)
if
(
globals
->
cls
==
module_cls
)
globals_dict
=
globals
->
getAttrWrapper
();
globals_dict
=
globals
->
getAttrWrapper
();
else
else
globals_dict
=
incref
(
globals
);
globals_dict
=
globals
;
AUTO_DECREF
(
globals_dict
);
auto
requested_builtins
=
PyDict_GetItemString
(
globals_dict
,
"__builtins__"
);
auto
requested_builtins
=
PyDict_GetItemString
(
globals_dict
,
"__builtins__"
);
if
(
requested_builtins
==
NULL
)
if
(
requested_builtins
==
NULL
)
...
@@ -517,7 +516,6 @@ static void pickGlobalsAndLocals(Box*& globals, Box*& locals) {
...
@@ -517,7 +516,6 @@ static void pickGlobalsAndLocals(Box*& globals, Box*& locals) {
}
}
extern
"C"
PyObject
*
PyEval_EvalCode
(
PyCodeObject
*
co
,
PyObject
*
globals
,
PyObject
*
locals
)
noexcept
{
extern
"C"
PyObject
*
PyEval_EvalCode
(
PyCodeObject
*
co
,
PyObject
*
globals
,
PyObject
*
locals
)
noexcept
{
assert
(
0
&&
"check refcounting"
);
try
{
try
{
pickGlobalsAndLocals
(
globals
,
locals
);
pickGlobalsAndLocals
(
globals
,
locals
);
return
evalOrExec
(
metadataFromCode
((
Box
*
)
co
),
globals
,
locals
);
return
evalOrExec
(
metadataFromCode
((
Box
*
)
co
),
globals
,
locals
);
...
...
src/codegen/unwinding.cpp
View file @
52fe1669
...
@@ -736,7 +736,7 @@ BORROWED(Box*) getGlobalsDict() {
...
@@ -736,7 +736,7 @@ BORROWED(Box*) getGlobalsDict() {
return
globals
;
return
globals
;
}
}
B
oxedModule
*
getCurrentModule
()
{
B
ORROWED
(
BoxedModule
*
)
getCurrentModule
()
{
FunctionMetadata
*
md
=
getTopPythonFunction
();
FunctionMetadata
*
md
=
getTopPythonFunction
();
if
(
!
md
)
if
(
!
md
)
return
NULL
;
return
NULL
;
...
...
src/codegen/unwinding.h
View file @
52fe1669
...
@@ -35,7 +35,7 @@ uint64_t getCXXUnwindSymbolAddress(llvm::StringRef sym);
...
@@ -35,7 +35,7 @@ uint64_t getCXXUnwindSymbolAddress(llvm::StringRef sym);
bool
isUnwinding
();
// use this instead of std::uncaught_exception
bool
isUnwinding
();
// use this instead of std::uncaught_exception
void
setupUnwinding
();
void
setupUnwinding
();
B
oxedModule
*
getCurrentModule
();
B
ORROWED
(
BoxedModule
*
)
getCurrentModule
();
BORROWED
(
Box
*
)
getGlobals
();
// returns either the module or a globals dict
BORROWED
(
Box
*
)
getGlobals
();
// returns either the module or a globals dict
BORROWED
(
Box
*
)
getGlobalsDict
();
// always returns a dict-like object
BORROWED
(
Box
*
)
getGlobalsDict
();
// always returns a dict-like object
CompiledFunction
*
getCFForAddress
(
uint64_t
addr
);
CompiledFunction
*
getCFForAddress
(
uint64_t
addr
);
...
...
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