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