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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_helper.dart

Issue 1200403003: JSInvocationMirror - return unmodifiable list or map (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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 | « sdk/lib/_internal/compiler/js_lib/constant_map.dart ('k') | tests/co19/co19-co19.status » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library _js_helper; 5 library _js_helper;
6 6
7 import 'dart:_async_await_error_codes' as async_error_codes; 7 import 'dart:_async_await_error_codes' as async_error_codes;
8 8
9 import 'dart:_js_embedded_names' show 9 import 'dart:_js_embedded_names' show
10 DEFERRED_LIBRARY_URIS, 10 DEFERRED_LIBRARY_URIS,
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 bool get isAccessor => _kind != METHOD; 293 bool get isAccessor => _kind != METHOD;
294 294
295 List get positionalArguments { 295 List get positionalArguments {
296 if (isGetter) return const []; 296 if (isGetter) return const [];
297 var argumentCount = _arguments.length - _namedArgumentNames.length; 297 var argumentCount = _arguments.length - _namedArgumentNames.length;
298 if (argumentCount == 0) return const []; 298 if (argumentCount == 0) return const [];
299 var list = []; 299 var list = [];
300 for (var index = 0 ; index < argumentCount ; index++) { 300 for (var index = 0 ; index < argumentCount ; index++) {
301 list.add(_arguments[index]); 301 list.add(_arguments[index]);
302 } 302 }
303 return makeLiteralListConst(list); 303 return JSArray.markUnmodifiableList(list);
304 } 304 }
305 305
306 Map<Symbol, dynamic> get namedArguments { 306 Map<Symbol, dynamic> get namedArguments {
307 // TODO: Make maps const (issue 10471) 307 if (isAccessor) return const <Symbol, dynamic>{};
308 if (isAccessor) return <Symbol, dynamic>{};
309 int namedArgumentCount = _namedArgumentNames.length; 308 int namedArgumentCount = _namedArgumentNames.length;
310 int namedArgumentsStartIndex = _arguments.length - namedArgumentCount; 309 int namedArgumentsStartIndex = _arguments.length - namedArgumentCount;
311 if (namedArgumentCount == 0) return <Symbol, dynamic>{}; 310 if (namedArgumentCount == 0) return const <Symbol, dynamic>{};
312 var map = new Map<Symbol, dynamic>(); 311 var map = new Map<Symbol, dynamic>();
313 for (int i = 0; i < namedArgumentCount; i++) { 312 for (int i = 0; i < namedArgumentCount; i++) {
314 map[new _symbol_dev.Symbol.unvalidated(_namedArgumentNames[i])] = 313 map[new _symbol_dev.Symbol.unvalidated(_namedArgumentNames[i])] =
315 _arguments[namedArgumentsStartIndex + i]; 314 _arguments[namedArgumentsStartIndex + i];
316 } 315 }
317 return map; 316 return new ConstantMapView<Symbol, dynamic>(map);
318 } 317 }
319 318
320 _getCachedInvocation(Object object) { 319 _getCachedInvocation(Object object) {
321 var interceptor = getInterceptor(object); 320 var interceptor = getInterceptor(object);
322 var receiver = object; 321 var receiver = object;
323 var name = _internalName; 322 var name = _internalName;
324 var arguments = _arguments; 323 var arguments = _arguments;
325 var interceptedNames = JS_EMBEDDED_GLOBAL('', INTERCEPTED_NAMES); 324 var interceptedNames = JS_EMBEDDED_GLOBAL('', INTERCEPTED_NAMES);
326 bool isIntercepted = 325 bool isIntercepted =
327 JS("bool", 'Object.prototype.hasOwnProperty.call(#, #)', 326 JS("bool", 'Object.prototype.hasOwnProperty.call(#, #)',
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 /** 1497 /**
1499 * This wraps the exception and does the throw. It is possible to call this in 1498 * This wraps the exception and does the throw. It is possible to call this in
1500 * a JS expression context, where the throw statement is not allowed. Helpers 1499 * a JS expression context, where the throw statement is not allowed. Helpers
1501 * are never inlined, so we don't risk inlining the throw statement into an 1500 * are never inlined, so we don't risk inlining the throw statement into an
1502 * expression context. 1501 * expression context.
1503 */ 1502 */
1504 throwExpression(ex) { 1503 throwExpression(ex) {
1505 JS('void', 'throw #', wrapException(ex)); 1504 JS('void', 'throw #', wrapException(ex));
1506 } 1505 }
1507 1506
1508 makeLiteralListConst(list) {
1509 JS('bool', r'#.immutable$list = #', list, true);
1510 JS('bool', r'#.fixed$length = #', list, true);
1511 return list;
1512 }
1513
1514 throwRuntimeError(message) { 1507 throwRuntimeError(message) {
1515 throw new RuntimeError(message); 1508 throw new RuntimeError(message);
1516 } 1509 }
1517 1510
1518 throwAbstractClassInstantiationError(className) { 1511 throwAbstractClassInstantiationError(className) {
1519 throw new AbstractClassInstantiationError(className); 1512 throw new AbstractClassInstantiationError(className);
1520 } 1513 }
1521 1514
1522 // This is used in open coded for-in loops on arrays. 1515 // This is used in open coded for-in loops on arrays.
1523 // 1516 //
(...skipping 2605 matching lines...) Expand 10 before | Expand all | Expand 10 after
4129 // This is a function that will return a helper function that does the 4122 // This is a function that will return a helper function that does the
4130 // iteration of the sync*. 4123 // iteration of the sync*.
4131 // 4124 //
4132 // Each invocation should give a body with fresh state. 4125 // Each invocation should give a body with fresh state.
4133 final dynamic /* js function */ _outerHelper; 4126 final dynamic /* js function */ _outerHelper;
4134 4127
4135 SyncStarIterable(this._outerHelper); 4128 SyncStarIterable(this._outerHelper);
4136 4129
4137 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper)); 4130 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper));
4138 } 4131 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/constant_map.dart ('k') | tests/co19/co19-co19.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698