OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 pub.asset.transformer_isolate; | 5 library pub.asset.transformer_isolate; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
10 | 10 |
11 import 'package:barback/barback.dart'; | 11 import 'package:barback/barback.dart'; |
12 | 12 |
13 import 'serialize.dart'; | 13 import 'serialize.dart'; |
14 | 14 |
15 /// The mirror system. | 15 /// The mirror system. |
| 16 /// |
| 17 /// Cached to avoid re-instantiating each time a transformer is initialized. |
16 final _mirrors = currentMirrorSystem(); | 18 final _mirrors = currentMirrorSystem(); |
17 | 19 |
18 /// The URI of this library. | 20 /// The URI of this library. |
19 final _baseUri = _mirrors.findLibrary( | 21 final _baseUri = _mirrors.findLibrary( |
20 const Symbol('pub.asset.transformer_isolate')).uri; | 22 const Symbol('pub.asset.transformer_isolate')).uri; |
21 | 23 |
22 /// Sets up the initial communication with the host isolate. | 24 /// Sets up the initial communication with the host isolate. |
23 void loadTransformers(SendPort replyTo) { | 25 void loadTransformers(SendPort replyTo) { |
24 var port = new ReceivePort(); | 26 var port = new ReceivePort(); |
25 replyTo.send(port.sendPort); | 27 replyTo.send(port.sendPort); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 101 |
100 // Older barbacks don't support [AggregateTransformer], and calling | 102 // Older barbacks don't support [AggregateTransformer], and calling |
101 // [reflectClass] on an undefined class will throw an error, so we just define a | 103 // [reflectClass] on an undefined class will throw an error, so we just define a |
102 // null getter for them. | 104 // null getter for them. |
103 //# if barback >=0.14.1 | 105 //# if barback >=0.14.1 |
104 ClassMirror get _aggregateTransformerClass => | 106 ClassMirror get _aggregateTransformerClass => |
105 reflectClass(AggregateTransformer); | 107 reflectClass(AggregateTransformer); |
106 //# else | 108 //# else |
107 //> ClassMirror get _aggregateTransformerClass => null; | 109 //> ClassMirror get _aggregateTransformerClass => null; |
108 //# end | 110 //# end |
OLD | NEW |