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

Unified Diff: frog/leg/tree_validator.dart

Issue 9873021: Move frog/leg to lib/compiler/implementation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « frog/leg/tree/visitors.dart ('k') | frog/leg/typechecker.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/tree_validator.dart
===================================================================
--- frog/leg/tree_validator.dart (revision 5925)
+++ frog/leg/tree_validator.dart (working copy)
@@ -1,68 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-class TreeValidatorTask extends CompilerTask {
- TreeValidatorTask(Compiler compiler) : super(compiler);
-
- void validate(Node tree) {
- assert(check(tree));
- }
-
- bool check(Node tree) {
- List<InvalidNodeError> errors = [];
- void report(node, message) {
- final error = new InvalidNodeError(node, message);
- errors.add(error);
- compiler.reportWarning(node, message);
- };
- final validator = new ValidatorVisitor(report);
- tree.accept(new TraversingVisitor(validator));
-
- return errors.isEmpty();
- }
-}
-
-class ValidatorVisitor extends AbstractVisitor {
- final Function reportInvalidNode;
-
- ValidatorVisitor(Function this.reportInvalidNode);
-
- expect(Node node, bool test, [message]) {
- if (!test) reportInvalidNode(node, message);
- }
-
- visitNode(Node node) {}
-
- visitSendSet(SendSet node) {
- final selector = node.selector;
- final name = node.assignmentOperator.source.stringValue;
- final arguments = node.arguments;
-
- expect(node, arguments !== null);
- expect(node, selector is Identifier, 'selector is not assignable');
- if (name === '++' || name === '--') {
- expect(node, node.assignmentOperator is Operator);
- if (node.isIndex) {
- expect(node.arguments.tail.head, node.arguments.tail.isEmpty());
- } else {
- expect(node.arguments.head, node.arguments.isEmpty());
- }
- } else {
- expect(node, !node.arguments.isEmpty());
- }
- }
-}
-
-class InvalidNodeError {
- final Node node;
- final String message;
- InvalidNodeError(this.node, [this.message]);
-
- toString() {
- String nodeString = new Unparser(true).unparse(node);
- String result = 'invalid node: $nodeString';
- if (message !== null) result = '$result ($message)';
- return result;
- }
-}
« no previous file with comments | « frog/leg/tree/visitors.dart ('k') | frog/leg/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698