Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Reorganize LinkTimeProperties. #5163

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 1 commit into from
May 7, 2025
Merged

Conversation

sjrd
Copy link
Member

@sjrd sjrd commented May 7, 2025

  • Move it to frontend.
  • Make it public.
  • Move the logic of validate and transformLinkTimeProperty to their respective call sites.
  • Construct them from a CoreSpec, rather than being contained by CoreSpec.

These changes better isolate the data (LinkTimeProperties) from the transformations we apply to that data (the logic in Analyzer and Desugarer).

Copy link
Contributor

@gzm0 gzm0 left a comment

Choose a reason for hiding this comment

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

Just optional nits. LGTM!

@@ -118,7 +120,7 @@ final class Desugarer(config: CommonPhaseConfig, checkIR: Boolean) {

private[linker] object Desugarer {

private final class DesugarTransformer(coreSpec: CoreSpec)
private final class DesugarTransformer(linkTimeProperties: LinkTimeProperties)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

implicit val pos = tree.pos
val value = linkTimeProperties.get(name).getOrElse {
throw new IllegalArgumentException(
s"link time property not found: 'name' of type ${tree.tpe}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
s"link time property not found: 'name' of type ${tree.tpe}")
s"link time property not found: '$name' of type ${tree.tpe}")

def tpe: Type = this match {
case LinkTimeInt(_) => IntType
case LinkTimeBoolean(_) => BooleanType
case LinkTimeString(_) => StringType
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Instead of self matching, pass the type as val constructor param to LinkTimeValue?

* Move it to `frontend`.
* Make it public.
* Move the logic of `validate` and `transformLinkTimeProperty` to
  their respective call sites.
* Construct them from a CoreSpec, rather than being contained by CoreSpec.

These changes better isolate the data (`LinkTimeProperties`) from the
transformations we apply to that data (the logic in `Analyzer` and `Desugarer`).
@sjrd sjrd force-pushed the reorg-link-time-properties branch from 55ff3cf to fd90409 Compare May 7, 2025 13:32
@sjrd sjrd merged commit 3ad65c7 into scala-js:main May 7, 2025
3 checks passed
@sjrd sjrd deleted the reorg-link-time-properties branch May 7, 2025 20:09
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