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.body_builder; | 5 library fasta.body_builder; |
6 | 6 |
7 import '../fasta_codes.dart' show Message; | 7 import 'package:kernel/ast.dart' |
| 8 hide InvalidExpression, InvalidInitializer, InvalidStatement; |
| 9 |
| 10 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; |
| 11 |
| 12 import 'package:kernel/clone.dart' show CloneVisitor; |
| 13 |
| 14 import 'package:kernel/core_types.dart' show CoreTypes; |
| 15 |
| 16 import 'package:kernel/transformations/flags.dart' show TransformerFlag; |
| 17 |
| 18 import '../../scanner/token.dart' show BeginToken, Token; |
| 19 |
| 20 import '../deprecated_problems.dart' |
| 21 show deprecated_InputError, deprecated_formatUnexpected; |
8 | 22 |
9 import '../fasta_codes.dart' as fasta; | 23 import '../fasta_codes.dart' as fasta; |
10 | 24 |
11 import '../parser/parser.dart' | 25 import '../fasta_codes.dart' show Message; |
12 show Assert, FormalParameterType, MemberKind, optional; | 26 |
| 27 import '../messages.dart' as messages show getLocationFromUri; |
| 28 |
| 29 import '../modifier.dart' show Modifier, constMask, finalMask; |
13 | 30 |
14 import '../parser/identifier_context.dart' show IdentifierContext; | 31 import '../parser/identifier_context.dart' show IdentifierContext; |
15 | 32 |
16 import '../parser/native_support.dart' show skipNativeClause; | 33 import '../parser/native_support.dart' show skipNativeClause; |
17 | 34 |
18 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'; | 35 import '../parser/parser.dart' |
| 36 show Assert, FormalParameterType, MemberKind, optional; |
19 | 37 |
20 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken; | 38 import '../problems.dart' |
21 | 39 show internalProblem, unexpected, unhandled, unsupported; |
22 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart' | |
23 show TypeInferrer; | |
24 | |
25 import 'package:front_end/src/fasta/type_inference/type_promotion.dart' | |
26 show TypePromoter; | |
27 | |
28 import 'package:kernel/ast.dart' | |
29 hide InvalidExpression, InvalidInitializer, InvalidStatement; | |
30 | |
31 import 'package:kernel/clone.dart' show CloneVisitor; | |
32 | |
33 import 'package:kernel/transformations/flags.dart' show TransformerFlag; | |
34 | |
35 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; | |
36 | |
37 import 'package:kernel/core_types.dart' show CoreTypes; | |
38 | |
39 import 'frontend_accessors.dart' show buildIsNull, makeBinary; | |
40 | |
41 import '../messages.dart' as messages show getLocationFromUri; | |
42 | |
43 import '../../scanner/token.dart' show BeginToken, Token; | |
44 | |
45 import '../scanner/token.dart' show isBinaryOperator, isMinusOperator; | |
46 | |
47 import '../deprecated_problems.dart' | |
48 show | |
49 deprecated_InputError, | |
50 deprecated_formatUnexpected, | |
51 deprecated_internalProblem; | |
52 | |
53 import '../source/scope_listener.dart' | |
54 show JumpTargetKind, NullValue, ScopeListener; | |
55 | |
56 import '../scope.dart' show ProblemBuilder; | |
57 | |
58 import 'fasta_accessors.dart'; | |
59 | 40 |
60 import '../quote.dart' | 41 import '../quote.dart' |
61 show | 42 show |
62 Quote, | 43 Quote, |
63 analyzeQuote, | 44 analyzeQuote, |
64 unescape, | 45 unescape, |
65 unescapeFirstStringPart, | 46 unescapeFirstStringPart, |
66 unescapeLastStringPart, | 47 unescapeLastStringPart, |
67 unescapeString; | 48 unescapeString; |
68 | 49 |
69 import '../modifier.dart' show Modifier, constMask, finalMask; | 50 import '../scanner/token.dart' show isBinaryOperator, isMinusOperator; |
| 51 |
| 52 import '../scope.dart' show ProblemBuilder; |
| 53 |
| 54 import '../source/scope_listener.dart' |
| 55 show JumpTargetKind, NullValue, ScopeListener; |
| 56 |
| 57 import '../type_inference/type_inferrer.dart' show TypeInferrer; |
| 58 |
| 59 import '../type_inference/type_promotion.dart' show TypePromoter; |
| 60 |
| 61 import 'frontend_accessors.dart' show buildIsNull, makeBinary; |
70 | 62 |
71 import 'redirecting_factory_body.dart' | 63 import 'redirecting_factory_body.dart' |
72 show | 64 show |
73 RedirectingFactoryBody, | 65 RedirectingFactoryBody, |
74 getRedirectingFactoryBody, | 66 getRedirectingFactoryBody, |
75 getRedirectionTarget; | 67 getRedirectionTarget; |
76 | 68 |
| 69 import 'utils.dart' show offsetForToken; |
| 70 |
| 71 import '../names.dart'; |
| 72 |
| 73 import 'fasta_accessors.dart'; |
| 74 |
77 import 'kernel_builder.dart'; | 75 import 'kernel_builder.dart'; |
78 | 76 |
79 import '../names.dart'; | 77 import 'kernel_shadow_ast.dart'; |
80 | 78 |
81 class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { | 79 class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
82 @override | 80 @override |
83 final KernelLibraryBuilder library; | 81 final KernelLibraryBuilder library; |
84 | 82 |
85 final ModifierBuilder member; | 83 final ModifierBuilder member; |
86 | 84 |
87 final KernelClassBuilder classBuilder; | 85 final KernelClassBuilder classBuilder; |
88 | 86 |
89 final ClassHierarchy hierarchy; | 87 final ClassHierarchy hierarchy; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 if (node is FastaAccessor) { | 221 if (node is FastaAccessor) { |
224 return node.buildSimpleRead(); | 222 return node.buildSimpleRead(); |
225 } else if (node is Expression) { | 223 } else if (node is Expression) { |
226 return node; | 224 return node; |
227 } else if (node is PrefixBuilder) { | 225 } else if (node is PrefixBuilder) { |
228 return deprecated_buildCompileTimeError( | 226 return deprecated_buildCompileTimeError( |
229 "A library can't be used as an expression."); | 227 "A library can't be used as an expression."); |
230 } else if (node is ProblemBuilder) { | 228 } else if (node is ProblemBuilder) { |
231 return buildProblemExpression(node, -1); | 229 return buildProblemExpression(node, -1); |
232 } else { | 230 } else { |
233 return deprecated_internalProblem("Unhandled: ${node.runtimeType}"); | 231 return unhandled("${node.runtimeType}", "toValue", -1, uri); |
234 } | 232 } |
235 } | 233 } |
236 | 234 |
237 Expression toEffect(Object node) { | 235 Expression toEffect(Object node) { |
238 if (node is FastaAccessor) return node.buildForEffect(); | 236 if (node is FastaAccessor) return node.buildForEffect(); |
239 return toValue(node); | 237 return toValue(node); |
240 } | 238 } |
241 | 239 |
242 List<Expression> popListForValue(int n) { | 240 List<Expression> popListForValue(int n) { |
243 List<Expression> list = | 241 List<Expression> list = |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 if (classBuilder != null) { | 432 if (classBuilder != null) { |
435 field = classBuilder[name]; | 433 field = classBuilder[name]; |
436 } else { | 434 } else { |
437 field = library[name]; | 435 field = library[name]; |
438 } | 436 } |
439 fields.add(field); | 437 fields.add(field); |
440 if (initializer != null) { | 438 if (initializer != null) { |
441 if (field.next != null) { | 439 if (field.next != null) { |
442 // TODO(ahe): This can happen, for example, if a final field is | 440 // TODO(ahe): This can happen, for example, if a final field is |
443 // combined with a setter. | 441 // combined with a setter. |
444 deprecated_internalProblem( | 442 unhandled("field with more than one declaration", field.name, |
445 "Unhandled: '${field.name}' has more than one declaration."); | 443 field.charOffset, field.fileUri); |
446 } | 444 } |
447 field.initializer = initializer; | 445 field.initializer = initializer; |
448 _typeInferrer.inferFieldInitializer( | 446 _typeInferrer.inferFieldInitializer( |
449 field.hasImplicitType ? null : field.builtType, initializer); | 447 field.hasImplicitType ? null : field.builtType, initializer); |
450 } | 448 } |
451 } | 449 } |
452 pop(); // Type. | 450 pop(); // Type. |
453 pop(); // Modifiers. | 451 pop(); // Modifiers. |
454 List annotations = pop(); | 452 List annotations = pop(); |
455 if (annotations != null) { | 453 if (annotations != null) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 _typeInferrer.inferParameterInitializer( | 612 _typeInferrer.inferParameterInitializer( |
615 initializer, realParameter.type); | 613 initializer, realParameter.type); |
616 realParameter.initializer = initializer..parent = realParameter; | 614 realParameter.initializer = initializer..parent = realParameter; |
617 } | 615 } |
618 } | 616 } |
619 if (builder is KernelConstructorBuilder) { | 617 if (builder is KernelConstructorBuilder) { |
620 finishConstructor(builder, asyncModifier); | 618 finishConstructor(builder, asyncModifier); |
621 } else if (builder is KernelProcedureBuilder) { | 619 } else if (builder is KernelProcedureBuilder) { |
622 builder.asyncModifier = asyncModifier; | 620 builder.asyncModifier = asyncModifier; |
623 } else { | 621 } else { |
624 deprecated_internalProblem("Unhandled: ${builder.runtimeType}"); | 622 unhandled("${builder.runtimeType}", "finishFunction", builder.charOffset, |
| 623 builder.fileUri); |
625 } | 624 } |
626 } | 625 } |
627 | 626 |
628 @override | 627 @override |
629 List<Expression> finishMetadata() { | 628 List<Expression> finishMetadata() { |
630 List<Expression> expressions = pop(); | 629 List<Expression> expressions = pop(); |
631 _typeInferrer.inferMetadata(expressions); | 630 _typeInferrer.inferMetadata(expressions); |
632 return expressions; | 631 return expressions; |
633 } | 632 } |
634 | 633 |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 deprecated_addCompileTimeError( | 1146 deprecated_addCompileTimeError( |
1148 offsetForToken(token), | 1147 offsetForToken(token), |
1149 "'$name' can't be used in a constant expression because it's " | 1148 "'$name' can't be used in a constant expression because it's " |
1150 "marked as 'deferred' which means it isn't available until " | 1149 "marked as 'deferred' which means it isn't available until " |
1151 "loaded.\n" | 1150 "loaded.\n" |
1152 "You might try moving the constant to the deferred library, " | 1151 "You might try moving the constant to the deferred library, " |
1153 "or removing 'deferred' from the import."); | 1152 "or removing 'deferred' from the import."); |
1154 } | 1153 } |
1155 return builder; | 1154 return builder; |
1156 } else { | 1155 } else { |
1157 if (builder.hasProblem && builder is! deprecated_AccessErrorBuilder) | 1156 if (builder.hasProblem && builder is! AccessErrorBuilder) return builder; |
1158 return builder; | |
1159 Builder setter; | 1157 Builder setter; |
1160 if (builder.isSetter) { | 1158 if (builder.isSetter) { |
1161 setter = builder; | 1159 setter = builder; |
1162 } else if (builder.isGetter) { | 1160 } else if (builder.isGetter) { |
1163 setter = scope.lookupSetter(name, offsetForToken(token), uri); | 1161 setter = scope.lookupSetter(name, offsetForToken(token), uri); |
1164 } else if (builder.isField && !builder.isFinal) { | 1162 } else if (builder.isField && !builder.isFinal) { |
1165 setter = builder; | 1163 setter = builder; |
1166 } | 1164 } |
1167 StaticAccessor accessor = | 1165 StaticAccessor accessor = |
1168 new StaticAccessor.fromBuilder(this, builder, token, setter); | 1166 new StaticAccessor.fromBuilder(this, builder, token, setter); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 variables.add(variableOrExpression); | 1487 variables.add(variableOrExpression); |
1490 } else if (variableOrExpression is List) { | 1488 } else if (variableOrExpression is List) { |
1491 // TODO(sigmund): remove this assignment (see issue #28651) | 1489 // TODO(sigmund): remove this assignment (see issue #28651) |
1492 Iterable vars = variableOrExpression; | 1490 Iterable vars = variableOrExpression; |
1493 variables.addAll(vars); | 1491 variables.addAll(vars); |
1494 } else if (variableOrExpression == null) { | 1492 } else if (variableOrExpression == null) { |
1495 // Do nothing. | 1493 // Do nothing. |
1496 } else if (variableOrExpression is Expression) { | 1494 } else if (variableOrExpression is Expression) { |
1497 begin = new KernelExpressionStatement(variableOrExpression); | 1495 begin = new KernelExpressionStatement(variableOrExpression); |
1498 } else { | 1496 } else { |
1499 return deprecated_internalProblem( | 1497 return unhandled("${variableOrExpression.runtimeType}", "endForStatement", |
1500 "Unhandled: ${variableOrExpression.runtimeType}"); | 1498 forKeyword.charOffset, uri); |
1501 } | 1499 } |
1502 exitLocalScope(); | 1500 exitLocalScope(); |
1503 JumpTarget continueTarget = exitContinueTarget(); | 1501 JumpTarget continueTarget = exitContinueTarget(); |
1504 JumpTarget breakTarget = exitBreakTarget(); | 1502 JumpTarget breakTarget = exitBreakTarget(); |
1505 if (continueTarget.hasUsers) { | 1503 if (continueTarget.hasUsers) { |
1506 body = new KernelLabeledStatement(body); | 1504 body = new KernelLabeledStatement(body); |
1507 continueTarget.resolveContinues(body); | 1505 continueTarget.resolveContinues(body); |
1508 } | 1506 } |
1509 Statement result = | 1507 Statement result = |
1510 new KernelForStatement(variables, condition, updates, body); | 1508 new KernelForStatement(variables, condition, updates, body); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1603 Expression key = popForValue(); | 1601 Expression key = popForValue(); |
1604 push(new MapEntry(key, value)); | 1602 push(new MapEntry(key, value)); |
1605 } | 1603 } |
1606 | 1604 |
1607 String symbolPartToString(name) { | 1605 String symbolPartToString(name) { |
1608 if (name is Identifier) { | 1606 if (name is Identifier) { |
1609 return name.name; | 1607 return name.name; |
1610 } else if (name is Operator) { | 1608 } else if (name is Operator) { |
1611 return name.name; | 1609 return name.name; |
1612 } else { | 1610 } else { |
1613 return deprecated_internalProblem("Unhandled: ${name.runtimeType}"); | 1611 return unhandled("${name.runtimeType}", "symbolPartToString", -1, uri); |
1614 } | 1612 } |
1615 } | 1613 } |
1616 | 1614 |
1617 @override | 1615 @override |
1618 void endLiteralSymbol(Token hashToken, int identifierCount) { | 1616 void endLiteralSymbol(Token hashToken, int identifierCount) { |
1619 debugEvent("LiteralSymbol"); | 1617 debugEvent("LiteralSymbol"); |
1620 String value; | 1618 String value; |
1621 if (identifierCount == 1) { | 1619 if (identifierCount == 1) { |
1622 value = symbolPartToString(pop()); | 1620 value = symbolPartToString(pop()); |
1623 } else { | 1621 } else { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1660 } | 1658 } |
1661 | 1659 |
1662 @override | 1660 @override |
1663 void handleType(Token beginToken, Token endToken) { | 1661 void handleType(Token beginToken, Token endToken) { |
1664 // TODO(ahe): The scope is wrong for return types of generic functions. | 1662 // TODO(ahe): The scope is wrong for return types of generic functions. |
1665 debugEvent("Type"); | 1663 debugEvent("Type"); |
1666 List<DartType> arguments = pop(); | 1664 List<DartType> arguments = pop(); |
1667 dynamic name = pop(); | 1665 dynamic name = pop(); |
1668 if (name is List) { | 1666 if (name is List) { |
1669 if (name.length != 2) { | 1667 if (name.length != 2) { |
1670 deprecated_internalProblem("Unexpected: $name.length"); | 1668 unexpected("${name.length}", "2", beginToken.charOffset, uri); |
1671 } | 1669 } |
1672 var prefix = name[0]; | 1670 var prefix = name[0]; |
1673 if (prefix is Identifier) { | 1671 if (prefix is Identifier) { |
1674 prefix = prefix.name; | 1672 prefix = prefix.name; |
1675 } | 1673 } |
1676 var suffix = name[1]; | 1674 var suffix = name[1]; |
1677 if (suffix is Identifier) { | 1675 if (suffix is Identifier) { |
1678 suffix = suffix.name; | 1676 suffix = suffix.name; |
1679 } | 1677 } |
1680 Builder builder; | 1678 Builder builder; |
(...skipping 21 matching lines...) Expand all Loading... |
1702 warningNotError(fasta.templateNotAType.withArguments(beginToken.lexeme), | 1700 warningNotError(fasta.templateNotAType.withArguments(beginToken.lexeme), |
1703 beginToken.charOffset); | 1701 beginToken.charOffset); |
1704 push(const InvalidType()); | 1702 push(const InvalidType()); |
1705 } else if (name is TypeBuilder) { | 1703 } else if (name is TypeBuilder) { |
1706 push(name.build(library)); | 1704 push(name.build(library)); |
1707 } else if (name is Builder) { | 1705 } else if (name is Builder) { |
1708 push(kernelTypeFromBuilder(name, arguments, beginToken.charOffset)); | 1706 push(kernelTypeFromBuilder(name, arguments, beginToken.charOffset)); |
1709 } else if (name is String) { | 1707 } else if (name is String) { |
1710 push(kernelTypeFromString(name, arguments, beginToken.charOffset)); | 1708 push(kernelTypeFromString(name, arguments, beginToken.charOffset)); |
1711 } else { | 1709 } else { |
1712 deprecated_internalProblem("Unhandled: '${name.runtimeType}'."); | 1710 unhandled( |
| 1711 "${name.runtimeType}", "handleType", beginToken.charOffset, uri); |
1713 } | 1712 } |
1714 // TODO(ahe): Unused code fasta.messageNonInstanceTypeVariableUse. | 1713 // TODO(ahe): Unused code fasta.messageNonInstanceTypeVariableUse. |
1715 } | 1714 } |
1716 | 1715 |
1717 @override | 1716 @override |
1718 void beginFunctionType(Token beginToken) { | 1717 void beginFunctionType(Token beginToken) { |
1719 debugEvent("beginFunctionType"); | 1718 debugEvent("beginFunctionType"); |
1720 enterFunctionTypeScope(); | 1719 enterFunctionTypeScope(); |
1721 } | 1720 } |
1722 | 1721 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 bool isConst = (modifiers & constMask) != 0; | 1837 bool isConst = (modifiers & constMask) != 0; |
1839 bool isFinal = (modifiers & finalMask) != 0; | 1838 bool isFinal = (modifiers & finalMask) != 0; |
1840 ignore(Unhandled.Metadata); | 1839 ignore(Unhandled.Metadata); |
1841 VariableDeclaration variable; | 1840 VariableDeclaration variable; |
1842 if (!inCatchClause && | 1841 if (!inCatchClause && |
1843 functionNestingLevel == 0 && | 1842 functionNestingLevel == 0 && |
1844 memberKind != MemberKind.GeneralizedFunctionType) { | 1843 memberKind != MemberKind.GeneralizedFunctionType) { |
1845 ProcedureBuilder member = this.member; | 1844 ProcedureBuilder member = this.member; |
1846 KernelFormalParameterBuilder formal = member.getFormal(name.name); | 1845 KernelFormalParameterBuilder formal = member.getFormal(name.name); |
1847 if (formal == null) { | 1846 if (formal == null) { |
1848 deprecated_internalProblem( | 1847 internalProblem( |
1849 "Internal error: formal missing for '${name.name}'"); | 1848 fasta.templateInternalProblemNotFoundIn |
| 1849 .withArguments(name.name, "formals"), |
| 1850 member.charOffset, |
| 1851 member.fileUri); |
1850 } else { | 1852 } else { |
1851 variable = formal.build(library); | 1853 variable = formal.build(library); |
1852 variable.initializer = name.initializer; | 1854 variable.initializer = name.initializer; |
1853 } | 1855 } |
1854 } else { | 1856 } else { |
1855 variable = new KernelVariableDeclaration(name?.name, functionNestingLevel, | 1857 variable = new KernelVariableDeclaration(name?.name, functionNestingLevel, |
1856 type: type, | 1858 type: type, |
1857 initializer: name?.initializer, | 1859 initializer: name?.initializer, |
1858 isFinal: isFinal, | 1860 isFinal: isFinal, |
1859 isConst: isConst); | 1861 isConst: isConst); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 // This *could* be a constant expression, we can't know without | 2051 // This *could* be a constant expression, we can't know without |
2050 // evaluating [receiver]. | 2052 // evaluating [receiver]. |
2051 isConstantExpression: true)); | 2053 isConstantExpression: true)); |
2052 } | 2054 } |
2053 } | 2055 } |
2054 } | 2056 } |
2055 | 2057 |
2056 Name incrementOperator(Token token) { | 2058 Name incrementOperator(Token token) { |
2057 if (optional("++", token)) return plusName; | 2059 if (optional("++", token)) return plusName; |
2058 if (optional("--", token)) return minusName; | 2060 if (optional("--", token)) return minusName; |
2059 return deprecated_internalProblem( | 2061 return unhandled(token.lexeme, "incrementOperator", token.charOffset, uri); |
2060 "Unknown increment operator: ${token.lexeme}"); | |
2061 } | 2062 } |
2062 | 2063 |
2063 @override | 2064 @override |
2064 void handleUnaryPrefixAssignmentExpression(Token token) { | 2065 void handleUnaryPrefixAssignmentExpression(Token token) { |
2065 debugEvent("UnaryPrefixAssignmentExpression"); | 2066 debugEvent("UnaryPrefixAssignmentExpression"); |
2066 var accessor = pop(); | 2067 var accessor = pop(); |
2067 if (accessor is FastaAccessor) { | 2068 if (accessor is FastaAccessor) { |
2068 push(accessor.buildPrefixIncrement(incrementOperator(token), | 2069 push(accessor.buildPrefixIncrement(incrementOperator(token), |
2069 offset: token.charOffset)); | 2070 offset: token.charOffset)); |
2070 } else { | 2071 } else { |
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3410 | 3411 |
3411 abstract class ContextAccessor extends FastaAccessor { | 3412 abstract class ContextAccessor extends FastaAccessor { |
3412 final BuilderHelper helper; | 3413 final BuilderHelper helper; |
3413 | 3414 |
3414 final FastaAccessor accessor; | 3415 final FastaAccessor accessor; |
3415 | 3416 |
3416 final Token token; | 3417 final Token token; |
3417 | 3418 |
3418 ContextAccessor(this.helper, this.token, this.accessor); | 3419 ContextAccessor(this.helper, this.token, this.accessor); |
3419 | 3420 |
3420 String get plainNameForRead => | 3421 String get plainNameForRead { |
3421 deprecated_internalProblem("Unsupported operation."); | 3422 return unsupported("plainNameForRead", token.charOffset, helper.uri); |
| 3423 } |
3422 | 3424 |
3423 Expression doInvocation(int charOffset, Arguments arguments) { | 3425 Expression doInvocation(int charOffset, Arguments arguments) { |
3424 return deprecated_internalProblem( | 3426 return unhandled("${runtimeType}", "doInvocation", charOffset, uri); |
3425 "Unhandled: ${runtimeType}", uri, charOffset); | |
3426 } | 3427 } |
3427 | 3428 |
3428 Expression buildSimpleRead(); | 3429 Expression buildSimpleRead(); |
3429 | 3430 |
3430 Expression buildForEffect(); | 3431 Expression buildForEffect(); |
3431 | 3432 |
3432 Expression buildAssignment(Expression value, {bool voidContext: false}) { | 3433 Expression buildAssignment(Expression value, {bool voidContext: false}) { |
3433 return makeInvalidWrite(value); | 3434 return makeInvalidWrite(value); |
3434 } | 3435 } |
3435 | 3436 |
(...skipping 18 matching lines...) Expand all Loading... |
3454 return makeInvalidWrite(null); | 3455 return makeInvalidWrite(null); |
3455 } | 3456 } |
3456 | 3457 |
3457 Expression buildPostfixIncrement(Name binaryOperator, | 3458 Expression buildPostfixIncrement(Name binaryOperator, |
3458 {int offset: TreeNode.noOffset, | 3459 {int offset: TreeNode.noOffset, |
3459 bool voidContext: false, | 3460 bool voidContext: false, |
3460 Procedure interfaceTarget}) { | 3461 Procedure interfaceTarget}) { |
3461 return makeInvalidWrite(null); | 3462 return makeInvalidWrite(null); |
3462 } | 3463 } |
3463 | 3464 |
3464 makeInvalidRead() => deprecated_internalProblem("not supported"); | 3465 makeInvalidRead() { |
| 3466 return unsupported("makeInvalidRead", token.charOffset, helper.uri); |
| 3467 } |
3465 | 3468 |
3466 Expression makeInvalidWrite(Expression value) { | 3469 Expression makeInvalidWrite(Expression value) { |
3467 return helper.deprecated_buildCompileTimeError( | 3470 return helper.deprecated_buildCompileTimeError( |
3468 "Can't be used as left-hand side of assignment.", | 3471 "Can't be used as left-hand side of assignment.", |
3469 offsetForToken(token)); | 3472 offsetForToken(token)); |
3470 } | 3473 } |
3471 } | 3474 } |
3472 | 3475 |
3473 class DelayedAssignment extends ContextAccessor { | 3476 class DelayedAssignment extends ContextAccessor { |
3474 final Expression value; | 3477 final Expression value; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3525 } else if (identical("^=", assignmentOperator)) { | 3528 } else if (identical("^=", assignmentOperator)) { |
3526 return accessor.buildCompoundAssignment(caretName, value, | 3529 return accessor.buildCompoundAssignment(caretName, value, |
3527 offset: offsetForToken(token), voidContext: voidContext); | 3530 offset: offsetForToken(token), voidContext: voidContext); |
3528 } else if (identical("|=", assignmentOperator)) { | 3531 } else if (identical("|=", assignmentOperator)) { |
3529 return accessor.buildCompoundAssignment(barName, value, | 3532 return accessor.buildCompoundAssignment(barName, value, |
3530 offset: offsetForToken(token), voidContext: voidContext); | 3533 offset: offsetForToken(token), voidContext: voidContext); |
3531 } else if (identical("~/=", assignmentOperator)) { | 3534 } else if (identical("~/=", assignmentOperator)) { |
3532 return accessor.buildCompoundAssignment(mustacheName, value, | 3535 return accessor.buildCompoundAssignment(mustacheName, value, |
3533 offset: offsetForToken(token), voidContext: voidContext); | 3536 offset: offsetForToken(token), voidContext: voidContext); |
3534 } else { | 3537 } else { |
3535 return deprecated_internalProblem("Unhandled: $assignmentOperator"); | 3538 return unhandled( |
| 3539 assignmentOperator, "handleAssignment", token.charOffset, helper.uri); |
3536 } | 3540 } |
3537 } | 3541 } |
3538 | 3542 |
3539 @override | 3543 @override |
3540 Initializer buildFieldInitializer(Map<String, int> initializedFields) { | 3544 Initializer buildFieldInitializer(Map<String, int> initializedFields) { |
3541 if (!identical("=", assignmentOperator) || | 3545 if (!identical("=", assignmentOperator) || |
3542 !accessor.isThisPropertyAccessor) { | 3546 !accessor.isThisPropertyAccessor) { |
3543 return accessor.buildFieldInitializer(initializedFields); | 3547 return accessor.buildFieldInitializer(initializedFields); |
3544 } | 3548 } |
3545 return helper.buildFieldInitializer( | 3549 return helper.buildFieldInitializer( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3642 | 3646 |
3643 LabelTarget(MemberBuilder member, this.functionNestingLevel, int charOffset) | 3647 LabelTarget(MemberBuilder member, this.functionNestingLevel, int charOffset) |
3644 : breakTarget = new JumpTarget( | 3648 : breakTarget = new JumpTarget( |
3645 JumpTargetKind.Break, functionNestingLevel, member, charOffset), | 3649 JumpTargetKind.Break, functionNestingLevel, member, charOffset), |
3646 continueTarget = new JumpTarget( | 3650 continueTarget = new JumpTarget( |
3647 JumpTargetKind.Continue, functionNestingLevel, member, charOffset), | 3651 JumpTargetKind.Continue, functionNestingLevel, member, charOffset), |
3648 super(member, charOffset, member.fileUri); | 3652 super(member, charOffset, member.fileUri); |
3649 | 3653 |
3650 bool get hasUsers => breakTarget.hasUsers || continueTarget.hasUsers; | 3654 bool get hasUsers => breakTarget.hasUsers || continueTarget.hasUsers; |
3651 | 3655 |
3652 List<Statement> get users => | 3656 List<Statement> get users => unsupported("users", charOffset, fileUri); |
3653 deprecated_internalProblem("Unsupported operation."); | |
3654 | 3657 |
3655 JumpTargetKind get kind => | 3658 JumpTargetKind get kind => unsupported("kind", charOffset, fileUri); |
3656 deprecated_internalProblem("Unsupported operation."); | |
3657 | 3659 |
3658 bool get isBreakTarget => true; | 3660 bool get isBreakTarget => true; |
3659 | 3661 |
3660 bool get isContinueTarget => true; | 3662 bool get isContinueTarget => true; |
3661 | 3663 |
3662 bool get isGotoTarget => false; | 3664 bool get isGotoTarget => false; |
3663 | 3665 |
3664 void addBreak(BreakStatement statement) { | 3666 void addBreak(BreakStatement statement) { |
3665 breakTarget.addBreak(statement); | 3667 breakTarget.addBreak(statement); |
3666 } | 3668 } |
3667 | 3669 |
3668 void addContinue(BreakStatement statement) { | 3670 void addContinue(BreakStatement statement) { |
3669 continueTarget.addContinue(statement); | 3671 continueTarget.addContinue(statement); |
3670 } | 3672 } |
3671 | 3673 |
3672 void addGoto(ContinueSwitchStatement statement) { | 3674 void addGoto(ContinueSwitchStatement statement) { |
3673 deprecated_internalProblem("Unsupported operation."); | 3675 unsupported("addGoto", charOffset, fileUri); |
3674 } | 3676 } |
3675 | 3677 |
3676 void resolveBreaks(LabeledStatement target) { | 3678 void resolveBreaks(LabeledStatement target) { |
3677 breakTarget.resolveBreaks(target); | 3679 breakTarget.resolveBreaks(target); |
3678 } | 3680 } |
3679 | 3681 |
3680 void resolveContinues(LabeledStatement target) { | 3682 void resolveContinues(LabeledStatement target) { |
3681 continueTarget.resolveContinues(target); | 3683 continueTarget.resolveContinues(target); |
3682 } | 3684 } |
3683 | 3685 |
3684 void resolveGotos(SwitchCase target) { | 3686 void resolveGotos(SwitchCase target) { |
3685 deprecated_internalProblem("Unsupported operation."); | 3687 unsupported("resolveGotos", charOffset, fileUri); |
3686 } | 3688 } |
3687 | 3689 |
3688 @override | 3690 @override |
3689 String get fullNameForErrors => "<label-target>"; | 3691 String get fullNameForErrors => "<label-target>"; |
3690 } | 3692 } |
3691 | 3693 |
3692 class OptionalFormals { | 3694 class OptionalFormals { |
3693 final FormalParameterType kind; | 3695 final FormalParameterType kind; |
3694 | 3696 |
3695 final List<VariableDeclaration> formals; | 3697 final List<VariableDeclaration> formals; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3801 String getNodeName(Object node) { | 3803 String getNodeName(Object node) { |
3802 if (node is Identifier) { | 3804 if (node is Identifier) { |
3803 return node.name; | 3805 return node.name; |
3804 } else if (node is Builder) { | 3806 } else if (node is Builder) { |
3805 return node.fullNameForErrors; | 3807 return node.fullNameForErrors; |
3806 } else if (node is ThisAccessor) { | 3808 } else if (node is ThisAccessor) { |
3807 return node.isSuper ? "super" : "this"; | 3809 return node.isSuper ? "super" : "this"; |
3808 } else if (node is FastaAccessor) { | 3810 } else if (node is FastaAccessor) { |
3809 return node.plainNameForRead; | 3811 return node.plainNameForRead; |
3810 } else { | 3812 } else { |
3811 return deprecated_internalProblem("Unhandled: ${node.runtimeType}"); | 3813 return unhandled("${node.runtimeType}", "getNodeName", -1, null); |
3812 } | 3814 } |
3813 } | 3815 } |
3814 | 3816 |
3815 AsyncMarker asyncMarkerFromTokens(Token asyncToken, Token starToken) { | 3817 AsyncMarker asyncMarkerFromTokens(Token asyncToken, Token starToken) { |
3816 if (asyncToken == null || identical(asyncToken.stringValue, "sync")) { | 3818 if (asyncToken == null || identical(asyncToken.stringValue, "sync")) { |
3817 if (starToken == null) { | 3819 if (starToken == null) { |
3818 return AsyncMarker.Sync; | 3820 return AsyncMarker.Sync; |
3819 } else { | 3821 } else { |
3820 assert(identical(starToken.stringValue, "*")); | 3822 assert(identical(starToken.stringValue, "*")); |
3821 return AsyncMarker.SyncStar; | 3823 return AsyncMarker.SyncStar; |
3822 } | 3824 } |
3823 } else if (identical(asyncToken.stringValue, "async")) { | 3825 } else if (identical(asyncToken.stringValue, "async")) { |
3824 if (starToken == null) { | 3826 if (starToken == null) { |
3825 return AsyncMarker.Async; | 3827 return AsyncMarker.Async; |
3826 } else { | 3828 } else { |
3827 assert(identical(starToken.stringValue, "*")); | 3829 assert(identical(starToken.stringValue, "*")); |
3828 return AsyncMarker.AsyncStar; | 3830 return AsyncMarker.AsyncStar; |
3829 } | 3831 } |
3830 } else { | 3832 } else { |
3831 return deprecated_internalProblem("Unknown async modifier: $asyncToken"); | 3833 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", |
| 3834 asyncToken.charOffset, null); |
3832 } | 3835 } |
3833 } | 3836 } |
OLD | NEW |