-
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.
Merge pull request #39 from Earthmark/wasm_marshaller
Swapped from frame push and pop to marshallers.
- Loading branch information
Showing
9 changed files
with
169 additions
and
156 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
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,30 @@ | ||
using Derg.Runtime; | ||
using Dergwasm.Runtime; | ||
using Elements.Core; | ||
using System.Collections.Generic; | ||
|
||
namespace Derg.Modules { | ||
public interface IWasmMarshaller<T> { | ||
// Get the type information for a parameter, Name will be filled out later. | ||
void AddParams(string name, List<Parameter> parameters); | ||
void To(Frame frame, Machine machine, T value); | ||
T From(Frame frame, Machine machine); | ||
} | ||
|
||
public struct DirectMarshaller<T> : IWasmMarshaller<T> | ||
{ | ||
public void AddParams(string name, List<Parameter> parameters) | ||
{ | ||
parameters.Add(new Parameter | ||
{ | ||
Name = name, | ||
Types = ModuleReflector.ValueTypesFor(typeof(T)), | ||
CSType = typeof(T).GetNiceName() | ||
}); | ||
} | ||
|
||
public T From(Frame frame, Machine machine) => frame.Pop().As<T>(); | ||
|
||
public void To(Frame frame, Machine machine, T value) => frame.Push(Value.From(value)); | ||
} | ||
} |
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
Oops, something went wrong.