Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
e607ac75
Commit
e607ac75
authored
Jun 07, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
8e01c45d
b0511036
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
30 deletions
+33
-30
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+4
-9
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+5
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+5
-1
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+5
-2
tests/run/big_indices.pyx
tests/run/big_indices.pyx
+3
-3
tests/run/inplace.pyx
tests/run/inplace.pyx
+2
-6
tests/run/modop.pyx
tests/run/modop.pyx
+9
-4
No files found.
Cython/Compiler/ExprNodes.py
View file @
e607ac75
...
@@ -168,16 +168,9 @@ class ExprNode(Node):
...
@@ -168,16 +168,9 @@ class ExprNode(Node):
saved_subexpr_nodes
=
None
saved_subexpr_nodes
=
None
is_temp
=
0
is_temp
=
0
def
get_child_attrs
(
self
):
return
self
.
subexprs
child_attrs
=
property
(
fget
=
get_child_attrs
)
def
get_child_attrs
(
self
):
def
get_child_attrs
(
self
):
"""Automatically provide the contents of subexprs as children, unless child_attr
return
self
.
subexprs
has been declared. See Nodes.Node.get_child_accessors."""
child_attrs
=
property
(
fget
=
get_child_attrs
)
if
self
.
child_attrs
is
not
None
:
return
self
.
child_attrs
elif
self
.
subexprs
is
not
None
:
return
self
.
subexprs
def
not_implemented
(
self
,
method_name
):
def
not_implemented
(
self
,
method_name
):
print_call_chain
(
method_name
,
"not implemented"
)
###
print_call_chain
(
method_name
,
"not implemented"
)
###
...
@@ -3289,6 +3282,8 @@ class CondExprNode(ExprNode):
...
@@ -3289,6 +3282,8 @@ class CondExprNode(ExprNode):
# false_val ExprNode
# false_val ExprNode
temp_bool
=
None
temp_bool
=
None
true_val
=
None
false_val
=
None
subexprs
=
[
'test'
,
'true_val'
,
'false_val'
]
subexprs
=
[
'test'
,
'true_val'
,
'false_val'
]
...
...
Cython/Compiler/Main.py
View file @
e607ac75
...
@@ -108,7 +108,7 @@ class Context:
...
@@ -108,7 +108,7 @@ class Context:
if
debug_find_module
:
if
debug_find_module
:
print
(
"Context.find_module: Parsing %s"
%
pxd_pathname
)
print
(
"Context.find_module: Parsing %s"
%
pxd_pathname
)
source_desc
=
FileSourceDescriptor
(
pxd_pathname
)
source_desc
=
FileSourceDescriptor
(
pxd_pathname
)
pxd_tree
=
self
.
parse
(
source_desc
,
scope
.
type_names
,
pxd
=
1
,
pxd_tree
=
self
.
parse
(
source_desc
,
scope
,
pxd
=
1
,
full_module_name
=
module_name
)
full_module_name
=
module_name
)
pxd_tree
.
analyse_declarations
(
scope
)
pxd_tree
.
analyse_declarations
(
scope
)
except
CompileError
:
except
CompileError
:
...
@@ -242,7 +242,7 @@ class Context:
...
@@ -242,7 +242,7 @@ class Context:
self
.
modules
[
name
]
=
scope
self
.
modules
[
name
]
=
scope
return
scope
return
scope
def
parse
(
self
,
source_desc
,
type_names
,
pxd
,
full_module_name
):
def
parse
(
self
,
source_desc
,
scope
,
pxd
,
full_module_name
):
if
not
isinstance
(
source_desc
,
FileSourceDescriptor
):
if
not
isinstance
(
source_desc
,
FileSourceDescriptor
):
raise
RuntimeError
(
"Only file sources for code supported"
)
raise
RuntimeError
(
"Only file sources for code supported"
)
source_filename
=
Utils
.
encode_filename
(
source_desc
.
filename
)
source_filename
=
Utils
.
encode_filename
(
source_desc
.
filename
)
...
@@ -251,7 +251,7 @@ class Context:
...
@@ -251,7 +251,7 @@ class Context:
f
=
Utils
.
open_source_file
(
source_filename
,
"rU"
)
f
=
Utils
.
open_source_file
(
source_filename
,
"rU"
)
try
:
try
:
s
=
PyrexScanner
(
f
,
source_desc
,
source_encoding
=
f
.
encoding
,
s
=
PyrexScanner
(
f
,
source_desc
,
source_encoding
=
f
.
encoding
,
type_names
=
type_names
,
context
=
self
)
scope
=
scope
,
context
=
self
)
tree
=
Parsing
.
p_module
(
s
,
pxd
,
full_module_name
)
tree
=
Parsing
.
p_module
(
s
,
pxd
,
full_module_name
)
finally
:
finally
:
f
.
close
()
f
.
close
()
...
@@ -304,7 +304,7 @@ class Context:
...
@@ -304,7 +304,7 @@ class Context:
c_suffix
=
".cpp"
c_suffix
=
".cpp"
else
:
else
:
c_suffix
=
".c"
c_suffix
=
".c"
result
.
c_file
=
Utils
.
replace_suffix
(
source
,
c_suffix
)
result
.
c_file
=
Utils
.
replace_suffix
(
source
,
c_suffix
)
c_stat
=
None
c_stat
=
None
if
result
.
c_file
:
if
result
.
c_file
:
try
:
try
:
...
@@ -317,7 +317,7 @@ class Context:
...
@@ -317,7 +317,7 @@ class Context:
scope
=
self
.
find_module
(
module_name
,
pos
=
initial_pos
,
need_pxd
=
0
)
scope
=
self
.
find_module
(
module_name
,
pos
=
initial_pos
,
need_pxd
=
0
)
errors_occurred
=
False
errors_occurred
=
False
try
:
try
:
tree
=
self
.
parse
(
source
,
scope
.
type_names
,
pxd
=
0
,
tree
=
self
.
parse
(
source
,
scope
,
pxd
=
0
,
full_module_name
=
full_module_name
)
full_module_name
=
full_module_name
)
tree
.
process_implementation
(
scope
,
options
,
result
)
tree
.
process_implementation
(
scope
,
options
,
result
)
except
CompileError
:
except
CompileError
:
...
...
Cython/Compiler/Nodes.py
View file @
e607ac75
...
@@ -2217,6 +2217,7 @@ class CascadedAssignmentNode(AssignmentNode):
...
@@ -2217,6 +2217,7 @@ class CascadedAssignmentNode(AssignmentNode):
# coerced_rhs_list [ExprNode] RHS coerced to type of each LHS
# coerced_rhs_list [ExprNode] RHS coerced to type of each LHS
child_attrs
=
[
"lhs_list"
,
"rhs"
,
"coerced_rhs_list"
]
child_attrs
=
[
"lhs_list"
,
"rhs"
,
"coerced_rhs_list"
]
coerced_rhs_list
=
None
def
analyse_declarations
(
self
,
env
):
def
analyse_declarations
(
self
,
env
):
for
lhs
in
self
.
lhs_list
:
for
lhs
in
self
.
lhs_list
:
...
@@ -2353,6 +2354,7 @@ class InPlaceAssignmentNode(AssignmentNode):
...
@@ -2353,6 +2354,7 @@ class InPlaceAssignmentNode(AssignmentNode):
# (it must be a NameNode, AttributeNode, or IndexNode).
# (it must be a NameNode, AttributeNode, or IndexNode).
child_attrs
=
[
"lhs"
,
"rhs"
,
"dup"
]
child_attrs
=
[
"lhs"
,
"rhs"
,
"dup"
]
dup
=
None
def
analyse_declarations
(
self
,
env
):
def
analyse_declarations
(
self
,
env
):
self
.
lhs
.
analyse_target_declaration
(
env
)
self
.
lhs
.
analyse_target_declaration
(
env
)
...
@@ -2987,6 +2989,7 @@ class ForInStatNode(LoopNode, StatNode):
...
@@ -2987,6 +2989,7 @@ class ForInStatNode(LoopNode, StatNode):
# item NextNode used internally
# item NextNode used internally
child_attrs
=
[
"target"
,
"iterator"
,
"body"
,
"else_clause"
,
"item"
]
child_attrs
=
[
"target"
,
"iterator"
,
"body"
,
"else_clause"
,
"item"
]
item
=
None
def
analyse_declarations
(
self
,
env
):
def
analyse_declarations
(
self
,
env
):
self
.
target
.
analyse_target_declaration
(
env
)
self
.
target
.
analyse_target_declaration
(
env
)
...
@@ -3103,7 +3106,7 @@ class ForFromStatNode(LoopNode, StatNode):
...
@@ -3103,7 +3106,7 @@ class ForFromStatNode(LoopNode, StatNode):
# is_py_target bool
# is_py_target bool
# loopvar_name string
# loopvar_name string
# py_loopvar_node PyTempNode or None
# py_loopvar_node PyTempNode or None
child_attrs
=
[
"target"
,
"bound1"
,
"bound2"
,
"step"
,
"body"
,
"else_clause"
,
"py_loopvar_node"
]
child_attrs
=
[
"target"
,
"bound1"
,
"bound2"
,
"step"
,
"body"
,
"else_clause"
]
def
analyse_declarations
(
self
,
env
):
def
analyse_declarations
(
self
,
env
):
self
.
target
.
analyse_target_declaration
(
env
)
self
.
target
.
analyse_target_declaration
(
env
)
...
@@ -3317,6 +3320,7 @@ class ExceptClauseNode(Node):
...
@@ -3317,6 +3320,7 @@ class ExceptClauseNode(Node):
# exc_vars (string * 3) local exception variables
# exc_vars (string * 3) local exception variables
child_attrs
=
[
"pattern"
,
"target"
,
"body"
,
"exc_value"
]
child_attrs
=
[
"pattern"
,
"target"
,
"body"
,
"exc_value"
]
exc_value
=
None
def
analyse_declarations
(
self
,
env
):
def
analyse_declarations
(
self
,
env
):
if
self
.
target
:
if
self
.
target
:
...
...
Cython/Compiler/Scanning.py
View file @
e607ac75
...
@@ -281,23 +281,26 @@ class StringSourceDescriptor(SourceDescriptor):
...
@@ -281,23 +281,26 @@ class StringSourceDescriptor(SourceDescriptor):
class
PyrexScanner
(
Scanner
):
class
PyrexScanner
(
Scanner
):
# context Context Compilation context
# context Context Compilation context
# type_names set Identifiers to be treated as type names
# type_names set Identifiers to be treated as type names
# included_files [string] Files included with 'include' statement
# compile_time_env dict Environment for conditional compilation
# compile_time_env dict Environment for conditional compilation
# compile_time_eval boolean In a true conditional compilation context
# compile_time_eval boolean In a true conditional compilation context
# compile_time_expr boolean In a compile-time expression context
# compile_time_expr boolean In a compile-time expression context
resword_dict
=
build_resword_dict
()
resword_dict
=
build_resword_dict
()
def
__init__
(
self
,
file
,
filename
,
parent_scanner
=
None
,
def
__init__
(
self
,
file
,
filename
,
parent_scanner
=
None
,
type_names
=
None
,
context
=
None
,
source_encoding
=
None
):
scope
=
None
,
context
=
None
,
source_encoding
=
None
):
Scanner
.
__init__
(
self
,
get_lexicon
(),
file
,
filename
)
Scanner
.
__init__
(
self
,
get_lexicon
(),
file
,
filename
)
if
parent_scanner
:
if
parent_scanner
:
self
.
context
=
parent_scanner
.
context
self
.
context
=
parent_scanner
.
context
self
.
type_names
=
parent_scanner
.
type_names
self
.
type_names
=
parent_scanner
.
type_names
self
.
included_files
=
parent_scanner
.
included_files
self
.
compile_time_env
=
parent_scanner
.
compile_time_env
self
.
compile_time_env
=
parent_scanner
.
compile_time_env
self
.
compile_time_eval
=
parent_scanner
.
compile_time_eval
self
.
compile_time_eval
=
parent_scanner
.
compile_time_eval
self
.
compile_time_expr
=
parent_scanner
.
compile_time_expr
self
.
compile_time_expr
=
parent_scanner
.
compile_time_expr
else
:
else
:
self
.
context
=
context
self
.
context
=
context
self
.
type_names
=
type_names
self
.
type_names
=
scope
.
type_names
self
.
included_files
=
scope
.
included_files
self
.
compile_time_env
=
initial_compile_time_env
()
self
.
compile_time_env
=
initial_compile_time_env
()
self
.
compile_time_eval
=
1
self
.
compile_time_eval
=
1
self
.
compile_time_expr
=
0
self
.
compile_time_expr
=
0
...
...
tests/run/big_indices.pyx
View file @
e607ac75
...
@@ -12,10 +12,10 @@ def test():
...
@@ -12,10 +12,10 @@ def test():
cdef
long
neg
=
-
1
cdef
long
neg
=
-
1
cdef
unsigned
long
pos
=
-
2
# will be a large positive number
cdef
unsigned
long
pos
=
-
2
# will be a large positive number
print
"neg"
,
neg
>
0
print
u
"neg"
,
neg
>
0
print
"pos"
,
pos
>
-
print
u"pos"
,
pos
>
0
D
=
{
neg
:
'neg'
,
pos
:
'pos'
}
D
=
{
neg
:
u'neg'
,
pos
:
u
'pos'
}
print
D
[
<
object
>
neg
]
print
D
[
<
object
>
neg
]
print
D
[
<
object
>
pos
]
print
D
[
<
object
>
pos
]
...
...
tests/run/inplace.pyx
View file @
e607ac75
__doc__
=
u"""
__doc__
=
u"""
>>>
f(5, 7
)
>>>
str(f(5, 7)
)
29509034655744L
'29509034655744'
>>> g(13, 4)
>>> g(13, 4)
32
32
...
@@ -9,10 +9,6 @@ __doc__ = u"""
...
@@ -9,10 +9,6 @@ __doc__ = u"""
105.0
105.0
"""
"""
import
sys
if
sys
.
version_info
[
0
]
>=
3
:
__doc__
=
__doc__
.
replace
(
u"L"
,
u""
)
def
f
(
a
,
b
):
def
f
(
a
,
b
):
a
+=
b
a
+=
b
a
*=
b
a
*=
b
...
...
tests/run/modop.pyx
View file @
e607ac75
...
@@ -6,9 +6,14 @@ __doc__ = u"""
...
@@ -6,9 +6,14 @@ __doc__ = u"""
>>> modint(9,2)
>>> modint(9,2)
1
1
"""
import
sys
if
sys
.
version_info
[
0
]
<
3
:
__doc__
=
__doc__
+
u"""
>>>
print
modptr()
>>> modptr()
spameggs
'spameggs'
"""
"""
def
modobj
(
obj2
,
obj3
):
def
modobj
(
obj2
,
obj3
):
...
@@ -25,5 +30,5 @@ def modptr():
...
@@ -25,5 +30,5 @@ def modptr():
str2
=
"spam%s"
str2
=
"spam%s"
str3
=
"eggs"
str3
=
"eggs"
obj1
=
str2
%
str3
obj1
=
str2
%
str3
# '%' operator doesn't work on byte strings in Py3
return
obj1
.
decode
(
u"ASCII"
)
return
obj1
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