Esempio n. 1
0
    private void CheckPointerUse(Statement stat, Variable v, NonNullState nn, string purpose)
    {
      if (v == null) return;

      if(nn.IsNull(v))
      {
        HandleError(stat, v, Error.UseOfNullPointer, purpose);
        nn.AssignNonNull(v);
      }
      else if(!nn.IsNonNull(v))
      {
        HandleError(stat, v, Error.UseOfPossiblyNullPointer, purpose);
        nn.AssumeNonNull(v);
      }
    }
Esempio n. 2
0
    private void CheckReceiver(Statement stat, Variable v, NonNullState nn, Node node)
    {
      Node offendingNode = v;
      if (v == null) return;
      if (v.Type.IsValueType) return;

      // Create a better source context for receiver null errors.
      offendingNode = new Statement(NodeType.Nop);
      offendingNode.SourceContext = v.SourceContext;
 //     offendingNode.SourceContext.StartPos = offendingNode.SourceContext.EndPos;
 //     offendingNode.SourceContext.EndPos++;

      if(nn.IsNull(v))
      {
        HandleError(stat, offendingNode, Error.ReceiverCannotBeNull, this.ts.GetTypeName(v.Type));
        nn.AssignNonNull(v);
      }
      else if(!nn.IsNonNull(v))
      {
        HandleError(stat, offendingNode, Error.ReceiverMightBeNull, this.ts.GetTypeName(v.Type));
        nn.AssumeNonNull(v);
      }
    }