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

Side by Side Diff: lib/runtime/dart/_js_helper.js

Issue 1649583002: allow JS builtin to be typed as needed (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 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
OLDNEW
1 dart_library.library('dart/_js_helper', null, /* Imports */[ 1 dart_library.library('dart/_js_helper', null, /* Imports */[
2 'dart/_runtime', 2 'dart/_runtime',
3 'dart/core', 3 'dart/core',
4 'dart/collection', 4 'dart/collection',
5 'dart/_interceptors', 5 'dart/_interceptors',
6 'dart/_foreign_helper' 6 'dart/_foreign_helper'
7 ], /* Lazy imports */[ 7 ], /* Lazy imports */[
8 ], function(exports, dart, core, collection, _interceptors, _foreign_helper) { 8 ], function(exports, dart, core, collection, _interceptors, _foreign_helper) {
9 'use strict'; 9 'use strict';
10 let dartx = dart.dartx; 10 let dartx = dart.dartx;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } catch (e) { 112 } catch (e) {
113 return e; 113 return e;
114 } 114 }
115 115
116 })(); 116 })();
117 if (regexp instanceof RegExp) return regexp; 117 if (regexp instanceof RegExp) return regexp;
118 let errorMessage = String(regexp); 118 let errorMessage = String(regexp);
119 dart.throw(new core.FormatException(`Illegal RegExp pattern: ${source}, ${ errorMessage}`)); 119 dart.throw(new core.FormatException(`Illegal RegExp pattern: ${source}, ${ errorMessage}`));
120 } 120 }
121 firstMatch(string) { 121 firstMatch(string) {
122 let m = dart.as(this[_nativeRegExp].exec(checkString(string)), core.List$( core.String)); 122 let m = this[_nativeRegExp].exec(checkString(string));
123 if (m == null) return null; 123 if (m == null) return null;
124 return new _MatchImplementation(this, m); 124 return new _MatchImplementation(this, m);
125 } 125 }
126 hasMatch(string) { 126 hasMatch(string) {
127 return this[_nativeRegExp].test(checkString(string)); 127 return this[_nativeRegExp].test(checkString(string));
128 } 128 }
129 stringMatch(string) { 129 stringMatch(string) {
130 let match = this.firstMatch(string); 130 let match = this.firstMatch(string);
131 if (match != null) return match.group(0); 131 if (match != null) return match.group(0);
132 return null; 132 return null;
133 } 133 }
134 allMatches(string, start) { 134 allMatches(string, start) {
135 if (start === void 0) start = 0; 135 if (start === void 0) start = 0;
136 checkString(string); 136 checkString(string);
137 checkInt(start); 137 checkInt(start);
138 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(string[d artx.length])) { 138 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(string[d artx.length])) {
139 dart.throw(new core.RangeError.range(start, 0, string[dartx.length])); 139 dart.throw(new core.RangeError.range(start, 0, string[dartx.length]));
140 } 140 }
141 return new _AllMatchesIterable(this, string, start); 141 return new _AllMatchesIterable(this, string, start);
142 } 142 }
143 [_execGlobal](string, start) { 143 [_execGlobal](string, start) {
144 let regexp = this[_nativeGlobalVersion]; 144 let regexp = this[_nativeGlobalVersion];
145 regexp.lastIndex = start; 145 regexp.lastIndex = start;
146 let match = dart.as(regexp.exec(string), core.List); 146 let match = regexp.exec(string);
147 if (match == null) return null; 147 if (match == null) return null;
148 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin g))); 148 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin g)));
149 } 149 }
150 [_execAnchored](string, start) { 150 [_execAnchored](string, start) {
151 let regexp = this[_nativeAnchoredVersion]; 151 let regexp = this[_nativeAnchoredVersion];
152 regexp.lastIndex = start; 152 regexp.lastIndex = start;
153 let match = dart.as(regexp.exec(string), core.List); 153 let match = regexp.exec(string);
154 if (match == null) return null; 154 if (match == null) return null;
155 if (match[dartx.get](dart.notNull(match[dartx.length]) - 1) != null) retur n null; 155 if (match[dartx.get](dart.notNull(match[dartx.length]) - 1) != null) retur n null;
156 match[dartx.length] = dart.notNull(match[dartx.length]) - 1; 156 match[dartx.length] = dart.notNull(match[dartx.length]) - 1;
157 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin g))); 157 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin g)));
158 } 158 }
159 matchAsPrefix(string, start) { 159 matchAsPrefix(string, start) {
160 if (start === void 0) start = 0; 160 if (start === void 0) start = 0;
161 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(string[d artx.length])) { 161 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(string[d artx.length])) {
162 dart.throw(new core.RangeError.range(start, 0, string[dartx.length])); 162 dart.throw(new core.RangeError.range(start, 0, string[dartx.length]));
163 } 163 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 checkNull(from); 489 checkNull(from);
490 dart.throw("String.replace(Pattern) UNIMPLEMENTED"); 490 dart.throw("String.replace(Pattern) UNIMPLEMENTED");
491 } 491 }
492 } 492 }
493 dart.fn(stringReplaceFirstUnchecked, dart.dynamic, [dart.dynamic, dart.dynamic , dart.dynamic], [core.int]); 493 dart.fn(stringReplaceFirstUnchecked, dart.dynamic, [dart.dynamic, dart.dynamic , dart.dynamic], [core.int]);
494 function stringJoinUnchecked(array, separator) { 494 function stringJoinUnchecked(array, separator) {
495 return array.join(separator); 495 return array.join(separator);
496 } 496 }
497 dart.fn(stringJoinUnchecked); 497 dart.fn(stringJoinUnchecked);
498 function getRuntimeType(object) { 498 function getRuntimeType(object) {
499 return dart.as(dart.realRuntimeType(object), core.Type); 499 return dart.realRuntimeType(object);
500 } 500 }
501 dart.fn(getRuntimeType, core.Type, [dart.dynamic]); 501 dart.fn(getRuntimeType, core.Type, [dart.dynamic]);
502 function getIndex(array, index) { 502 function getIndex(array, index) {
503 dart.assert(isJsArray(array)); 503 dart.assert(isJsArray(array));
504 return array[index]; 504 return array[index];
505 } 505 }
506 dart.fn(getIndex, dart.dynamic, [dart.dynamic, core.int]); 506 dart.fn(getIndex, dart.dynamic, [dart.dynamic, core.int]);
507 function getLength(array) { 507 function getLength(array) {
508 dart.assert(isJsArray(array)); 508 dart.assert(isJsArray(array));
509 return array.length; 509 return array.length;
(...skipping 11 matching lines...) Expand all
521 constructors: () => ({_Patch: [_Patch, []]}) 521 constructors: () => ({_Patch: [_Patch, []]})
522 }); 522 });
523 const patch = dart.const(new _Patch()); 523 const patch = dart.const(new _Patch());
524 class InternalMap extends core.Object {} 524 class InternalMap extends core.Object {}
525 class Primitives extends core.Object { 525 class Primitives extends core.Object {
526 static initializeStatics(id) { 526 static initializeStatics(id) {
527 Primitives.mirrorFunctionCacheName = dart.notNull(Primitives.mirrorFunctio nCacheName) + `_${id}`; 527 Primitives.mirrorFunctionCacheName = dart.notNull(Primitives.mirrorFunctio nCacheName) + `_${id}`;
528 Primitives.mirrorInvokeCacheName = dart.notNull(Primitives.mirrorInvokeCac heName) + `_${id}`; 528 Primitives.mirrorInvokeCacheName = dart.notNull(Primitives.mirrorInvokeCac heName) + `_${id}`;
529 } 529 }
530 static objectHashCode(object) { 530 static objectHashCode(object) {
531 let hash = dart.as(object.$identityHash, core.int); 531 let hash = object.$identityHash;
532 if (hash == null) { 532 if (hash == null) {
533 hash = Math.random() * 0x3fffffff | 0; 533 hash = Math.random() * 0x3fffffff | 0;
534 object.$identityHash = hash; 534 object.$identityHash = hash;
535 } 535 }
536 return hash; 536 return hash;
537 } 537 }
538 static _throwFormatException(string) { 538 static _throwFormatException(string) {
539 dart.throw(new core.FormatException(string)); 539 dart.throw(new core.FormatException(string));
540 } 540 }
541 static parseInt(source, radix, handleError) { 541 static parseInt(source, radix, handleError) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 dart.throw(new core.RangeError.range(dart.as(charCode, core.num), 0, 11141 11)); 690 dart.throw(new core.RangeError.range(dart.as(charCode, core.num), 0, 11141 11));
691 } 691 }
692 static stringConcatUnchecked(string1, string2) { 692 static stringConcatUnchecked(string1, string2) {
693 return _foreign_helper.JS_STRING_CONCAT(string1, string2); 693 return _foreign_helper.JS_STRING_CONCAT(string1, string2);
694 } 694 }
695 static flattenString(str) { 695 static flattenString(str) {
696 return str.charCodeAt(0) == 0 ? str : str; 696 return str.charCodeAt(0) == 0 ? str : str;
697 } 697 }
698 static getTimeZoneName(receiver) { 698 static getTimeZoneName(receiver) {
699 let d = Primitives.lazyAsJsDate(receiver); 699 let d = Primitives.lazyAsJsDate(receiver);
700 let match = dart.as(/\((.*)\)/.exec(d.toString()), core.List); 700 let match = /\((.*)\)/.exec(d.toString());
701 if (match != null) return dart.as(match[dartx.get](1), core.String); 701 if (match != null) return dart.as(match[dartx.get](1), core.String);
702 match = dart.as(/^[A-Z,a-z]{3}\s[A-Z,a-z]{3}\s\d+\s\d{2}:\d{2}:\d{2}\s([A- Z]{3,5})\s\d{4}$/.exec(d.toString()), core.List); 702 match = /^[A-Z,a-z]{3}\s[A-Z,a-z]{3}\s\d+\s\d{2}:\d{2}:\d{2}\s([A-Z]{3,5}) \s\d{4}$/.exec(d.toString());
703 if (match != null) return dart.as(match[dartx.get](1), core.String); 703 if (match != null) return dart.as(match[dartx.get](1), core.String);
704 match = dart.as(/(?:GMT|UTC)[+-]\d{4}/.exec(d.toString()), core.List); 704 match = /(?:GMT|UTC)[+-]\d{4}/.exec(d.toString());
705 if (match != null) return dart.as(match[dartx.get](0), core.String); 705 if (match != null) return dart.as(match[dartx.get](0), core.String);
706 return ""; 706 return "";
707 } 707 }
708 static getTimeZoneOffsetInMinutes(receiver) { 708 static getTimeZoneOffsetInMinutes(receiver) {
709 return -Primitives.lazyAsJsDate(receiver).getTimezoneOffset(); 709 return -Primitives.lazyAsJsDate(receiver).getTimezoneOffset();
710 } 710 }
711 static valueFromDecomposedDate(years, month, day, hours, minutes, seconds, m illiseconds, isUtc) { 711 static valueFromDecomposedDate(years, month, day, hours, minutes, seconds, m illiseconds, isUtc) {
712 let MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000; 712 let MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000;
713 checkInt(years); 713 checkInt(years);
714 checkInt(month); 714 checkInt(month);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 const _trace = Symbol('_trace'); 942 const _trace = Symbol('_trace');
943 class _StackTrace extends core.Object { 943 class _StackTrace extends core.Object {
944 _StackTrace(exception) { 944 _StackTrace(exception) {
945 this[_exception] = exception; 945 this[_exception] = exception;
946 this[_trace] = null; 946 this[_trace] = null;
947 } 947 }
948 toString() { 948 toString() {
949 if (this[_trace] != null) return this[_trace]; 949 if (this[_trace] != null) return this[_trace];
950 let trace = null; 950 let trace = null;
951 if (typeof this[_exception] === "object") { 951 if (typeof this[_exception] === "object") {
952 trace = dart.as(this[_exception].stack, core.String); 952 trace = this[_exception].stack;
953 } 953 }
954 return this[_trace] = trace == null ? '' : trace; 954 return this[_trace] = trace == null ? '' : trace;
955 } 955 }
956 } 956 }
957 _StackTrace[dart.implements] = () => [core.StackTrace]; 957 _StackTrace[dart.implements] = () => [core.StackTrace];
958 dart.setSignature(_StackTrace, { 958 dart.setSignature(_StackTrace, {
959 constructors: () => ({_StackTrace: [_StackTrace, [dart.dynamic]]}) 959 constructors: () => ({_StackTrace: [_StackTrace, [dart.dynamic]]})
960 }); 960 });
961 function objectHashCode(object) { 961 function objectHashCode(object) {
962 if (object == null || typeof object != 'object') { 962 if (object == null || typeof object != 'object') {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 class SyncIterator extends core.Object { 1094 class SyncIterator extends core.Object {
1095 SyncIterator(jsIterator) { 1095 SyncIterator(jsIterator) {
1096 this[_jsIterator] = jsIterator; 1096 this[_jsIterator] = jsIterator;
1097 this[_current] = null; 1097 this[_current] = null;
1098 } 1098 }
1099 get current() { 1099 get current() {
1100 return this[_current]; 1100 return this[_current];
1101 } 1101 }
1102 moveNext() { 1102 moveNext() {
1103 let ret = this[_jsIterator].next(); 1103 let ret = this[_jsIterator].next();
1104 this[_current] = dart.as(ret.value, E); 1104 this[_current] = ret.value;
1105 return !ret.done; 1105 return !ret.done;
1106 } 1106 }
1107 } 1107 }
1108 SyncIterator[dart.implements] = () => [core.Iterator$(E)]; 1108 SyncIterator[dart.implements] = () => [core.Iterator$(E)];
1109 dart.setSignature(SyncIterator, { 1109 dart.setSignature(SyncIterator, {
1110 constructors: () => ({SyncIterator: [SyncIterator$(E), [dart.dynamic]]}), 1110 constructors: () => ({SyncIterator: [SyncIterator$(E), [dart.dynamic]]}),
1111 methods: () => ({moveNext: [core.bool, []]}) 1111 methods: () => ({moveNext: [core.bool, []]})
1112 }); 1112 });
1113 return SyncIterator; 1113 return SyncIterator;
1114 }); 1114 });
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 exports.CastErrorImplementation = CastErrorImplementation; 1193 exports.CastErrorImplementation = CastErrorImplementation;
1194 exports.FallThroughErrorImplementation = FallThroughErrorImplementation; 1194 exports.FallThroughErrorImplementation = FallThroughErrorImplementation;
1195 exports.RuntimeError = RuntimeError; 1195 exports.RuntimeError = RuntimeError;
1196 exports.random64 = random64; 1196 exports.random64 = random64;
1197 exports.jsonEncodeNative = jsonEncodeNative; 1197 exports.jsonEncodeNative = jsonEncodeNative;
1198 exports.SyncIterator$ = SyncIterator$; 1198 exports.SyncIterator$ = SyncIterator$;
1199 exports.SyncIterator = SyncIterator; 1199 exports.SyncIterator = SyncIterator;
1200 exports.SyncIterable$ = SyncIterable$; 1200 exports.SyncIterable$ = SyncIterable$;
1201 exports.SyncIterable = SyncIterable; 1201 exports.SyncIterable = SyncIterable;
1202 }); 1202 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698