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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2746013003: [fasta] Add and correct even more offsets (Closed)
Patch Set: Created 3 years, 9 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
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 4
5 library fasta.body_builder; 5 library fasta.body_builder;
6 6
7 import '../parser/parser.dart' show FormalParameterType, optional; 7 import '../parser/parser.dart' show FormalParameterType, optional;
8 8
9 import '../parser/error_kind.dart' show ErrorKind; 9 import '../parser/error_kind.dart' show ErrorKind;
10 10
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 List<Expression> popListForEffect(int n) { 219 List<Expression> popListForEffect(int n) {
220 List<Expression> list = 220 List<Expression> list =
221 new List<Expression>.filled(n, null, growable: true); 221 new List<Expression>.filled(n, null, growable: true);
222 for (int i = n - 1; i >= 0; i--) { 222 for (int i = n - 1; i >= 0; i--) {
223 list[i] = popForEffect(); 223 list[i] = popForEffect();
224 } 224 }
225 return list; 225 return list;
226 } 226 }
227 227
228 Block popBlock(int count) { 228 Block popBlock(int count, Token beginToken) {
ahe 2017/03/13 14:33:52 Should take an int, not a token.
jensj 2017/03/14 12:37:11 Fixed.
229 List<dynamic /*Statement | List<Statement>*/ > statements = 229 List<dynamic /*Statement | List<Statement>*/ > statements =
230 popList(count) ?? <Statement>[]; 230 popList(count) ?? <Statement>[];
231 List<Statement> copy; 231 List<Statement> copy;
232 for (int i = 0; i < statements.length; i++) { 232 for (int i = 0; i < statements.length; i++) {
233 var statement = statements[i]; 233 var statement = statements[i];
234 if (statement is List) { 234 if (statement is List) {
235 copy ??= new List<Statement>.from(statements.getRange(0, i)); 235 copy ??= new List<Statement>.from(statements.getRange(0, i));
236 // TODO(sigmund): remove this assignment (issue #28651) 236 // TODO(sigmund): remove this assignment (issue #28651)
237 Iterable subStatements = statement; 237 Iterable subStatements = statement;
238 copy.addAll(subStatements); 238 copy.addAll(subStatements);
239 } else if (copy != null) { 239 } else if (copy != null) {
240 copy.add(statement); 240 copy.add(statement);
241 } 241 }
242 } 242 }
243 return new Block(copy ?? statements); 243 return new Block(copy ?? statements)..fileOffset = beginToken.charOffset;
244 } 244 }
245 245
246 Statement popStatementIfNotNull(Object value) { 246 Statement popStatementIfNotNull(Object value) {
247 return value == null ? null : popStatement(); 247 return value == null ? null : popStatement();
248 } 248 }
249 249
250 Statement popStatement() { 250 Statement popStatement() {
251 var statement = pop(); 251 var statement = pop();
252 if (statement is List) { 252 if (statement is List) {
253 return new Block(new List<Statement>.from(statement)); 253 return new Block(new List<Statement>.from(statement));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 checkEmpty(-1); 349 checkEmpty(-1);
350 } 350 }
351 351
352 @override 352 @override
353 void endFunctionBody(int count, Token beginToken, Token endToken) { 353 void endFunctionBody(int count, Token beginToken, Token endToken) {
354 debugEvent("FunctionBody"); 354 debugEvent("FunctionBody");
355 if (beginToken == null) { 355 if (beginToken == null) {
356 assert(count == 0); 356 assert(count == 0);
357 push(NullValue.Block); 357 push(NullValue.Block);
358 } else { 358 } else {
359 Block block = popBlock(count); 359 Block block = popBlock(count, beginToken);
360 exitLocalScope(); 360 exitLocalScope();
361 push(block); 361 push(block);
362 } 362 }
363 } 363 }
364 364
365 @override 365 @override
366 void prepareInitializers() { 366 void prepareInitializers() {
367 scope = formalParameterScope; 367 scope = formalParameterScope;
368 assert(fieldInitializers.isEmpty); 368 assert(fieldInitializers.isEmpty);
369 final member = this.member; 369 final member = this.member;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 if (arguments != null && typeArguments != null) { 518 if (arguments != null && typeArguments != null) {
519 arguments.types.addAll(typeArguments); 519 arguments.types.addAll(typeArguments);
520 } else { 520 } else {
521 assert(typeArguments == null); 521 assert(typeArguments == null);
522 } 522 }
523 if (receiver is Identifier) { 523 if (receiver is Identifier) {
524 Name name = new Name(receiver.name, library.library); 524 Name name = new Name(receiver.name, library.library);
525 if (arguments == null) { 525 if (arguments == null) {
526 push(new IncompletePropertyAccessor(this, beginToken.charOffset, name)); 526 push(new IncompletePropertyAccessor(this, beginToken.charOffset, name));
527 } else { 527 } else {
528 push(new SendAccessor(this, endToken.charOffset, name, arguments)); 528 push(new SendAccessor(this, beginToken.charOffset, name, arguments));
529 } 529 }
530 } else if (arguments == null) { 530 } else if (arguments == null) {
531 push(receiver); 531 push(receiver);
532 } else { 532 } else {
533 push(finishSend(receiver, arguments, beginToken.charOffset)); 533 push(finishSend(receiver, arguments, beginToken.charOffset));
534 } 534 }
535 } 535 }
536 536
537 @override 537 @override
538 finishSend(Object receiver, Arguments arguments, int charOffset) { 538 finishSend(Object receiver, Arguments arguments, int charOffset) {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 864
865 @override 865 @override
866 void handleLiteralInt(Token token) { 866 void handleLiteralInt(Token token) {
867 debugEvent("LiteralInt"); 867 debugEvent("LiteralInt");
868 push(new IntLiteral(int.parse(token.lexeme))); 868 push(new IntLiteral(int.parse(token.lexeme)));
869 } 869 }
870 870
871 @override 871 @override
872 void endExpressionFunctionBody(Token arrowToken, Token endToken) { 872 void endExpressionFunctionBody(Token arrowToken, Token endToken) {
873 debugEvent("ExpressionFunctionBody"); 873 debugEvent("ExpressionFunctionBody");
874 endReturnStatement(true, arrowToken, endToken); 874 endReturnStatement(true, arrowToken.next, endToken);
875 } 875 }
876 876
877 @override 877 @override
878 void endReturnStatement( 878 void endReturnStatement(
879 bool hasExpression, Token beginToken, Token endToken) { 879 bool hasExpression, Token beginToken, Token endToken) {
880 debugEvent("ReturnStatement"); 880 debugEvent("ReturnStatement");
881 Expression expression = hasExpression ? popForValue() : null; 881 Expression expression = hasExpression ? popForValue() : null;
882 if (expression != null && inConstructor) { 882 if (expression != null && inConstructor) {
883 push(buildCompileTimeErrorStatement( 883 push(buildCompileTimeErrorStatement(
884 "Can't return from a constructor.", beginToken.charOffset)); 884 "Can't return from a constructor.", beginToken.charOffset));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 if (variables.length != 1) { 962 if (variables.length != 1) {
963 push(variables); 963 push(variables);
964 } else { 964 } else {
965 push(variables.single); 965 push(variables.single);
966 } 966 }
967 } 967 }
968 968
969 @override 969 @override
970 void endBlock(int count, Token beginToken, Token endToken) { 970 void endBlock(int count, Token beginToken, Token endToken) {
971 debugEvent("Block"); 971 debugEvent("Block");
972 Block block = popBlock(count); 972 Block block = popBlock(count, beginToken);
973 exitLocalScope(); 973 exitLocalScope();
974 push(block); 974 push(block);
975 } 975 }
976 976
977 @override 977 @override
978 void handleAssignmentExpression(Token token) { 978 void handleAssignmentExpression(Token token) {
979 debugEvent("AssignmentExpression"); 979 debugEvent("AssignmentExpression");
980 Expression value = popForValue(); 980 Expression value = popForValue();
981 var accessor = pop(); 981 var accessor = pop();
982 if (accessor is TypeDeclarationBuilder) { 982 if (accessor is TypeDeclarationBuilder) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 if (breakTarget.hasUsers) { 1057 if (breakTarget.hasUsers) {
1058 result = new LabeledStatement(result); 1058 result = new LabeledStatement(result);
1059 breakTarget.resolveBreaks(result); 1059 breakTarget.resolveBreaks(result);
1060 } 1060 }
1061 exitLoopOrSwitch(result); 1061 exitLoopOrSwitch(result);
1062 } 1062 }
1063 1063
1064 @override 1064 @override
1065 void endAwaitExpression(Token beginToken, Token endToken) { 1065 void endAwaitExpression(Token beginToken, Token endToken) {
1066 debugEvent("AwaitExpression"); 1066 debugEvent("AwaitExpression");
1067 push(new AwaitExpression(popForValue())); 1067 push(
1068 new AwaitExpression(popForValue())..fileOffset = beginToken.charOffset);
1068 } 1069 }
1069 1070
1070 @override 1071 @override
1071 void handleAsyncModifier(Token asyncToken, Token starToken) { 1072 void handleAsyncModifier(Token asyncToken, Token starToken) {
1072 debugEvent("AsyncModifier"); 1073 debugEvent("AsyncModifier");
1073 push(asyncMarkerFromTokens(asyncToken, starToken)); 1074 push(asyncMarkerFromTokens(asyncToken, starToken));
1074 } 1075 }
1075 1076
1076 @override 1077 @override
1077 void handleLiteralList( 1078 void handleLiteralList(
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 } 1293 }
1293 1294
1294 @override 1295 @override
1295 void endThrowExpression(Token throwToken, Token endToken) { 1296 void endThrowExpression(Token throwToken, Token endToken) {
1296 debugEvent("ThrowExpression"); 1297 debugEvent("ThrowExpression");
1297 Expression expression = popForValue(); 1298 Expression expression = popForValue();
1298 push(new Throw(expression)..fileOffset = throwToken.charOffset); 1299 push(new Throw(expression)..fileOffset = throwToken.charOffset);
1299 } 1300 }
1300 1301
1301 @override 1302 @override
1302 void endFormalParameter( 1303 void endFormalParameter(Token covariantKeyword, Token thisKeyword,
1303 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { 1304 Token nameToken, FormalParameterType kind) {
1304 debugEvent("FormalParameter"); 1305 debugEvent("FormalParameter");
1305 // TODO(ahe): Need beginToken here. 1306 // TODO(ahe): Need beginToken here.
1306 int charOffset = thisKeyword?.charOffset; 1307 int charOffset = thisKeyword?.charOffset;
1307 if (thisKeyword != null) { 1308 if (thisKeyword != null) {
1308 if (!inConstructor) { 1309 if (!inConstructor) {
1309 addCompileTimeError(thisKeyword.charOffset, 1310 addCompileTimeError(thisKeyword.charOffset,
1310 "'this' parameters can only be used on constructors."); 1311 "'this' parameters can only be used on constructors.");
1311 thisKeyword = null; 1312 thisKeyword = null;
1312 } 1313 }
1313 } 1314 }
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 Expression buildStaticInvocation(Member target, Arguments arguments, 1606 Expression buildStaticInvocation(Member target, Arguments arguments,
1606 {bool isConst: false, int charOffset: -1}) { 1607 {bool isConst: false, int charOffset: -1}) {
1607 List<TypeParameter> typeParameters = target.function.typeParameters; 1608 List<TypeParameter> typeParameters = target.function.typeParameters;
1608 if (target is Constructor) { 1609 if (target is Constructor) {
1609 typeParameters = target.enclosingClass.typeParameters; 1610 typeParameters = target.enclosingClass.typeParameters;
1610 } 1611 }
1611 if (!addDefaultArguments(target.function, arguments, typeParameters)) { 1612 if (!addDefaultArguments(target.function, arguments, typeParameters)) {
1612 return throwNoSuchMethodError(target.name.name, arguments, charOffset); 1613 return throwNoSuchMethodError(target.name.name, arguments, charOffset);
1613 } 1614 }
1614 if (target is Constructor) { 1615 if (target is Constructor) {
1615 return new ConstructorInvocation(target, arguments)..isConst = isConst; 1616 return new ConstructorInvocation(target, arguments)
1617 ..isConst = isConst
1618 ..fileOffset = charOffset;
1616 } else { 1619 } else {
1617 return new StaticInvocation(target, arguments)..isConst = isConst; 1620 return new StaticInvocation(target, arguments)
1621 ..isConst = isConst
1622 ..fileOffset = charOffset;
1618 } 1623 }
1619 } 1624 }
1620 1625
1621 bool addDefaultArguments(FunctionNode function, Arguments arguments, 1626 bool addDefaultArguments(FunctionNode function, Arguments arguments,
1622 List<TypeParameter> typeParameters) { 1627 List<TypeParameter> typeParameters) {
1623 bool missingInitializers = false; 1628 bool missingInitializers = false;
1624 1629
1625 Expression defaultArgumentFrom(Expression expression) { 1630 Expression defaultArgumentFrom(Expression expression) {
1626 if (expression == null) { 1631 if (expression == null) {
1627 missingInitializers = true; 1632 missingInitializers = true;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 1681
1677 if (missingInitializers) { 1682 if (missingInitializers) {
1678 library.addArgumentsWithMissingDefaultValues(arguments, function); 1683 library.addArgumentsWithMissingDefaultValues(arguments, function);
1679 } 1684 }
1680 return true; 1685 return true;
1681 } 1686 }
1682 1687
1683 @override 1688 @override
1684 void handleNewExpression(Token token) { 1689 void handleNewExpression(Token token) {
1685 debugEvent("NewExpression"); 1690 debugEvent("NewExpression");
1691 Token nameToken = token.next ?? token;
ahe 2017/03/13 14:33:52 token.next can't be null.
jensj 2017/03/14 12:37:11 Acknowledged.
1686 Arguments arguments = pop(); 1692 Arguments arguments = pop();
1687 String name = pop(); 1693 String name = pop();
1688 List<DartType> typeArguments = pop(); 1694 List<DartType> typeArguments = pop();
1689 var type = pop(); 1695 var type = pop();
1690 1696
1691 if (arguments == null) { 1697 if (arguments == null) {
1692 push(buildCompileTimeError("No arguments.", token.charOffset)); 1698 push(buildCompileTimeError("No arguments.", nameToken.charOffset));
1693 return; 1699 return;
1694 } 1700 }
1695 1701
1696 if (typeArguments != null) { 1702 if (typeArguments != null) {
1697 assert(arguments.types.isEmpty); 1703 assert(arguments.types.isEmpty);
1698 arguments.types.addAll(typeArguments); 1704 arguments.types.addAll(typeArguments);
1699 } 1705 }
1700 1706
1701 String errorName; 1707 String errorName;
1702 if (type is ClassBuilder) { 1708 if (type is ClassBuilder) {
1703 Builder b = type.findConstructorOrFactory(name); 1709 Builder b = type.findConstructorOrFactory(name);
1704 Member target; 1710 Member target;
1705 if (b == null) { 1711 if (b == null) {
1706 // Not found. Reported below. 1712 // Not found. Reported below.
1707 } else if (b.isConstructor) { 1713 } else if (b.isConstructor) {
1708 if (type.isAbstract) { 1714 if (type.isAbstract) {
1709 // TODO(ahe): Generate abstract instantiation error. 1715 // TODO(ahe): Generate abstract instantiation error.
1710 } else { 1716 } else {
1711 target = b.target; 1717 target = b.target;
1712 } 1718 }
1713 } else if (b.isFactory) { 1719 } else if (b.isFactory) {
1714 target = getRedirectionTarget(b.target); 1720 target = getRedirectionTarget(b.target);
1715 if (target == null) { 1721 if (target == null) {
1716 push(buildCompileTimeError( 1722 push(buildCompileTimeError(
1717 "Cyclic definition of factory '${name}'.", token.charOffset)); 1723 "Cyclic definition of factory '${name}'.", nameToken.charOffset));
1718 return; 1724 return;
1719 } 1725 }
1720 } 1726 }
1721 if (target is Constructor || 1727 if (target is Constructor ||
1722 (target is Procedure && target.kind == ProcedureKind.Factory)) { 1728 (target is Procedure && target.kind == ProcedureKind.Factory)) {
1723 push(buildStaticInvocation(target, arguments, 1729 push(buildStaticInvocation(target, arguments,
1724 isConst: optional("const", token), charOffset: token.charOffset)); 1730 isConst: optional("const", token),
1731 charOffset: nameToken.charOffset));
1725 return; 1732 return;
1726 } else { 1733 } else {
1727 errorName = debugName(type.name, name); 1734 errorName = debugName(type.name, name);
1728 } 1735 }
1729 } else { 1736 } else {
1730 errorName = debugName(getNodeName(type), name); 1737 errorName = debugName(getNodeName(type), name);
1731 } 1738 }
1732 errorName ??= name; 1739 errorName ??= name;
1733 push(throwNoSuchMethodError(errorName, arguments, token.charOffset)); 1740 push(throwNoSuchMethodError(errorName, arguments, nameToken.charOffset));
1734 } 1741 }
1735 1742
1736 @override 1743 @override
1737 void handleConstExpression(Token token) { 1744 void handleConstExpression(Token token) {
1738 debugEvent("ConstExpression"); 1745 debugEvent("ConstExpression");
1739 handleNewExpression(token); 1746 handleNewExpression(token);
1740 } 1747 }
1741 1748
1742 @override 1749 @override
1743 void endTypeArguments(int count, Token beginToken, Token endToken) { 1750 void endTypeArguments(int count, Token beginToken, Token endToken) {
(...skipping 28 matching lines...) Expand all
1772 1779
1773 @override 1780 @override
1774 void handleNamedArgument(Token colon) { 1781 void handleNamedArgument(Token colon) {
1775 debugEvent("NamedArgument"); 1782 debugEvent("NamedArgument");
1776 Expression value = popForValue(); 1783 Expression value = popForValue();
1777 Identifier identifier = pop(); 1784 Identifier identifier = pop();
1778 push(new NamedExpression(identifier.name, value)); 1785 push(new NamedExpression(identifier.name, value));
1779 } 1786 }
1780 1787
1781 @override 1788 @override
1782 void endFunctionName(Token token) { 1789 void endFunctionName(Token beginToken, Token token) {
1783 debugEvent("FunctionName"); 1790 debugEvent("FunctionName");
1784 Identifier name = pop(); 1791 Identifier name = pop();
1785 VariableDeclaration variable = 1792 VariableDeclaration variable =
1786 new VariableDeclaration(name.name, isFinal: true); 1793 new VariableDeclaration(name.name, isFinal: true);
1787 push(new FunctionDeclaration( 1794 push(new FunctionDeclaration(
1788 variable, new FunctionNode(new InvalidStatement()))); 1795 variable, new FunctionNode(new InvalidStatement()))
1796 ..fileOffset = beginToken.charOffset);
1789 scope[variable.name] = new KernelVariableBuilder( 1797 scope[variable.name] = new KernelVariableBuilder(
1790 variable, member ?? classBuilder ?? library, uri); 1798 variable, member ?? classBuilder ?? library, uri);
1791 enterLocalScope(); 1799 enterLocalScope();
1792 } 1800 }
1793 1801
1794 void enterFunction() { 1802 void enterFunction() {
1795 debugEvent("enterFunction"); 1803 debugEvent("enterFunction");
1796 functionNestingLevel++; 1804 functionNestingLevel++;
1797 push(switchScope ?? NullValue.SwitchScope); 1805 push(switchScope ?? NullValue.SwitchScope);
1798 switchScope = null; 1806 switchScope = null;
(...skipping 11 matching lines...) Expand all
1810 enterFunction(); 1818 enterFunction();
1811 } 1819 }
1812 1820
1813 @override 1821 @override
1814 void beginUnnamedFunction(Token token) { 1822 void beginUnnamedFunction(Token token) {
1815 debugEvent("beginUnnamedFunction"); 1823 debugEvent("beginUnnamedFunction");
1816 enterFunction(); 1824 enterFunction();
1817 } 1825 }
1818 1826
1819 @override 1827 @override
1820 void endFunction(Token getOrSet, Token endToken) { 1828 void endFunction(
1829 Token getOrSet, Token formalParametersToken, Token endToken) {
1821 debugEvent("Function"); 1830 debugEvent("Function");
1822 Statement body = popStatement(); 1831 Statement body = popStatement();
1823 AsyncMarker asyncModifier = pop(); 1832 AsyncMarker asyncModifier = pop();
1824 if (functionNestingLevel != 0) { 1833 if (functionNestingLevel != 0) {
1825 exitLocalScope(); 1834 exitLocalScope();
1826 } 1835 }
1827 FormalParameters formals = pop(); 1836 FormalParameters formals = pop();
1828 List<TypeParameter> typeParameters = pop(); 1837 List<TypeParameter> typeParameters = pop();
1829 push(formals.addToFunction(new FunctionNode(body, 1838 push(formals.addToFunction(new FunctionNode(body,
1830 typeParameters: typeParameters, asyncMarker: asyncModifier))); 1839 typeParameters: typeParameters, asyncMarker: asyncModifier)
1840 ..fileOffset = formalParametersToken.charOffset
1841 ..fileEndOffset = endToken.charOffset));
1831 } 1842 }
1832 1843
1833 @override 1844 @override
1834 void endFunctionDeclaration(Token token) { 1845 void endFunctionDeclaration(Token token) {
1835 debugEvent("FunctionDeclaration"); 1846 debugEvent("FunctionDeclaration");
1836 FunctionNode function = pop(); 1847 FunctionNode function = pop();
1837 exitLocalScope(); 1848 exitLocalScope();
1838 FunctionDeclaration declaration = pop(); 1849 FunctionDeclaration declaration = pop();
1839 function.returnType = pop() ?? const DynamicType(); 1850 function.returnType = pop() ?? const DynamicType();
1840 pop(); // Modifiers. 1851 pop(); // Modifiers.
1841 exitFunction(); 1852 exitFunction();
1842 declaration.function = function; 1853 declaration.function = function;
1843 function.parent = declaration; 1854 function.parent = declaration;
1844 push(declaration); 1855 push(declaration);
1845 } 1856 }
1846 1857
1847 @override 1858 @override
1848 void endUnnamedFunction(Token token) { 1859 void endUnnamedFunction(Token beginToken, Token token) {
1849 debugEvent("UnnamedFunction"); 1860 debugEvent("UnnamedFunction");
1850 Statement body = popStatement(); 1861 Statement body = popStatement();
1851 AsyncMarker asyncModifier = pop(); 1862 AsyncMarker asyncModifier = pop();
1852 exitLocalScope(); 1863 exitLocalScope();
1853 FormalParameters formals = pop(); 1864 FormalParameters formals = pop();
1854 exitFunction(); 1865 exitFunction();
1855 List<TypeParameter> typeParameters = pop(); 1866 List<TypeParameter> typeParameters = pop();
1856 FunctionNode function = formals.addToFunction(new FunctionNode(body, 1867 FunctionNode function = formals.addToFunction(new FunctionNode(body,
1857 typeParameters: typeParameters, asyncMarker: asyncModifier)); 1868 typeParameters: typeParameters, asyncMarker: asyncModifier)
1858 push(new FunctionExpression(function)); 1869 ..fileOffset = beginToken.charOffset
1870 ..fileEndOffset = token.charOffset);
1871 push(new FunctionExpression(function)..fileOffset = beginToken.charOffset);
1859 } 1872 }
1860 1873
1861 @override 1874 @override
1862 void endDoWhileStatement( 1875 void endDoWhileStatement(
1863 Token doKeyword, Token whileKeyword, Token endToken) { 1876 Token doKeyword, Token whileKeyword, Token endToken) {
1864 debugEvent("DoWhileStatement"); 1877 debugEvent("DoWhileStatement");
1865 Expression condition = popForValue(); 1878 Expression condition = popForValue();
1866 Statement body = popStatement(); 1879 Statement body = popStatement();
1867 JumpTarget continueTarget = exitContinueTarget(); 1880 JumpTarget continueTarget = exitContinueTarget();
1868 JumpTarget breakTarget = exitBreakTarget(); 1881 JumpTarget breakTarget = exitBreakTarget();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 statement = new LabeledStatement(statement); 1987 statement = new LabeledStatement(statement);
1975 } 1988 }
1976 target.continueTarget.resolveContinues(statement); 1989 target.continueTarget.resolveContinues(statement);
1977 } 1990 }
1978 push(statement); 1991 push(statement);
1979 } 1992 }
1980 1993
1981 @override 1994 @override
1982 void endRethrowStatement(Token throwToken, Token endToken) { 1995 void endRethrowStatement(Token throwToken, Token endToken) {
1983 debugEvent("RethrowStatement"); 1996 debugEvent("RethrowStatement");
1984 push(new ExpressionStatement(new Rethrow())); 1997 push(new ExpressionStatement(
1998 new Rethrow()..fileOffset = throwToken.charOffset));
1985 } 1999 }
1986 2000
1987 @override 2001 @override
1988 void handleFinallyBlock(Token finallyKeyword) { 2002 void handleFinallyBlock(Token finallyKeyword) {
1989 debugEvent("FinallyBlock"); 2003 debugEvent("FinallyBlock");
1990 // Do nothing, handled by [endTryStatement]. 2004 // Do nothing, handled by [endTryStatement].
1991 } 2005 }
1992 2006
1993 @override 2007 @override
1994 void endWhileStatement(Token whileKeyword, Token endToken) { 2008 void endWhileStatement(Token whileKeyword, Token endToken) {
(...skipping 25 matching lines...) Expand all
2020 Token assertKeyword, Token commaToken, Token semicolonToken) { 2034 Token assertKeyword, Token commaToken, Token semicolonToken) {
2021 debugEvent("AssertStatement"); 2035 debugEvent("AssertStatement");
2022 Expression message = popForValueIfNotNull(commaToken); 2036 Expression message = popForValueIfNotNull(commaToken);
2023 Expression condition = popForValue(); 2037 Expression condition = popForValue();
2024 push(new AssertStatement(condition, message)); 2038 push(new AssertStatement(condition, message));
2025 } 2039 }
2026 2040
2027 @override 2041 @override
2028 void endYieldStatement(Token yieldToken, Token starToken, Token endToken) { 2042 void endYieldStatement(Token yieldToken, Token starToken, Token endToken) {
2029 debugEvent("YieldStatement"); 2043 debugEvent("YieldStatement");
2030 push(new YieldStatement(popForValue(), isYieldStar: starToken != null)); 2044 push(new YieldStatement(popForValue(), isYieldStar: starToken != null)
2045 ..fileOffset = yieldToken.charOffset);
2031 } 2046 }
2032 2047
2033 @override 2048 @override
2034 void beginSwitchBlock(Token token) { 2049 void beginSwitchBlock(Token token) {
2035 debugEvent("beginSwitchBlock"); 2050 debugEvent("beginSwitchBlock");
2036 enterLocalScope(); 2051 enterLocalScope();
2037 enterSwitchScope(); 2052 enterSwitchScope();
2038 enterBreakTarget(token.charOffset); 2053 enterBreakTarget(token.charOffset);
2039 } 2054 }
2040 2055
(...skipping 28 matching lines...) Expand all
2069 2084
2070 @override 2085 @override
2071 void handleSwitchCase( 2086 void handleSwitchCase(
2072 int labelCount, 2087 int labelCount,
2073 int expressionCount, 2088 int expressionCount,
2074 Token defaultKeyword, 2089 Token defaultKeyword,
2075 int statementCount, 2090 int statementCount,
2076 Token firstToken, 2091 Token firstToken,
2077 Token endToken) { 2092 Token endToken) {
2078 debugEvent("SwitchCase"); 2093 debugEvent("SwitchCase");
2079 Block block = popBlock(statementCount); 2094 Block block = popBlock(statementCount, firstToken);
2080 exitLocalScope(); 2095 exitLocalScope();
2081 List<Label> labels = pop(); 2096 List<Label> labels = pop();
2082 List<Expression> expressions = pop(); 2097 List<Expression> expressions = pop();
2083 push(new SwitchCase(expressions, block, isDefault: defaultKeyword != null) 2098 push(new SwitchCase(expressions, block, isDefault: defaultKeyword != null)
2084 ..fileOffset = firstToken.charOffset); 2099 ..fileOffset = firstToken.charOffset);
2085 push(labels); 2100 push(labels);
2086 } 2101 }
2087 2102
2088 @override 2103 @override
2089 void endSwitchStatement(Token switchKeyword, Token endToken) { 2104 void endSwitchStatement(Token switchKeyword, Token endToken) {
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 } else if (node is PrefixBuilder) { 2778 } else if (node is PrefixBuilder) {
2764 return node.name; 2779 return node.name;
2765 } else if (node is ThisAccessor) { 2780 } else if (node is ThisAccessor) {
2766 return node.isSuper ? "super" : "this"; 2781 return node.isSuper ? "super" : "this";
2767 } else if (node is BuilderAccessor) { 2782 } else if (node is BuilderAccessor) {
2768 return node.plainNameForRead; 2783 return node.plainNameForRead;
2769 } else { 2784 } else {
2770 return internalError("Unhandled: ${node.runtimeType}"); 2785 return internalError("Unhandled: ${node.runtimeType}");
2771 } 2786 }
2772 } 2787 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698