//public UnresolvedInterfaceAnnotation( // CCCheckExtraInfo extra_info, // Squiggle squiggle, // ClousotSuggestion.Kind kind) // : base(null, null, extra_info.SuggestedCode, squiggle, kind) //{ // // TODO there are ways this can fail to create a valid annotation // // there is a lot of string parsing going on that could go wrong // // could be refactored into a TryXXXX? // //this.extraInfo = extra_info; // this.InterfaceMethod = extra_info.CalleeDocumentId; // this.InterfaceName = extra_info.TypeDocumentId; // if (InterfaceName.Contains('<')) // { // var lastAngle = InterfaceName.LastIndexOf('<'); // var beforeAngle = InterfaceName.Remove(lastAngle); // var afterAngle = InterfaceName.Replace(beforeAngle, ""); // InterfaceName = beforeAngle; // var parts = afterAngle.Trim('<', '>').Split(','); // NumberParameters = parts.Count(); // ParametersString = "<" + parts[0].Replace("type parameter.", ""); // for (int i = 1; i < parts.Length; i++) // { // ParametersString += ',' + parts[i].Replace("type parameter.", ""); // } // ParametersString += ">"; // } // this.InterfaceShortName = InterfaceAnnotationHelpers.GetUnqualifiedName(InterfaceName); //} public UnresolvedInterfaceAnnotation(string annotation, Squiggle squiggle, ClousotSuggestion.Kind kind, string parameterstring, string interfacename, string interfacemethod) : base(null, null, annotation, squiggle, kind) { this.ParametersString = parameterstring; this.InterfaceName = interfacename; this.InterfaceMethod = interfacemethod; this.InterfaceShortName = InterfaceAnnotationHelpers.GetUnqualifiedName(interfacename); }
private void InitializeLine() { squiggle = Prefabs.Instantiate <Squiggle>(); line = Prefabs.Instantiate <LineVisualizer>(); line.Initialize(HasAnimated); line.transform.parent = transform; line.SetGradient(config.ActiveConnectionGradient); }
public Precondition(string filename, string methodname, string annotation, Squiggle squiggle, ClousotSuggestion.Kind kind) : base(filename, methodname, annotation, squiggle, kind) { Contract.Requires(filename != null); Contract.Requires(methodname != null); Contract.Requires(squiggle != null); Contract.Requires((kind == ClousotSuggestion.Kind.Requires) || (kind == ClousotSuggestion.Kind.Ensures) || (kind == ClousotSuggestion.Kind.AssumeOnEntry) || (kind == ClousotSuggestion.Kind.AssumeOnCallee) ); }
public UnresolvedObjectInvariant(string filename, string methodname, string typename, string annotation, Squiggle squiggle, ClousotSuggestion.Kind kind) : base(filename, methodname, annotation, squiggle, kind) { #region CodeContracts Contract.Requires(methodname != null); Contract.Requires(annotation != null); Contract.Requires(typename != null); Contract.Requires(kind == ClousotSuggestion.Kind.ObjectInvariant); Contract.Ensures(typename == this.TypeName); #endregion CodeContracts this.TypeName = typename; }
public ResolvedInterfaceAnnotation(string filename, string methodname, string annotation, Squiggle squiggle, ClousotSuggestion.Kind kind, UnresolvedInterfaceAnnotation originalAnnotation) : base(filename, methodname, annotation, squiggle, kind) { #region CodeContracts Contract.Requires(methodname != null); Contract.Requires(filename != null); Contract.Requires(kind == ClousotSuggestion.Kind.EnsuresNecessary); #endregion CodeContracts this.OriginalAnnotation = originalAnnotation; }
public BaseAnnotation(string filename, string methodName, string annotation, Squiggle squiggle, ClousotSuggestion.Kind kind) { #region CodeContracts Contract.Requires(annotation != null, "We need an annotation!!!"); Contract.Ensures(this.FileName == filename); Contract.Ensures(this.Annotation == annotation + Constants.String.Signature); Contract.Ensures(this.MethodName == methodName); Contract.Ensures(this.Squiggle == squiggle); Contract.Ensures(this.Kind == kind); #endregion CodeContracts this.Squiggle = squiggle; this.FileName = filename; this.MethodName = methodName; this.Annotation = annotation + Constants.String.Signature; this.Kind = kind; this.statement_syntax = SyntaxFactory.ParseStatement(Annotation); }
internal static bool TryMakeUnresolvedInterfaceAnnotation(CCCheckExtraInfo extrainfo, Squiggle squiggle, ClousotSuggestion.Kind kind, out UnresolvedInterfaceAnnotation annotation) { #region CodeContracts Contract.Requires(extrainfo != null); Contract.Requires(extrainfo.CalleeDocumentId != null); Contract.Requires(extrainfo.TypeDocumentId != null); Contract.Requires(extrainfo.SuggestedCode != null); Contract.Requires(squiggle != null); Contract.Requires(kind == ClousotSuggestion.Kind.EnsuresNecessary); Contract.Ensures(!Contract.Result <bool>() || Contract.ValueAtReturn <UnresolvedInterfaceAnnotation>(out annotation) != null); #endregion CodeContracts annotation = null; var InterfaceMethod = extrainfo.CalleeDocumentId; var InterfaceName = extrainfo.TypeDocumentId; var ParametersString = ""; if (InterfaceName.Contains('<')) { var lastAngle = InterfaceName.LastIndexOf('<'); var beforeAngle = InterfaceName.Remove(lastAngle); var afterAngle = InterfaceName.Replace(beforeAngle, ""); if (string.IsNullOrEmpty(afterAngle)) { RBLogger.Error("Failed to parse interface name {0}", InterfaceName); return(false); } InterfaceName = beforeAngle; var parts = afterAngle.Trim('<', '>').Split(','); ParametersString = "<" + parts[0].Replace("type parameter.", ""); for (int i = 1; i < parts.Length; i++) { ParametersString += ',' + parts[i].Replace("type parameter.", ""); } ParametersString += ">"; } annotation = new UnresolvedInterfaceAnnotation(extrainfo.SuggestedCode, squiggle, kind, ParametersString, InterfaceName, InterfaceMethod); return(true); }
public static bool TryMakeAnnotation(CCCheckOutputAssemblyMethod method, CCCheckOutputAssemblyMethodSuggestion suggestion, ClousotSuggestion.Kind suggestionKind, string path, Squiggle squiggle, out BaseAnnotation annotation, out string whyFailed) { #region CodeContracts Contract.Ensures(!Contract.Result <bool>() || Contract.ValueAtReturn(out annotation) != null); Contract.Ensures(Contract.Result <bool>() || Contract.ValueAtReturn(out whyFailed) != null); #endregion CodeContracts whyFailed = null; annotation = null; switch (suggestionKind) { case ClousotSuggestion.Kind.AssumeOnEntry: case ClousotSuggestion.Kind.Ensures: case ClousotSuggestion.Kind.Requires: { annotation = new Precondition(path, method.Name, suggestion.Suggested, squiggle, suggestionKind); return(true); } case ClousotSuggestion.Kind.ObjectInvariant: { Contract.Assert(suggestion.SuggestionExtraInfo != null, "We expect to have extra info for the suggestion of an object invariant"); var exinfo2 = suggestion.SuggestionExtraInfo[0]; annotation = new UnresolvedObjectInvariant(path, method.Name, exinfo2.TypeDocumentId, exinfo2.SuggestedCode, squiggle, suggestionKind); return(true); } case ClousotSuggestion.Kind.EnsuresNecessary: { Contract.Assert(suggestion.SuggestionExtraInfo != null, "We expect to have extra info for the suggestion of an ensures necessary"); if (suggestion.SuggestionExtraInfo.First().CalleeMemberKind == "Interface") { var exinfo = suggestion.SuggestionExtraInfo[0]; if (exinfo.CalleeIsDeclaredInTheSameAssembly.Equals("False")) { whyFailed = "Don't know what to do when callee is in another assembly"; return(false); } //annotation = new UnresolvedInterfaceAnnotation(exinfo, squiggle, suggestionKind); UnresolvedInterfaceAnnotation ann; if (InterfaceAnnotationHelpers.TryMakeUnresolvedInterfaceAnnotation(exinfo, squiggle, suggestionKind, out ann)) { annotation = ann; return(true); } whyFailed = "Unknown suggestion"; return(false); } whyFailed = string.Format("Unhandled clousot suggestion kind {0} {1}", suggestionKind, suggestion.SuggestionExtraInfo.First().CalleeMemberKind); return(false); } case ClousotSuggestion.Kind.ReadonlyField: { Contract.Assert(suggestion.SuggestionExtraInfo != null, "We expect to have extra info for the suggestion of a readonly field"); var extraInfo = suggestion.SuggestionExtraInfo[0]; annotation = new ReadonlyField(extraInfo.CalleeDocumentId, path, extraInfo.TypeDocumentId, method.Name, squiggle, ClousotSuggestion.Kind.ReadonlyField); return(true); } default: { whyFailed = string.Format("Unhandled clousot suggestion kind {0}", suggestionKind); return(false); } } }
public ReadonlyField(string fieldname, string filename, string typename, string methodname, Squiggle squiggle, ClousotSuggestion.Kind kind) : base(filename, methodname, String.Empty, squiggle, kind) { Contract.Requires(typename != null); Contract.Requires(fieldname != null); Contract.Requires(methodname != null); this.TypeName = typename; this.FieldName = fieldname; }
internal static bool TryMakeUnresolvedInterfaceAnnotation(CCCheckExtraInfo extrainfo, Squiggle squiggle, ClousotSuggestion.Kind kind, out UnresolvedInterfaceAnnotation annotation) { #region CodeContracts Contract.Requires(extrainfo != null); Contract.Requires(extrainfo.CalleeDocumentId != null); Contract.Requires(extrainfo.TypeDocumentId != null); Contract.Requires(extrainfo.SuggestedCode != null); Contract.Requires(squiggle != null); Contract.Requires(kind == ClousotSuggestion.Kind.EnsuresNecessary); Contract.Ensures(!Contract.Result<bool>() || Contract.ValueAtReturn<UnresolvedInterfaceAnnotation>(out annotation) != null); #endregion CodeContracts annotation = null; var InterfaceMethod = extrainfo.CalleeDocumentId; var InterfaceName = extrainfo.TypeDocumentId; var ParametersString = ""; if (InterfaceName.Contains('<')) { var lastAngle = InterfaceName.LastIndexOf('<'); var beforeAngle = InterfaceName.Remove(lastAngle); var afterAngle = InterfaceName.Replace(beforeAngle, ""); if (string.IsNullOrEmpty(afterAngle)) { RBLogger.Error("Failed to parse interface name {0}", InterfaceName); return false; } InterfaceName = beforeAngle; var parts = afterAngle.Trim('<', '>').Split(','); ParametersString = "<" + parts[0].Replace("type parameter.", ""); for (int i = 1; i < parts.Length; i++) { ParametersString += ',' + parts[i].Replace("type parameter.", ""); } ParametersString += ">"; } annotation = new UnresolvedInterfaceAnnotation(extrainfo.SuggestedCode, squiggle, kind, ParametersString, InterfaceName, InterfaceMethod); return true; }
public static bool TryMakeAnnotation(CCCheckOutputAssemblyMethod method, CCCheckOutputAssemblyMethodSuggestion suggestion, ClousotSuggestion.Kind suggestionKind, string path, Squiggle squiggle, out BaseAnnotation annotation, out string whyFailed) { #region CodeContracts Contract.Ensures(!Contract.Result<bool>() || Contract.ValueAtReturn(out annotation) != null); Contract.Ensures(Contract.Result<bool>() || Contract.ValueAtReturn(out whyFailed) != null); #endregion CodeContracts whyFailed = null; annotation = null; switch (suggestionKind) { case ClousotSuggestion.Kind.AssumeOnEntry: case ClousotSuggestion.Kind.Ensures: case ClousotSuggestion.Kind.Requires: { annotation = new Precondition(path, method.Name, suggestion.Suggested, squiggle, suggestionKind); return true; } case ClousotSuggestion.Kind.ObjectInvariant: { Contract.Assert(suggestion.SuggestionExtraInfo != null, "We expect to have extra info for the suggestion of an object invariant"); var exinfo2 = suggestion.SuggestionExtraInfo[0]; annotation = new UnresolvedObjectInvariant(path, method.Name, exinfo2.TypeDocumentId, exinfo2.SuggestedCode, squiggle, suggestionKind); return true; } case ClousotSuggestion.Kind.EnsuresNecessary: { Contract.Assert(suggestion.SuggestionExtraInfo != null, "We expect to have extra info for the suggestion of an ensures necessary"); if (suggestion.SuggestionExtraInfo.First().CalleeMemberKind == "Interface") { var exinfo = suggestion.SuggestionExtraInfo[0]; if (exinfo.CalleeIsDeclaredInTheSameAssembly.Equals("False")) { whyFailed = "Don't know what to do when callee is in another assembly"; return false; } //annotation = new UnresolvedInterfaceAnnotation(exinfo, squiggle, suggestionKind); UnresolvedInterfaceAnnotation ann; if (InterfaceAnnotationHelpers.TryMakeUnresolvedInterfaceAnnotation(exinfo, squiggle, suggestionKind, out ann)) { annotation = ann; return true; } whyFailed = "Unknown suggestion"; return false; } whyFailed = string.Format("Unhandled clousot suggestion kind {0} {1}", suggestionKind, suggestion.SuggestionExtraInfo.First().CalleeMemberKind); return false; } case ClousotSuggestion.Kind.ReadonlyField: { Contract.Assert(suggestion.SuggestionExtraInfo != null, "We expect to have extra info for the suggestion of a readonly field"); var extraInfo = suggestion.SuggestionExtraInfo[0]; annotation = new ReadonlyField(extraInfo.CalleeDocumentId, path, extraInfo.TypeDocumentId, method.Name, squiggle, ClousotSuggestion.Kind.ReadonlyField); return true; } default: { whyFailed = string.Format("Unhandled clousot suggestion kind {0}", suggestionKind); return false; } } }