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

Front-end support for header_unions #606

Merged
merged 7 commits into from
May 15, 2017
Merged

Conversation

mihaibudiu
Copy link
Contributor

I renamed the IR node to header_union, in case we ever get a real union. Most changes are due to this renaming.
Def-use analysis now handles unions; not many changes were required.
Also, changed the grammar to allow empty list expressions - good for initializing empty structs.

cstring fieldName = name + "." + f->name;
auto sl = create(f->type, fieldName);
if (globalValid != nullptr)
dynamic_cast<StructLocation*>(sl)->replaceField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that dynamic_cast is used here instead of a to method?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would guess because the to methods currently all return const pointers. We should probably overload them to return non-const pointers when called on non-const objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the single call of this method.
We have to rewrite this pass at some point: #151.

// For header unions we will model all of the valid fields
// for all components as a single shared field. The
// reason is that updating one of may change all of the
// other ones.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanding this overview to what is implemented below would be helpful. (Could be done later.)

Copy link
Contributor

@jnfoster jnfoster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just a few small comments.

|| type-is<IR::Type_Error>() || type->is<IR::Type_Var>(),
{ BUG_CHECK(type->is<IR::Type_Bits>() || type->is<IR::Type_Enum>() ||
type->is<IR::Type_Boolean>() || type->is<IR::Type_Var>() ||
type->is<IR::Type_Tuple>() || type-is<IR::Type_Error>(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this not a syntax error (missing > in type-is<...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't C++ beautiful? 'is' is a method on 'this', and this is just pointer arithmetic!
Sick, I will push a fix. Note that the bug has been there for a longer time.
And I was counting on the C++ type-checker...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow.

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

Successfully merging this pull request may close these issues.

3 participants