|
|
|
@ -12,24 +12,22 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
@@ -12,24 +12,22 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
|
|
|
|
|
static void Main() |
|
|
|
|
{ |
|
|
|
|
Test(); |
|
|
|
|
var twice = GetExpression(Expression.Constant(2)).Compile(); |
|
|
|
|
Console.WriteLine(twice(21)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Expression<Func<int, int>> GetExpression(int i) |
|
|
|
|
{ |
|
|
|
|
return a => a + i; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Expression<Func<int, Func<int, int>>> GetExpression2() |
|
|
|
|
{ |
|
|
|
|
return a => b => a + b; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void Test() |
|
|
|
|
static void Test() |
|
|
|
|
{ |
|
|
|
|
int i = 0; |
|
|
|
|
Expression<Func<int>> expression = () => i; |
|
|
|
|
i = 1; |
|
|
|
|
Console.WriteLine(expression.Compile()()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static Expression<Func<int, int>> GetExpression(Expression factor) |
|
|
|
|
{ |
|
|
|
|
ParameterExpression parameterExpression = Expression.Parameter(typeof(int), "x"); |
|
|
|
|
return Expression.Lambda<Func<int, int>>(Expression.Multiply(parameterExpression, factor), parameterExpression); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|