Partager via


2.4.4.17.5 Literal Tokens

Token Type

Byte-Code

Token Data Encoding

Invalid token

0x00

Padding value.

Signed int8

0x01

1 QWORD, least significant byte first, for the value, 2's complement, -128 to +127.

1 BYTE for sign. (possible values for sign in the following table) .

1 BYTE for base. (possible values for base in the following table).

Signed int16

0x02

1 QWORD, least significant byte first, 2's complement, -32768 to +32767.

1 BYTE for sign.

1 BYTE for base.

Signed int32

0x03

1 QWORD, least significant byte first, 2's complement.

1 BYTE for sign.

1 BYTE for base.

Signed int64

0x04

1 QWORD, least significant byte first, 2's complement.

1 BYTE for sign.

1 BYTE for base.

Unicode String

0x10

1 DWORD for the length in bytes.

1 WORD for each Unicode character. Characters are stored LSB first. Strings are not null-terminated.

Octet String

0x18

Custom data is represented as a contiguous sequence of bytes.

1 DWORD for the length in bytes.

1 BYTE for each data octet.

Composite

0x50

1 DWORD that specifies the entire length in bytes of the entire set of elements.

List type--can be heterogeneous. Elements are stored in contiguous fashion according to the built-in data type storage rules.

SID

0x51

1 DWORD that specifies the entire length in bytes of the SID.

SID in binary representation (as specified in section 2.4.2.2.)

Tokens in the preceding table that contain a base MUST include a base code from the following table.

Base

Code

Description

8

0x01

Octal

10

0x02

Decimal

16

0x03

Hexadecimal

Tokens in the preceding table that contain signs MUST include a sign code from the following table.

Relational operators interpret no sign (0x03) as positive.

Relational operators MUST use this to determine the sign of the literal during evaluation.

Sign

Code

Description

+

0x01

Plus sign in condition.

-

0x02

Minus sign in condition.

None

0x03

No sign in condition.

Thus the decimal value -1 encoded as a signed int64 would have the following binary representation (byte code, QWORD, sign byte, base byte):

 0x04 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x02 0x02
  

There are several things to note in the example. The sign and base bytes are used for display of the value. Even though the base byte indicates base 10, the value is stored as a 2's complement binary value. However, it will be displayed as a base 10 number.

The sign byte is handled similarly though with one important difference. If the sign byte indicates no sign, the value is treated as a positive number when displayed but appears with no explicit sign. However, when the value is used with a relational operator, the sign byte overrides the 2's complement sign.