-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adjusted general philosophy for handling nulls, there are many cases where properties of an object are pulled from an LLVM IR operand. That technically is nullable, however in the context of that type and property it should never be null. In such cases the '!' operator is applied. Thus any such, totally unexpected cases can still trigger a fatal null ref exception but the code is simpler and more efficient by not always checking for null when it isn't ever supposed to be null. (The only way it can be is bug in the LLVM internals or a bug in the .NET bindings in this library) * Reversed course on Debug metadata types nullability and null object pattern. Fundamentally LLVM itself is designed where DIScope, DIFile and DIType are allowed null in most cases (and in fact null for each has a meaning. [i.e. DIType == null => void]) Fighting against that complicates the code base and makes using the API harder. The biggest problem is in mapping a handle back to a concrete type. Since handles are equivalent to a pointer to the base type it's impossible to determine what the derived type is supposed to be when the pointer is null. There are a lot of places in the code (especially operands) that deal in collections of the base type and there's no way to determine which "null object" is supposed to be used. Thus it is simpler and cleaner to accept the design of the underlying LLVM library and formally declare these as nullable, so that analysis tooling can warn consumers appropriately. There are cases where a null is not appropriate (like creating an array, where void makes no sense as the element type) * Significant re-work of the operand handling. The previous approach of using an operand container interface was just plain confusing and hard to follow. (Multiple indexers in play depending on explicit interface vs not etc... made it hard to read and follow - the new approach uses more specific classes that implement a common interface and that supports slicing via the new C#8 ranges so creating slices for properties is much simpler.
- Loading branch information
Showing
67 changed files
with
794 additions
and
691 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
BuildMinor = "0" | ||
BuildPatch = "0" | ||
PreReleaseName = "alpha" | ||
PreReleaseNumber ="2" | ||
PreReleaseNumber ="3" | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/Interop/Ubiquity.NET.Llvm.Interop/UnexpectedNullHandleException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="UnexpectedNullInteropHandle.cs" company="Ubiquity.NET Contributors"> | ||
// Copyright (c) Ubiquity.NET Contributors. All rights reserved. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Ubiquity.NET.Llvm.Interop | ||
{ | ||
/// <summary>Exception thrown when an underlying LLVM handle is unexpectedly null</summary> | ||
/// <remarks> | ||
/// This is generally a non-recoverable error state where the underlying LLVM library is | ||
/// in an inconsistent or unexpected state. | ||
/// </remarks> | ||
public sealed class UnexpectedNullHandleException | ||
: InvalidOperationException | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="UnexpectedNullHandleException"/> class.</summary> | ||
/// <param name="message">Exception error message</param> | ||
public UnexpectedNullHandleException( string message ) | ||
: base( message ) | ||
{ | ||
} | ||
|
||
/// <summary>Initializes a new instance of the <see cref="UnexpectedNullHandleException"/> class.</summary> | ||
/// <param name="message">Exception error message</param> | ||
/// <param name="innerException">Inner Exception</param> | ||
public UnexpectedNullHandleException( string message, Exception innerException ) | ||
: base( message, innerException ) | ||
{ | ||
} | ||
|
||
/// <summary>Initializes a new instance of the <see cref="UnexpectedNullHandleException"/> class.</summary> | ||
public UnexpectedNullHandleException( ) | ||
{ | ||
} | ||
|
||
/// <summary>Initializes a new instance of the <see cref="UnexpectedNullHandleException"/> class.</summary> | ||
/// <param name="info">Serialization information</param> | ||
/// <param name="context">Context for serialization</param> | ||
public UnexpectedNullHandleException( SerializationInfo info, StreamingContext context ) | ||
: base( info, context ) | ||
{ | ||
} | ||
} | ||
} |
Oops, something went wrong.