Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to merge initialisation and assignment in cgen? #11

Closed
richard-zhang opened this issue Sep 12, 2016 · 2 comments
Closed

How to merge initialisation and assignment in cgen? #11

richard-zhang opened this issue Sep 12, 2016 · 2 comments

Comments

@richard-zhang
Copy link

I have a cgen.Value("float", "temp") and an assignemnt, cgen.Assign("temp", "somefunc(1)"). It will generate the following C code

float temp;
temp = somefunc(1);

How to make the generated C code more nested from cgen.Value and cgen.Assign, such that it will look like:

float temp = somefunc(1);
@richard-zhang
Copy link
Author

Can I do it in this way?

import cgen as c

decl = c.Value('float', 'temp')
assign = c.Assign('temp', 'func(1)')
# make it nested
assign = c.Assign(decl.__str__()[:-1], assign.rvalue)

print(assign)

@inducer
Copy link
Owner

inducer commented Sep 12, 2016

cgen.Initializer

@inducer inducer closed this as completed Sep 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants