Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support to expressions in bellvue and fixing float32 support
- Loading branch information
Showing
11 changed files
with
224 additions
and
135 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
58 changes: 32 additions & 26 deletions
58
src/FluentIL/Emitters/FluentHelpers/DynamicMethodBody.Expression.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 |
---|---|---|
@@ -1,26 +1,32 @@ | ||
using System.Linq.Expressions; | ||
using FluentIL.ExpressionInterpreter; | ||
using FluentIL.ExpressionParser; | ||
|
||
// ReSharper disable CheckNamespace | ||
namespace FluentIL.Emitters | ||
// ReSharper restore CheckNamespace | ||
{ | ||
partial class DynamicMethodBody | ||
{ | ||
public DynamicMethodBody Parse(string expression) | ||
{ | ||
Parser.Parse(expression, this); | ||
return this; | ||
} | ||
|
||
public DynamicMethodBody Expression(Expression expression) | ||
{ | ||
expression = new ExpressionSimplifierVisitor().Visit(expression); | ||
new ILEmitterVisitor(this).Visit( | ||
expression | ||
); | ||
return this; | ||
} | ||
} | ||
} | ||
using System.Linq.Expressions; | ||
using FluentIL.ExpressionInterpreter; | ||
using FluentIL.ExpressionParser; | ||
|
||
// ReSharper disable CheckNamespace | ||
namespace FluentIL.Emitters | ||
// ReSharper restore CheckNamespace | ||
{ | ||
partial class DynamicMethodBody | ||
{ | ||
public DynamicMethodBody Parse(string expression) | ||
{ | ||
Parser.Parse(expression, this); | ||
return this; | ||
} | ||
|
||
public DynamicMethodBody Parse(string expression, out ParseResult result) | ||
{ | ||
result = Parser.Parse(expression, this); | ||
return this; | ||
} | ||
|
||
public DynamicMethodBody Expression(Expression expression) | ||
{ | ||
expression = new ExpressionSimplifierVisitor().Visit(expression); | ||
new ILEmitterVisitor(this).Visit( | ||
expression | ||
); | ||
return this; | ||
} | ||
} | ||
} |
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,93 +1,100 @@ | ||
using System; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
namespace FluentIL.Emitters | ||
{ | ||
public abstract class ILEmitter | ||
{ | ||
public void DeclareLocal(Type type) | ||
{ | ||
OnDeclareLocal(type); | ||
} | ||
|
||
protected abstract void OnDeclareLocal(Type type); | ||
|
||
public void MarkLabel(Label label) | ||
{ | ||
OnMarkLabel(label); | ||
} | ||
|
||
protected abstract void OnMarkLabel(Label label); | ||
|
||
public Label DefineLabel() | ||
{ | ||
return OnDefineLabel(); | ||
} | ||
|
||
protected abstract Label OnDefineLabel(); | ||
|
||
public void Emit(OpCode opcode) | ||
{ | ||
OnEmit(opcode); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode); | ||
|
||
public void Emit(OpCode opcode, string arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, string arg); | ||
|
||
public void Emit(OpCode opcode, int arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, int arg); | ||
|
||
public void Emit(OpCode opcode, double arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, double arg); | ||
|
||
public void Emit(OpCode opcode, Label arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, Label arg); | ||
|
||
public void Emit(OpCode opcode, MethodInfo arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, MethodInfo arg); | ||
|
||
public void Emit(OpCode opcode, ConstructorInfo arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, ConstructorInfo arg); | ||
|
||
public void Emit(OpCode opcode, FieldInfo arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, FieldInfo arg); | ||
|
||
public void Emit(OpCode opcode, Type arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, Type arg); | ||
} | ||
using System; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
namespace FluentIL.Emitters | ||
{ | ||
public abstract class ILEmitter | ||
{ | ||
public void DeclareLocal(Type type) | ||
{ | ||
OnDeclareLocal(type); | ||
} | ||
|
||
protected abstract void OnDeclareLocal(Type type); | ||
|
||
public void MarkLabel(Label label) | ||
{ | ||
OnMarkLabel(label); | ||
} | ||
|
||
protected abstract void OnMarkLabel(Label label); | ||
|
||
public Label DefineLabel() | ||
{ | ||
return OnDefineLabel(); | ||
} | ||
|
||
protected abstract Label OnDefineLabel(); | ||
|
||
public void Emit(OpCode opcode) | ||
{ | ||
OnEmit(opcode); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode); | ||
|
||
public void Emit(OpCode opcode, string arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, string arg); | ||
|
||
public void Emit(OpCode opcode, int arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, int arg); | ||
|
||
public void Emit(OpCode opcode, double arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, double arg); | ||
|
||
public void Emit(OpCode opcode, float arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, float arg); | ||
|
||
public void Emit(OpCode opcode, Label arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, Label arg); | ||
|
||
public void Emit(OpCode opcode, MethodInfo arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, MethodInfo arg); | ||
|
||
public void Emit(OpCode opcode, ConstructorInfo arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, ConstructorInfo arg); | ||
|
||
public void Emit(OpCode opcode, FieldInfo arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, FieldInfo arg); | ||
|
||
public void Emit(OpCode opcode, Type arg) | ||
{ | ||
OnEmit(opcode, arg); | ||
} | ||
|
||
protected abstract void OnEmit(OpCode opcode, Type arg); | ||
} | ||
} |
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,22 @@ | ||
using System; | ||
|
||
namespace FluentIL.ExpressionParser | ||
{ | ||
public class ParseResult | ||
{ | ||
public Type ExpressionType { get; internal set; } | ||
|
||
internal void AnalyzeType(Type type) | ||
{ | ||
var shouldUse = | ||
(ExpressionType == null) || | ||
(type == typeof(bool)) || | ||
(type == typeof(double) && ExpressionType == typeof(int)); | ||
|
||
if (shouldUse) | ||
{ | ||
ExpressionType = type; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.