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

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

Issue 964853002: Let CSP-mode-flag be available as a foreign_helper constant. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
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 JsGetName, 10 JsGetName,
(...skipping 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 return JS( 2252 return JS(
2253 '', 2253 '',
2254 'function(f,s){' 2254 'function(f,s){'
2255 'return function(){' 2255 'return function(){'
2256 'return f.apply(s(this),arguments)' 2256 'return f.apply(s(this),arguments)'
2257 '}' 2257 '}'
2258 '}(#,#)', function, getSelf); 2258 '}(#,#)', function, getSelf);
2259 } 2259 }
2260 } 2260 }
2261 2261
2262 static bool get isCsp => JS('bool', 'typeof dart_precompiled == "function"'); 2262 static bool get isCsp => JS_GET_FLAG("USE_CONTENT_SECURITY_POLICY");
2263 2263
2264 static forwardCallTo(receiver, function, bool isIntercepted) { 2264 static forwardCallTo(receiver, function, bool isIntercepted) {
2265 if (isIntercepted) return forwardInterceptedCallTo(receiver, function); 2265 if (isIntercepted) return forwardInterceptedCallTo(receiver, function);
2266 String stubName = JS('String|Null', '#.\$stubName', function); 2266 String stubName = JS('String|Null', '#.\$stubName', function);
2267 int arity = JS('int', '#.length', function); 2267 int arity = JS('int', '#.length', function);
2268 var lookedUpFunction = JS("", "#[#]", receiver, stubName); 2268 var lookedUpFunction = JS("", "#[#]", receiver, stubName);
2269 // The receiver[stubName] may not be equal to the function if we try to 2269 // The receiver[stubName] may not be equal to the function if we try to
2270 // forward to a super-method. Especially when we create a bound closure 2270 // forward to a super-method. Especially when we create a bound closure
2271 // of a super-call we need to make sure that we don't forward back to the 2271 // of a super-call we need to make sure that we don't forward back to the
2272 // dynamically looked up function. 2272 // dynamically looked up function.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 '}' 2369 '}'
2370 '}(#,#,#)', function, getSelf, getReceiver); 2370 '}(#,#,#)', function, getSelf, getReceiver);
2371 } 2371 }
2372 } 2372 }
2373 2373
2374 static forwardInterceptedCallTo(receiver, function) { 2374 static forwardInterceptedCallTo(receiver, function) {
2375 String selfField = BoundClosure.selfFieldName(); 2375 String selfField = BoundClosure.selfFieldName();
2376 String receiverField = BoundClosure.receiverFieldName(); 2376 String receiverField = BoundClosure.receiverFieldName();
2377 String stubName = JS('String|Null', '#.\$stubName', function); 2377 String stubName = JS('String|Null', '#.\$stubName', function);
2378 int arity = JS('int', '#.length', function); 2378 int arity = JS('int', '#.length', function);
2379 bool isCsp = JS('bool', 'typeof dart_precompiled == "function"'); 2379 bool isCsp = JS_GET_FLAG("USE_CONTENT_SECURITY_POLICY");
2380 var lookedUpFunction = JS("", "#[#]", receiver, stubName); 2380 var lookedUpFunction = JS("", "#[#]", receiver, stubName);
2381 // The receiver[stubName] may not be equal to the function if we try to 2381 // The receiver[stubName] may not be equal to the function if we try to
2382 // forward to a super-method. Especially when we create a bound closure 2382 // forward to a super-method. Especially when we create a bound closure
2383 // of a super-call we need to make sure that we don't forward back to the 2383 // of a super-call we need to make sure that we don't forward back to the
2384 // dynamically looked up function. 2384 // dynamically looked up function.
2385 bool isSuperCall = !identical(function, lookedUpFunction); 2385 bool isSuperCall = !identical(function, lookedUpFunction);
2386 2386
2387 if (isCsp || isSuperCall || arity >= 28) { 2387 if (isCsp || isSuperCall || arity >= 28) {
2388 return cspForwardInterceptedCall(arity, isSuperCall, stubName, 2388 return cspForwardInterceptedCall(arity, isSuperCall, stubName,
2389 function); 2389 function);
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
3879 // This is a function that will return a helper function that does the 3879 // This is a function that will return a helper function that does the
3880 // iteration of the sync*. 3880 // iteration of the sync*.
3881 // 3881 //
3882 // Each invocation should give a body with fresh state. 3882 // Each invocation should give a body with fresh state.
3883 final dynamic /* js function */ _outerHelper; 3883 final dynamic /* js function */ _outerHelper;
3884 3884
3885 SyncStarIterable(this._outerHelper); 3885 SyncStarIterable(this._outerHelper);
3886 3886
3887 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper)); 3887 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper));
3888 } 3888 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | sdk/lib/_internal/compiler/js_lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698