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
868538b3
Commit
868538b3
authored
Jun 19, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scope now creating by parse stage in Main
parent
06d7ad86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
17 deletions
+29
-17
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+24
-17
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+5
-0
No files found.
Cython/Compiler/Main.py
View file @
868538b3
...
...
@@ -318,40 +318,50 @@ class Context:
class
CompilationSource
(
object
):
def
__init__
(
self
,
source_desc
,
full_module_name
):
"""
Contains the data necesarry to start up a compilation pipeline for
a single compilation source (= file, usually).
"""
def
__init__
(
self
,
source_desc
,
full_module_name
,
cwd
):
self
.
source_desc
=
source_desc
self
.
full_module_name
=
full_module_name
self
.
cwd
=
cwd
def
create_parse
(
context
,
scope
):
def
create_parse
(
context
):
def
parse
(
compsrc
):
source_desc
=
compsrc
.
source_desc
full_module_name
=
compsrc
.
full_module_name
initial_pos
=
(
source_desc
,
1
,
0
)
scope
=
context
.
find_module
(
full_module_name
,
pos
=
initial_pos
,
need_pxd
=
0
)
tree
=
context
.
parse
(
source_desc
,
scope
,
pxd
=
0
,
full_module_name
=
full_module_name
)
tree
.
compilation_source
=
compsrc
tree
.
scope
=
scope
return
tree
return
parse
def
create_generate_code
(
context
,
scope
,
options
):
def
generate_code
(
tree
):
result
=
create_default_resultobj
(
tree
.
compilation_source
.
source_desc
,
options
,
os
.
getcwd
())
tree
.
process_implementation
(
scope
,
options
,
result
)
def
create_generate_code
(
context
,
options
):
def
generate_code
(
module_node
):
scope
=
module_node
.
scope
result
=
create_default_resultobj
(
module_node
.
compilation_source
,
options
)
module_node
.
process_implementation
(
scope
,
options
,
result
)
return
result
return
generate_code
def
create_default_pipeline
(
context
,
scope
,
options
):
def
create_default_pipeline
(
context
,
options
):
from
ParseTreeTransforms
import
WithTransform
,
PostParse
return
[
create_parse
(
context
,
scope
),
create_parse
(
context
),
PostParse
(),
WithTransform
(),
create_generate_code
(
context
,
scope
,
options
)
create_generate_code
(
context
,
options
)
]
def
create_default_resultobj
(
source_desc
,
options
,
cwd
):
def
create_default_resultobj
(
compilation_source
,
options
):
result
=
CompilationResult
()
result
.
main_source_file
=
source_desc
.
filename
result
.
main_source_file
=
compilation_source
.
source_desc
.
filename
source_desc
=
compilation_source
.
source_desc
if
options
.
output_file
:
result
.
c_file
=
os
.
path
.
join
(
cwd
,
options
.
output_file
)
result
.
c_file
=
os
.
path
.
join
(
c
ompilation_source
.
c
wd
,
options
.
output_file
)
else
:
if
options
.
cplus
:
c_suffix
=
".cpp"
...
...
@@ -379,13 +389,10 @@ def run_pipeline(source, options = None, full_module_name = None):
cwd
=
os
.
getcwd
()
source_desc
=
FileSourceDescriptor
(
os
.
path
.
join
(
cwd
,
source
))
full_module_name
=
full_module_name
or
context
.
extract_module_name
(
source
,
options
)
source
=
CompilationSource
(
source_desc
,
full_module_name
)
source
=
CompilationSource
(
source_desc
,
full_module_name
,
cwd
)
# Get pipeline
initial_pos
=
(
source_desc
,
1
,
0
)
scope
=
context
.
find_module
(
full_module_name
,
pos
=
initial_pos
,
need_pxd
=
0
)
pipeline
=
create_default_pipeline
(
context
,
scope
,
options
)
pipeline
=
create_default_pipeline
(
context
,
options
)
data
=
source
errors_occurred
=
False
...
...
Cython/Compiler/ModuleNode.py
View file @
868538b3
...
...
@@ -32,6 +32,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# referenced_modules [ModuleScope]
# module_temp_cname string
# full_module_name string
#
# scope The module scope.
# compilation_source A CompilationSource (see Main)
child_attrs
=
[
"body"
]
...
...
@@ -45,6 +48,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
body
.
analyse_declarations
(
env
)
def
process_implementation
(
self
,
env
,
options
,
result
):
# Currently, scope is also set by the parse step in Main.py; they will be the same
assert
self
.
scope
is
env
self
.
scope
=
env
from
ParseTreeTransforms
import
AnalyseDeclarationsTransform
,
AnalyseExpressionsTransform
AnalyseDeclarationsTransform
(
env
).
visit_ModuleNode
(
self
)
# self.analyse_declarations(env)
...
...
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