OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 // This is an interface to the Dart Kernel parser and Kernel binary generator. | 5 // This is an interface to the Dart Kernel parser and Kernel binary generator. |
6 // It is used by the kernel-isolate to load Dart source code and generate | 6 // It is used by the kernel-isolate to load Dart source code and generate |
7 // Kernel binary format. | 7 // Kernel binary format. |
8 | 8 |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 import 'dart:async'; | 10 import 'dart:async'; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 try { | 85 try { |
86 result = await parseScript(scriptUri, packagesUri.path, patchedSdk.path); | 86 result = await parseScript(scriptUri, packagesUri.path, patchedSdk.path); |
87 } catch (error) { | 87 } catch (error) { |
88 tag = -tag; // Mark reply as an exception. | 88 tag = -tag; // Mark reply as an exception. |
89 result = error.toString(); | 89 result = error.toString(); |
90 } | 90 } |
91 | 91 |
92 port.send([tag, inputFileUrl, inputFileUrl, null, result]); | 92 port.send([tag, inputFileUrl, inputFileUrl, null, result]); |
93 } | 93 } |
94 | 94 |
95 // This entry point is used when running in the kernel isolate. | 95 main() => new RawReceivePort()..handler = _processLoadRequest; |
96 start() => new RawReceivePort()..handler = _processLoadRequest; | |
97 | |
98 // This entry point is used when creating an app snapshot. The argument provides | |
99 // a script to compile to warm-up generated code. | |
100 main(args) { | |
101 var tag = 1; | |
102 var scriptUri = args[0]; | |
103 var responsePort = new RawReceivePort(); | |
104 responsePort.handler = (response) { | |
105 if (response[0] == tag) { | |
106 // Success. | |
107 responsePort.close(); | |
108 } else if (response[0] == -tag) { | |
109 // Compilation error. | |
110 throw response[4]; | |
111 } else { | |
112 throw "Unexpected response: $response"; | |
113 } | |
114 }; | |
115 var request = [tag, responsePort.sendPort, scriptUri]; | |
116 _processLoadRequest(request); | |
117 } | |
OLD | NEW |