OLD | NEW |
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 | 4 |
5 library fasta.kernel_library_builder; | 5 library fasta.kernel_library_builder; |
6 | 6 |
7 import 'package:front_end/src/scanner/token.dart' show Token; | 7 import 'package:front_end/src/scanner/token.dart' show Token; |
8 | 8 |
9 import 'package:kernel/ast.dart'; | 9 import 'package:kernel/ast.dart'; |
10 | 10 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 void addClass( | 101 void addClass( |
102 List<MetadataBuilder> metadata, | 102 List<MetadataBuilder> metadata, |
103 int modifiers, | 103 int modifiers, |
104 String className, | 104 String className, |
105 List<TypeVariableBuilder> typeVariables, | 105 List<TypeVariableBuilder> typeVariables, |
106 KernelTypeBuilder supertype, | 106 KernelTypeBuilder supertype, |
107 List<KernelTypeBuilder> interfaces, | 107 List<KernelTypeBuilder> interfaces, |
108 int charOffset) { | 108 int charOffset) { |
109 // Nested declaration began in `OutlineBuilder.beginClassDeclaration`. | 109 // Nested declaration began in `OutlineBuilder.beginClassDeclaration`. |
110 var declaration = endNestedDeclaration()..resolveTypes(typeVariables, this); | 110 var declaration = endNestedDeclaration(className) |
| 111 ..resolveTypes(typeVariables, this); |
111 assert(declaration.parent == libraryDeclaration); | 112 assert(declaration.parent == libraryDeclaration); |
112 Map<String, MemberBuilder> members = declaration.members; | 113 Map<String, MemberBuilder> members = declaration.members; |
113 Map<String, MemberBuilder> constructors = declaration.constructors; | 114 Map<String, MemberBuilder> constructors = declaration.constructors; |
114 Map<String, MemberBuilder> setters = declaration.setters; | 115 Map<String, MemberBuilder> setters = declaration.setters; |
115 | 116 |
116 Scope classScope = new Scope( | 117 Scope classScope = new Scope( |
117 members, setters, scope.withTypeVariables(typeVariables), | 118 members, setters, scope.withTypeVariables(typeVariables), |
118 isModifiable: false); | 119 isModifiable: false); |
119 | 120 |
120 // When looking up a constructor, we don't consider type variables or the | 121 // When looking up a constructor, we don't consider type variables or the |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 446 |
446 void addNamedMixinApplication( | 447 void addNamedMixinApplication( |
447 List<MetadataBuilder> metadata, | 448 List<MetadataBuilder> metadata, |
448 String name, | 449 String name, |
449 List<TypeVariableBuilder> typeVariables, | 450 List<TypeVariableBuilder> typeVariables, |
450 int modifiers, | 451 int modifiers, |
451 KernelTypeBuilder mixinApplication, | 452 KernelTypeBuilder mixinApplication, |
452 List<KernelTypeBuilder> interfaces, | 453 List<KernelTypeBuilder> interfaces, |
453 int charOffset) { | 454 int charOffset) { |
454 // Nested declaration began in `OutlineBuilder.beginNamedMixinApplication`. | 455 // Nested declaration began in `OutlineBuilder.beginNamedMixinApplication`. |
455 endNestedDeclaration().resolveTypes(typeVariables, this); | 456 endNestedDeclaration(name).resolveTypes(typeVariables, this); |
456 KernelNamedTypeBuilder supertype = applyMixins(mixinApplication, | 457 KernelNamedTypeBuilder supertype = applyMixins(mixinApplication, |
457 metadata: metadata, | 458 metadata: metadata, |
458 name: name, | 459 name: name, |
459 typeVariables: typeVariables, | 460 typeVariables: typeVariables, |
460 modifiers: modifiers, | 461 modifiers: modifiers, |
461 interfaces: interfaces, | 462 interfaces: interfaces, |
462 charOffset: charOffset); | 463 charOffset: charOffset); |
463 checkTypeVariables(typeVariables, supertype.builder); | 464 checkTypeVariables(typeVariables, supertype.builder); |
464 } | 465 } |
465 | 466 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 List<TypeVariableBuilder> typeVariables, | 512 List<TypeVariableBuilder> typeVariables, |
512 List<FormalParameterBuilder> formals, | 513 List<FormalParameterBuilder> formals, |
513 ProcedureKind kind, | 514 ProcedureKind kind, |
514 int charOffset, | 515 int charOffset, |
515 int charOpenParenOffset, | 516 int charOpenParenOffset, |
516 int charEndOffset, | 517 int charEndOffset, |
517 String nativeMethodName, | 518 String nativeMethodName, |
518 {bool isTopLevel}) { | 519 {bool isTopLevel}) { |
519 // Nested declaration began in `OutlineBuilder.beginMethod` or | 520 // Nested declaration began in `OutlineBuilder.beginMethod` or |
520 // `OutlineBuilder.beginTopLevelMethod`. | 521 // `OutlineBuilder.beginTopLevelMethod`. |
521 endNestedDeclaration().resolveTypes(typeVariables, this); | 522 endNestedDeclaration(name).resolveTypes(typeVariables, this); |
522 ProcedureBuilder procedure; | 523 ProcedureBuilder procedure; |
523 String constructorName = | 524 String constructorName = |
524 isTopLevel ? null : computeAndValidateConstructorName(name, charOffset); | 525 isTopLevel ? null : computeAndValidateConstructorName(name, charOffset); |
525 if (constructorName != null) { | 526 if (constructorName != null) { |
526 name = constructorName; | 527 name = constructorName; |
527 procedure = new KernelConstructorBuilder( | 528 procedure = new KernelConstructorBuilder( |
528 metadata, | 529 metadata, |
529 modifiers & ~abstractMask, | 530 modifiers & ~abstractMask, |
530 returnType, | 531 returnType, |
531 name, | 532 name, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 List<FormalParameterBuilder> formals, | 566 List<FormalParameterBuilder> formals, |
566 ConstructorReferenceBuilder redirectionTarget, | 567 ConstructorReferenceBuilder redirectionTarget, |
567 int charOffset, | 568 int charOffset, |
568 int charOpenParenOffset, | 569 int charOpenParenOffset, |
569 int charEndOffset, | 570 int charEndOffset, |
570 String nativeMethodName) { | 571 String nativeMethodName) { |
571 KernelTypeBuilder returnType = addNamedType( | 572 KernelTypeBuilder returnType = addNamedType( |
572 currentDeclaration.parent.name, <KernelTypeBuilder>[], charOffset); | 573 currentDeclaration.parent.name, <KernelTypeBuilder>[], charOffset); |
573 // Nested declaration began in `OutlineBuilder.beginFactoryMethod`. | 574 // Nested declaration began in `OutlineBuilder.beginFactoryMethod`. |
574 DeclarationBuilder<KernelTypeBuilder> factoryDeclaration = | 575 DeclarationBuilder<KernelTypeBuilder> factoryDeclaration = |
575 endNestedDeclaration(); | 576 endNestedDeclaration("#factory_method"); |
576 String name = constructorNameReference.name; | 577 String name = constructorNameReference.name; |
577 String constructorName = | 578 String constructorName = |
578 computeAndValidateConstructorName(name, charOffset); | 579 computeAndValidateConstructorName(name, charOffset); |
579 if (constructorName != null) { | 580 if (constructorName != null) { |
580 name = constructorName; | 581 name = constructorName; |
581 } | 582 } |
582 assert(constructorNameReference.suffix == null); | 583 assert(constructorNameReference.suffix == null); |
583 KernelProcedureBuilder procedure = new KernelProcedureBuilder( | 584 KernelProcedureBuilder procedure = new KernelProcedureBuilder( |
584 metadata, | 585 metadata, |
585 staticMask | modifiers, | 586 staticMask | modifiers, |
(...skipping 28 matching lines...) Expand all Loading... |
614 List<MetadataBuilder> metadata, | 615 List<MetadataBuilder> metadata, |
615 KernelTypeBuilder returnType, | 616 KernelTypeBuilder returnType, |
616 String name, | 617 String name, |
617 List<TypeVariableBuilder> typeVariables, | 618 List<TypeVariableBuilder> typeVariables, |
618 List<FormalParameterBuilder> formals, | 619 List<FormalParameterBuilder> formals, |
619 int charOffset) { | 620 int charOffset) { |
620 FunctionTypeAliasBuilder typedef = new KernelFunctionTypeAliasBuilder( | 621 FunctionTypeAliasBuilder typedef = new KernelFunctionTypeAliasBuilder( |
621 metadata, returnType, name, typeVariables, formals, this, charOffset); | 622 metadata, returnType, name, typeVariables, formals, this, charOffset); |
622 checkTypeVariables(typeVariables, typedef); | 623 checkTypeVariables(typeVariables, typedef); |
623 // Nested declaration began in `OutlineBuilder.beginFunctionTypeAlias`. | 624 // Nested declaration began in `OutlineBuilder.beginFunctionTypeAlias`. |
624 endNestedDeclaration().resolveTypes(typeVariables, this); | 625 endNestedDeclaration("#typedef").resolveTypes(typeVariables, this); |
625 addBuilder(name, typedef, charOffset); | 626 addBuilder(name, typedef, charOffset); |
626 } | 627 } |
627 | 628 |
628 KernelFunctionTypeBuilder addFunctionType( | 629 KernelFunctionTypeBuilder addFunctionType( |
629 KernelTypeBuilder returnType, | 630 KernelTypeBuilder returnType, |
630 List<TypeVariableBuilder> typeVariables, | 631 List<TypeVariableBuilder> typeVariables, |
631 List<FormalParameterBuilder> formals, | 632 List<FormalParameterBuilder> formals, |
632 int charOffset) { | 633 int charOffset) { |
633 var builder = new KernelFunctionTypeBuilder( | 634 var builder = new KernelFunctionTypeBuilder( |
634 charOffset, fileUri, returnType, typeVariables, formals); | 635 charOffset, fileUri, returnType, typeVariables, formals); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 mixinApplicationClasses.putIfAbsent(name, () => builder); | 856 mixinApplicationClasses.putIfAbsent(name, () => builder); |
856 if (existing != builder) { | 857 if (existing != builder) { |
857 part.scope.local.remove(name); | 858 part.scope.local.remove(name); |
858 } | 859 } |
859 }); | 860 }); |
860 super.includePart(part); | 861 super.includePart(part); |
861 nativeMethods.addAll(part.nativeMethods); | 862 nativeMethods.addAll(part.nativeMethods); |
862 boundlessTypeVariables.addAll(part.boundlessTypeVariables); | 863 boundlessTypeVariables.addAll(part.boundlessTypeVariables); |
863 } | 864 } |
864 } | 865 } |
OLD | NEW |