| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// Logic to build unlinked summaries. | 5 /// Logic to build unlinked summaries. |
| 6 library summary.src.summary_builder; | 6 library summary.src.summary_builder; |
| 7 | 7 |
| 8 import 'package:front_end/src/fasta/parser/class_member_parser.dart'; | 8 import 'package:front_end/src/fasta/parser/class_member_parser.dart'; |
| 9 import 'package:front_end/src/fasta/parser/identifier_context.dart'; | 9 import 'package:front_end/src/fasta/parser/identifier_context.dart'; |
| 10 import 'package:front_end/src/fasta/parser/parser.dart'; | 10 import 'package:front_end/src/fasta/parser/parser.dart'; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 | 202 |
| 203 void beginFunctionDeclaration(token) { | 203 void beginFunctionDeclaration(token) { |
| 204 debugEvent("BeginFunctionDeclaration"); | 204 debugEvent("BeginFunctionDeclaration"); |
| 205 _withinFunction++; | 205 _withinFunction++; |
| 206 } | 206 } |
| 207 | 207 |
| 208 void beginLiteralString(Token token) { | 208 void beginLiteralString(Token token) { |
| 209 debugEvent("beginLiteralString"); | 209 debugEvent("beginLiteralString"); |
| 210 if (ignore) return; | 210 if (ignore) return; |
| 211 push(new StringLiteral(token.value)); | 211 push(new StringLiteral(token.lexeme)); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void beginUnnamedFunction(token) { | 214 void beginUnnamedFunction(token) { |
| 215 debugEvent("BeginUnnamedFunction"); | 215 debugEvent("BeginUnnamedFunction"); |
| 216 var check = pop(); | 216 var check = pop(); |
| 217 assert(check == _invariantCheckToken); | 217 assert(check == _invariantCheckToken); |
| 218 _withinFunction++; | 218 _withinFunction++; |
| 219 } | 219 } |
| 220 | 220 |
| 221 UnlinkedExprBuilder computeExpression(Token token, Scope scope) { | 221 UnlinkedExprBuilder computeExpression(Token token, Scope scope) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 var constructorName = pop(); | 414 var constructorName = pop(); |
| 415 var positional = args.where((a) => a is! NamedArg).toList(); | 415 var positional = args.where((a) => a is! NamedArg).toList(); |
| 416 var named = args.where((a) => a is NamedArg).toList(); | 416 var named = args.where((a) => a is NamedArg).toList(); |
| 417 // ignore: strong_mode_down_cast_composite | 417 // ignore: strong_mode_down_cast_composite |
| 418 push(new ConstCreation(constructorName, positional, named)); | 418 push(new ConstCreation(constructorName, positional, named)); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void handleIdentifier(Token token, IdentifierContext context) { | 421 void handleIdentifier(Token token, IdentifierContext context) { |
| 422 debugEvent("Identifier"); | 422 debugEvent("Identifier"); |
| 423 if (ignore) return; | 423 if (ignore) return; |
| 424 push(new Ref(token.value)); | 424 push(new Ref(token.lexeme)); |
| 425 } | 425 } |
| 426 | 426 |
| 427 void handleIsOperator(Token operator, Token not, Token endToken) { | 427 void handleIsOperator(Token operator, Token not, Token endToken) { |
| 428 debugEvent("Is"); | 428 debugEvent("Is"); |
| 429 if (ignore) return; | 429 if (ignore) return; |
| 430 push(new Is(pop(), pop())); | 430 push(new Is(pop(), pop())); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void handleLiteralBool(Token token) { | 433 void handleLiteralBool(Token token) { |
| 434 debugEvent("LiteralBool"); | 434 debugEvent("LiteralBool"); |
| 435 if (ignore) return; | 435 if (ignore) return; |
| 436 push(new BoolLiteral(token.value == 'true')); | 436 push(new BoolLiteral(token.value == 'true')); |
| 437 } | 437 } |
| 438 | 438 |
| 439 void handleLiteralDouble(Token token) { | 439 void handleLiteralDouble(Token token) { |
| 440 debugEvent("LiteralDouble"); | 440 debugEvent("LiteralDouble"); |
| 441 if (ignore) return; | 441 if (ignore) return; |
| 442 push(new DoubleLiteral(double.parse(token.value))); | 442 push(new DoubleLiteral(double.parse(token.lexeme))); |
| 443 } | 443 } |
| 444 | 444 |
| 445 void handleLiteralInt(Token token) { | 445 void handleLiteralInt(Token token) { |
| 446 debugEvent("LiteralInt"); | 446 debugEvent("LiteralInt"); |
| 447 if (ignore) return; | 447 if (ignore) return; |
| 448 push(new IntLiteral(int.parse(token.value))); | 448 push(new IntLiteral(int.parse(token.lexeme))); |
| 449 } | 449 } |
| 450 | 450 |
| 451 void handleLiteralList(count, begin, constKeyword, end) { | 451 void handleLiteralList(count, begin, constKeyword, end) { |
| 452 debugEvent("LiteralList"); | 452 debugEvent("LiteralList"); |
| 453 if (ignore) return; | 453 if (ignore) return; |
| 454 var values = popList(count) ?? const <Expression>[]; | 454 var values = popList(count) ?? const <Expression>[]; |
| 455 // ignore: strong_mode_down_cast_composite | 455 // ignore: strong_mode_down_cast_composite |
| 456 List<TypeRef> typeArguments = pop(); | 456 List<TypeRef> typeArguments = pop(); |
| 457 var type = typeArguments?.single; | 457 var type = typeArguments?.single; |
| 458 // ignore: strong_mode_down_cast_composite | 458 // ignore: strong_mode_down_cast_composite |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 void handleStringJuxtaposition(int count) { | 542 void handleStringJuxtaposition(int count) { |
| 543 debugEvent("StringJuxtaposition"); | 543 debugEvent("StringJuxtaposition"); |
| 544 if (ignore) return; | 544 if (ignore) return; |
| 545 popList(count); | 545 popList(count); |
| 546 push(new StringLiteral('<juxtapose $count>')); | 546 push(new StringLiteral('<juxtapose $count>')); |
| 547 } | 547 } |
| 548 | 548 |
| 549 void handleStringPart(token) { | 549 void handleStringPart(token) { |
| 550 debugEvent("handleStringPart"); | 550 debugEvent("handleStringPart"); |
| 551 if (ignore) return; | 551 if (ignore) return; |
| 552 push(new StringLiteral(token.value)); | 552 push(new StringLiteral(token.lexeme)); |
| 553 } | 553 } |
| 554 | 554 |
| 555 void handleType(Token beginToken, Token endToken) { | 555 void handleType(Token beginToken, Token endToken) { |
| 556 debugEvent("Type"); | 556 debugEvent("Type"); |
| 557 if (ignore) return; | 557 if (ignore) return; |
| 558 // ignore: strong_mode_down_cast_composite | 558 // ignore: strong_mode_down_cast_composite |
| 559 List<TypeRef> arguments = pop(); | 559 List<TypeRef> arguments = pop(); |
| 560 Ref name = pop(); | 560 Ref name = pop(); |
| 561 push(new TypeRef(name, arguments)); | 561 push(new TypeRef(name, arguments)); |
| 562 } | 562 } |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 bool get needInitializer => !typeSeen || inConstContext; | 766 bool get needInitializer => !typeSeen || inConstContext; |
| 767 | 767 |
| 768 // Directives: imports, exports, parts | 768 // Directives: imports, exports, parts |
| 769 | 769 |
| 770 /// Assign the next slot. | 770 /// Assign the next slot. |
| 771 int assignSlot() => ++_slots; | 771 int assignSlot() => ++_slots; |
| 772 | 772 |
| 773 void beginClassDeclaration(Token beginToken, Token name) { | 773 void beginClassDeclaration(Token beginToken, Token name) { |
| 774 debugEvent("beginClass"); | 774 debugEvent("beginClass"); |
| 775 var classScope = scope = new ClassScope(scope); | 775 var classScope = scope = new ClassScope(scope); |
| 776 classScope.className = name.value; | 776 classScope.className = name.lexeme; |
| 777 } | 777 } |
| 778 | 778 |
| 779 void beginCompilationUnit(Token token) { | 779 void beginCompilationUnit(Token token) { |
| 780 scope = topScope = new TopScope(); | 780 scope = topScope = new TopScope(); |
| 781 } | 781 } |
| 782 | 782 |
| 783 void beginEnum(Token token) { | 783 void beginEnum(Token token) { |
| 784 debugEvent("beginEnum"); | 784 debugEvent("beginEnum"); |
| 785 scope = new EnumScope(scope); | 785 scope = new EnumScope(scope); |
| 786 } | 786 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 807 // TODO: use a single scope | 807 // TODO: use a single scope |
| 808 scope = new TypeParameterScope(scope); | 808 scope = new TypeParameterScope(scope); |
| 809 } | 809 } |
| 810 | 810 |
| 811 beginInitializer(Token token) { | 811 beginInitializer(Token token) { |
| 812 // TODO(paulberry): Add support for this. | 812 // TODO(paulberry): Add support for this. |
| 813 } | 813 } |
| 814 | 814 |
| 815 void beginLiteralString(Token token) { | 815 void beginLiteralString(Token token) { |
| 816 debugEvent("beginLiteralString"); | 816 debugEvent("beginLiteralString"); |
| 817 push(token.value.substring(1, token.value.length - 1)); | 817 push(token.lexeme.substring(1, token.lexeme.length - 1)); |
| 818 } | 818 } |
| 819 | 819 |
| 820 void beginMember(Token token) { | 820 void beginMember(Token token) { |
| 821 typeSeen = false; | 821 typeSeen = false; |
| 822 inConstContext = false; | 822 inConstContext = false; |
| 823 } | 823 } |
| 824 | 824 |
| 825 // classes, enums, mixins, and typedefs. | 825 // classes, enums, mixins, and typedefs. |
| 826 | 826 |
| 827 void beginNamedMixinApplication(Token beginToken, Token name) { | 827 void beginNamedMixinApplication(Token beginToken, Token name) { |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 | 1471 |
| 1472 void handleQualified(Token period) { | 1472 void handleQualified(Token period) { |
| 1473 debugEvent("handleQualified"); | 1473 debugEvent("handleQualified"); |
| 1474 String name = pop(); | 1474 String name = pop(); |
| 1475 String receiver = pop(); | 1475 String receiver = pop(); |
| 1476 push("$receiver.$name"); | 1476 push("$receiver.$name"); |
| 1477 } | 1477 } |
| 1478 | 1478 |
| 1479 void handleStringPart(token) { | 1479 void handleStringPart(token) { |
| 1480 debugEvent("handleStringPart"); | 1480 debugEvent("handleStringPart"); |
| 1481 push(token.value.substring(1, token.value.length - 1)); | 1481 push(token.lexeme.substring(1, token.lexeme.length - 1)); |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 void handleType(Token beginToken, Token endToken) { | 1484 void handleType(Token beginToken, Token endToken) { |
| 1485 debugEvent("Type"); | 1485 debugEvent("Type"); |
| 1486 // ignore: strong_mode_down_cast_composite | 1486 // ignore: strong_mode_down_cast_composite |
| 1487 List<EntityRef> arguments = pop(); | 1487 List<EntityRef> arguments = pop(); |
| 1488 String name = pop(); | 1488 String name = pop(); |
| 1489 | 1489 |
| 1490 var type; | 1490 var type; |
| 1491 if (name.contains('.')) { | 1491 if (name.contains('.')) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 } | 1590 } |
| 1591 | 1591 |
| 1592 /// Internal representation of an initialized name. | 1592 /// Internal representation of an initialized name. |
| 1593 class _InitializedName { | 1593 class _InitializedName { |
| 1594 final String name; | 1594 final String name; |
| 1595 final UnlinkedExecutableBuilder initializer; | 1595 final UnlinkedExecutableBuilder initializer; |
| 1596 _InitializedName(this.name, this.initializer); | 1596 _InitializedName(this.name, this.initializer); |
| 1597 | 1597 |
| 1598 toString() => "II:" + (initializer != null ? "$name = $initializer" : name); | 1598 toString() => "II:" + (initializer != null ? "$name = $initializer" : name); |
| 1599 } | 1599 } |
| OLD | NEW |