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

Side by Side Diff: initialize/lib/src/static_loader.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 | « initialize/lib/src/mirror_loader.dart ('k') | initialize/lib/transformer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
4 library initialize.static_loader;
5
6 import 'dart:collection' show Queue;
7 import 'package:initialize/initialize.dart';
8
9 /// This represents an annotation/declaration pair.
10 class InitEntry<T> {
11 /// The annotation instance.
12 final Initializer<T> meta;
13
14 /// The target of the annotation to pass to initialize.
15 final T target;
16
17 InitEntry(this.meta, this.target);
18 }
19
20 /// Set of initializers that are invoked by `run`. This is initialized with
21 /// code automatically generated by the transformer.
22 Queue<InitEntry> initializers = new Queue<InitEntry>();
23
24 /// Returns initializer functions matching the supplied filters and removes them
25 /// from `initializers` so they won't be ran again.
26 Queue<Function> loadInitializers(
27 {List<Type> typeFilter, InitializerFilter customFilter, Uri from}) {
28 if (from != null) {
29 throw 'The `from` option is not supported in deploy mode.';
30 }
31 Queue<Function> result = new Queue<Function>();
32
33 var matchesFilters = (initializer) {
34 if (typeFilter != null &&
35 !typeFilter.any((t) => initializer.meta.runtimeType == t)) {
36 return false;
37 }
38 if (customFilter != null && !customFilter(initializer.meta)) {
39 return false;
40 }
41 return true;
42 };
43
44 result.addAll(initializers
45 .where(matchesFilters)
46 .map((i) => () => i.meta.initialize(i.target)));
47
48 initializers.removeWhere(matchesFilters);
49
50 return result;
51 }
OLDNEW
« no previous file with comments | « initialize/lib/src/mirror_loader.dart ('k') | initialize/lib/transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698