|
| 1 | +package dotty.tools |
| 2 | +package dotc |
| 3 | +package core |
| 4 | +package unpickleScala2 |
| 5 | + |
| 6 | +/** This object provides constants for pickling attributes. |
| 7 | + * |
| 8 | + * If you extend the format, be sure to increase the |
| 9 | + * version minor number. |
| 10 | + * |
| 11 | + * This was adapted from https://github.com/scala/scala/blob/2.11.x/src/reflect/scala/reflect/internal/pickling/PickleFormat.scala |
| 12 | + * |
| 13 | + * @author Martin Odersky |
| 14 | + * @version 1.0 |
| 15 | + */ |
| 16 | +object PickleFormat { |
| 17 | + |
| 18 | +/*************************************************** |
| 19 | + * Symbol table attribute format: |
| 20 | + * Symtab = nentries_Nat {Entry} |
| 21 | + * Entry = 1 TERMNAME len_Nat NameInfo |
| 22 | + * | 2 TYPENAME len_Nat NameInfo |
| 23 | + * | 3 NONEsym len_Nat |
| 24 | + * | 4 TYPEsym len_Nat SymbolInfo |
| 25 | + * | 5 ALIASsym len_Nat SymbolInfo |
| 26 | + * | 6 CLASSsym len_Nat SymbolInfo [thistype_Ref] |
| 27 | + * | 7 MODULEsym len_Nat SymbolInfo |
| 28 | + * | 8 VALsym len_Nat [defaultGetter_Ref /* no longer needed*/] SymbolInfo [alias_Ref] |
| 29 | + * | 9 EXTref len_Nat name_Ref [owner_Ref] |
| 30 | + * | 10 EXTMODCLASSref len_Nat name_Ref [owner_Ref] |
| 31 | + * | 11 NOtpe len_Nat |
| 32 | + * | 12 NOPREFIXtpe len_Nat |
| 33 | + * | 13 THIStpe len_Nat sym_Ref |
| 34 | + * | 14 SINGLEtpe len_Nat type_Ref sym_Ref |
| 35 | + * | 15 CONSTANTtpe len_Nat constant_Ref |
| 36 | + * | 16 TYPEREFtpe len_Nat type_Ref sym_Ref {targ_Ref} |
| 37 | + * | 17 TYPEBOUNDStpe len_Nat tpe_Ref tpe_Ref |
| 38 | + * | 18 REFINEDtpe len_Nat classsym_Ref {tpe_Ref} |
| 39 | + * | 19 CLASSINFOtpe len_Nat classsym_Ref {tpe_Ref} |
| 40 | + * | 20 METHODtpe len_Nat tpe_Ref {sym_Ref} |
| 41 | + * | 21 POLYTtpe len_Nat tpe_Ref {sym_Ref} |
| 42 | + * | 22 IMPLICITMETHODtpe len_Nat tpe_Ref {sym_Ref} /* no longer needed */ |
| 43 | + * | 52 SUPERtpe len_Nat tpe_Ref tpe_Ref |
| 44 | + * | 24 LITERALunit len_Nat |
| 45 | + * | 25 LITERALboolean len_Nat value_Long |
| 46 | + * | 26 LITERALbyte len_Nat value_Long |
| 47 | + * | 27 LITERALshort len_Nat value_Long |
| 48 | + * | 28 LITERALchar len_Nat value_Long |
| 49 | + * | 29 LITERALint len_Nat value_Long |
| 50 | + * | 30 LITERALlong len_Nat value_Long |
| 51 | + * | 31 LITERALfloat len_Nat value_Long |
| 52 | + * | 32 LITERALdouble len_Nat value_Long |
| 53 | + * | 33 LITERALstring len_Nat name_Ref |
| 54 | + * | 34 LITERALnull len_Nat |
| 55 | + * | 35 LITERALclass len_Nat tpe_Ref |
| 56 | + * | 36 LITERALenum len_Nat sym_Ref |
| 57 | + * | 40 SYMANNOT len_Nat sym_Ref AnnotInfoBody |
| 58 | + * | 41 CHILDREN len_Nat sym_Ref {sym_Ref} |
| 59 | + * | 42 ANNOTATEDtpe len_Nat [sym_Ref /* no longer needed */] tpe_Ref {annotinfo_Ref} |
| 60 | + * | 43 ANNOTINFO len_Nat AnnotInfoBody |
| 61 | + * | 44 ANNOTARGARRAY len_Nat {constAnnotArg_Ref} |
| 62 | + * | 47 DEBRUIJNINDEXtpe len_Nat level_Nat index_Nat /* no longer needed */ |
| 63 | + * | 48 EXISTENTIALtpe len_Nat type_Ref {symbol_Ref} |
| 64 | + * | 49 TREE len_Nat 1 EMPTYtree |
| 65 | + * | 49 TREE len_Nat 2 PACKAGEtree type_Ref sym_Ref mods_Ref name_Ref {tree_Ref} |
| 66 | + * | 49 TREE len_Nat 3 CLASStree type_Ref sym_Ref mods_Ref name_Ref tree_Ref {tree_Ref} |
| 67 | + * | 49 TREE len_Nat 4 MODULEtree type_Ref sym_Ref mods_Ref name_Ref tree_Ref |
| 68 | + * | 49 TREE len_Nat 5 VALDEFtree type_Ref sym_Ref mods_Ref name_Ref tree_Ref tree_Ref |
| 69 | + * | 49 TREE len_Nat 6 DEFDEFtree type_Ref sym_Ref mods_Ref name_Ref numtparams_Nat {tree_Ref} numparamss_Nat {numparams_Nat {tree_Ref}} tree_Ref tree_Ref |
| 70 | + * | 49 TREE len_Nat 7 TYPEDEFtree type_Ref sym_Ref mods_Ref name_Ref tree_Ref {tree_Ref} |
| 71 | + * | 49 TREE len_Nat 8 LABELtree type_Ref sym_Ref tree_Ref {tree_Ref} |
| 72 | + * | 49 TREE len_Nat 9 IMPORTtree type_Ref sym_Ref tree_Ref {name_Ref name_Ref} |
| 73 | + * | 49 TREE len_Nat 11 DOCDEFtree type_Ref sym_Ref string_Ref tree_Ref |
| 74 | + * | 49 TREE len_Nat 12 TEMPLATEtree type_Ref sym_Ref numparents_Nat {tree_Ref} tree_Ref {tree_Ref} |
| 75 | + * | 49 TREE len_Nat 13 BLOCKtree type_Ref tree_Ref {tree_Ref} |
| 76 | + * | 49 TREE len_Nat 14 CASEtree type_Ref tree_Ref tree_Ref tree_Ref |
| 77 | + * | 49 TREE len_Nat 15 SEQUENCEtree type_Ref {tree_Ref} |
| 78 | + * | 49 TREE len_Nat 16 ALTERNATIVEtree type_Ref {tree_Ref} |
| 79 | + * | 49 TREE len_Nat 17 STARtree type_Ref {tree_Ref} |
| 80 | + * | 49 TREE len_Nat 18 BINDtree type_Ref sym_Ref name_Ref tree_Ref |
| 81 | + * | 49 TREE len_Nat 19 UNAPPLYtree type_Ref tree_Ref {tree_Ref} |
| 82 | + * | 49 TREE len_Nat 20 ARRAYVALUEtree type_Ref tree_Ref {tree_Ref} |
| 83 | + * | 49 TREE len_Nat 21 FUNCTIONtree type_Ref sym_Ref tree_Ref {tree_Ref} |
| 84 | + * | 49 TREE len_Nat 22 ASSIGNtree type_Ref tree_Ref tree_Ref |
| 85 | + * | 49 TREE len_Nat 23 IFtree type_Ref tree_Ref tree_Ref tree_Ref |
| 86 | + * | 49 TREE len_Nat 24 MATCHtree type_Ref tree_Ref {tree_Ref} |
| 87 | + * | 49 TREE len_Nat 25 RETURNtree type_Ref sym_Ref tree_Ref |
| 88 | + * | 49 TREE len_Nat 26 TREtree type_Ref tree_Ref tree_Ref {tree_Ref} |
| 89 | + * | 49 TREE len_Nat 27 THROWtree type_Ref tree_Ref |
| 90 | + * | 49 TREE len_Nat 28 NEWtree type_Ref tree_Ref |
| 91 | + * | 49 TREE len_Nat 29 TYPEDtree type_Ref tree_Ref tree_Ref |
| 92 | + * | 49 TREE len_Nat 30 TYPEAPPLYtree type_Ref tree_Ref {tree_Ref} |
| 93 | + * | 49 TREE len_Nat 31 APPLYtree type_Ref tree_Ref {tree_Ref} |
| 94 | + * | 49 TREE len_Nat 32 APPLYDYNAMICtree type_Ref sym_Ref tree_Ref {tree_Ref} |
| 95 | + * | 49 TREE len_Nat 33 SUPERtree type_Ref sym_Ref tree_Ref name_Ref |
| 96 | + * | 49 TREE len_Nat 34 THIStree type_Ref sym_Ref name_Ref |
| 97 | + * | 49 TREE len_Nat 35 SELECTtree type_Ref sym_Ref tree_Ref name_Ref |
| 98 | + * | 49 TREE len_Nat 36 IDENTtree type_Ref sym_Ref name_Ref |
| 99 | + * | 49 TREE len_Nat 37 LITERALtree type_Ref constant_Ref |
| 100 | + * | 49 TREE len_Nat 38 TYPEtree type_Ref |
| 101 | + * | 49 TREE len_Nat 39 ANNOTATEDtree type_Ref tree_Ref tree_Ref |
| 102 | + * | 49 TREE len_Nat 40 SINGLETONTYPEtree type_Ref tree_Ref |
| 103 | + * | 49 TREE len_Nat 41 SELECTFROMTYPEtree type_Ref tree_Ref name_Ref |
| 104 | + * | 49 TREE len_Nat 42 COMPOUNDTYPEtree type_Ref tree_Ref |
| 105 | + * | 49 TREE len_Nat 43 APPLIEDTYPEtree type_Ref tree_Ref {tree_Ref} |
| 106 | + * | 49 TREE len_Nat 44 TYPEBOUNDStree type_Ref tree_Ref tree_Ref |
| 107 | + * | 49 TREE len_Nat 45 EXISTENTIALTYPEtree type_Ref tree_Ref {tree_Ref} |
| 108 | + * | 50 MODIFIERS len_Nat flags_Long privateWithin_Ref |
| 109 | + * SymbolInfo = name_Ref owner_Ref flags_LongNat [privateWithin_Ref] info_Ref |
| 110 | + * NameInfo = <character sequence of length len_Nat in Utf8 format> |
| 111 | + * NumInfo = <len_Nat-byte signed number in big endian format> |
| 112 | + * Ref = Nat |
| 113 | + * AnnotInfoBody = info_Ref {annotArg_Ref} {name_Ref constAnnotArg_Ref} |
| 114 | + * AnnotArg = Tree | Constant |
| 115 | + * ConstAnnotArg = Constant | AnnotInfo | AnnotArgArray |
| 116 | + * |
| 117 | + * len is remaining length after `len`. |
| 118 | + */ |
| 119 | + val MajorVersion = 5 |
| 120 | + val MinorVersion = 0 |
| 121 | + |
| 122 | + final val TERMname = 1 |
| 123 | + final val TYPEname = 2 |
| 124 | + final val NONEsym = 3 |
| 125 | + final val TYPEsym = 4 |
| 126 | + final val ALIASsym = 5 |
| 127 | + final val CLASSsym = 6 |
| 128 | + final val MODULEsym = 7 |
| 129 | + final val VALsym = 8 |
| 130 | + final val EXTref = 9 |
| 131 | + final val EXTMODCLASSref = 10 |
| 132 | + final val NOtpe = 11 |
| 133 | + final val NOPREFIXtpe = 12 |
| 134 | + final val THIStpe = 13 |
| 135 | + final val SINGLEtpe = 14 |
| 136 | + final val CONSTANTtpe = 15 |
| 137 | + final val TYPEREFtpe = 16 |
| 138 | + final val TYPEBOUNDStpe = 17 |
| 139 | + final val REFINEDtpe = 18 |
| 140 | + final val CLASSINFOtpe = 19 |
| 141 | + final val METHODtpe = 20 |
| 142 | + final val POLYtpe = 21 |
| 143 | + final val IMPLICITMETHODtpe = 22 // no longer generated |
| 144 | + |
| 145 | + final val LITERAL = 23 // base line for literals |
| 146 | + final val LITERALunit = 24 |
| 147 | + final val LITERALboolean = 25 |
| 148 | + final val LITERALbyte = 26 |
| 149 | + final val LITERALshort = 27 |
| 150 | + final val LITERALchar = 28 |
| 151 | + final val LITERALint = 29 |
| 152 | + final val LITERALlong = 30 |
| 153 | + final val LITERALfloat = 31 |
| 154 | + final val LITERALdouble = 32 |
| 155 | + final val LITERALstring = 33 |
| 156 | + final val LITERALnull = 34 |
| 157 | + final val LITERALclass = 35 |
| 158 | + final val LITERALenum = 36 |
| 159 | + final val SYMANNOT = 40 |
| 160 | + final val CHILDREN = 41 |
| 161 | + final val ANNOTATEDtpe = 42 |
| 162 | + final val ANNOTINFO = 43 |
| 163 | + final val ANNOTARGARRAY = 44 |
| 164 | + |
| 165 | + final val SUPERtpe = 46 |
| 166 | + final val DEBRUIJNINDEXtpe = 47 // no longer generated |
| 167 | + final val EXISTENTIALtpe = 48 |
| 168 | + |
| 169 | + final val TREE = 49 // prefix code that means a tree is coming |
| 170 | + final val EMPTYtree = 1 |
| 171 | + final val PACKAGEtree = 2 |
| 172 | + final val CLASStree = 3 |
| 173 | + final val MODULEtree = 4 |
| 174 | + final val VALDEFtree = 5 |
| 175 | + final val DEFDEFtree = 6 |
| 176 | + final val TYPEDEFtree = 7 |
| 177 | + final val LABELtree = 8 |
| 178 | + final val IMPORTtree = 9 |
| 179 | + final val DOCDEFtree = 11 |
| 180 | + final val TEMPLATEtree = 12 |
| 181 | + final val BLOCKtree = 13 |
| 182 | + final val CASEtree = 14 |
| 183 | + // This node type has been removed. |
| 184 | + // final val SEQUENCEtree = 15 |
| 185 | + final val ALTERNATIVEtree = 16 |
| 186 | + final val STARtree = 17 |
| 187 | + final val BINDtree = 18 |
| 188 | + final val UNAPPLYtree = 19 |
| 189 | + final val ARRAYVALUEtree = 20 |
| 190 | + final val FUNCTIONtree = 21 |
| 191 | + final val ASSIGNtree = 22 |
| 192 | + final val IFtree = 23 |
| 193 | + final val MATCHtree = 24 |
| 194 | + final val RETURNtree = 25 |
| 195 | + final val TREtree = 26 |
| 196 | + final val THROWtree = 27 |
| 197 | + final val NEWtree = 28 |
| 198 | + final val TYPEDtree = 29 |
| 199 | + final val TYPEAPPLYtree = 30 |
| 200 | + final val APPLYtree = 31 |
| 201 | + final val APPLYDYNAMICtree = 32 |
| 202 | + final val SUPERtree = 33 |
| 203 | + final val THIStree = 34 |
| 204 | + final val SELECTtree = 35 |
| 205 | + final val IDENTtree = 36 |
| 206 | + final val LITERALtree = 37 |
| 207 | + final val TYPEtree = 38 |
| 208 | + final val ANNOTATEDtree = 39 |
| 209 | + final val SINGLETONTYPEtree = 40 |
| 210 | + final val SELECTFROMTYPEtree = 41 |
| 211 | + final val COMPOUNDTYPEtree = 42 |
| 212 | + final val APPLIEDTYPEtree = 43 |
| 213 | + final val TYPEBOUNDStree = 44 |
| 214 | + final val EXISTENTIALTYPEtree = 45 |
| 215 | + |
| 216 | + final val MODIFIERS = 50 |
| 217 | + |
| 218 | + final val firstSymTag = NONEsym |
| 219 | + final val lastSymTag = VALsym |
| 220 | + final val lastExtSymTag = EXTMODCLASSref |
| 221 | + |
| 222 | + |
| 223 | + //The following two are no longer accurate, because ANNOTATEDtpe, |
| 224 | + //SUPERtpe, ... are not in the same range as the other types |
| 225 | + //final val firstTypeTag = NOtpe |
| 226 | + //final val lastTypeTag = POLYtpe |
| 227 | +} |
0 commit comments