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
163f4574
Commit
163f4574
authored
Nov 13, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More
parent
7199f0e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
24 deletions
+23
-24
src/runtime/builtin_modules/ast.cpp
src/runtime/builtin_modules/ast.cpp
+3
-4
src/runtime/builtin_modules/pyston.cpp
src/runtime/builtin_modules/pyston.cpp
+1
-1
src/runtime/import.cpp
src/runtime/import.cpp
+15
-15
src/runtime/types.cpp
src/runtime/types.cpp
+4
-4
No files found.
src/runtime/builtin_modules/ast.cpp
View file @
163f4574
...
...
@@ -65,15 +65,14 @@ extern "C" int PyAST_Check(PyObject* o) noexcept {
}
void
setupAST
()
{
BoxedModule
*
ast_module
=
createModule
(
boxString
(
"_ast"
),
"__builtin__"
);
BoxedModule
*
ast_module
=
createModule
(
autoDecref
(
boxString
(
"_ast"
)
),
"__builtin__"
);
ast_module
->
giveAttr
(
"PyCF_ONLY_AST"
,
boxInt
(
PyCF_ONLY_AST
));
// ::create takes care of registering the class as a GC root.
#define MAKE_CLS(name, base_cls) \
BoxedClass* name##_cls = BoxedClass::create(type_cls, base_cls, 0, 0, sizeof(BoxedAST), \
false, STRINGIFY(name)); \
ast_module->giveAttr(STRINGIFY(name), name##_cls); \
BoxedClass* name##_cls = BoxedClass::create(type_cls, base_cls, 0, 0, sizeof(BoxedAST), false, STRINGIFY(name)); \
ast_module->giveAttrBorrowed(STRINGIFY(name), name##_cls); \
type_to_cls[AST_TYPE::name] = name##_cls; \
name##_cls->giveAttr("__module__", boxString("_ast")); \
name##_cls->freeze()
...
...
src/runtime/builtin_modules/pyston.cpp
View file @
163f4574
...
...
@@ -65,7 +65,7 @@ static Box* dumpStats(Box* includeZeros) {
}
void
setupPyston
()
{
pyston_module
=
createModule
(
boxString
(
"__pyston__"
));
pyston_module
=
createModule
(
autoDecref
(
boxString
(
"__pyston__"
)
));
pyston_module
->
giveAttr
(
"setOption"
,
new
BoxedBuiltinFunctionOrMethod
(
FunctionMetadata
::
create
((
void
*
)
setOption
,
UNKNOWN
,
2
),
"setOption"
));
...
...
src/runtime/import.cpp
View file @
163f4574
...
...
@@ -67,7 +67,7 @@ static Box* createAndRunModule(BoxedString* name, const std::string& fn, const s
BoxedList
*
path_list
=
new
BoxedList
();
listAppendInternal
(
path_list
,
b_path
);
static
BoxedString
*
path_str
=
internStringImmortal
(
"__path__"
);
static
BoxedString
*
path_str
=
getStaticString
(
"__path__"
);
module
->
setattr
(
path_str
,
path_list
,
NULL
);
AST_Module
*
ast
=
caching_parse_file
(
fn
.
c_str
(),
/* future_flags = */
0
);
...
...
@@ -185,12 +185,12 @@ struct SearchResult {
};
SearchResult
findModule
(
const
std
::
string
&
name
,
BoxedString
*
full_name
,
BoxedList
*
path_list
)
{
static
BoxedString
*
meta_path_str
=
internStringImmortal
(
"meta_path"
);
static
BoxedString
*
meta_path_str
=
getStaticString
(
"meta_path"
);
BoxedList
*
meta_path
=
static_cast
<
BoxedList
*>
(
sys_module
->
getattr
(
meta_path_str
));
if
(
!
meta_path
||
meta_path
->
cls
!=
list_cls
)
raiseExcHelper
(
RuntimeError
,
"sys.meta_path must be a list of import hooks"
);
static
BoxedString
*
findmodule_str
=
internStringImmortal
(
"find_module"
);
static
BoxedString
*
findmodule_str
=
getStaticString
(
"find_module"
);
for
(
int
i
=
0
;
i
<
meta_path
->
size
;
i
++
)
{
Box
*
finder
=
meta_path
->
elts
->
elts
[
i
];
...
...
@@ -209,12 +209,12 @@ SearchResult findModule(const std::string& name, BoxedString* full_name, BoxedLi
raiseExcHelper
(
RuntimeError
,
"sys.path must be a list of directory names"
);
}
static
BoxedString
*
path_hooks_str
=
internStringImmortal
(
"path_hooks"
);
static
BoxedString
*
path_hooks_str
=
getStaticString
(
"path_hooks"
);
BoxedList
*
path_hooks
=
static_cast
<
BoxedList
*>
(
sys_module
->
getattr
(
path_hooks_str
));
if
(
!
path_hooks
||
path_hooks
->
cls
!=
list_cls
)
raiseExcHelper
(
RuntimeError
,
"sys.path_hooks must be a list of import hooks"
);
static
BoxedString
*
path_importer_cache_str
=
internStringImmortal
(
"path_importer_cache"
);
static
BoxedString
*
path_importer_cache_str
=
getStaticString
(
"path_importer_cache"
);
BoxedDict
*
path_importer_cache
=
static_cast
<
BoxedDict
*>
(
sys_module
->
getattr
(
path_importer_cache_str
));
if
(
!
path_importer_cache
||
path_importer_cache
->
cls
!=
dict_cls
)
raiseExcHelper
(
RuntimeError
,
"sys.path_importer_cache must be a dict"
);
...
...
@@ -293,7 +293,7 @@ static Box* getParent(Box* globals, int level, std::string& buf) {
if
(
globals
==
NULL
||
globals
==
None
||
level
==
0
)
return
None
;
static
BoxedString
*
package_str
=
internStringImmortal
(
"__package__"
);
static
BoxedString
*
package_str
=
getStaticString
(
"__package__"
);
BoxedString
*
pkgname
=
static_cast
<
BoxedString
*>
(
getFromGlobals
(
globals
,
package_str
));
if
(
pkgname
!=
NULL
&&
pkgname
!=
None
)
{
/* __package__ is set, so use it */
...
...
@@ -312,14 +312,14 @@ static Box* getParent(Box* globals, int level, std::string& buf) {
}
buf
+=
pkgname
->
s
();
}
else
{
static
BoxedString
*
name_str
=
internStringImmortal
(
"__name__"
);
static
BoxedString
*
name_str
=
getStaticString
(
"__name__"
);
/* __package__ not set, so figure it out and set it */
BoxedString
*
modname
=
static_cast
<
BoxedString
*>
(
getFromGlobals
(
globals
,
name_str
));
if
(
modname
==
NULL
||
modname
->
cls
!=
str_cls
)
return
None
;
static
BoxedString
*
path_str
=
internStringImmortal
(
"__path__"
);
static
BoxedString
*
path_str
=
getStaticString
(
"__path__"
);
Box
*
modpath
=
getFromGlobals
(
globals
,
path_str
);
if
(
modpath
!=
NULL
)
{
...
...
@@ -411,7 +411,7 @@ static Box* importSub(const std::string& name, BoxedString* full_name, Box* pare
else
if
(
sr
.
type
==
SearchResult
::
C_EXTENSION
)
module
=
importCExtension
(
full_name
,
name
,
sr
.
path
);
else
if
(
sr
.
type
==
SearchResult
::
IMP_HOOK
)
{
static
BoxedString
*
loadmodule_str
=
internStringImmortal
(
"load_module"
);
static
BoxedString
*
loadmodule_str
=
getStaticString
(
"load_module"
);
CallattrFlags
callattr_flags
{.
cls_only
=
false
,
.
null_on_nonexistent
=
false
,
.
argspec
=
ArgPassSpec
(
1
)
};
...
...
@@ -593,7 +593,7 @@ static void ensureFromlist(Box* module, Box* fromlist, std::string& buf, bool re
if
(
recursive
)
continue
;
static
BoxedString
*
all_str
=
internStringImmortal
(
"__all__"
);
static
BoxedString
*
all_str
=
getStaticString
(
"__all__"
);
Box
*
all
=
getattrInternal
<
ExceptionStyle
::
CXX
>
(
module
,
all_str
);
if
(
all
)
{
ensureFromlist
(
module
,
all
,
buf
,
true
);
...
...
@@ -669,7 +669,7 @@ extern "C" PyObject* PyImport_ExecCodeModuleEx(char* name, PyObject* co, char* p
if
(
module
==
NULL
)
return
NULL
;
static
BoxedString
*
file_str
=
internStringImmortal
(
"__file__"
);
static
BoxedString
*
file_str
=
getStaticString
(
"__file__"
);
module
->
setattr
(
file_str
,
boxString
(
pathname
),
NULL
);
AST_Module
*
ast
=
parse_string
(
code
->
data
(),
/* future_flags = */
0
);
compileAndRunModule
(
ast
,
module
);
...
...
@@ -844,7 +844,7 @@ BoxedModule* importCExtension(BoxedString* full_name, const std::string& last_na
assert
(
_m
->
cls
==
module_cls
);
BoxedModule
*
m
=
static_cast
<
BoxedModule
*>
(
_m
);
static
BoxedString
*
file_str
=
internStringImmortal
(
"__file__"
);
static
BoxedString
*
file_str
=
getStaticString
(
"__file__"
);
m
->
setattr
(
file_str
,
boxString
(
path
),
NULL
);
return
m
;
}
...
...
@@ -881,7 +881,7 @@ Box* impIsBuiltin(Box* _name) {
if
(
!
PyString_Check
(
_name
))
raiseExcHelper
(
TypeError
,
"must be string, not %s"
,
getTypeName
(
_name
));
static
BoxedString
*
builtin_module_names_str
=
internStringImmortal
(
"builtin_module_names"
);
static
BoxedString
*
builtin_module_names_str
=
getStaticString
(
"builtin_module_names"
);
BoxedTuple
*
builtin_modules
=
(
BoxedTuple
*
)
sys_module
->
getattr
(
builtin_module_names_str
);
RELEASE_ASSERT
(
PyTuple_Check
(
builtin_modules
),
""
);
for
(
Box
*
m
:
builtin_modules
->
pyElements
())
{
...
...
@@ -923,7 +923,7 @@ On platforms without threads, this function does nothing.");
void
setupImport
()
{
BoxedModule
*
imp_module
=
createModule
(
boxString
(
"imp"
),
NULL
,
"'This module provides the components needed to build your own
\n
"
=
createModule
(
autoDecref
(
boxString
(
"imp"
)
),
NULL
,
"'This module provides the components needed to build your own
\n
"
"__import__ function. Undocumented functions are obsolete.'"
);
imp_module
->
giveAttr
(
"PY_SOURCE"
,
boxInt
(
SearchResult
::
PY_SOURCE
));
...
...
@@ -942,7 +942,7 @@ void setupImport() {
new
BoxedBuiltinFunctionOrMethod
(
FunctionMetadata
::
create
((
void
*
)
nullImporterFindModule
,
NONE
,
2
,
false
,
false
),
"find_module"
,
{
None
},
NULL
,
find_module_doc
));
null_importer_cls
->
freeze
();
imp_module
->
giveAttr
(
"NullImporter"
,
null_importer_cls
);
imp_module
->
giveAttr
Borrowed
(
"NullImporter"
,
null_importer_cls
);
FunctionMetadata
*
find_module_func
=
FunctionMetadata
::
create
((
void
*
)
impFindModule
,
UNKNOWN
,
2
,
false
,
false
,
ParamNames
({
"name"
,
"path"
},
""
,
""
));
...
...
src/runtime/types.cpp
View file @
163f4574
...
...
@@ -3918,11 +3918,11 @@ void setupRuntime() {
setupBuiltins
();
_PyExc_Init
();
//
setupThread();
setupThread
();
//initgc();
//
setupImport();
//
setupPyston();
//
setupAST();
setupImport
();
setupPyston
();
setupAST
();
// XXX
PyType_ClearCache
();
...
...
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