OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 abstract class Visitor<R> { | 5 abstract class Visitor<R> { |
6 const Visitor(); | 6 const Visitor(); |
7 | 7 |
8 abstract R visitNode(Node node); | 8 abstract R visitNode(Node node); |
9 | 9 |
10 R visitBlock(Block node) => visitStatement(node); | 10 R visitBlock(Block node) => visitStatement(node); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 Send selectorSend = selector; | 350 Send selectorSend = selector; |
351 if (selectorSend.receiver is TypeAnnotation) { | 351 if (selectorSend.receiver is TypeAnnotation) { |
352 return selectorSend.receiver; | 352 return selectorSend.receiver; |
353 } | 353 } |
354 } | 354 } |
355 return null; | 355 return null; |
356 } | 356 } |
357 } | 357 } |
358 | 358 |
359 class Postfix extends NodeList { | 359 class Postfix extends NodeList { |
360 Postfix() : super(nodes: const Link<Node>()); | 360 Postfix() : super(null, const Link<Node>()); |
361 Postfix.singleton(Node argument) : super.singleton(argument); | 361 Postfix.singleton(Node argument) : super.singleton(argument); |
362 } | 362 } |
363 | 363 |
364 class Prefix extends NodeList { | 364 class Prefix extends NodeList { |
365 Prefix() : super(nodes: const Link<Node>()); | 365 Prefix() : super(null, const Link<Node>()); |
366 Prefix.singleton(Node argument) : super.singleton(argument); | 366 Prefix.singleton(Node argument) : super.singleton(argument); |
367 } | 367 } |
368 | 368 |
369 class SendSet extends Send { | 369 class SendSet extends Send { |
370 final Operator assignmentOperator; | 370 final Operator assignmentOperator; |
371 SendSet(receiver, selector, this.assignmentOperator, argumentsNode) | 371 SendSet(receiver, selector, this.assignmentOperator, argumentsNode) |
372 : super(receiver, selector, argumentsNode); | 372 : super(receiver, selector, argumentsNode); |
373 SendSet.postfix(receiver, | 373 SendSet.postfix(receiver, |
374 selector, | 374 selector, |
375 this.assignmentOperator, | 375 this.assignmentOperator, |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 MULTILINE_SQ, | 797 MULTILINE_SQ, |
798 RAW_MULTILINE_SQ, | 798 RAW_MULTILINE_SQ, |
799 MULTILINE_NL_SQ, | 799 MULTILINE_NL_SQ, |
800 RAW_MULTILINE_NL_SQ, | 800 RAW_MULTILINE_NL_SQ, |
801 MULTILINE_NL2_SQ, | 801 MULTILINE_NL2_SQ, |
802 RAW_MULTILINE_NL2_SQ | 802 RAW_MULTILINE_NL2_SQ |
803 ]; | 803 ]; |
804 final bool raw; | 804 final bool raw; |
805 final int leftQuoteCharCount; | 805 final int leftQuoteCharCount; |
806 final int quote; | 806 final int quote; |
807 const StringQuoting(this.quote, [bool raw, int leftQuoteLength]) | 807 const StringQuoting(this.quote, {bool raw, int leftQuoteLength}) |
808 : this.raw = raw, this.leftQuoteCharCount = leftQuoteLength; | 808 : this.raw = raw, this.leftQuoteCharCount = leftQuoteLength; |
809 String get quoteChar => quote === $DQ ? '"' : "'"; | 809 String get quoteChar => quote === $DQ ? '"' : "'"; |
810 | 810 |
811 int get leftQuoteLength => (raw ? 1 : 0) + leftQuoteCharCount; | 811 int get leftQuoteLength => (raw ? 1 : 0) + leftQuoteCharCount; |
812 int get rightQuoteLength => (leftQuoteCharCount > 2) ? 3 : 1; | 812 int get rightQuoteLength => (leftQuoteCharCount > 2) ? 3 : 1; |
813 static StringQuoting getQuoting(int quote, bool raw, int quoteLength) { | 813 static StringQuoting getQuoting(int quote, bool raw, int quoteLength) { |
814 int index = quoteLength - 1; | 814 int index = quoteLength - 1; |
815 if (quoteLength > 2) index -= 1; | 815 if (quoteLength > 2) index -= 1; |
816 return mapping[(raw ? 1 : 0) + index * 2 + (quote === $SQ ? 8 : 0)]; | 816 return mapping[(raw ? 1 : 0) + index * 2 + (quote === $SQ ? 8 : 0)]; |
817 } | 817 } |
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2017 * argument). | 2017 * argument). |
2018 * | 2018 * |
2019 * TODO(ahe): This method is controversial, the team needs to discuss | 2019 * TODO(ahe): This method is controversial, the team needs to discuss |
2020 * if top-level methods are acceptable and what naming conventions to | 2020 * if top-level methods are acceptable and what naming conventions to |
2021 * use. | 2021 * use. |
2022 */ | 2022 */ |
2023 initializerDo(Node node, f(Node node)) { | 2023 initializerDo(Node node, f(Node node)) { |
2024 SendSet send = node.asSendSet(); | 2024 SendSet send = node.asSendSet(); |
2025 if (send !== null) return f(send.arguments.head); | 2025 if (send !== null) return f(send.arguments.head); |
2026 } | 2026 } |
OLD | NEW |