Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephan Seitz
pystencils
Commits
995da7fc
Commit
995da7fc
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Add option to omit globals when printing C code
parent
9f76ea1d
Branches
omit-globals-when-printing-c-code
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#18976
passed
5 years ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils/backends/cbackend.py
+9
-4
9 additions, 4 deletions
pystencils/backends/cbackend.py
with
9 additions
and
4 deletions
pystencils/backends/cbackend.py
+
9
−
4
View file @
995da7fc
...
...
@@ -26,7 +26,11 @@ __all__ = ['generate_c', 'CustomCodeNode', 'PrintNode', 'get_headers', 'CustomSy
KERNCRAFT_NO_TERNARY_MODE
=
False
def
generate_c
(
ast_node
:
Node
,
signature_only
:
bool
=
False
,
dialect
=
'
c
'
,
custom_backend
=
None
)
->
str
:
def
generate_c
(
ast_node
:
Node
,
signature_only
:
bool
=
False
,
dialect
=
'
c
'
,
custom_backend
=
None
,
with_globals
=
True
)
->
str
:
"""
Prints an abstract syntax tree node as C or CUDA code.
This function does not need to distinguish between C, C++ or CUDA code, it just prints
'
C-like
'
code as encoded
...
...
@@ -65,9 +69,10 @@ def generate_c(ast_node: Node, signature_only: bool = False, dialect='c', custom
raise
ValueError
(
"
Unknown dialect:
"
+
str
(
dialect
))
code
=
printer
(
ast_node
)
if
not
signature_only
and
isinstance
(
ast_node
,
KernelFunction
):
code
=
"
\n
"
+
code
for
declaration
in
global_declarations
:
code
=
printer
(
declaration
)
+
"
\n
"
+
code
if
with_globals
and
global_declarations
:
code
=
"
\n
"
+
code
for
declaration
in
global_declarations
:
code
=
printer
(
declaration
)
+
"
\n
"
+
code
return
code
...
...
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