@@ -93,10 +93,8 @@ internal class IonManagedWriterEncodingContext_1_1 {
9393 * make sure that any prior e-expressions are still valid. In addition, we would need to re-export all
9494 * the other macros from `_` (the default module).
9595 * - For now, we're just throwing an Exception.
96- *
97- * Visible for testing.
9896 */
99- fun getOrAssignMacroAddressAndName (name : String , macro : MacroImpl ): Int {
97+ private fun getOrAssignMacroAddressAndName (name : String , macro : MacroImpl ): Int {
10098 // TODO: This is O(n), but could be O(1).
10199 var existingAddress = macroNames.indexOf(name)
102100 if (existingAddress < 0 ) {
@@ -131,7 +129,7 @@ internal class IonManagedWriterEncodingContext_1_1 {
131129 * 2. Check newMacros, if found, return that address
132130 * 3. Add to newMacros, return new address
133131 */
134- fun getOrAssignMacroAddress (macro : MacroImpl ): Int {
132+ private fun getOrAssignMacroAddress (macro : MacroImpl ): Int {
135133 var address = macroTable.getOrDefault(macro, - 1 )
136134 if (address >= 0 ) return address
137135 address = newMacros.getOrDefault(macro, - 1 )
@@ -140,6 +138,13 @@ internal class IonManagedWriterEncodingContext_1_1 {
140138 return assignMacroAddress(macro)
141139 }
142140
141+ fun getOrAssignMacroAddress (macro : MacroImpl , name : String? ): Int {
142+ return if (name == null )
143+ getOrAssignMacroAddress(macro)
144+ else
145+ getOrAssignMacroAddressAndName(name, macro)
146+ }
147+
143148 fun getMacroNameForId (id : Int ): String? = macroNames[id]
144149
145150 /* * Unconditionally adds a macro to the macro table data structures and returns the new address. */
0 commit comments