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

Side by Side Diff: tool/input_sdk/private/isolate_helper.dart

Issue 1152333009: Delete dart2js specific private library code (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 _isolate_helper; 5 library _isolate_helper;
6 6
7 import 'dart:_js_embedded_names' show 7 import 'dart:_js_embedded_names' show
8 CLASS_ID_EXTRACTOR, 8 CLASS_ID_EXTRACTOR,
9 CLASS_FIELDS_EXTRACTOR, 9 CLASS_FIELDS_EXTRACTOR,
10 CURRENT_SCRIPT, 10 CURRENT_SCRIPT,
11 GLOBAL_FUNCTIONS, 11 GLOBAL_FUNCTIONS,
12 INITIALIZE_EMPTY_INSTANCE, 12 INITIALIZE_EMPTY_INSTANCE,
13 INSTANCE_FROM_CLASS_ID; 13 INSTANCE_FROM_CLASS_ID;
14 14
15 import 'dart:async'; 15 import 'dart:async';
16 import 'dart:collection' show Queue, HashMap; 16 import 'dart:collection' show Queue, HashMap;
17 import 'dart:isolate'; 17 import 'dart:isolate';
18 import 'dart:_native_typed_data' show NativeByteBuffer, NativeTypedData; 18 import 'dart:_native_typed_data' show NativeByteBuffer, NativeTypedData;
19 19
20 import 'dart:_js_helper' show 20 import 'dart:_js_helper' show
21 Closure,
22 InternalMap, 21 InternalMap,
23 Null, 22 Null,
24 Primitives, 23 Primitives,
25 convertDartClosureToJS, 24 convertDartClosureToJS,
26 random64, 25 random64;
27 requiresPreamble;
28 26
29 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, 27 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS,
30 JS, 28 JS,
31 JS_CREATE_ISOLATE, 29 JS_CREATE_ISOLATE,
32 JS_CURRENT_ISOLATE_CONTEXT, 30 JS_CURRENT_ISOLATE_CONTEXT,
33 JS_CURRENT_ISOLATE, 31 JS_CURRENT_ISOLATE,
34 JS_EMBEDDED_GLOBAL, 32 JS_EMBEDDED_GLOBAL,
35 JS_SET_CURRENT_ISOLATE, 33 JS_SET_CURRENT_ISOLATE,
36 IsolateContext; 34 IsolateContext;
37 35
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 697
700 /** A stub for interacting with the main manager. */ 698 /** A stub for interacting with the main manager. */
701 class _MainManagerStub { 699 class _MainManagerStub {
702 void postMessage(msg) { 700 void postMessage(msg) {
703 // "self" is a way to refer to the global context object that 701 // "self" is a way to refer to the global context object that
704 // works in HTML pages and in Web Workers. It does not work in d8 702 // works in HTML pages and in Web Workers. It does not work in d8
705 // and Firefox jsshell, because that would have been too easy. 703 // and Firefox jsshell, because that would have been too easy.
706 // 704 //
707 // See: http://www.w3.org/TR/workers/#the-global-scope 705 // See: http://www.w3.org/TR/workers/#the-global-scope
708 // and: http://www.w3.org/TR/Window/#dfn-self-attribute 706 // and: http://www.w3.org/TR/Window/#dfn-self-attribute
709 requiresPreamble();
710 JS("void", r"self.postMessage(#)", msg); 707 JS("void", r"self.postMessage(#)", msg);
711 } 708 }
712 } 709 }
713 710
714 const String _SPAWNED_SIGNAL = "spawned"; 711 const String _SPAWNED_SIGNAL = "spawned";
715 const String _SPAWN_FAILED_SIGNAL = "spawn failed"; 712 const String _SPAWN_FAILED_SIGNAL = "spawn failed";
716 713
717 get globalWindow { 714 get globalWindow {
718 requiresPreamble();
719 return JS('', "self.window"); 715 return JS('', "self.window");
720 } 716 }
721 717
722 get globalWorker { 718 get globalWorker {
723 requiresPreamble();
724 return JS('', "self.Worker"); 719 return JS('', "self.Worker");
725 } 720 }
726 bool get globalPostMessageDefined { 721 bool get globalPostMessageDefined {
727 requiresPreamble();
728 return JS('bool', "!!self.postMessage"); 722 return JS('bool', "!!self.postMessage");
729 } 723 }
730 724
731 typedef _MainFunction(); 725 typedef _MainFunction();
732 typedef _MainFunctionArgs(args); 726 typedef _MainFunctionArgs(args);
733 typedef _MainFunctionArgsMessage(args, message); 727 typedef _MainFunctionArgsMessage(args, message);
734 728
735 /// Note: IsolateNatives depends on _globalState which is only set up correctly 729 /// Note: IsolateNatives depends on _globalState which is only set up correctly
736 /// when 'dart:isolate' has been imported. 730 /// when 'dart:isolate' has been imported.
737 class IsolateNatives { 731 class IsolateNatives {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 } else { 895 } else {
902 try { 896 try {
903 _consoleLog(msg); 897 _consoleLog(msg);
904 } catch (e, trace) { 898 } catch (e, trace) {
905 throw new Exception(trace); 899 throw new Exception(trace);
906 } 900 }
907 } 901 }
908 } 902 }
909 903
910 static void _consoleLog(msg) { 904 static void _consoleLog(msg) {
911 requiresPreamble();
912 JS("void", r"self.console.log(#)", msg); 905 JS("void", r"self.console.log(#)", msg);
913 } 906 }
914 907
915 static _getJSFunctionFromName(String functionName) { 908 static _getJSFunctionFromName(String functionName) {
916 var globalFunctionsContainer = JS_EMBEDDED_GLOBAL("", GLOBAL_FUNCTIONS); 909 var globalFunctionsContainer = JS_EMBEDDED_GLOBAL("", GLOBAL_FUNCTIONS);
917 return JS("", "#[#]()", globalFunctionsContainer, functionName); 910 return JS("", "#[#]()", globalFunctionsContainer, functionName);
918 } 911 }
919 912
920 /** 913 /**
921 * Get a string name for the function, if possible. The result for 914 * Get a string name for the function, if possible. The result for
922 * anonymous functions is browser-dependent -- it may be "" or "anonymous" 915 * anonymous functions is browser-dependent -- it may be "" or "anonymous"
923 * but you should probably not count on this. 916 * but you should probably not count on this.
924 */ 917 */
925 static String _getJSFunctionName(Function f) { 918 static String _getJSFunctionName(Function f) {
926 return (f is Closure) ? JS("String|Null", r'#.$name', f) : null; 919 return JS("String|Null", r'#.$name', f);
927 } 920 }
928 921
929 /** Create a new JavaScript object instance given its constructor. */ 922 /** Create a new JavaScript object instance given its constructor. */
930 static dynamic _allocate(var ctor) { 923 static dynamic _allocate(var ctor) {
931 return JS("", "new #()", ctor); 924 return JS("", "new #()", ctor);
932 } 925 }
933 926
934 static Future<List> spawnFunction(void topLevelFunction(message), 927 static Future<List> spawnFunction(void topLevelFunction(message),
935 var message, 928 var message,
936 bool startPaused) { 929 bool startPaused) {
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 _handle = null; 1403 _handle = null;
1411 } else { 1404 } else {
1412 throw new UnsupportedError("Canceling a timer."); 1405 throw new UnsupportedError("Canceling a timer.");
1413 } 1406 }
1414 } 1407 }
1415 1408
1416 bool get isActive => _handle != null; 1409 bool get isActive => _handle != null;
1417 } 1410 }
1418 1411
1419 bool hasTimer() { 1412 bool hasTimer() {
1420 requiresPreamble();
1421 return JS('', 'self.setTimeout') != null; 1413 return JS('', 'self.setTimeout') != null;
1422 } 1414 }
1423 1415
1424 1416
1425 /** 1417 /**
1426 * Implementation class for [Capability]. 1418 * Implementation class for [Capability].
1427 * 1419 *
1428 * It has the same name to make it harder for users to distinguish. 1420 * It has the same name to make it harder for users to distinguish.
1429 */ 1421 */
1430 class CapabilityImpl implements Capability { 1422 class CapabilityImpl implements Capability {
(...skipping 20 matching lines...) Expand all
1451 } 1443 }
1452 1444
1453 bool operator==(Object other) { 1445 bool operator==(Object other) {
1454 if (identical(other, this)) return true; 1446 if (identical(other, this)) return true;
1455 if (other is CapabilityImpl) { 1447 if (other is CapabilityImpl) {
1456 return identical(_id, other._id); 1448 return identical(_id, other._id);
1457 } 1449 }
1458 return false; 1450 return false;
1459 } 1451 }
1460 } 1452 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698