visitVarDecl method

  1. @override
void visitVarDecl(
  1. VarDecl node
)
override

Implementation

@override
void visitVarDecl(VarDecl node) {
  /// Skip if the value is already been computed.
  if (node.isConstValue) return;
  if (_visitingInitializers.contains(node)) {
    final err = HTError.circleInit(node.id.id,
        filename: node.source!.fullName,
        line: node.line,
        column: node.column,
        offset: node.offset,
        length: node.length);
    errors.add(HTAnalysisError.fromError(err,
        filename: node.source!.fullName,
        line: node.line,
        column: node.column,
        offset: node.offset,
        length: node.length));
  } else {
    _visitingInitializers.add(node);
    node.subAccept(this);
    if (node.isConst) {
      if (!node.initializer!.isConstValue) {
        final err = HTAnalysisError.constValue(node.id.id,
            filename: node.source!.fullName,
            line: node.initializer!.line,
            column: node.initializer!.column,
            offset: node.initializer!.offset,
            length: node.initializer!.length);
        errors.add(err);
      } else {
        node.value = node.initializer!.value;
      }
    }
    _visitingInitializers.remove(node);
  }
}