Skip to content

compiler: refactor globals and named types #401

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

Merged
merged 2 commits into from
Jun 8, 2019
Merged

compiler: refactor globals and named types #401

merged 2 commits into from
Jun 8, 2019

Conversation

aykevl
Copy link
Member

@aykevl aykevl commented Jun 8, 2019

Trying to get rid of the ir package, that is not necessary anymore and has been holding back other refactors (in particular, #285).

There is more to come, but refactoring functions in the same way has far more side effects so needs some more fixes (like #399).

aykevl added 2 commits June 8, 2019 14:59
This commit refactors named types to be created lazily. Instead of
defining all types in advance, do it only when necessary.
This is part of a larger rafactor that tries to shrink the ir package
and in general tries to shrink the amount of state that is kept around
in the compiler. The end goal is being able to compile packages
independent of each other, linking them together in a later stage. Along
the way, it cleans up lots of old cruft that has accumulated over the
months.

This refactor also results in globals being loaded lazily. This may be a
problem for some specific programs but will probably change back in a
commit in the near future.

// loadASTComments loads comments on globals from the AST, for use later in the
// program. In particular, they are required for //go:extern pragmas on globals.
func (c *Compiler) loadASTComments(lprogram *loader.Program) {
Copy link
Member

Choose a reason for hiding this comment

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

OMG this function... yes I know it is just in a new location, but this just brings it to our collective attention. 😸

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I know but it's the only way to support pragmas on globals. I would really like to get rid of it as it's rather dirty.

@deadprogram
Copy link
Member

Now merging...

@deadprogram deadprogram merged commit b0e767c into dev Jun 8, 2019
@deadprogram deadprogram deleted the refactor-ir branch June 8, 2019 20:17
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