-
Notifications
You must be signed in to change notification settings - Fork 16
/
source_map_vlq.format.txt
41 lines (34 loc) · 4.01 KB
/
source_map_vlq.format.txt
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
32
33
34
35
36
37
38
39
40
41
SOURCE_MAP_VLQ
GOAL ==> #Arbitrary-precision signed integer
#Uses base64:
# - require less memory than using ASCII digits
# - but less escaping problems that using binary
RANGE ==> #Decoded value is 32 bits signed integer
FORMAT ==> # - sequence of 6-bits bytes
# - each is translated into one base64 [A-Za-z+/]
# - MSB last
# - first bit of each byte is 1 if there is a next byte
# - "zigzag encoding": LSB's last bit is signedness
#See integers doc for more details about VLQs
TABLE ==> #Each 6-bits byte is translated as:
#
# +------+------------------+------------------------------------------------------------------------------------------------+
# | Sign | Position | 0 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|
# +------+------------------+------------------------------------------------------------------------------------------------+
# | +/- | Last char (MSB) | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f |
# | +/- | Middle chars | g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 + / |
# | + | First & last char| A C E G I K M O Q S U W Y a c e |
# | - | First & last char| B D F H J L N P R T V X Z b d f |
# | + | First char (LSB) | g i k m o q s u w y 0 2 4 6 8 + |
# | - | First char (LSB) | h j l n p r t v x z 1 3 5 7 9 / |
# +------+------------------+------------------------------------------------------------------------------------------------+
#
#I.e. since LSB has 4 bits of significance and other bits 5 bits, should multiply:
# - LSB by 1
# - LSB+1 by 16
# - LSB+2 by 16 * 32**1
# - LSB+3 by 16 * 32**2
# - LSB+4 by 16 * 32**3
#For example, '/quD' -> - (15 + 10 * 16 + 14 * 16*32 + 3 * 16*32*32) -> -56495