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
e6cbc8ae
Commit
e6cbc8ae
authored
Jun 26, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic docstring support
Pretty similar to #78
parent
38fa581e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
6 deletions
+55
-6
src/Makefile
src/Makefile
+7
-5
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+23
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+1
-1
test/tests/docstrings.py
test/tests/docstrings.py
+24
-0
No files found.
src/Makefile
View file @
e6cbc8ae
...
...
@@ -337,11 +337,15 @@ cpplint:
.PHONY
:
check quick_check
check
:
@
# These are ordered roughly in decreasing order of
(
chance will expose issue
)
/
(
time
to run
test
)
$(MAKE)
lint
$(MAKE)
ext pyston_dbg
#
$(MAKE)
run_unittests
$(MAKE)
check_dbg
$(MAKE)
check_release
$(MAKE)
check_format
$(MAKE)
run_unittests
@# jit_prof forces the use of GCC as the compiler, which can expose other errors, so just build it and see what happens
:
#
$(MAKE)
check_prof
$(MAKE)
pyston_prof
...
...
@@ -349,9 +353,7 @@ check:
$(
call
checksha,./pyston_prof
-cqn
$(TESTS_DIR)
/raytrace_small.py,0544f4621dd45fe94205219488a2576b84dc044d
)
$(
call
checksha,./pyston_prof
-cqO
$(TESTS_DIR)
/raytrace_small.py,0544f4621dd45fe94205219488a2576b84dc044d
)
$(MAKE)
run_unittests
$(MAKE)
check_format
$(MAKE)
check_release
echo
"All tests passed"
quick_check
:
...
...
src/codegen/irgen/irgenerator.cpp
View file @
e6cbc8ae
...
...
@@ -1404,10 +1404,29 @@ private:
// cls->setattr(emitter, "__name__", name);
// name->decvref(emitter);
bool
had_docstring
=
false
;
static
std
::
string
doc_str
(
"__doc__"
);
for
(
int
i
=
0
,
n
=
node
->
body
.
size
();
i
<
n
;
i
++
)
{
AST_TYPE
::
AST_TYPE
type
=
node
->
body
[
i
]
->
type
;
if
(
type
==
AST_TYPE
::
Pass
)
{
continue
;
}
else
if
(
type
==
AST_TYPE
::
Expr
)
{
AST_Expr
*
expr
=
ast_cast
<
AST_Expr
>
(
node
->
body
[
i
]);
if
(
expr
->
value
->
type
==
AST_TYPE
::
Str
)
{
if
(
i
==
0
)
{
had_docstring
=
true
;
CompilerVariable
*
str
=
evalExpr
(
expr
->
value
,
exc_info
);
cls
->
setattr
(
emitter
,
getEmptyOpInfo
(
exc_info
),
&
doc_str
,
str
);
}
}
else
{
fprintf
(
stderr
,
"Currently don't support non-noop expressions in classes:
\n
"
);
printf
(
"On line %d: "
,
expr
->
lineno
);
print_ast
(
expr
);
printf
(
"
\n
"
);
abort
();
}
}
else
if
(
type
==
AST_TYPE
::
FunctionDef
)
{
AST_FunctionDef
*
fdef
=
ast_cast
<
AST_FunctionDef
>
(
node
->
body
[
i
]);
assert
(
fdef
->
args
->
defaults
.
size
()
==
0
);
...
...
@@ -1424,6 +1443,10 @@ private:
}
}
if
(
!
had_docstring
)
{
cls
->
setattr
(
emitter
,
getEmptyOpInfo
(
exc_info
),
&
doc_str
,
getNone
());
}
_doSet
(
node
->
name
,
cls
,
exc_info
);
cls
->
decvref
(
emitter
);
}
...
...
src/runtime/objmodel.cpp
View file @
e6cbc8ae
...
...
@@ -2944,7 +2944,7 @@ extern "C" Box* import(const std::string* name) {
continue
;
if
(
VERBOSITY
()
>=
1
)
printf
(
"
Beginning import of %s...
\n
"
,
fn
.
c_str
());
printf
(
"
Importing %s from %s
\n
"
,
name
->
c_str
()
,
fn
.
c_str
());
// TODO duplication with jit.cpp:
BoxedModule
*
module
=
createModule
(
*
name
,
fn
);
...
...
test/tests/docstrings.py
0 → 100644
View file @
e6cbc8ae
class
C1
(
object
):
"hello world"
print
C1
.
__doc__
class
C2
(
object
):
"doc1"
"doc2"
print
C2
.
__doc__
class
C3
(
object
):
pass
print
C3
.
__doc__
"""
# Not supported yet:
class C3(object):
1
assert C3.__doc__ is None
class C4(object):
("a")
assert C3.__doc__ is None
"""
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