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

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

Issue 1233553005: Fixes #254 - Better stacktrace support (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: format fix Created 5 years, 5 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 | « lib/runtime/dart/isolate.js ('k') | lib/runtime/dart/math.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 dart_library.library('dart/js', null, /* Imports */[ 1 dart_library.library('dart/js', null, /* Imports */[
2 "dart_runtime/dart", 2 "dart_runtime/dart",
3 'dart/core', 3 'dart/core',
4 'dart/collection', 4 'dart/collection',
5 'dart/_js_helper' 5 'dart/_js_helper'
6 ], /* Lazy imports */[ 6 ], /* Lazy imports */[
7 ], function(exports, dart, core, collection, _js_helper) { 7 ], function(exports, dart, core, collection, _js_helper) {
8 'use strict'; 8 'use strict';
9 let dartx = dart.dartx; 9 let dartx = dart.dartx;
10 dart.defineLazyProperties(exports, { 10 dart.defineLazyProperties(exports, {
(...skipping 11 matching lines...) Expand all
22 if (arguments$ === void 0) 22 if (arguments$ === void 0)
23 arguments$ = null; 23 arguments$ = null;
24 let ctor = constructor[_jsObject]; 24 let ctor = constructor[_jsObject];
25 if (arguments$ == null) { 25 if (arguments$ == null) {
26 return dart.as(_wrapToDart(new ctor()), JsObject); 26 return dart.as(_wrapToDart(new ctor()), JsObject);
27 } 27 }
28 return dart.as(_wrapToDart(new ctor(...arguments$)), JsObject); 28 return dart.as(_wrapToDart(new ctor(...arguments$)), JsObject);
29 } 29 }
30 static fromBrowserObject(object) { 30 static fromBrowserObject(object) {
31 if (dart.is(object, core.num) || typeof object == 'string' || typeof objec t == 'boolean' || object == null) { 31 if (dart.is(object, core.num) || typeof object == 'string' || typeof objec t == 'boolean' || object == null) {
32 throw new core.ArgumentError("object cannot be a num, string, bool, or n ull"); 32 dart.throw(new core.ArgumentError("object cannot be a num, string, bool, or null"));
33 } 33 }
34 return dart.as(_wrapToDart(_convertToJS(object)), JsObject); 34 return dart.as(_wrapToDart(_convertToJS(object)), JsObject);
35 } 35 }
36 static jsify(object) { 36 static jsify(object) {
37 if (!dart.is(object, core.Map) && !dart.is(object, core.Iterable)) { 37 if (!dart.is(object, core.Map) && !dart.is(object, core.Iterable)) {
38 throw new core.ArgumentError("object must be a Map or Iterable"); 38 dart.throw(new core.ArgumentError("object must be a Map or Iterable"));
39 } 39 }
40 return dart.as(_wrapToDart(JsObject._convertDataTree(object)), JsObject); 40 return dart.as(_wrapToDart(JsObject._convertDataTree(object)), JsObject);
41 } 41 }
42 static _convertDataTree(data) { 42 static _convertDataTree(data) {
43 let _convertedObjects = collection.HashMap.identity(); 43 let _convertedObjects = collection.HashMap.identity();
44 function _convert(o) { 44 function _convert(o) {
45 if (dart.notNull(_convertedObjects.containsKey(o))) { 45 if (dart.notNull(_convertedObjects.containsKey(o))) {
46 return _convertedObjects.get(o); 46 return _convertedObjects.get(o);
47 } 47 }
48 if (dart.is(o, core.Map)) { 48 if (dart.is(o, core.Map)) {
(...skipping 10 matching lines...) Expand all
59 return convertedList; 59 return convertedList;
60 } else { 60 } else {
61 return _convertToJS(o); 61 return _convertToJS(o);
62 } 62 }
63 } 63 }
64 dart.fn(_convert); 64 dart.fn(_convert);
65 return _convert(data); 65 return _convert(data);
66 } 66 }
67 get(property) { 67 get(property) {
68 if (!(typeof property == 'string') && !dart.is(property, core.num)) { 68 if (!(typeof property == 'string') && !dart.is(property, core.num)) {
69 throw new core.ArgumentError("property is not a String or num"); 69 dart.throw(new core.ArgumentError("property is not a String or num"));
70 } 70 }
71 return _convertToDart(this[_jsObject][property]); 71 return _convertToDart(this[_jsObject][property]);
72 } 72 }
73 set(property, value) { 73 set(property, value) {
74 if (!(typeof property == 'string') && !dart.is(property, core.num)) { 74 if (!(typeof property == 'string') && !dart.is(property, core.num)) {
75 throw new core.ArgumentError("property is not a String or num"); 75 dart.throw(new core.ArgumentError("property is not a String or num"));
76 } 76 }
77 this[_jsObject][property] = _convertToJS(value); 77 this[_jsObject][property] = _convertToJS(value);
78 } 78 }
79 get hashCode() { 79 get hashCode() {
80 return 0; 80 return 0;
81 } 81 }
82 ['=='](other) { 82 ['=='](other) {
83 return dart.is(other, JsObject) && this[_jsObject] === dart.dload(other, _ jsObject); 83 return dart.is(other, JsObject) && this[_jsObject] === dart.dload(other, _ jsObject);
84 } 84 }
85 hasProperty(property) { 85 hasProperty(property) {
86 if (!(typeof property == 'string') && !dart.is(property, core.num)) { 86 if (!(typeof property == 'string') && !dart.is(property, core.num)) {
87 throw new core.ArgumentError("property is not a String or num"); 87 dart.throw(new core.ArgumentError("property is not a String or num"));
88 } 88 }
89 return property in this[_jsObject]; 89 return property in this[_jsObject];
90 } 90 }
91 deleteProperty(property) { 91 deleteProperty(property) {
92 if (!(typeof property == 'string') && !dart.is(property, core.num)) { 92 if (!(typeof property == 'string') && !dart.is(property, core.num)) {
93 throw new core.ArgumentError("property is not a String or num"); 93 dart.throw(new core.ArgumentError("property is not a String or num"));
94 } 94 }
95 delete this[_jsObject][property]; 95 delete this[_jsObject][property];
96 } 96 }
97 instanceof(type) { 97 instanceof(type) {
98 return this[_jsObject] instanceof _convertToJS(type); 98 return this[_jsObject] instanceof _convertToJS(type);
99 } 99 }
100 toString() { 100 toString() {
101 try { 101 try {
102 return String(this[_jsObject]); 102 return String(this[_jsObject]);
103 } catch (e) { 103 } catch (e) {
104 return super.toString(); 104 return super.toString();
105 } 105 }
106 106
107 } 107 }
108 callMethod(method, args) { 108 callMethod(method, args) {
109 if (args === void 0) 109 if (args === void 0)
110 args = null; 110 args = null;
111 if (!(typeof method == 'string') && !dart.is(method, core.num)) { 111 if (!(typeof method == 'string') && !dart.is(method, core.num)) {
112 throw new core.ArgumentError("method is not a String or num"); 112 dart.throw(new core.ArgumentError("method is not a String or num"));
113 } 113 }
114 if (args != null) 114 if (args != null)
115 args = core.List.from(args[dartx.map](_convertToJS)); 115 args = core.List.from(args[dartx.map](_convertToJS));
116 let fn = this[_jsObject][method]; 116 let fn = this[_jsObject][method];
117 if (!(fn instanceof Function)) { 117 if (!(fn instanceof Function)) {
118 throw new core.NoSuchMethodError(this[_jsObject], core.Symbol.new(dart.a s(method, core.String)), args, dart.map()); 118 dart.throw(new core.NoSuchMethodError(this[_jsObject], core.Symbol.new(d art.as(method, core.String)), args, dart.map()));
119 } 119 }
120 return _convertToDart(fn.apply(this[_jsObject], args)); 120 return _convertToDart(fn.apply(this[_jsObject], args));
121 } 121 }
122 } 122 }
123 dart.defineNamedConstructor(JsObject, '_fromJs'); 123 dart.defineNamedConstructor(JsObject, '_fromJs');
124 dart.setSignature(JsObject, { 124 dart.setSignature(JsObject, {
125 constructors: () => ({ 125 constructors: () => ({
126 _fromJs: [JsObject, [dart.dynamic]], 126 _fromJs: [JsObject, [dart.dynamic]],
127 new: [JsObject, [JsFunction], [core.List]], 127 new: [JsObject, [JsFunction], [core.List]],
128 fromBrowserObject: [JsObject, [dart.dynamic]], 128 fromBrowserObject: [JsObject, [dart.dynamic]],
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 let _ = []; 177 let _ = [];
178 _[dartx.addAll](other[dartx.map](dart.as(_convertToJS, __CastType0))); 178 _[dartx.addAll](other[dartx.map](dart.as(_convertToJS, __CastType0)));
179 return _; 179 return _;
180 })()); 180 })());
181 } 181 }
182 _fromJs(jsObject) { 182 _fromJs(jsObject) {
183 super._fromJs(jsObject); 183 super._fromJs(jsObject);
184 } 184 }
185 [_checkIndex](index) { 185 [_checkIndex](index) {
186 if (typeof index == 'number' && (dart.notNull(index) < 0 || dart.notNull (index) >= dart.notNull(this.length))) { 186 if (typeof index == 'number' && (dart.notNull(index) < 0 || dart.notNull (index) >= dart.notNull(this.length))) {
187 throw new core.RangeError.range(index, 0, this.length); 187 dart.throw(new core.RangeError.range(index, 0, this.length));
188 } 188 }
189 } 189 }
190 [_checkInsertIndex](index) { 190 [_checkInsertIndex](index) {
191 if (typeof index == 'number' && (dart.notNull(index) < 0 || dart.notNull (index) >= dart.notNull(this.length) + 1)) { 191 if (typeof index == 'number' && (dart.notNull(index) < 0 || dart.notNull (index) >= dart.notNull(this.length) + 1)) {
192 throw new core.RangeError.range(index, 0, this.length); 192 dart.throw(new core.RangeError.range(index, 0, this.length));
193 } 193 }
194 } 194 }
195 static _checkRange(start, end, length) { 195 static _checkRange(start, end, length) {
196 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(length )) { 196 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(length )) {
197 throw new core.RangeError.range(start, 0, length); 197 dart.throw(new core.RangeError.range(start, 0, length));
198 } 198 }
199 if (dart.notNull(end) < dart.notNull(start) || dart.notNull(end) > dart. notNull(length)) { 199 if (dart.notNull(end) < dart.notNull(start) || dart.notNull(end) > dart. notNull(length)) {
200 throw new core.RangeError.range(end, start, length); 200 dart.throw(new core.RangeError.range(end, start, length));
201 } 201 }
202 } 202 }
203 get(index) { 203 get(index) {
204 if (dart.is(index, core.num) && dart.equals(index, dart.dsend(index, 'to Int'))) { 204 if (dart.is(index, core.num) && dart.equals(index, dart.dsend(index, 'to Int'))) {
205 this[_checkIndex](dart.as(index, core.int)); 205 this[_checkIndex](dart.as(index, core.int));
206 } 206 }
207 return dart.as(super.get(index), E); 207 return dart.as(super.get(index), E);
208 } 208 }
209 set(index, value) { 209 set(index, value) {
210 dart.as(value, E); 210 dart.as(value, E);
211 if (dart.is(index, core.num) && dart.equals(index, dart.dsend(index, 'to Int'))) { 211 if (dart.is(index, core.num) && dart.equals(index, dart.dsend(index, 'to Int'))) {
212 this[_checkIndex](dart.as(index, core.int)); 212 this[_checkIndex](dart.as(index, core.int));
213 } 213 }
214 super.set(index, value); 214 super.set(index, value);
215 } 215 }
216 get length() { 216 get length() {
217 let len = this[_jsObject].length; 217 let len = this[_jsObject].length;
218 if (typeof len === "number" && len >>> 0 === len) { 218 if (typeof len === "number" && len >>> 0 === len) {
219 return len; 219 return len;
220 } 220 }
221 throw new core.StateError('Bad JsArray length'); 221 dart.throw(new core.StateError('Bad JsArray length'));
222 } 222 }
223 set length(length) { 223 set length(length) {
224 super.set('length', length); 224 super.set('length', length);
225 } 225 }
226 add(value) { 226 add(value) {
227 dart.as(value, E); 227 dart.as(value, E);
228 this.callMethod('push', [value]); 228 this.callMethod('push', [value]);
229 } 229 }
230 addAll(iterable) { 230 addAll(iterable) {
231 dart.as(iterable, core.Iterable$(E)); 231 dart.as(iterable, core.Iterable$(E));
232 let list = iterable instanceof Array ? iterable : core.List.from(iterabl e); 232 let list = iterable instanceof Array ? iterable : core.List.from(iterabl e);
233 this.callMethod('push', dart.as(list, core.List)); 233 this.callMethod('push', dart.as(list, core.List));
234 } 234 }
235 insert(index, element) { 235 insert(index, element) {
236 dart.as(element, E); 236 dart.as(element, E);
237 this[_checkInsertIndex](index); 237 this[_checkInsertIndex](index);
238 this.callMethod('splice', [index, 0, element]); 238 this.callMethod('splice', [index, 0, element]);
239 } 239 }
240 removeAt(index) { 240 removeAt(index) {
241 this[_checkIndex](index); 241 this[_checkIndex](index);
242 return dart.as(dart.dindex(this.callMethod('splice', [index, 1]), 0), E) ; 242 return dart.as(dart.dindex(this.callMethod('splice', [index, 1]), 0), E) ;
243 } 243 }
244 removeLast() { 244 removeLast() {
245 if (this.length == 0) 245 if (this.length == 0)
246 throw new core.RangeError(-1); 246 dart.throw(new core.RangeError(-1));
247 return dart.as(this.callMethod('pop'), E); 247 return dart.as(this.callMethod('pop'), E);
248 } 248 }
249 removeRange(start, end) { 249 removeRange(start, end) {
250 JsArray$()._checkRange(start, end, this.length); 250 JsArray$()._checkRange(start, end, this.length);
251 this.callMethod('splice', [start, dart.notNull(end) - dart.notNull(start )]); 251 this.callMethod('splice', [start, dart.notNull(end) - dart.notNull(start )]);
252 } 252 }
253 setRange(start, end, iterable, skipCount) { 253 setRange(start, end, iterable, skipCount) {
254 dart.as(iterable, core.Iterable$(E)); 254 dart.as(iterable, core.Iterable$(E));
255 if (skipCount === void 0) 255 if (skipCount === void 0)
256 skipCount = 0; 256 skipCount = 0;
257 JsArray$()._checkRange(start, end, this.length); 257 JsArray$()._checkRange(start, end, this.length);
258 let length = dart.notNull(end) - dart.notNull(start); 258 let length = dart.notNull(end) - dart.notNull(start);
259 if (length == 0) 259 if (length == 0)
260 return; 260 return;
261 if (dart.notNull(skipCount) < 0) 261 if (dart.notNull(skipCount) < 0)
262 throw new core.ArgumentError(skipCount); 262 dart.throw(new core.ArgumentError(skipCount));
263 let args = [start, length]; 263 let args = [start, length];
264 args[dartx.addAll](iterable[dartx.skip](skipCount)[dartx.take](length)); 264 args[dartx.addAll](iterable[dartx.skip](skipCount)[dartx.take](length));
265 this.callMethod('splice', args); 265 this.callMethod('splice', args);
266 } 266 }
267 sort(compare) { 267 sort(compare) {
268 if (compare === void 0) 268 if (compare === void 0)
269 compare = null; 269 compare = null;
270 dart.as(compare, dart.functionType(core.int, [E, E])); 270 dart.as(compare, dart.functionType(core.int, [E, E]));
271 this.callMethod('sort', compare == null ? [] : [compare]); 271 this.callMethod('sort', compare == null ? [] : [compare]);
272 } 272 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(dart.d ynamic, [E])); 392 let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(dart.d ynamic, [E]));
393 return __CastType0; 393 return __CastType0;
394 }); 394 });
395 let __CastType0 = __CastType0$(); 395 let __CastType0 = __CastType0$();
396 // Exports: 396 // Exports:
397 exports.JsObject = JsObject; 397 exports.JsObject = JsObject;
398 exports.JsFunction = JsFunction; 398 exports.JsFunction = JsFunction;
399 exports.JsArray$ = JsArray$; 399 exports.JsArray$ = JsArray$;
400 exports.JsArray = JsArray; 400 exports.JsArray = JsArray;
401 }); 401 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/isolate.js ('k') | lib/runtime/dart/math.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698