| Index: pkg/analyzer/lib/src/summary/fasta/visitor.dart
|
| diff --git a/pkg/analyzer/lib/src/summary/fasta/visitor.dart b/pkg/analyzer/lib/src/summary/fasta/visitor.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a5bc271377259a9b5c58576f936fb3b94462476d
|
| --- /dev/null
|
| +++ b/pkg/analyzer/lib/src/summary/fasta/visitor.dart
|
| @@ -0,0 +1,141 @@
|
| +// Copyright (c) 2017, 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.
|
| +
|
| +/// Visitor of the simplified expression syntax tree.
|
| +library summary.src.visitor;
|
| +
|
| +import 'expressions.dart';
|
| +
|
| +/// Plain non-recursive visitor.
|
| +class Visitor {
|
| + // References
|
| +
|
| + visitRef(Ref n) => handleRef(n);
|
| + handleRef(Ref n) {}
|
| +
|
| + // Literals
|
| +
|
| + visitNull(NullLiteral n) => handleNull(n);
|
| + visitBool(BoolLiteral n) => handleBool(n);
|
| + visitInt(IntLiteral n) => handleInt(n);
|
| + visitDouble(DoubleLiteral n) => handleDouble(n);
|
| + visitList(ListLiteral n) => handleList(n);
|
| + visitMap(MapLiteral n) => handleMap(n);
|
| + visitString(StringLiteral n) => handleString(n);
|
| + visitSymbol(SymbolLiteral n) => handleSymbol(n);
|
| +
|
| + handleNull(NullLiteral n){}
|
| + handleBool(BoolLiteral n){}
|
| + handleInt(IntLiteral n){}
|
| + handleDouble(DoubleLiteral n){}
|
| + handleList(ListLiteral n){}
|
| + handleMap(MapLiteral n){}
|
| + handleString(StringLiteral n){}
|
| + handleSymbol(SymbolLiteral n){}
|
| +
|
| + // Compound expressions
|
| +
|
| + visitAs(As n) => handleAs(n);
|
| + visitIs(Is n) => handleIs(n);
|
| + visitUnary(Unary n) => handleUnary(n);
|
| + visitBinary(Binary n) => handleBinary(n);
|
| + visitLoad(Load n) => handleLoad(n);
|
| + visitIdentical(Identical n) => handleIdentical(n);
|
| + visitConditional(Conditional n) => handleConditional(n);
|
| + visitConstCreation(ConstCreation n) => handleConstCreation(n);
|
| +
|
| + handleAs(As n){}
|
| + handleIs(Is n){}
|
| + handleUnary(Unary n){}
|
| + handleBinary(Binary n){}
|
| + handleLoad(Load n){}
|
| + handleIdentical(Identical n){}
|
| + handleConditional(Conditional n){}
|
| + handleConstCreation(ConstCreation n){}
|
| +
|
| + // Non-traditional expressions.
|
| +
|
| + visitInvalid(Invalid n) => handleInvalid(n);
|
| + visitOpaque(Opaque n) => handleOpaque(n);
|
| + visitOpaqueOp(OpaqueOp n) => handleOpaqueOp(n);
|
| +
|
| + handleInvalid(Invalid n){}
|
| + handleOpaque(Opaque n){}
|
| + handleOpaqueOp(OpaqueOp n){}
|
| +}
|
| +
|
| +/// Post-order recursive visitor.
|
| +///
|
| +/// Will invoke `handle*` methods in post order (children first, parents
|
| +/// afterwards).
|
| +class RecursiveVisitor extends Visitor {
|
| + visitList(ListLiteral n){
|
| + for (var v in n.values) {
|
| + v.accept(this);
|
| + }
|
| + handleList(n);
|
| + }
|
| +
|
| + visitMap(MapLiteral n) {
|
| + for (var v in n.values) {
|
| + v.key.accept(this);
|
| + v.value.accept(this);
|
| + }
|
| + handleMap(n);
|
| + }
|
| +
|
| + visitAs(As n) {
|
| + n.exp.accept(this);
|
| + handleAs(n);
|
| + }
|
| +
|
| + visitIs(Is n) {
|
| + n.exp.accept(this);
|
| + handleIs(n);
|
| + }
|
| +
|
| + visitUnary(Unary n) {
|
| + n.exp.accept(this);
|
| + handleUnary(n);
|
| + }
|
| +
|
| + visitBinary(Binary n) {
|
| + n.left.accept(this);
|
| + n.right.accept(this);
|
| + handleBinary(n);
|
| + }
|
| +
|
| + visitIdentical(Identical n) {
|
| + n.left.accept(this);
|
| + n.right.accept(this);
|
| + handleIdentical(n);
|
| + }
|
| +
|
| + visitLoad(Load n) {
|
| + n.left.accept(this);
|
| + handleLoad(n);
|
| + }
|
| +
|
| + visitConditional(Conditional n) {
|
| + n.test.accept(this);
|
| + n.trueBranch.accept(this);
|
| + n.falseBranch.accept(this);
|
| + handleConditional(n);
|
| + }
|
| +
|
| + visitConstCreation(ConstCreation n) {
|
| + for (var arg in n.positionalArgs) {
|
| + arg.accept(this);
|
| + }
|
| + for (var arg in n.namedArgs) {
|
| + arg.value.accept(this);
|
| + }
|
| + handleConstCreation(n);
|
| + }
|
| +
|
| + visitOpaqueOp(OpaqueOp n) {
|
| + n.exp.accept(this);
|
| + handleOpaqueOp(n);
|
| + }
|
| +}
|
|
|