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

Adds macro compiler #697

Merged
merged 2 commits into from
Jan 25, 2024
Merged

Conversation

popematt
Copy link
Contributor

Issue #, if available:

None

Description of changes:

  • Adds MacroCompiler, a class that can decorate an IonReader to read TemplateMacros from it.
  • Promotes signature to be a property of the Macro interface.
  • Moves MacroSignature.Parameter to Macro interface. (And the parameter encoding enum.)
  • Removes MacroSignature in favor of using List<Macro.Parameter>
  • Overrides hashCode and equals in TemplateMacro to use a cached hashcode value.
  • Rewrite of TemplateExpression so that it's completely flat instead of having nested IonElement trees, as well as renaming it to TemplateBodyExpression.
  • Adds toString, hashCode, and equals to FakeSymbolToken

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@popematt popematt force-pushed the compile-macros branch 2 times, most recently from 263be46 to 17d884a Compare January 16, 2024 22:54
Copy link

codecov bot commented Jan 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (ion-11-encoding@82d4497). Click here to learn what that means.

Additional details and impacted files
@@                Coverage Diff                 @@
##             ion-11-encoding     #697   +/-   ##
==================================================
  Coverage                   ?   65.38%           
  Complexity                 ?     5963           
==================================================
  Files                      ?      201           
  Lines                      ?    25499           
  Branches                   ?     4534           
==================================================
  Hits                       ?    16673           
  Misses                     ?     7488           
  Partials                   ?     1338           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@popematt popematt requested review from zslayton and tgregg January 16, 2024 23:12
src/main/java/com/amazon/ion/impl/macro/Macro.kt Outdated Show resolved Hide resolved
src/main/java/com/amazon/ion/impl/macro/MacroCompiler.kt Outdated Show resolved Hide resolved
src/main/java/com/amazon/ion/impl/macro/MacroCompiler.kt Outdated Show resolved Hide resolved
data class IntValue(val annotations: List<SymbolToken> = emptyList(), val value: Long) : TemplateBodyExpression
data class BigIntValue(val annotations: List<SymbolToken> = emptyList(), val value: BigInteger) : TemplateBodyExpression
data class FloatValue(val annotations: List<SymbolToken> = emptyList(), val value: Double) : TemplateBodyExpression
data class DecimalValue(val annotations: List<SymbolToken> = emptyList(), val value: BigDecimal) : TemplateBodyExpression
Copy link
Contributor

Choose a reason for hiding this comment

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

Will probably have to be Decimal to support -0...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decimal extends BigDecimal, so this can be constructed with a -0 decimal, but I can't think of any problem with changing it to Decimal here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it ends up making the tests (or other programmatic construction of a template body) more annoying if I change this to Decimal. I'm going to leave it for now, and we can revisit it later if it causes problems.

@popematt popematt merged commit a73a38f into amazon-ion:ion-11-encoding Jan 25, 2024
22 of 33 checks passed
tgregg pushed a commit that referenced this pull request Feb 10, 2024
tgregg pushed a commit that referenced this pull request May 2, 2024
tgregg pushed a commit that referenced this pull request Jun 28, 2024
tgregg pushed a commit that referenced this pull request Sep 9, 2024
tgregg pushed a commit that referenced this pull request Dec 13, 2024
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