OLD | NEW |
1 dart.library('dart/_js_helper', null, /* Imports */[ | 1 dart.library('dart/_js_helper', null, /* Imports */[ |
2 'dart/core', | 2 'dart/core', |
3 'dart/collection', | 3 'dart/collection', |
4 'dart/_foreign_helper' | 4 'dart/_foreign_helper' |
5 ], /* Lazy imports */[ | 5 ], /* Lazy imports */[ |
6 'dart/_interceptors' | 6 'dart/_interceptors' |
7 ], function(exports, core, collection, _foreign_helper, _interceptors) { | 7 ], function(exports, core, collection, _foreign_helper, _interceptors) { |
8 'use strict'; | 8 'use strict'; |
9 class NoThrows extends core.Object { | 9 class NoThrows extends core.Object { |
10 NoThrows() { | 10 NoThrows() { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 let match = this.firstMatch(string); | 141 let match = this.firstMatch(string); |
142 if (match != null) | 142 if (match != null) |
143 return match.group(0); | 143 return match.group(0); |
144 return null; | 144 return null; |
145 } | 145 } |
146 allMatches(string, start) { | 146 allMatches(string, start) { |
147 if (start === void 0) | 147 if (start === void 0) |
148 start = 0; | 148 start = 0; |
149 checkString(string); | 149 checkString(string); |
150 checkInt(start); | 150 checkInt(start); |
151 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(string.l
ength)) { | 151 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(string[d
artx.length])) { |
152 throw new core.RangeError.range(start, 0, string.length); | 152 throw new core.RangeError.range(start, 0, string[dartx.length]); |
153 } | 153 } |
154 return new _AllMatchesIterable(this, string, start); | 154 return new _AllMatchesIterable(this, string, start); |
155 } | 155 } |
156 [_execGlobal](string, start) { | 156 [_execGlobal](string, start) { |
157 let regexp = this[_nativeGlobalVersion]; | 157 let regexp = this[_nativeGlobalVersion]; |
158 regexp.lastIndex = start; | 158 regexp.lastIndex = start; |
159 let match = dart.as(regexp.exec(string), core.List); | 159 let match = dart.as(regexp.exec(string), core.List); |
160 if (match == null) | 160 if (match == null) |
161 return null; | 161 return null; |
162 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin
g))); | 162 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin
g))); |
163 } | 163 } |
164 [_execAnchored](string, start) { | 164 [_execAnchored](string, start) { |
165 let regexp = this[_nativeAnchoredVersion]; | 165 let regexp = this[_nativeAnchoredVersion]; |
166 regexp.lastIndex = start; | 166 regexp.lastIndex = start; |
167 let match = dart.as(regexp.exec(string), core.List); | 167 let match = dart.as(regexp.exec(string), core.List); |
168 if (match == null) | 168 if (match == null) |
169 return null; | 169 return null; |
170 if (match[dartx.get](dart.notNull(match.length) - 1) != null) | 170 if (match[dartx.get](dart.notNull(match[dartx.length]) - 1) != null) |
171 return null; | 171 return null; |
172 match.length = dart.notNull(match.length) - 1; | 172 match[dartx.length] = dart.notNull(match[dartx.length]) - 1; |
173 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin
g))); | 173 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin
g))); |
174 } | 174 } |
175 matchAsPrefix(string, start) { | 175 matchAsPrefix(string, start) { |
176 if (start === void 0) | 176 if (start === void 0) |
177 start = 0; | 177 start = 0; |
178 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(string.l
ength)) { | 178 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(string[d
artx.length])) { |
179 throw new core.RangeError.range(start, 0, string.length); | 179 throw new core.RangeError.range(start, 0, string[dartx.length]); |
180 } | 180 } |
181 return this[_execAnchored](string, start); | 181 return this[_execAnchored](string, start); |
182 } | 182 } |
183 get isMultiLine() { | 183 get isMultiLine() { |
184 return this[_isMultiLine]; | 184 return this[_isMultiLine]; |
185 } | 185 } |
186 get isCaseSensitive() { | 186 get isCaseSensitive() { |
187 return this[_isCaseSensitive]; | 187 return this[_isCaseSensitive]; |
188 } | 188 } |
189 } | 189 } |
(...skipping 21 matching lines...) Expand all Loading... |
211 dart.assert(typeof this[_match].input == 'string'); | 211 dart.assert(typeof this[_match].input == 'string'); |
212 dart.assert(typeof this[_match].index == 'number'); | 212 dart.assert(typeof this[_match].index == 'number'); |
213 } | 213 } |
214 get input() { | 214 get input() { |
215 return this[_match].input; | 215 return this[_match].input; |
216 } | 216 } |
217 get start() { | 217 get start() { |
218 return this[_match].index; | 218 return this[_match].index; |
219 } | 219 } |
220 get end() { | 220 get end() { |
221 return dart.notNull(this.start) + dart.notNull(this[_match][dartx.get](0).
length); | 221 return dart.notNull(this.start) + dart.notNull(this[_match][dartx.get](0)[
dartx.length]); |
222 } | 222 } |
223 group(index) { | 223 group(index) { |
224 return this[_match][dartx.get](index); | 224 return this[_match][dartx.get](index); |
225 } | 225 } |
226 get(index) { | 226 get(index) { |
227 return this.group(index); | 227 return this.group(index); |
228 } | 228 } |
229 get groupCount() { | 229 get groupCount() { |
230 return dart.notNull(this[_match].length) - 1; | 230 return dart.notNull(this[_match][dartx.length]) - 1; |
231 } | 231 } |
232 groups(groups) { | 232 groups(groups) { |
233 let out = dart.list([], core.String); | 233 let out = dart.list([], core.String); |
234 for (let i of groups) { | 234 for (let i of groups) { |
235 out[dartx.add](this.group(i)); | 235 out[dartx.add](this.group(i)); |
236 } | 236 } |
237 return out; | 237 return out; |
238 } | 238 } |
239 } | 239 } |
240 _MatchImplementation[dart.implements] = () => [core.Match]; | 240 _MatchImplementation[dart.implements] = () => [core.Match]; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 this[_string] = string; | 273 this[_string] = string; |
274 this[_nextIndex] = nextIndex; | 274 this[_nextIndex] = nextIndex; |
275 this[_current] = null; | 275 this[_current] = null; |
276 } | 276 } |
277 get current() { | 277 get current() { |
278 return this[_current]; | 278 return this[_current]; |
279 } | 279 } |
280 moveNext() { | 280 moveNext() { |
281 if (this[_string] == null) | 281 if (this[_string] == null) |
282 return false; | 282 return false; |
283 if (dart.notNull(this[_nextIndex]) <= dart.notNull(this[_string].length))
{ | 283 if (dart.notNull(this[_nextIndex]) <= dart.notNull(this[_string][dartx.len
gth])) { |
284 let match = this[_regExp][_execGlobal](this[_string], this[_nextIndex]); | 284 let match = this[_regExp][_execGlobal](this[_string], this[_nextIndex]); |
285 if (match != null) { | 285 if (match != null) { |
286 this[_current] = match; | 286 this[_current] = match; |
287 let nextIndex = match.end; | 287 let nextIndex = match.end; |
288 if (match.start == nextIndex) { | 288 if (match.start == nextIndex) { |
289 nextIndex = dart.notNull(nextIndex) + 1; | 289 nextIndex = dart.notNull(nextIndex) + 1; |
290 } | 290 } |
291 this[_nextIndex] = nextIndex; | 291 this[_nextIndex] = nextIndex; |
292 return true; | 292 return true; |
293 } | 293 } |
(...skipping 12 matching lines...) Expand all Loading... |
306 return regExp[_execGlobal](string, start); | 306 return regExp[_execGlobal](string, start); |
307 } | 307 } |
308 dart.fn(firstMatchAfter, core.Match, [JSSyntaxRegExp, core.String, core.int]); | 308 dart.fn(firstMatchAfter, core.Match, [JSSyntaxRegExp, core.String, core.int]); |
309 class StringMatch extends core.Object { | 309 class StringMatch extends core.Object { |
310 StringMatch(start, input, pattern) { | 310 StringMatch(start, input, pattern) { |
311 this.start = start; | 311 this.start = start; |
312 this.input = input; | 312 this.input = input; |
313 this.pattern = pattern; | 313 this.pattern = pattern; |
314 } | 314 } |
315 get end() { | 315 get end() { |
316 return dart.notNull(this.start) + dart.notNull(this.pattern.length); | 316 return dart.notNull(this.start) + dart.notNull(this.pattern[dartx.length])
; |
317 } | 317 } |
318 get(g) { | 318 get(g) { |
319 return this.group(g); | 319 return this.group(g); |
320 } | 320 } |
321 get groupCount() { | 321 get groupCount() { |
322 return 0; | 322 return 0; |
323 } | 323 } |
324 group(group_) { | 324 group(group_) { |
325 if (group_ != 0) { | 325 if (group_ != 0) { |
326 throw new core.RangeError.value(group_); | 326 throw new core.RangeError.value(group_); |
(...skipping 12 matching lines...) Expand all Loading... |
339 dart.setSignature(StringMatch, { | 339 dart.setSignature(StringMatch, { |
340 constructors: () => ({StringMatch: [StringMatch, [core.int, core.String, cor
e.String]]}), | 340 constructors: () => ({StringMatch: [StringMatch, [core.int, core.String, cor
e.String]]}), |
341 methods: () => ({ | 341 methods: () => ({ |
342 get: [core.String, [core.int]], | 342 get: [core.String, [core.int]], |
343 group: [core.String, [core.int]], | 343 group: [core.String, [core.int]], |
344 groups: [core.List$(core.String), [core.List$(core.int)]] | 344 groups: [core.List$(core.String), [core.List$(core.int)]] |
345 }) | 345 }) |
346 }); | 346 }); |
347 function allMatchesInStringUnchecked(needle, haystack, startIndex) { | 347 function allMatchesInStringUnchecked(needle, haystack, startIndex) { |
348 let result = core.List$(core.Match).new(); | 348 let result = core.List$(core.Match).new(); |
349 let length = haystack.length; | 349 let length = haystack[dartx.length]; |
350 let patternLength = needle.length; | 350 let patternLength = needle[dartx.length]; |
351 while (true) { | 351 while (true) { |
352 let position = haystack[dartx.indexOf](needle, startIndex); | 352 let position = haystack[dartx.indexOf](needle, startIndex); |
353 if (position == -1) { | 353 if (position == -1) { |
354 break; | 354 break; |
355 } | 355 } |
356 result[dartx.add](new StringMatch(position, haystack, needle)); | 356 result[dartx.add](new StringMatch(position, haystack, needle)); |
357 let endIndex = dart.notNull(position) + dart.notNull(patternLength); | 357 let endIndex = dart.notNull(position) + dart.notNull(patternLength); |
358 if (endIndex == length) { | 358 if (endIndex == length) { |
359 break; | 359 break; |
360 } else if (position == endIndex) { | 360 } else if (position == endIndex) { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 return parseInt(source, 10); | 592 return parseInt(source, 10); |
593 } | 593 } |
594 if (dart.notNull(radix) < 10 || dart.dindex(match, decimalIndex) == nu
ll) { | 594 if (dart.notNull(radix) < 10 || dart.dindex(match, decimalIndex) == nu
ll) { |
595 let maxCharCode = null; | 595 let maxCharCode = null; |
596 if (dart.notNull(radix) <= 10) { | 596 if (dart.notNull(radix) <= 10) { |
597 maxCharCode = 48 + dart.notNull(radix) - 1; | 597 maxCharCode = 48 + dart.notNull(radix) - 1; |
598 } else { | 598 } else { |
599 maxCharCode = 97 + dart.notNull(radix) - 10 - 1; | 599 maxCharCode = 97 + dart.notNull(radix) - 10 - 1; |
600 } | 600 } |
601 let digitsPart = dart.as(dart.dindex(match, digitsIndex), core.Strin
g); | 601 let digitsPart = dart.as(dart.dindex(match, digitsIndex), core.Strin
g); |
602 for (let i = 0; dart.notNull(i) < dart.notNull(digitsPart.length); i
= dart.notNull(i) + 1) { | 602 for (let i = 0; dart.notNull(i) < dart.notNull(digitsPart[dartx.leng
th]); i = dart.notNull(i) + 1) { |
603 let characterCode = dart.notNull(digitsPart[dartx.codeUnitAt](0))
| 32; | 603 let characterCode = dart.notNull(digitsPart[dartx.codeUnitAt](0))
| 32; |
604 if (dart.notNull(digitsPart[dartx.codeUnitAt](i)) > dart.notNull(m
axCharCode)) { | 604 if (dart.notNull(digitsPart[dartx.codeUnitAt](i)) > dart.notNull(m
axCharCode)) { |
605 return handleError(source); | 605 return handleError(source); |
606 } | 606 } |
607 } | 607 } |
608 } | 608 } |
609 } | 609 } |
610 } | 610 } |
611 if (match == null) | 611 if (match == null) |
612 return handleError(source); | 612 return handleError(source); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } | 665 } |
666 static currentUri() { | 666 static currentUri() { |
667 if (!!self.location) { | 667 if (!!self.location) { |
668 return self.location.href; | 668 return self.location.href; |
669 } | 669 } |
670 return null; | 670 return null; |
671 } | 671 } |
672 static _fromCharCodeApply(array) { | 672 static _fromCharCodeApply(array) { |
673 let result = ""; | 673 let result = ""; |
674 let kMaxApply = 500; | 674 let kMaxApply = 500; |
675 let end = array.length; | 675 let end = array[dartx.length]; |
676 for (let i = 0; dart.notNull(i) < dart.notNull(end); i = dart.notNull(i) +
dart.notNull(kMaxApply)) { | 676 for (let i = 0; dart.notNull(i) < dart.notNull(end); i = dart.notNull(i) +
dart.notNull(kMaxApply)) { |
677 let subarray = null; | 677 let subarray = null; |
678 if (dart.notNull(end) <= dart.notNull(kMaxApply)) { | 678 if (dart.notNull(end) <= dart.notNull(kMaxApply)) { |
679 subarray = array; | 679 subarray = array; |
680 } else { | 680 } else { |
681 subarray = array.slice(i, dart.notNull(i) + dart.notNull(kMaxApply) <
dart.notNull(end) ? dart.notNull(i) + dart.notNull(kMaxApply) : end); | 681 subarray = array.slice(i, dart.notNull(i) + dart.notNull(kMaxApply) <
dart.notNull(end) ? dart.notNull(i) + dart.notNull(kMaxApply) : end); |
682 } | 682 } |
683 result = result + String.fromCharCode.apply(null, subarray); | 683 result = result + String.fromCharCode.apply(null, subarray); |
684 } | 684 } |
685 return result; | 685 return result; |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 exports.Creates = Creates; | 1197 exports.Creates = Creates; |
1198 exports.Returns = Returns; | 1198 exports.Returns = Returns; |
1199 exports.JSName = JSName; | 1199 exports.JSName = JSName; |
1200 exports.TypeErrorImplementation = TypeErrorImplementation; | 1200 exports.TypeErrorImplementation = TypeErrorImplementation; |
1201 exports.CastErrorImplementation = CastErrorImplementation; | 1201 exports.CastErrorImplementation = CastErrorImplementation; |
1202 exports.FallThroughErrorImplementation = FallThroughErrorImplementation; | 1202 exports.FallThroughErrorImplementation = FallThroughErrorImplementation; |
1203 exports.RuntimeError = RuntimeError; | 1203 exports.RuntimeError = RuntimeError; |
1204 exports.random64 = random64; | 1204 exports.random64 = random64; |
1205 exports.jsonEncodeNative = jsonEncodeNative; | 1205 exports.jsonEncodeNative = jsonEncodeNative; |
1206 }); | 1206 }); |
OLD | NEW |