Skip to content

Conversation

nirosys
Copy link
Contributor

@nirosys nirosys commented Sep 9, 2025

Issue #, if available: #943

Description of changes:
Prior to this PR supported tagless encoding was limited to unsigned int types. This PR extends the types to include signed integers (int8, int16, int32, and int64).

CLI Testing

Below is an inspect of an encoding and usage of the following macro:

(macro foo (int8::a int16::b int32::c int64::d)
   (.sum (.sum (%a) (%b)) (.sum (%c) (%d)))
)
 ./target/release/ion inspect ../sandbox/tagless_output/output-ints.10n
┌──────────────┬──────────────┬─────────────────────────┬──────────────────────┐
│    Offset    │    Length    │       Binary Ion        │       Text Ion       │
├──────────────┼──────────────┼─────────────────────────┼──────────────────────┘
│            0 │            4 │ e0 01 01 ea             │ $ion_1_1 // Version marker
├──────────────┼──────────────┼─────────────────────────┤
│            4 │            6 │ e7 f9 24 69 6f 6e       │ $ion:: // <text>
│           10 │          110 │ fc d9                   │ (
│           12 │            2 │ ee 10                   │ · module
│           14 │            2 │ a1 5f                   │ · _
│           16 │            5 │ c4                      │ · (
│           17 │            2 │ ee 0f                   │ · · symbol_table
│           19 │            2 │ a1 5f                   │ · · _
│              │              │                         │ · )
│           21 │           99 │ fc c3                   │ · (
│           23 │            2 │ ee 0e                   │ · · macro_table
│           25 │            2 │ a1 5f                   │ · · _
│           27 │           93 │ fc b7                   │ · · (
│           29 │            6 │ a5 6d 61 63 72 6f       │ · · · macro
│           35 │            4 │ a3 66 6f 6f             │ · · · foo
│           39 │           37 │ fc 47                   │ · · · (
│           41 │            6 │ e7 f9 69 6e 74 38       │ · · · · int8:: // <text>
│           47 │            2 │ a1 61                   │ · · · · a
│           49 │            7 │ e7 f7 69 6e 74 31 36    │ · · · · int16:: // <text>
│           56 │            2 │ a1 62                   │ · · · · b
│           58 │            7 │ e7 f7 69 6e 74 33 32    │ · · · · int32:: // <text>
│           65 │            2 │ a1 63                   │ · · · · c
│           67 │            7 │ e7 f7 69 6e 74 36 34    │ · · · · int64:: // <text>
│           74 │            2 │ a1 64                   │ · · · · d
│              │              │                         │ · · · )
│           76 │           44 │ fc 55                   │ · · · (
│           78 │            2 │ a1 2e                   │ · · · · '.'
│           80 │            4 │ a3 73 75 6d             │ · · · · sum
│           84 │           18 │ fc 21                   │ · · · · (
│           86 │            2 │ a1 2e                   │ · · · · · '.'
│           88 │            4 │ a3 73 75 6d             │ · · · · · sum
│           92 │            5 │ c4                      │ · · · · · (
│           93 │            2 │ a1 25                   │ · · · · · · '%'
│           95 │            2 │ a1 61                   │ · · · · · · a
│              │              │                         │ · · · · · )
│           97 │            5 │ c4                      │ · · · · · (
│           98 │            2 │ a1 25                   │ · · · · · · '%'
│          100 │            2 │ a1 62                   │ · · · · · · b
│              │              │                         │ · · · · · )
│              │              │                         │ · · · · )
│          102 │           18 │ fc 21                   │ · · · · (
│          104 │            2 │ a1 2e                   │ · · · · · '.'
│          106 │            4 │ a3 73 75 6d             │ · · · · · sum
│          110 │            5 │ c4                      │ · · · · · (
│          111 │            2 │ a1 25                   │ · · · · · · '%'
│          113 │            2 │ a1 63                   │ · · · · · · c
│              │              │                         │ · · · · · )
│          115 │            5 │ c4                      │ · · · · · (
│          116 │            2 │ a1 25                   │ · · · · · · '%'
│          118 │            2 │ a1 64                   │ · · · · · · d
│              │              │                         │ · · · · · )
│              │              │                         │ · · · · )
│              │              │                         │ · · · )
│              │              │                         │ · · )
│              │              │                         │ · )
│              │              │                         │ )
├──────────────┼──────────────┼─────────────────────────┤
│          120 │           16 │ 18                      │ (:foo
│          121 │            1 │ ff                      │ · -1 // a
│          122 │            2 │ fe ff                   │ · -2 // b
│          124 │            4 │ fd ff ff ff             │ · -3 // c
│          128 │            8 │ 1e 00 00 00 00 00 00 00 │ · 30 // d
│              │              │                         │ )
│              │              │                         │ 24
├──────────────┼──────────────┼─────────────────────────┤
│          136 │              │                         │  // End of stream
└──────────────┴──────────────┴─────────────────────────┘

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

@nirosys nirosys marked this pull request as ready for review September 9, 2025 23:30
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.

1 participant