Move Wasmtime for .NET to the Wasmtime repo.

This moves the Wasmtime for .NET implementation to the Wasmtime repo.

Wasmtime for .NET is a binding of the Wasmtime API for use in .NET.
This commit is contained in:
Peter Huene
2019-11-22 17:11:00 -08:00
parent bbe2a797ba
commit 9fdf5bce8e
100 changed files with 6391 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace Wasmtime
{
/// <summary>
/// The exception for WebAssembly traps.
/// </summary>
[Serializable]
public class TrapException : WasmtimeException
{
/// <inheritdoc/>
public TrapException() { }
/// <inheritdoc/>
public TrapException(string message) : base(message) { }
/// <inheritdoc/>
public TrapException(string message, Exception inner) : base(message, inner) { }
/// <inheritdoc/>
protected TrapException(SerializationInfo info, StreamingContext context) : base(info, context) { }
internal static TrapException FromOwnedTrap(IntPtr trap)
{
unsafe
{
Interop.wasm_trap_message(trap, out var bytes);
var message = Marshal.PtrToStringUTF8((IntPtr)bytes.data, (int)bytes.size - 1 /* remove null */);
Interop.wasm_byte_vec_delete(ref bytes);
Interop.wasm_trap_delete(trap);
return new TrapException(message);
}
}
// TODO: expose trap frames
}
}