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
49fe0ddf
Commit
49fe0ddf
authored
Apr 24, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code.co_firstlineno
parent
7b71c6f8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
1 deletion
+21
-1
src/core/cfg.cpp
src/core/cfg.cpp
+2
-0
src/runtime/code.cpp
src/runtime/code.cpp
+16
-0
test/integration/virtualenv_test.py
test/integration/virtualenv_test.py
+1
-1
test/tests/code_test.py
test/tests/code_test.py
+2
-0
No files found.
src/core/cfg.cpp
View file @
49fe0ddf
...
...
@@ -1427,6 +1427,8 @@ public:
bool
visit_functiondef
(
AST_FunctionDef
*
node
)
override
{
auto
def
=
new
AST_FunctionDef
();
def
->
lineno
=
node
->
lineno
;
def
->
col_offset
=
node
->
col_offset
;
def
->
name
=
node
->
name
;
def
->
body
=
node
->
body
;
// expensive vector copy
// Decorators are evaluated before the defaults, so this *must* go before remapArguments().
...
...
src/runtime/code.cpp
View file @
49fe0ddf
...
...
@@ -51,6 +51,20 @@ public:
return
boxString
(
static_cast
<
BoxedCode
*>
(
b
)
->
f
->
source
->
fn
);
}
static
Box
*
firstlineno
(
Box
*
b
,
void
*
)
{
RELEASE_ASSERT
(
b
->
cls
==
code_cls
,
""
);
BoxedCode
*
code
=
static_cast
<
BoxedCode
*>
(
b
);
CLFunction
*
cl
=
code
->
f
;
if
(
!
cl
->
source
)
{
// I don't think it really matters what we return here;
// in CPython, builtin functions don't have code objects.
return
boxInt
(
-
1
);
}
return
boxInt
(
cl
->
source
->
ast
->
lineno
);
}
static
Box
*
argcount
(
Box
*
b
,
void
*
)
{
RELEASE_ASSERT
(
b
->
cls
==
code_cls
,
""
);
...
...
@@ -114,6 +128,8 @@ void setupCode() {
code_cls
->
giveAttr
(
"co_name"
,
new
(
pyston_getset_cls
)
BoxedGetsetDescriptor
(
BoxedCode
::
name
,
NULL
,
NULL
));
code_cls
->
giveAttr
(
"co_filename"
,
new
(
pyston_getset_cls
)
BoxedGetsetDescriptor
(
BoxedCode
::
filename
,
NULL
,
NULL
));
code_cls
->
giveAttr
(
"co_firstlineno"
,
new
(
pyston_getset_cls
)
BoxedGetsetDescriptor
(
BoxedCode
::
firstlineno
,
NULL
,
NULL
));
code_cls
->
giveAttr
(
"co_argcount"
,
new
(
pyston_getset_cls
)
BoxedGetsetDescriptor
(
BoxedCode
::
argcount
,
NULL
,
NULL
));
code_cls
->
giveAttr
(
"co_varnames"
,
new
(
pyston_getset_cls
)
BoxedGetsetDescriptor
(
BoxedCode
::
varnames
,
NULL
,
NULL
));
code_cls
->
giveAttr
(
"co_flags"
,
new
(
pyston_getset_cls
)
BoxedGetsetDescriptor
(
BoxedCode
::
flags
,
NULL
,
NULL
));
...
...
test/integration/virtualenv_test.py
View file @
49fe0ddf
...
...
@@ -21,7 +21,7 @@ set -e
set -ux
python -c 'import __future__'
python -c 'import sys; print sys.executable'
pip install six==1.9.0 cffi==0.9.2
pip install six==1.9.0 cffi==0.9.2
pycparser==2.12
python -c 'import six; print six.__version__'
"""
.
strip
()
...
...
test/tests/code_test.py
View file @
49fe0ddf
...
...
@@ -4,6 +4,7 @@ def f(a, b=2, *args, **kw):
c
=
f
.
func_code
print
c
.
co_argcount
print
c
.
co_varnames
print
c
.
co_firstlineno
print
hex
(
c
.
co_flags
&
0x0c
)
def
f
(
l
=
[]):
...
...
@@ -15,3 +16,4 @@ f()
def
f
():
pass
print
f
.
func_defaults
print
f
.
func_code
.
co_firstlineno
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