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

Pointer value improvements #789

Merged
merged 6 commits into from
Oct 17, 2024
Merged

Pointer value improvements #789

merged 6 commits into from
Oct 17, 2024

Conversation

ehaas
Copy link
Collaborator

@ehaas ehaas commented Oct 16, 2024

Allow array-to-pointer decay to produce a pointer value
Handle address-of locals as well as globals
Rename "reloc" to pointer for consistency

ehaas added 3 commits October 15, 2024 23:38
Arrays decay to pointer values
Handle address-of locals as well as globals
@@ -30,7 +30,7 @@ fn_def: 'fn (x: int, ...) void'
builtin_call_expr: 'void'
name: __builtin_va_start
args:
implicit_cast: (array_to_pointer) 'va_list': '*d[1]struct __va_list_tag'
implicit_cast: (array_to_pointer) 'va_list': '*d[1]struct __va_list_tag' (value: )
Copy link
Owner

Choose a reason for hiding this comment

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

Would be nice if pointer values printed the offset (if non-zero).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I meant to ask about this - should I just print the offset (without the name of the variable)?

Copy link
Owner

Choose a reason for hiding this comment

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

Printing the NodeIndex probably won't be too useful so I guess just the offset is good for now. Maybe add something to distinguish it from just ints.

Copy link
Collaborator Author

@ehaas ehaas Oct 17, 2024

Choose a reason for hiding this comment

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

What if we change the return type of Value.print from @TypeOf(w).Error!void to something like @TypeOf(w).Error!?NestedPrint where NestedPrint is

const NestedPrint = union(enum) {
    pointer: struct {
        node: u32,
        offset: Value,
    },
};

and then the caller can handle it?

@Vexu Vexu merged commit 0620577 into Vexu:master Oct 17, 2024
3 checks passed
@ehaas ehaas deleted the array-value branch October 17, 2024 14:27
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.

2 participants