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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
30aff7fb
Commit
30aff7fb
authored
Jan 17, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generic constant code
parent
c5cc0c48
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+25
-2
No files found.
Cython/Compiler/Symtab.py
View file @
30aff7fb
...
...
@@ -184,6 +184,7 @@ class Scope:
self
.
pow_function_used
=
0
self
.
string_to_entry
=
{}
self
.
num_to_entry
=
{}
self
.
obj_to_entry
=
{}
self
.
pystring_entries
=
[]
def
__str__
(
self
):
...
...
@@ -470,6 +471,27 @@ class Scope:
genv
.
pynum_entries
.
append
(
entry
)
return
entry
def
add_py_obj
(
self
,
obj
,
c_prefix
=
''
):
obj
.
check_const
()
cname
=
self
.
new_const_cname
(
c_prefix
)
entry
=
Entry
(
""
,
cname
,
py_object_type
,
init
=
value
)
entry
.
used
=
1
entry
.
is_interned
=
1
self
.
const_entries
.
append
(
entry
)
self
.
interned_objs
.
append
(
entry
)
return
entry
def
get_py_obj
(
self
,
obj
,
c_prefix
=
''
):
# Get entry for a generic constant. Returns an existing
# one if possible, otherwise creates a new one.
genv
=
self
.
global_scope
()
entry
=
genv
.
obj_to_entry
.
get
(
obj
)
if
not
entry
:
entry
=
genv
.
add_py_num
(
obj
,
c_prefix
)
genv
.
obj_to_entry
[
obj
]
=
entry
return
entry
def
new_const_cname
(
self
):
# Create a new globally-unique name for a constant.
return
self
.
global_scope
().
new_const_cname
()
...
...
@@ -675,6 +697,7 @@ class ModuleScope(Scope):
self
.
intern_map
=
{}
self
.
interned_names
=
[]
self
.
interned_nums
=
[]
self
.
interned_objs
=
[]
self
.
all_pystring_entries
=
[]
self
.
types_imported
=
{}
self
.
pynum_entries
=
[]
...
...
@@ -813,11 +836,11 @@ class ModuleScope(Scope):
self
.
default_entries
.
append
(
entry
)
return
entry
def
new_const_cname
(
self
):
def
new_const_cname
(
self
,
prefix
=
''
):
# Create a new globally-unique name for a constant.
n
=
self
.
const_counter
self
.
const_counter
=
n
+
1
return
"%s%
d"
%
(
Naming
.
const_
prefix
,
n
)
return
"%s%
s_%d"
%
(
Naming
.
const_prefix
,
prefix
,
n
)
def
use_utility_code
(
self
,
new_code
):
# Add string to list of utility code to be included,
...
...
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