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

Side by Side Diff: pkg/compiler/lib/src/string_validator.dart

Issue 2675103003: Refactor BackendHelpers to be reusageable with KernelWorldBuilder (Closed)
Patch Set: Updated cf. comments Created 3 years, 10 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/types.dart ('k') | tests/compiler/dart2js/map_tracer_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Check the validity of string literals. 5 // Check the validity of string literals.
6 6
7 library stringvalidator; 7 library stringvalidator;
8 8
9 import 'dart:collection'; 9 import 'dart:collection';
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 * literals (including an initial 'r' for raw strings). 92 * literals (including an initial 'r' for raw strings).
93 */ 93 */
94 String copyWithoutQuotes(String string, int initial, int terminal) { 94 String copyWithoutQuotes(String string, int initial, int terminal) {
95 assert(0 <= initial); 95 assert(0 <= initial);
96 assert(0 <= terminal); 96 assert(0 <= terminal);
97 assert(initial + terminal <= string.length); 97 assert(initial + terminal <= string.length);
98 return string.substring(initial, string.length - terminal); 98 return string.substring(initial, string.length - terminal);
99 } 99 }
100 100
101 void stringParseError(String message, Token token, int offset) { 101 void stringParseError(String message, Token token, int offset) {
102 reporter.reportErrorMessage( 102 reporter.reportErrorMessage(reporter.spanFromToken(token),
103 reporter.spanFromToken(token), MessageKind.GENERIC, 103 MessageKind.GENERIC, {'text': "$message @ $offset"});
104 {'text': "$message @ $offset"});
105 } 104 }
106 105
107 /** 106 /**
108 * Validates the escape sequences and special characters of a string literal. 107 * Validates the escape sequences and special characters of a string literal.
109 * Returns a DartString if valid, and null if not. 108 * Returns a DartString if valid, and null if not.
110 */ 109 */
111 DartString validateString( 110 DartString validateString(
112 Token token, int startOffset, String string, StringQuoting quoting) { 111 Token token, int startOffset, String string, StringQuoting quoting) {
113 // We need to check for invalid x and u escapes, for line 112 // We need to check for invalid x and u escapes, for line
114 // terminators in non-multiline strings, and for invalid Unicode 113 // terminators in non-multiline strings, and for invalid Unicode
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 205 }
207 } 206 }
208 // String literal successfully validated. 207 // String literal successfully validated.
209 if (quoting.raw || !containsEscape) { 208 if (quoting.raw || !containsEscape) {
210 // A string without escapes could just as well have been raw. 209 // A string without escapes could just as well have been raw.
211 return new DartString.rawString(string, length); 210 return new DartString.rawString(string, length);
212 } 211 }
213 return new DartString.escapedString(string, length); 212 return new DartString.escapedString(string, length);
214 } 213 }
215 } 214 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/types.dart ('k') | tests/compiler/dart2js/map_tracer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698