Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: lib/binary/ast_from_binary.dart

Issue 2439043002: Introduce Substitution class and Supertype class. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/ast.dart ('k') | lib/binary/ast_to_binary.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library kernel.ast_from_binary; 4 library kernel.ast_from_binary;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import 'tag.dart'; 7 import 'tag.dart';
8 import 'loader.dart'; 8 import 'loader.dart';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'package:kernel/transformations/flags.dart'; 10 import 'package:kernel/transformations/flags.dart';
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 int flags = readByte(); 322 int flags = readByte();
323 node.isAbstract = flags & 0x1 != 0; 323 node.isAbstract = flags & 0x1 != 0;
324 node.level = _currentLibrary.isExternal 324 node.level = _currentLibrary.isExternal
325 ? (flags & 0x2 != 0) ? ClassLevel.Type : ClassLevel.Hierarchy 325 ? (flags & 0x2 != 0) ? ClassLevel.Type : ClassLevel.Hierarchy
326 : ClassLevel.Body; 326 : ClassLevel.Body;
327 node.name = readStringOrNullIfEmpty(); 327 node.name = readStringOrNullIfEmpty();
328 node.fileUri = readUriReference(); 328 node.fileUri = readUriReference();
329 node.annotations = readAnnotationList(node); 329 node.annotations = readAnnotationList(node);
330 debugPath.add(node.name ?? 'normal-class'); 330 debugPath.add(node.name ?? 'normal-class');
331 readAndPushTypeParameterList(node.typeParameters, node); 331 readAndPushTypeParameterList(node.typeParameters, node);
332 node.supertype = readDartTypeOption(); 332 node.supertype = readSupertypeOption();
333 _fillNonTreeNodeList(node.implementedTypes, readDartType); 333 _fillNonTreeNodeList(node.implementedTypes, readSupertype);
334 _fillLazilyLoadedList(node.fields, (int tag, int index) { 334 _fillLazilyLoadedList(node.fields, (int tag, int index) {
335 readField(loader.getClassMemberReference(node, tag, index), tag); 335 readField(loader.getClassMemberReference(node, tag, index), tag);
336 }); 336 });
337 _fillLazilyLoadedList(node.constructors, (int tag, int index) { 337 _fillLazilyLoadedList(node.constructors, (int tag, int index) {
338 readConstructor(loader.getClassMemberReference(node, tag, index), tag); 338 readConstructor(loader.getClassMemberReference(node, tag, index), tag);
339 }); 339 });
340 _fillLazilyLoadedList(node.procedures, (int tag, int index) { 340 _fillLazilyLoadedList(node.procedures, (int tag, int index) {
341 readProcedure(loader.getClassMemberReference(node, tag, index), tag); 341 readProcedure(loader.getClassMemberReference(node, tag, index), tag);
342 }); 342 });
343 typeParameterStack.length = 0; 343 typeParameterStack.length = 0;
344 debugPath.removeLast(); 344 debugPath.removeLast();
345 } 345 }
346 346
347 void readMixinClass(Class node) { 347 void readMixinClass(Class node) {
348 int flags = readByte(); 348 int flags = readByte();
349 node.isAbstract = flags & 0x1 != 0; 349 node.isAbstract = flags & 0x1 != 0;
350 node.level = _currentLibrary.isExternal 350 node.level = _currentLibrary.isExternal
351 ? (flags & 0x2 != 0) ? ClassLevel.Type : ClassLevel.Hierarchy 351 ? (flags & 0x2 != 0) ? ClassLevel.Type : ClassLevel.Hierarchy
352 : ClassLevel.Body; 352 : ClassLevel.Body;
353 node.name = readStringOrNullIfEmpty(); 353 node.name = readStringOrNullIfEmpty();
354 node.fileUri = readUriReference(); 354 node.fileUri = readUriReference();
355 node.annotations = readAnnotationList(node); 355 node.annotations = readAnnotationList(node);
356 debugPath.add(node.name ?? 'mixin-class'); 356 debugPath.add(node.name ?? 'mixin-class');
357 readAndPushTypeParameterList(node.typeParameters, node); 357 readAndPushTypeParameterList(node.typeParameters, node);
358 node.supertype = readDartType(); 358 node.supertype = readSupertype();
359 node.mixedInType = readDartType(); 359 node.mixedInType = readSupertype();
360 _fillNonTreeNodeList(node.implementedTypes, readDartType); 360 _fillNonTreeNodeList(node.implementedTypes, readDartType);
361 _fillLazilyLoadedList(node.constructors, (int tag, int index) { 361 _fillLazilyLoadedList(node.constructors, (int tag, int index) {
362 readConstructor(loader.getClassMemberReference(node, tag, index), tag); 362 readConstructor(loader.getClassMemberReference(node, tag, index), tag);
363 }); 363 });
364 typeParameterStack.length = 0; 364 typeParameterStack.length = 0;
365 debugPath.removeLast(); 365 debugPath.removeLast();
366 } 366 }
367 367
368 int getAndResetTransformerFlags() { 368 int getAndResetTransformerFlags() {
369 int flags = _transformerFlags; 369 int flags = _transformerFlags;
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 return new Catch(exception, body, guard: guard, stackTrace: stackTrace); 796 return new Catch(exception, body, guard: guard, stackTrace: stackTrace);
797 } 797 }
798 798
799 Block readBlock() { 799 Block readBlock() {
800 int stackHeight = variableStack.length; 800 int stackHeight = variableStack.length;
801 var body = readStatementList(); 801 var body = readStatementList();
802 variableStack.length = stackHeight; 802 variableStack.length = stackHeight;
803 return new Block(body); 803 return new Block(body);
804 } 804 }
805 805
806 Supertype readSupertype() {
807 InterfaceType type = readDartType();
808 return new Supertype(type.classNode, type.typeArguments);
809 }
810
811 Supertype readSupertypeOption() {
812 return readAndCheckOptionTag() ? readSupertype() : null;
813 }
814
815 List<Supertype> readSupertypeList() {
816 return new List<Supertype>.generate(readUInt(), (i) => readSupertype());
817 }
818
806 List<DartType> readDartTypeList() { 819 List<DartType> readDartTypeList() {
807 return new List<DartType>.generate(readUInt(), (i) => readDartType()); 820 return new List<DartType>.generate(readUInt(), (i) => readDartType());
808 } 821 }
809 822
810 DartType readDartTypeOption() { 823 DartType readDartTypeOption() {
811 return readAndCheckOptionTag() ? readDartType() : null; 824 return readAndCheckOptionTag() ? readDartType() : null;
812 } 825 }
813 826
814 DartType readDartType() { 827 DartType readDartType() {
815 int tag = readByte(); 828 int tag = readByte();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 isFinal: flags & 0x1 != 0, 934 isFinal: flags & 0x1 != 0,
922 isConst: flags & 0x2 != 0); 935 isConst: flags & 0x2 != 0);
923 } 936 }
924 937
925 int readOffset() { 938 int readOffset() {
926 // Offset is saved as unsigned, 939 // Offset is saved as unsigned,
927 // but actually ranges from -1 and up (thus the -1) 940 // but actually ranges from -1 and up (thus the -1)
928 return readUInt() - 1; 941 return readUInt() - 1;
929 } 942 }
930 } 943 }
OLDNEW
« no previous file with comments | « lib/ast.dart ('k') | lib/binary/ast_to_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698