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

Add class_path as a record type #11477

Merged
merged 14 commits into from
Jan 11, 2024
Merged

Add class_path as a record type #11477

merged 14 commits into from
Jan 11, 2024

Conversation

Simn
Copy link
Member

@Simn Simn commented Jan 8, 2024

Instead of a string list we now have a record with a path and a kind. Currently, the only kind is Directory because all I want for now is parity. Ultimately, I'd like to look into zip/archive class paths, and distinguish user/lib/std class paths explicitly.

@Simn
Copy link
Member Author

Simn commented Jan 9, 2024

To be honest, the diff here looks pretty awkward with all the path.Path.path business. I'll see if this can be encapsulated a bit better...

@Simn
Copy link
Member Author

Simn commented Jan 10, 2024

I ended up doing a bit more than I originally wanted, but all these should be good changes:

  • class paths are now instances of ClassPath.class_path instead of raw strings, carrying some additional information and making this easily extensible. They all have their own readdir_cache, which was previously indexed by their path already anyway.
  • Instead of matching against "std" and "_std" in various places, the compiler now tracks the scope of such class paths, which is Std and StdTarget respectively. This also led to the removal of com.std_path
  • Similarly, class paths that come from haxelib have a Lib scope. This should make it possible to have something like -dce lib running on std and library, but not user code.
  • The main file resolution function find_file now lives in ClassPaths.class_paths and has been greatly simplified. The file_lookup_cache also moved there.
  • Resolved files are associated with the class path that was used to find them in ClassPaths.resolved_file. This distinction will allow consumers (that care) to adapt their behavior. For instance, the parser could read a file from a .zip archive instead of the disk.

Something else we could do now is associate modules with class paths. I'm not sure yet if this is useful for the compilation cache, but it's good to have the option.

@kLabz Would be good to test Shiro codebases with this, there's a chance that I missed some behavioral change.

Simn added 2 commits January 11, 2024 09:48
# Conflicts:
#	src/compiler/retyper.ml
# Conflicts:
#	src/typing/macroContext.ml
@kLabz kLabz merged commit ba272a6 into development Jan 11, 2024
121 of 122 checks passed
@kLabz kLabz mentioned this pull request Jan 12, 2024
@Simn Simn deleted the class_path branch January 15, 2024 15:03
0b1kn00b pushed a commit to 0b1kn00b/haxe that referenced this pull request Jan 25, 2024
* add class_path as a record type

* one thing led to another...

* add secret -libcp CLI argument to distinguish library class paths

We don't know the name of the lib though because haxelib doesn't tell us in an obvious way, and I can't be parsed to arse it out of the preceeding -D or something...

* embrace plural

* don't debug

* make find_file control flow a bit less silly

* check current file while caching so we don't have to find it afterwards

* do we actually need this special case?

Since we always have the empty class path anyway, this should just work via normal recursion. Maybe.

* store class path alongside file

* so that's what that does
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