forked from amazon-ion/ion-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnnotationSIDOpcodeHandler.kt
More file actions
31 lines (29 loc) · 1.19 KB
/
AnnotationSIDOpcodeHandler.kt
File metadata and controls
31 lines (29 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package com.amazon.ion.bytecode.bin11.bytearray
import com.amazon.ion.bytecode.ir.Instructions
import com.amazon.ion.bytecode.ir.Instructions.packInstructionData
import com.amazon.ion.bytecode.util.AppendableConstantPoolView
import com.amazon.ion.bytecode.util.BytecodeBuffer
/**
* Writes an annotation with symbol address to the bytecode buffer. Handles opcode `0x58`.
*/
internal object AnnotationSIDOpcodeHandler : OpcodeToBytecodeHandler {
@OptIn(ExperimentalStdlibApi::class)
override fun convertOpcodeToBytecode(
opcode: Int,
source: ByteArray,
position: Int,
destination: BytecodeBuffer,
constantPool: AppendableConstantPoolView,
macroSrc: IntArray,
macroIndices: IntArray,
symbolTable: Array<String?>
): Int {
val sidValueAndLength = PrimitiveDecoder.readFlexUIntValueAndLength(source, position)
val sid = sidValueAndLength.toInt()
val length = sidValueAndLength.shr(Int.SIZE_BITS).toInt()
destination.add(Instructions.I_ANNOTATION_SID.packInstructionData(sid))
return length
}
}