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

Side by Side Diff: lib/src/backend/platform_selector/evaluator.dart

Issue 1717483002: Make PlatformSelector use boolean_selector. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 10 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
(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
5 import '../operating_system.dart';
6 import '../test_platform.dart';
7 import 'ast.dart';
8 import 'visitor.dart';
9
10 /// A visitor for evaluating platform selectors against a specific
11 /// [TestPlatform] and [OperatingSystem].
12 class Evaluator implements Visitor<bool> {
13 /// The platform to test against.
14 final TestPlatform _platform;
15
16 /// The operating system to test against.
17 final OperatingSystem _os;
18
19 Evaluator(this._platform, {OperatingSystem os})
20 : _os = os == null ? OperatingSystem.none : os;
21
22 bool visitVariable(VariableNode node) {
23 if (node.name == _platform.identifier) return true;
24 if (node.name == _os.name) return true;
25
26 switch (node.name) {
27 case "dart-vm": return _platform.isDartVM;
28 case "browser": return _platform.isBrowser;
29 case "js": return _platform.isJS;
30 case "blink": return _platform.isBlink;
31 case "posix": return _os.isPosix;
32 default: return false;
33 }
34 }
35
36 bool visitNot(NotNode node) => !node.child.accept(this);
37
38 bool visitOr(OrNode node) =>
39 node.left.accept(this) || node.right.accept(this);
40
41 bool visitAnd(AndNode node) =>
42 node.left.accept(this) && node.right.accept(this);
43
44 bool visitConditional(ConditionalNode node) => node.condition.accept(this)
45 ? node.whenTrue.accept(this)
46 : node.whenFalse.accept(this);
47 }
OLDNEW
« no previous file with comments | « lib/src/backend/platform_selector/ast.dart ('k') | lib/src/backend/platform_selector/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698