All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.checkerframework.common.initializedfields.InitializedFieldsTransfer Maven / Gradle / Ivy

Go to download

The Checker Framework enhances Java's type system to make it more powerful and useful. This lets software developers detect and prevent errors in their Java programs. The Checker Framework includes compiler plug-ins ("checkers") that find bugs or verify their absence. It also permits you to write your own compiler plug-ins.

There is a newer version: 3.48.2
Show newest version
package org.checkerframework.common.initializedfields;

import org.checkerframework.common.accumulation.AccumulationAnalysis;
import org.checkerframework.common.accumulation.AccumulationStore;
import org.checkerframework.common.accumulation.AccumulationTransfer;
import org.checkerframework.common.accumulation.AccumulationValue;
import org.checkerframework.dataflow.analysis.TransferInput;
import org.checkerframework.dataflow.analysis.TransferResult;
import org.checkerframework.dataflow.cfg.node.AssignmentNode;
import org.checkerframework.dataflow.cfg.node.FieldAccessNode;
import org.checkerframework.dataflow.cfg.node.Node;

/** Accumulates the names of fields that are initialized. */
public class InitializedFieldsTransfer extends AccumulationTransfer {

  /**
   * Create an InitializedFieldsTransfer.
   *
   * @param analysis the analysis
   */
  public InitializedFieldsTransfer(AccumulationAnalysis analysis) {
    super(analysis);
  }

  @Override
  public TransferResult visitAssignment(
      AssignmentNode node, TransferInput input) {
    TransferResult result =
        super.visitAssignment(node, input);
    Node lhs = node.getTarget();
    if (lhs instanceof FieldAccessNode) {
      FieldAccessNode fieldAccess = (FieldAccessNode) lhs;
      accumulate(fieldAccess.getReceiver(), result, fieldAccess.getFieldName());
    }
    return result;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy