当前位置: 首页>>代码示例>>Java>>正文


Java ThisLiteralNode类代码示例

本文整理汇总了Java中org.checkerframework.dataflow.cfg.node.ThisLiteralNode的典型用法代码示例。如果您正苦于以下问题:Java ThisLiteralNode类的具体用法?Java ThisLiteralNode怎么用?Java ThisLiteralNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ThisLiteralNode类属于org.checkerframework.dataflow.cfg.node包,在下文中一共展示了ThisLiteralNode类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populateElementsRec

import org.checkerframework.dataflow.cfg.node.ThisLiteralNode; //导入依赖的package包/类
@Nullable
private static Root populateElementsRec(Node node, List<Element> elements) {
  Root result;
  if (node instanceof FieldAccessNode) {
    FieldAccessNode fieldAccess = (FieldAccessNode) node;
    if (fieldAccess.isStatic()) {
      // this is the root
      result = new Root(fieldAccess.getElement());
    } else {
      // instance field access
      result = populateElementsRec(fieldAccess.getReceiver(), elements);
      elements.add(fieldAccess.getElement());
    }
  } else if (node instanceof MethodInvocationNode) {
    MethodInvocationNode invocation = (MethodInvocationNode) node;
    // only support zero-argument methods
    if (invocation.getArguments().size() > 0) {
      return null;
    }
    MethodAccessNode accessNode = invocation.getTarget();
    result = populateElementsRec(accessNode.getReceiver(), elements);
    elements.add(accessNode.getMethod());
  } else if (node instanceof LocalVariableNode) {
    result = new Root(((LocalVariableNode) node).getElement());
  } else if (node instanceof ThisLiteralNode) {
    result = new Root();
  } else {
    // don't handle any other cases
    result = null;
  }
  return result;
}
 
开发者ID:uber,项目名称:NullAway,代码行数:33,代码来源:AccessPath.java

示例2: visitAssignment

import org.checkerframework.dataflow.cfg.node.ThisLiteralNode; //导入依赖的package包/类
@Override
public TransferResult<Nullness, NullnessStore<Nullness>> visitAssignment(
    AssignmentNode node, TransferInput<Nullness, NullnessStore<Nullness>> input) {
  ReadableUpdates updates = new ReadableUpdates();
  Nullness value = values(input).valueOfSubNode(node.getExpression());
  Node target = node.getTarget();

  if (target instanceof LocalVariableNode) {
    updates.set((LocalVariableNode) target, value);
  }

  if (target instanceof ArrayAccessNode) {
    setNonnullIfAnalyzeable(updates, ((ArrayAccessNode) target).getArray());
  }

  if (target instanceof FieldAccessNode) {
    // we don't allow arbitrary access paths to be tracked from assignments
    // here we still require an access of a field of this, or a static field
    FieldAccessNode fieldAccessNode = (FieldAccessNode) target;
    Node receiver = fieldAccessNode.getReceiver();
    if ((receiver instanceof ThisLiteralNode || fieldAccessNode.isStatic())
        && fieldAccessNode.getElement().getKind().equals(ElementKind.FIELD)) {
      updates.set(fieldAccessNode, value);
    }
  }

  return updateRegularStore(value, input, updates);
}
 
开发者ID:uber,项目名称:NullAway,代码行数:29,代码来源:AccessPathNullnessPropagation.java

示例3: internalReprOf

import org.checkerframework.dataflow.cfg.node.ThisLiteralNode; //导入依赖的package包/类
/**
 * We ignore operations such as widening and
 * narrowing when computing the internal representation.
 *
 * @return The internal representation (as {@link Receiver}) of any
 *         {@link Node}. Might contain {@link Unknown}.
 */
public static Receiver internalReprOf(AnnotationProvider provider,
        Node receiverNode, boolean allowNonDeterminitic) {
    Receiver receiver = null;
    if (receiverNode instanceof FieldAccessNode) {
        receiver = internalReprOfFieldAccess(provider,
                (FieldAccessNode) receiverNode);
    } else if (receiverNode instanceof ThisLiteralNode) {
        receiver = new ThisReference(receiverNode.getType());
    } else if (receiverNode instanceof SuperNode) {
        receiver = new ThisReference(receiverNode.getType());
    } else if (receiverNode instanceof LocalVariableNode) {
        LocalVariableNode lv = (LocalVariableNode) receiverNode;
        receiver = new LocalVariable(lv);
    } else if (receiverNode instanceof ArrayAccessNode) {
        ArrayAccessNode a = (ArrayAccessNode) receiverNode;
        receiver = internalReprOfArrayAccess(provider, a);
    } else if (receiverNode instanceof StringConversionNode) {
        // ignore string conversion
        return internalReprOf(provider,
                ((StringConversionNode) receiverNode).getOperand());
    } else if (receiverNode instanceof WideningConversionNode) {
        // ignore widening
        return internalReprOf(provider,
                ((WideningConversionNode) receiverNode).getOperand());
    } else if (receiverNode instanceof NarrowingConversionNode) {
        // ignore narrowing
        return internalReprOf(provider,
                ((NarrowingConversionNode) receiverNode).getOperand());
    } else if (receiverNode instanceof ClassNameNode) {
        ClassNameNode cn = (ClassNameNode) receiverNode;
        receiver = new ClassName(cn.getType());
    } else if (receiverNode instanceof ValueLiteralNode) {
        ValueLiteralNode vn = (ValueLiteralNode) receiverNode;
        receiver = new ValueLiteral(vn.getType(), vn);
    } else if (receiverNode instanceof MethodInvocationNode) {
        MethodInvocationNode mn = (MethodInvocationNode) receiverNode;
        ExecutableElement invokedMethod = TreeUtils.elementFromUse(mn
                .getTree());

        // check if this represents a boxing operation of a constant, in which
        // case we treat the method call as deterministic, because there is no way
        // to behave differently in two executions where two constants are being used.
        boolean considerDeterministic = false;
        if (invokedMethod.toString().equals("valueOf(long)")
                && mn.getTarget().getReceiver().toString().equals("Long")) {
            Node arg = mn.getArgument(0);
            if (arg instanceof ValueLiteralNode) {
                considerDeterministic = true;
            }
        }

        if (PurityUtils.isDeterministic(provider, invokedMethod) || allowNonDeterminitic || considerDeterministic) {
            List<Receiver> parameters = new ArrayList<>();
            for (Node p : mn.getArguments()) {
                parameters.add(internalReprOf(provider, p));
            }
            Receiver methodReceiver;
            if (ElementUtils.isStatic(invokedMethod)) {
                methodReceiver = new ClassName(mn.getTarget().getReceiver()
                        .getType());
            } else {
                methodReceiver = internalReprOf(provider, mn.getTarget()
                        .getReceiver());
            }
            receiver = new PureMethodCall(mn.getType(), invokedMethod,
                    methodReceiver, parameters);
        }
    }

    if (receiver == null) {
        receiver = new Unknown(receiverNode.getType());
    }
    return receiver;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:82,代码来源:FlowExpressions.java


注:本文中的org.checkerframework.dataflow.cfg.node.ThisLiteralNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。