-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
89 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
(ion_1_1 "a macro that can create a monomorphized variant of the values macro" | ||
(mactab (macro tiny_decimal (int8::a int8::b) (.make_decimal a b)) | ||
(macro tagless_values (mod_or_type type?) | ||
(macro | ||
// Macro name | ||
(.$ion::make_symbol (.. (%mod_or_type) (.$ion::if_some (%type) "_") (%type) "_values")) | ||
// Signature | ||
((.$ion::annotate (.. (%mod_or_type) (%type)) vals) *) | ||
// Body | ||
((.$ion::values %) vals)) | ||
)) | ||
(then "for a built-in encoding type" | ||
(toplevel ('#$:$ion::add_macros' ('#$:tagless_values' uint8))) | ||
(then "when invoked in Ion text" | ||
(text "(:uint8_values 1 2 3 4 5)") | ||
(produces 1 2 3 4 5)) | ||
(then "when invoked in Ion binary" | ||
// Invoke our new "uint8_values" macro | ||
(binary "02 02 0B 01 02 03 04 05") | ||
(produces 1 2 3 4 5))) | ||
(then "for a macro-shape" | ||
(toplevel ('#$:$ion::add_macros' ('#$:tagless_values' tiny_decimal))) | ||
// TODO: Add case demoing binary | ||
(then "when invoked in Ion text" | ||
(text "(:tiny_decimal_values (1 2) (3 4))") | ||
(produces 1d2 3d4))) | ||
(then "for a qualified type name" | ||
(toplevel ('#$:$ion::add_macros' ('#$:tagless_values' $ion make_decimal))) | ||
// TODO: Add case demoing binary | ||
(then "when invoked in Ion text" | ||
(text "(:$ion_make_decimal_values (1 2) (3 4))") | ||
(produces 1d2 3d4)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters