Skip to content
This repository has been archived by the owner on Jun 13, 2020. It is now read-only.

Struct allocation with alloc should initialize default fields #339

Closed
raoulvdberge opened this issue May 17, 2015 · 3 comments
Closed

Struct allocation with alloc should initialize default fields #339

raoulvdberge opened this issue May 17, 2015 · 3 comments

Comments

@raoulvdberge
Copy link
Contributor

No description provided.

@raoulvdberge
Copy link
Contributor Author

This is a little more complicated than I thought. Since it's an expression, this should work in every context: return, arguments in functions, ...

Since C cannot handle struct initializers without assigning, I'm not sure if we're able to do this in a clean way.

@MovingtoMars
Copy link
Member

Yeah, it's kinda difficult. That's why I didn't have it in the original PR.

One way it could be done is by creating functions like this:

__alloc_Test(): Test {
    ret: Test = alloc Test;
    ret->x = 5;
    return ret;
}

and using them in the codegen.

@felixangell
Copy link
Member

In #345

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants