| OLD | NEW |
| 1 This file describes the binary format of Dart Kernel. | 1 This file describes the binary format of Dart Kernel. |
| 2 | 2 |
| 3 Notation | 3 Notation |
| 4 -------- | 4 -------- |
| 5 Bitmasks are described with the syntax: | 5 Bitmasks are described with the syntax: |
| 6 ```scala | 6 ```scala |
| 7 Byte flags (flag1, flag2, ..., flagN) | 7 Byte flags (flag1, flag2, ..., flagN) |
| 8 ``` | 8 ``` |
| 9 where 'flag<N>' is the N-th least significant bit, | 9 where 'flag<N>' is the N-th least significant bit, |
| 10 (so flag1 is the least significant bit). | 10 (so flag1 is the least significant bit). |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 Byte tag; | 84 Byte tag; |
| 85 } | 85 } |
| 86 type Nothing extends Option<T> { | 86 type Nothing extends Option<T> { |
| 87 Byte tag = 0; | 87 Byte tag = 0; |
| 88 } | 88 } |
| 89 type Something<T> extends Option<T> { | 89 type Something<T> extends Option<T> { |
| 90 Byte tag = 1; | 90 Byte tag = 1; |
| 91 T value; | 91 T value; |
| 92 } | 92 } |
| 93 | 93 |
| 94 type CanonicalNameReference { |
| 95 UInt biasedIndex; // 0 if null, otherwise N+1 where N is index of parent |
| 96 } |
| 97 |
| 98 type CanonicalName { |
| 99 CanonicalNameReference parent; |
| 100 StringReference name; |
| 101 } |
| 102 |
| 94 type ProgramFile { | 103 type ProgramFile { |
| 95 MagicWord magic = 0x90ABCDEF; | 104 MagicWord magic = 0x90ABCDEF; |
| 96 StringTable strings; | 105 StringTable strings; |
| 97 UriSource sourceMap; | 106 UriSource sourceMap; |
| 107 List<CanonicalName> canonicalNames; |
| 98 List<Library> libraries; | 108 List<Library> libraries; |
| 99 LibraryProcedureReference mainMethod; | 109 CanonicalNameReference mainMethod; |
| 100 } | 110 } |
| 101 | 111 |
| 102 type LibraryReference { | 112 type LibraryReference { |
| 103 // Index into the ProgramFile libraries. | 113 // Must be populated by a library (possibly later in the file). |
| 104 UInt index; | 114 CanonicalNameReference canonicalName; |
| 105 } | 115 } |
| 106 | 116 |
| 107 abstract type ClassReference {} | 117 type ClassReference { |
| 108 | 118 // Must be populated by a class (possibly later in the file). |
| 109 type NormalClassReference extends ClassReference { | 119 CanonicalNameReference canonicalName; |
| 110 Byte tag = 100; | |
| 111 LibraryReference library; | |
| 112 UInt classIndex; | |
| 113 } | 120 } |
| 114 | 121 |
| 115 type MixinClassReference extends ClassReference { | 122 type MemberReference { |
| 116 Byte tag = 101; | 123 // Must be populated by a member (possibly later in the file). |
| 117 LibraryReference library; | 124 CanonicalNameReference canonicalName; |
| 118 UInt classIndex; | |
| 119 } | 125 } |
| 120 | 126 |
| 121 abstract type MemberReference { | 127 type FieldReference { |
| 128 // Must be populated by a field (possibly later in the file). |
| 129 CanonicalNameReference canonicalName; |
| 122 } | 130 } |
| 123 | 131 |
| 124 type LibraryFieldReference extends MemberReference { | 132 type ConstructorReference { |
| 125 Byte tag = 102; | 133 // Must be populated by a constructor (possibly later in the file). |
| 126 LibraryReference library; | 134 CanonicalNameReference canonicalName; |
| 127 UInt fieldIndex; // Index in list of fields. | |
| 128 } | 135 } |
| 129 | 136 |
| 130 type ClassFieldReference extends MemberReference { | 137 type ProcedureReference { |
| 131 Byte tag = 103; | 138 // Must be populated by a procedure (possibly later in the file). |
| 132 ClassReference class; | 139 CanonicalNameReference canonicalName; |
| 133 UInt fieldIndex; | |
| 134 } | |
| 135 | |
| 136 type ClassConstructorReference extends MemberReference { | |
| 137 Byte tag = 104; | |
| 138 ClassReference class; | |
| 139 UInt constructorIndex; // Index in list of constructors. | |
| 140 } | |
| 141 | |
| 142 type LibraryProcedureReference extends MemberReference { | |
| 143 Byte tag = 105; | |
| 144 LibraryReference library; | |
| 145 UInt procedureIndex; // Index in list of procedures. | |
| 146 } | |
| 147 | |
| 148 type ClassProcedureReference extends MemberReference { | |
| 149 Byte tag = 106; | |
| 150 ClassReference class; | |
| 151 UInt procedureIndex; | |
| 152 } | |
| 153 | |
| 154 // Can be used as MemberReference or ClassReference *only* if indicated that | |
| 155 // the given reference may be a NullReference. | |
| 156 type NullReference extends MemberReference, ClassReference { | |
| 157 Byte tag = 99; | |
| 158 } | 140 } |
| 159 | 141 |
| 160 type Name { | 142 type Name { |
| 161 StringReference name; | 143 StringReference name; |
| 162 if name begins with '_' { | 144 if name begins with '_' { |
| 163 LibraryReference library; | 145 LibraryReference library; |
| 164 } | 146 } |
| 165 } | 147 } |
| 166 | 148 |
| 167 type Library { | 149 type Library { |
| 168 Byte flags (isExternal); | 150 Byte flags (isExternal); |
| 151 CanonicalNameReference canonicalName; |
| 169 StringReference name; | 152 StringReference name; |
| 170 // A URI from which the library was created. The URI has the dart, package, | |
| 171 // file, or app scheme. For file URIs, the path is an absolute path to the | |
| 172 // .dart file from which the library was created. For app URIs, the path is | |
| 173 // relative to an application root that was specified when the binary was | |
| 174 // generated. | |
| 175 StringReference importUri; | |
| 176 // An absolute path URI to the .dart file from which the library was created. | 153 // An absolute path URI to the .dart file from which the library was created. |
| 177 UriReference fileUri; | 154 UriReference fileUri; |
| 178 List<Class> classes; | 155 List<Class> classes; |
| 179 List<Field> fields; | 156 List<Field> fields; |
| 180 List<Procedure> procedures; | 157 List<Procedure> procedures; |
| 181 } | 158 } |
| 182 | 159 |
| 183 abstract type Node { | 160 abstract type Node { |
| 184 Byte tag; | 161 Byte tag; |
| 185 } | 162 } |
| 186 | 163 |
| 187 // A class can be represented at one of three levels: type, hierarchy, or body. | 164 // A class can be represented at one of three levels: type, hierarchy, or body. |
| 188 // | 165 // |
| 189 // If the enclosing library is external, a class is either at type or | 166 // If the enclosing library is external, a class is either at type or |
| 190 // hierarchy level, depending on its isTypeLevel flag. | 167 // hierarchy level, depending on its isTypeLevel flag. |
| 191 // If the enclosing library is not external, a class is always at body level. | 168 // If the enclosing library is not external, a class is always at body level. |
| 192 // | 169 // |
| 193 // See ClassLevel in ast.dart for the details of each loading level. | 170 // See ClassLevel in ast.dart for the details of each loading level. |
| 194 | 171 |
| 195 abstract type Class extends Node {} | 172 abstract type Class extends Node { |
| 196 | |
| 197 type NormalClass extends Class { | |
| 198 Byte tag = 2; | 173 Byte tag = 2; |
| 174 CanonicalNameReference canonicalName; |
| 199 FileOffset fileOffset; | 175 FileOffset fileOffset; |
| 200 Byte flags (isAbstract, isTypeLevel); | 176 Byte flags (isAbstract, isTypeLevel); |
| 201 StringReference name; | 177 StringReference name; |
| 202 // An absolute path URI to the .dart file from which the class was created. | 178 // An absolute path URI to the .dart file from which the class was created. |
| 203 UriReference fileUri; | 179 UriReference fileUri; |
| 204 List<Expression> annotations; | 180 List<Expression> annotations; |
| 205 List<TypeParameter> typeParameters; | 181 List<TypeParameter> typeParameters; |
| 206 Option<InterfaceType> superClass; | 182 Option<InterfaceType> superClass; |
| 183 Option<InterfaceType> mixedInType; |
| 207 List<InterfaceType> implementedClasses; | 184 List<InterfaceType> implementedClasses; |
| 208 List<Field> fields; | 185 List<Field> fields; |
| 209 List<Constructor> constructors; | 186 List<Constructor> constructors; |
| 210 List<Procedure> procedures; | 187 List<Procedure> procedures; |
| 211 } | 188 } |
| 212 | 189 |
| 213 type MixinClass extends Class { | |
| 214 Byte tag = 3; | |
| 215 FileOffset fileOffset; | |
| 216 Byte flags (isAbstract, isTypeLevel); | |
| 217 StringReference name; | |
| 218 // An absolute path URI to the .dart file from which the class was created. | |
| 219 UriReference fileUri; | |
| 220 List<Expression> annotations; | |
| 221 List<TypeParameter> typeParameters; | |
| 222 InterfaceType firstSuperClass; | |
| 223 InterfaceType secondSuperClass; | |
| 224 List<InterfaceType> implementedClasses; | |
| 225 List<Constructor> constructors; | |
| 226 } | |
| 227 | |
| 228 abstract type Member extends Node {} | 190 abstract type Member extends Node {} |
| 229 | 191 |
| 230 type Field extends Member { | 192 type Field extends Member { |
| 231 Byte tag = 4; | 193 Byte tag = 4; |
| 194 CanonicalNameReference canonicalName; |
| 232 FileOffset fileOffset; | 195 FileOffset fileOffset; |
| 233 FileOffset fileEndOffset; | 196 FileOffset fileEndOffset; |
| 234 Byte flags (isFinal, isConst, isStatic); | 197 Byte flags (isFinal, isConst, isStatic); |
| 235 Name name; | 198 Name name; |
| 236 // An absolute path URI to the .dart file from which the field was created. | 199 // An absolute path URI to the .dart file from which the field was created. |
| 237 UriReference fileUri; | 200 UriReference fileUri; |
| 238 List<Expression> annotations; | 201 List<Expression> annotations; |
| 239 DartType type; | 202 DartType type; |
| 240 Option<InferredValue> inferredValue; | 203 Option<InferredValue> inferredValue; |
| 241 Option<Expression> initializer; | 204 Option<Expression> initializer; |
| 242 } | 205 } |
| 243 | 206 |
| 244 type Constructor extends Member { | 207 type Constructor extends Member { |
| 245 Byte tag = 5; | 208 Byte tag = 5; |
| 209 CanonicalNameReference canonicalName; |
| 246 FileOffset fileOffset; | 210 FileOffset fileOffset; |
| 247 FileOffset fileEndOffset; | 211 FileOffset fileEndOffset; |
| 248 Byte flags (isConst, isExternal); | 212 Byte flags (isConst, isExternal); |
| 249 Name name; | 213 Name name; |
| 250 List<Expression> annotations; | 214 List<Expression> annotations; |
| 251 FunctionNode function; | 215 FunctionNode function; |
| 252 List<Initializer> initializers; | 216 List<Initializer> initializers; |
| 253 } | 217 } |
| 254 | 218 |
| 255 /* | 219 /* |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 | 881 |
| 918 /* enum BaseClassKind { None, Exact, Subclass, Subtype, } */ | 882 /* enum BaseClassKind { None, Exact, Subclass, Subtype, } */ |
| 919 | 883 |
| 920 type InferredValue { | 884 type InferredValue { |
| 921 ClassReference baseClass; // May be NullReference if kind = None. | 885 ClassReference baseClass; // May be NullReference if kind = None. |
| 922 Byte kind; // Index into BaseClassKind. | 886 Byte kind; // Index into BaseClassKind. |
| 923 Byte valueBits; // See lib/type_propagation/type_propagation.dart | 887 Byte valueBits; // See lib/type_propagation/type_propagation.dart |
| 924 } | 888 } |
| 925 | 889 |
| 926 ``` | 890 ``` |
| OLD | NEW |