-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Runtime: Add WASI Preview 1 proc_exit function
This function will normally call Environment.Exit(code), but an integration point was added to WasmRuntime in order to facilitate unit testing (or allow a user of the runtime to choose to do something else upon this call).
- Loading branch information
Showing
7 changed files
with
102 additions
and
14 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
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,6 @@ | ||
namespace WasmNet.Core.Wasi; | ||
|
||
public static partial class Preview1 | ||
{ | ||
public static void ProcExit(WasmRuntime runtime, int exitCode) => runtime.ExitHandler(exitCode); | ||
} |
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,20 @@ | ||
namespace WasmNet.Core.Wasi; | ||
|
||
public static partial class Preview1 | ||
{ | ||
public const string Namespace = "wasi_snapshot_preview1"; | ||
|
||
public static void RegisterWasiPreview1(this WasmRuntime runtime) | ||
{ | ||
var actionIntType = new WasmType | ||
{ | ||
Kind = WasmTypeKind.Function, | ||
Parameters = new List<WasmValueType> | ||
{ | ||
WasmNumberType.I32 | ||
} | ||
}; | ||
|
||
runtime.RegisterImportable(Namespace, "proc_exit", (int exitCode) => ProcExit(runtime, exitCode)); | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
WasmNet.Tests/IntegrationTests/0150-WasiPreview1ProcExit.wat
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,12 @@ | ||
;; invoke: proc-exit | ||
;; exit_code: 1 | ||
|
||
(module | ||
(type $t0 (func (param i32))) | ||
(import "wasi_snapshot_preview1" "proc_exit" (func $exit (type $t0))) | ||
(func (export "proc-exit") | ||
(call $exit (i32.const 1)) | ||
) | ||
(memory (;0;) 256 256) | ||
(export "memory" (memory 0)) | ||
) |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=importables/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=logmem/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=logmem/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Wasi/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |