Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenVMS
Python
Modules
cython
Commits
e15c6702a0ef
Commit
e15c6702a0ef
authored
17 years ago
by
Dag Sverre Seljebotn
Browse files
Options
Downloads
Patches
Plain Diff
Have the code generator transform generate the CompilationResult
parent
840634a555b8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Cython/Compiler/Main.py
+11
-76
11 additions, 76 deletions
Cython/Compiler/Main.py
with
11 additions
and
76 deletions
Cython/Compiler/Main.py
+
11
−
76
View file @
e15c6702
...
@@ -58,6 +58,8 @@
...
@@ -58,6 +58,8 @@
#self.modules = {"__builtin__" : BuiltinScope()}
#self.modules = {"__builtin__" : BuiltinScope()}
import
Builtin
import
Builtin
self
.
modules
=
{
"
__builtin__
"
:
Builtin
.
builtin_scope
}
self
.
modules
=
{
"
__builtin__
"
:
Builtin
.
builtin_scope
}
self
.
pxds
=
{}
self
.
pyxs
=
{}
self
.
include_directories
=
include_directories
self
.
include_directories
=
include_directories
self
.
future_directives
=
set
()
self
.
future_directives
=
set
()
...
@@ -285,74 +287,6 @@
...
@@ -285,74 +287,6 @@
names
.
reverse
()
names
.
reverse
()
return
"
.
"
.
join
(
names
)
return
"
.
"
.
join
(
names
)
def
compile
(
self
,
source
,
options
=
None
,
full_module_name
=
None
):
raise
Exception
(
"
Deprecated
"
)
# Compile a Pyrex implementation file in this context
# and return a CompilationResult.
if
not
options
:
options
=
default_options
result
=
CompilationResult
()
cwd
=
os
.
getcwd
()
source
=
os
.
path
.
join
(
cwd
,
source
)
result
.
main_source_file
=
source
if
options
.
use_listing_file
:
result
.
listing_file
=
Utils
.
replace_suffix
(
source
,
"
.lis
"
)
Errors
.
open_listing_file
(
result
.
listing_file
,
echo_to_stderr
=
options
.
errors_to_stderr
)
else
:
Errors
.
open_listing_file
(
None
)
if
options
.
output_file
:
result
.
c_file
=
os
.
path
.
join
(
cwd
,
options
.
output_file
)
else
:
if
options
.
cplus
:
c_suffix
=
"
.cpp
"
else
:
c_suffix
=
"
.c
"
result
.
c_file
=
Utils
.
replace_suffix
(
source
,
c_suffix
)
c_stat
=
None
if
result
.
c_file
:
try
:
c_stat
=
os
.
stat
(
result
.
c_file
)
except
EnvironmentError
:
pass
full_module_name
=
full_module_name
or
self
.
extract_module_name
(
source
,
options
)
source
=
FileSourceDescriptor
(
source
)
initial_pos
=
(
source
,
1
,
0
)
scope
=
self
.
find_module
(
full_module_name
,
pos
=
initial_pos
,
need_pxd
=
0
)
errors_occurred
=
False
try
:
tree
=
self
.
parse
(
source
,
scope
,
pxd
=
0
,
full_module_name
=
full_module_name
)
from
ParseTreeTransforms
import
WithTransform
,
PostParse
tree
=
PostParse
()(
tree
)
tree
=
WithTransform
()(
tree
)
tree
.
process_implementation
(
scope
,
options
,
result
)
except
CompileError
:
errors_occurred
=
True
Errors
.
close_listing_file
()
result
.
num_errors
=
Errors
.
num_errors
if
result
.
num_errors
>
0
:
errors_occurred
=
True
if
errors_occurred
and
result
.
c_file
:
try
:
Utils
.
castrate_file
(
result
.
c_file
,
os
.
stat
(
source
.
filename
))
except
EnvironmentError
:
pass
result
.
c_file
=
None
if
result
.
c_file
and
not
options
.
c_only
and
c_compile
:
result
.
object_file
=
c_compile
(
result
.
c_file
,
verbose_flag
=
options
.
show_version
,
cplus
=
options
.
cplus
)
if
not
options
.
obj_only
and
c_link
:
result
.
extension_file
=
c_link
(
result
.
object_file
,
extra_objects
=
options
.
objects
,
verbose_flag
=
options
.
show_version
,
cplus
=
options
.
cplus
)
return
result
def
setup_errors
(
self
,
options
):
def
setup_errors
(
self
,
options
):
if
options
.
use_listing_file
:
if
options
.
use_listing_file
:
result
.
listing_file
=
Utils
.
replace_suffix
(
source
,
"
.lis
"
)
result
.
listing_file
=
Utils
.
replace_suffix
(
source
,
"
.lis
"
)
...
@@ -393,6 +327,7 @@
...
@@ -393,6 +327,7 @@
source_desc
=
compsrc
.
source_desc
source_desc
=
compsrc
.
source_desc
full_module_name
=
compsrc
.
full_module_name
full_module_name
=
compsrc
.
full_module_name
tree
=
context
.
parse
(
source_desc
,
scope
,
pxd
=
0
,
full_module_name
=
full_module_name
)
tree
=
context
.
parse
(
source_desc
,
scope
,
pxd
=
0
,
full_module_name
=
full_module_name
)
tree
.
compilation_source
=
compsrc
return
tree
return
tree
return
parse
return
parse
...
@@ -396,5 +331,5 @@
...
@@ -396,5 +331,5 @@
return
tree
return
tree
return
parse
return
parse
def
create_generate_code
(
context
,
scope
,
options
,
result
):
def
create_generate_code
(
context
,
scope
,
options
):
def
generate_code
(
tree
):
def
generate_code
(
tree
):
...
@@ -400,2 +335,3 @@
...
@@ -400,2 +335,3 @@
def
generate_code
(
tree
):
def
generate_code
(
tree
):
result
=
create_default_resultobj
(
tree
.
compilation_source
.
source_desc
,
options
,
os
.
getcwd
())
tree
.
process_implementation
(
scope
,
options
,
result
)
tree
.
process_implementation
(
scope
,
options
,
result
)
...
@@ -401,3 +337,4 @@
...
@@ -401,3 +337,4 @@
tree
.
process_implementation
(
scope
,
options
,
result
)
tree
.
process_implementation
(
scope
,
options
,
result
)
return
result
return
generate_code
return
generate_code
...
@@ -402,8 +339,8 @@
...
@@ -402,8 +339,8 @@
return
generate_code
return
generate_code
def
create_default_pipeline
(
context
,
scope
,
options
,
result
):
def
create_default_pipeline
(
context
,
scope
,
options
):
from
ParseTreeTransforms
import
WithTransform
,
PostParse
from
ParseTreeTransforms
import
WithTransform
,
PostParse
return
[
return
[
create_parse
(
context
,
scope
),
create_parse
(
context
,
scope
),
PostParse
(),
PostParse
(),
WithTransform
(),
WithTransform
(),
...
@@ -405,9 +342,9 @@
...
@@ -405,9 +342,9 @@
from
ParseTreeTransforms
import
WithTransform
,
PostParse
from
ParseTreeTransforms
import
WithTransform
,
PostParse
return
[
return
[
create_parse
(
context
,
scope
),
create_parse
(
context
,
scope
),
PostParse
(),
PostParse
(),
WithTransform
(),
WithTransform
(),
create_generate_code
(
context
,
scope
,
options
,
result
)
create_generate_code
(
context
,
scope
,
options
)
]
]
def
create_default_resultobj
(
source_desc
,
options
,
cwd
):
def
create_default_resultobj
(
source_desc
,
options
,
cwd
):
...
@@ -444,10 +381,7 @@
...
@@ -444,10 +381,7 @@
full_module_name
=
full_module_name
or
context
.
extract_module_name
(
source
,
options
)
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
)
# Set up result object
result
=
create_default_resultobj
(
source_desc
,
options
,
cwd
)
# Get pipeline
# Get pipeline
initial_pos
=
(
source_desc
,
1
,
0
)
initial_pos
=
(
source_desc
,
1
,
0
)
scope
=
context
.
find_module
(
full_module_name
,
pos
=
initial_pos
,
need_pxd
=
0
)
scope
=
context
.
find_module
(
full_module_name
,
pos
=
initial_pos
,
need_pxd
=
0
)
...
@@ -450,6 +384,6 @@
...
@@ -450,6 +384,6 @@
# Get pipeline
# Get pipeline
initial_pos
=
(
source_desc
,
1
,
0
)
initial_pos
=
(
source_desc
,
1
,
0
)
scope
=
context
.
find_module
(
full_module_name
,
pos
=
initial_pos
,
need_pxd
=
0
)
scope
=
context
.
find_module
(
full_module_name
,
pos
=
initial_pos
,
need_pxd
=
0
)
pipeline
=
create_default_pipeline
(
context
,
scope
,
options
,
result
)
pipeline
=
create_default_pipeline
(
context
,
scope
,
options
)
...
@@ -455,3 +389,4 @@
...
@@ -455,3 +389,4 @@
data
=
source
errors_occurred
=
False
errors_occurred
=
False
try
:
try
:
...
@@ -456,7 +391,6 @@
...
@@ -456,7 +391,6 @@
errors_occurred
=
False
errors_occurred
=
False
try
:
try
:
data
=
source
for
phase
in
pipeline
:
for
phase
in
pipeline
:
data
=
phase
(
data
)
data
=
phase
(
data
)
except
CompileError
:
except
CompileError
:
errors_occurred
=
True
errors_occurred
=
True
...
@@ -459,7 +393,8 @@
...
@@ -459,7 +393,8 @@
for
phase
in
pipeline
:
for
phase
in
pipeline
:
data
=
phase
(
data
)
data
=
phase
(
data
)
except
CompileError
:
except
CompileError
:
errors_occurred
=
True
errors_occurred
=
True
result
=
data
context
.
teardown_errors
(
errors_occurred
,
options
,
result
,
source_desc
)
context
.
teardown_errors
(
errors_occurred
,
options
,
result
,
source_desc
)
return
result
return
result
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment