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
189b1150
Commit
189b1150
authored
Dec 19, 2014
by
Kevin Modzelewski
Committed by
Kevin Modzelewski
Jan 04, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sys.exit()
parent
520dd6e6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
9 deletions
+29
-9
Makefile
Makefile
+1
-1
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+2
-0
src/jit.cpp
src/jit.cpp
+18
-8
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+8
-0
No files found.
Makefile
View file @
189b1150
...
...
@@ -321,7 +321,7 @@ NONSTDLIB_SRCS := $(MAIN_SRCS) $(OPTIONAL_SRCS) $(TOOL_SRCS) $(UNITTEST_SRCS)
# all: pyston_dbg pyston_release pyston_oprof pyston_prof $(OPTIONAL_SRCS:.cpp=.o) ext_python ext_pyston
all
:
pyston_dbg pyston_release pyston_prof ext_python ext_pyston unittests
ALL_HEADERS
:=
$(
wildcard
src/
*
/
*
.h
)
$(
wildcard
src/
*
/
*
/
*
.h
)
$(
wildcard
./i
nclude/
*
.h
)
ALL_HEADERS
:=
$(
wildcard
src/
*
/
*
.h
)
$(
wildcard
src/
*
/
*
/
*
.h
)
$(
wildcard
cpython2.7/I
nclude/
*
.h
)
tags
:
$(SRCS) $(OPTIONAL_SRCS) $(FROM_CPYTHON_SRCS) $(ALL_HEADERS)
$(ECHO)
Calculating tags...
$(VERB)
ctags
$^
...
...
src/codegen/irgen.cpp
View file @
189b1150
...
...
@@ -290,6 +290,8 @@ static ConcreteCompilerType* getTypeAtBlockStart(TypeAnalysis* types, const std:
return
GENERATOR
;
else
if
(
name
==
PASSED_CLOSURE_NAME
)
return
CLOSURE
;
else
if
(
name
==
CREATED_CLOSURE_NAME
)
return
CLOSURE
;
else
return
types
->
getTypeAtBlockStart
(
name
,
block
);
}
...
...
src/jit.cpp
View file @
189b1150
...
...
@@ -37,6 +37,7 @@
#include "core/threading.h"
#include "core/types.h"
#include "core/util.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
...
...
@@ -150,11 +151,15 @@ int main(int argc, char** argv) {
try
{
main_module
=
createAndRunModule
(
"__main__"
,
fn
);
}
catch
(
Box
*
b
)
{
std
::
string
msg
=
formatException
(
b
);
printLastTraceback
();
fprintf
(
stderr
,
"%s
\n
"
,
msg
.
c_str
());
return
1
;
if
(
isInstance
(
b
,
SystemExit
))
{
printf
(
"Warning: ignoring SystemExit code
\n
"
);
return
1
;
}
else
{
std
::
string
msg
=
formatException
(
b
);
printLastTraceback
();
fprintf
(
stderr
,
"%s
\n
"
,
msg
.
c_str
());
return
1
;
}
}
}
...
...
@@ -218,9 +223,14 @@ int main(int argc, char** argv) {
try
{
compileAndRunModule
(
m
,
main_module
);
}
catch
(
Box
*
b
)
{
std
::
string
msg
=
formatException
(
b
);
printLastTraceback
();
fprintf
(
stderr
,
"%s
\n
"
,
msg
.
c_str
());
if
(
isInstance
(
b
,
SystemExit
))
{
printf
(
"Warning: ignoring SystemExit code
\n
"
);
return
1
;
}
else
{
std
::
string
msg
=
formatException
(
b
);
printLastTraceback
();
fprintf
(
stderr
,
"%s
\n
"
,
msg
.
c_str
());
}
}
}
}
...
...
src/runtime/builtin_modules/sys.cpp
View file @
189b1150
...
...
@@ -38,6 +38,13 @@ Box* sysExcInfo() {
threading
::
cur_thread_state
.
exc_traceback
?
threading
::
cur_thread_state
.
exc_traceback
:
None
});
}
static
Box
*
sysExit
(
Box
*
arg
)
{
if
(
arg
)
raiseExc
(
exceptionNew1
(
SystemExit
));
else
raiseExc
(
exceptionNew2
(
SystemExit
,
arg
));
}
BoxedDict
*
getSysModulesDict
()
{
// PyPy's behavior: fetch from sys.modules each time:
// Box *_sys_modules = sys_module->getattr("modules");
...
...
@@ -142,6 +149,7 @@ void setupSys() {
sys_module
->
giveAttr
(
"stderr"
,
new
BoxedFile
(
stderr
,
"<stderr>"
,
"w"
));
sys_module
->
giveAttr
(
"exc_info"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
sysExcInfo
,
BOXED_TUPLE
,
0
)));
sys_module
->
giveAttr
(
"exit"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
sysExit
,
NONE
,
1
,
1
,
false
,
false
),
{
None
}));
sys_module
->
giveAttr
(
"warnoptions"
,
new
BoxedList
());
sys_module
->
giveAttr
(
"py3kwarning"
,
False
);
...
...
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