From dd417cbf9f8dc7e89c7182c7810045fedb71543f Mon Sep 17 00:00:00 2001 From: Phantom Date: Fri, 12 Aug 2022 15:04:42 +0400 Subject: [PATCH 01/11] Add FloatConstant --- .../Ir/Expressions/ConstantExpression.cs | 1 + .../Expressions/Constants/FloatConstant .cs | 27 +++++++++++++++++++ Cesium.CodeGen/Ir/Types/CTypeSystem.cs | 1 + 3 files changed, 29 insertions(+) create mode 100644 Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant .cs diff --git a/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs b/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs index 900c01ef..dbac644d 100644 --- a/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs +++ b/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs @@ -35,6 +35,7 @@ private static IConstant GetConstant(Ast.ConstantExpression expression) CTokenType.IntLiteral => new IntegerConstant(constant.Text), CTokenType.CharLiteral => new CharConstant(constant.Text), CTokenType.StringLiteral => new StringConstant(constant), + CTokenType.FloatLiteral => new FloatConstant(constant.Text), _ => throw new WipException(228, $"Constant of kind {constant.Kind} is not supported.") }; } diff --git a/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant .cs b/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant .cs new file mode 100644 index 00000000..52aede03 --- /dev/null +++ b/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant .cs @@ -0,0 +1,27 @@ +using Cesium.CodeGen.Contexts; +using Cesium.CodeGen.Ir.Types; +using Mono.Cecil; +using Mono.Cecil.Cil; +using System.Globalization; + +namespace Cesium.CodeGen.Ir.Expressions.Constants; + +internal class FloatConstant : IConstant +{ + private readonly float _value; + + public FloatConstant(string value) + { + if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out _value)) + throw new NotSupportedException($"Cannot parse an float literal: {value}."); + } + + public void EmitTo(IDeclarationScope scope) + { + scope.Method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldc_R4, _value)); + } + + public IType GetConstantType(IDeclarationScope scope) => scope.CTypeSystem.Float; + + public override string ToString() => $"float: {_value}"; +} diff --git a/Cesium.CodeGen/Ir/Types/CTypeSystem.cs b/Cesium.CodeGen/Ir/Types/CTypeSystem.cs index 3009988f..ba50e6b4 100644 --- a/Cesium.CodeGen/Ir/Types/CTypeSystem.cs +++ b/Cesium.CodeGen/Ir/Types/CTypeSystem.cs @@ -8,4 +8,5 @@ internal class CTypeSystem public IType Char { get; } = new PrimitiveType(PrimitiveTypeKind.Char); public IType Int { get; } = new PrimitiveType(PrimitiveTypeKind.Int); public IType CharPtr { get; } = new PrimitiveType(PrimitiveTypeKind.Char).MakePointerType(); + public IType Float { get; } = new PrimitiveType(PrimitiveTypeKind.Float); } From 8d42f6c47df654b46e6dfab61129b31fbbe1c02b Mon Sep 17 00:00:00 2001 From: Phantom Date: Fri, 12 Aug 2022 15:05:35 +0400 Subject: [PATCH 02/11] Add DoubleConstant and todo comment --- .../Expressions/Constants/DoubleConstant.cs | 27 +++++++++++++++++++ Cesium.CodeGen/Ir/Types/CTypeSystem.cs | 1 + 2 files changed, 28 insertions(+) create mode 100644 Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs diff --git a/Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs b/Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs new file mode 100644 index 00000000..76e64b52 --- /dev/null +++ b/Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs @@ -0,0 +1,27 @@ +using Cesium.CodeGen.Contexts; +using Cesium.CodeGen.Ir.Types; +using Mono.Cecil; +using Mono.Cecil.Cil; +using System.Globalization; + +namespace Cesium.CodeGen.Ir.Expressions.Constants; + +internal class DoubleConstant : IConstant +{ + private readonly double _value; + + public DoubleConstant(string value) + { + if (!double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out _value)) + throw new NotSupportedException($"Cannot parse an double literal: {value}."); + } + + public void EmitTo(IDeclarationScope scope) + { + scope.Method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldc_R8, _value)); + } + + public IType GetConstantType(IDeclarationScope scope) => scope.CTypeSystem.Double; + + public override string ToString() => $"double: {_value}"; +} diff --git a/Cesium.CodeGen/Ir/Types/CTypeSystem.cs b/Cesium.CodeGen/Ir/Types/CTypeSystem.cs index ba50e6b4..3f0ba272 100644 --- a/Cesium.CodeGen/Ir/Types/CTypeSystem.cs +++ b/Cesium.CodeGen/Ir/Types/CTypeSystem.cs @@ -9,4 +9,5 @@ internal class CTypeSystem public IType Int { get; } = new PrimitiveType(PrimitiveTypeKind.Int); public IType CharPtr { get; } = new PrimitiveType(PrimitiveTypeKind.Char).MakePointerType(); public IType Float { get; } = new PrimitiveType(PrimitiveTypeKind.Float); + public IType Double { get; } = new PrimitiveType(PrimitiveTypeKind.Double); } From f70bafdf95551f308e9523cd31fd5b1e04f091d7 Mon Sep 17 00:00:00 2001 From: Phantom Date: Fri, 12 Aug 2022 15:17:21 +0400 Subject: [PATCH 03/11] Add tests --- Cesium.CodeGen.Tests/CodeGenMethodTests.cs | 1 + .../CodeGenMethodTests.FloatConstTest.verified.txt | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 Cesium.CodeGen.Tests/verified/CodeGenMethodTests.FloatConstTest.verified.txt diff --git a/Cesium.CodeGen.Tests/CodeGenMethodTests.cs b/Cesium.CodeGen.Tests/CodeGenMethodTests.cs index 898a4927..d4cdc8e3 100644 --- a/Cesium.CodeGen.Tests/CodeGenMethodTests.cs +++ b/Cesium.CodeGen.Tests/CodeGenMethodTests.cs @@ -73,6 +73,7 @@ public void VarArgMainDoesNotCompile2() => DoesNotCompile( [Fact] public Task Parameter1Get() => DoTest("int foo(int x){ return x + 1; }"); [Fact] public Task Parameter5Get() => DoTest("int foo(int a, int b, int c, int d, int e){ return e + 1; }"); [Fact] public Task CharConstTest() => DoTest("int main() { char x = '\\t'; return 42; }"); + [Fact] public Task FloatConstTest() => DoTest("int main() { float x = 1.5; return 42; }"); [Fact] public Task MultiDeclaration() => DoTest("int main() { int x = 0, y = 2 + 2; }"); diff --git a/Cesium.CodeGen.Tests/verified/CodeGenMethodTests.FloatConstTest.verified.txt b/Cesium.CodeGen.Tests/verified/CodeGenMethodTests.FloatConstTest.verified.txt new file mode 100644 index 00000000..8b76afc2 --- /dev/null +++ b/Cesium.CodeGen.Tests/verified/CodeGenMethodTests.FloatConstTest.verified.txt @@ -0,0 +1,7 @@ +System.Int32 ::main() + Locals: + System.Single V_0 + IL_0000: ldc.r4 1,5 + IL_0005: stloc.0 + IL_0006: ldc.i4.s 42 + IL_0008: ret From 43e761f33a87d89cb7bf350077d147e8994379ba Mon Sep 17 00:00:00 2001 From: Phantom Date: Wed, 17 Aug 2022 01:07:31 +0400 Subject: [PATCH 04/11] fix space in filename --- .../Expressions/Constants/{FloatConstant .cs => FloatConstant.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Cesium.CodeGen/Ir/Expressions/Constants/{FloatConstant .cs => FloatConstant.cs} (100%) diff --git a/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant .cs b/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant.cs similarity index 100% rename from Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant .cs rename to Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant.cs From 0516cc7497e8dbd99451f9ec1651e62d98758f0d Mon Sep 17 00:00:00 2001 From: Phantom Date: Wed, 17 Aug 2022 01:08:02 +0400 Subject: [PATCH 05/11] Add UseInvariantCultureAttribute Add UseInvariantCultureAttribute to CodeGenTestBase --- Cesium.CodeGen.Tests/CodeGenTestBase.cs | 1 + .../UseInvariantCultureAttribute.cs | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Cesium.CodeGen.Tests/UseInvariantCultureAttribute.cs diff --git a/Cesium.CodeGen.Tests/CodeGenTestBase.cs b/Cesium.CodeGen.Tests/CodeGenTestBase.cs index 275c896c..d4530bf5 100644 --- a/Cesium.CodeGen.Tests/CodeGenTestBase.cs +++ b/Cesium.CodeGen.Tests/CodeGenTestBase.cs @@ -11,6 +11,7 @@ namespace Cesium.CodeGen.Tests; +[UseCulture("")] public abstract class CodeGenTestBase : VerifyTestBase { protected static AssemblyDefinition GenerateAssembly(TargetRuntimeDescriptor? runtime, params string[] sources) diff --git a/Cesium.CodeGen.Tests/UseInvariantCultureAttribute.cs b/Cesium.CodeGen.Tests/UseInvariantCultureAttribute.cs new file mode 100644 index 00000000..0537f29e --- /dev/null +++ b/Cesium.CodeGen.Tests/UseInvariantCultureAttribute.cs @@ -0,0 +1,35 @@ +using System; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Threading; +using Xunit.Sdk; + + +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] +public class UseInvariantCultureAttribute : BeforeAfterTestAttribute +{ + CultureInfo originalCulture = null!; + CultureInfo originalUICulture = null!; + + public override void Before(MethodInfo methodUnderTest) + { + originalCulture = Thread.CurrentThread.CurrentCulture; + originalUICulture = Thread.CurrentThread.CurrentUICulture; + + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; + + CultureInfo.CurrentCulture.ClearCachedData(); + CultureInfo.CurrentUICulture.ClearCachedData(); + } + + public override void After(MethodInfo methodUnderTest) + { + Thread.CurrentThread.CurrentCulture = originalCulture; + Thread.CurrentThread.CurrentUICulture = originalUICulture; + + CultureInfo.CurrentCulture.ClearCachedData(); + CultureInfo.CurrentUICulture.ClearCachedData(); + } +} From 70ca721a2e4fdefa4db2e163ccbb0d923ffccd76 Mon Sep 17 00:00:00 2001 From: Phantom Date: Wed, 17 Aug 2022 01:08:08 +0400 Subject: [PATCH 06/11] Add tests --- Cesium.CodeGen.Tests/CodeGenMethodTests.cs | 2 +- .../CodeGenMethodTests.DoubleConstTest.verified.txt | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 Cesium.CodeGen.Tests/verified/CodeGenMethodTests.DoubleConstTest.verified.txt diff --git a/Cesium.CodeGen.Tests/CodeGenMethodTests.cs b/Cesium.CodeGen.Tests/CodeGenMethodTests.cs index d4cdc8e3..b18db6d9 100644 --- a/Cesium.CodeGen.Tests/CodeGenMethodTests.cs +++ b/Cesium.CodeGen.Tests/CodeGenMethodTests.cs @@ -73,7 +73,7 @@ public void VarArgMainDoesNotCompile2() => DoesNotCompile( [Fact] public Task Parameter1Get() => DoTest("int foo(int x){ return x + 1; }"); [Fact] public Task Parameter5Get() => DoTest("int foo(int a, int b, int c, int d, int e){ return e + 1; }"); [Fact] public Task CharConstTest() => DoTest("int main() { char x = '\\t'; return 42; }"); - [Fact] public Task FloatConstTest() => DoTest("int main() { float x = 1.5; return 42; }"); + [Fact] public Task DoubleConstTest() => DoTest("int main() { double x = 1.5; return 42; }"); [Fact] public Task MultiDeclaration() => DoTest("int main() { int x = 0, y = 2 + 2; }"); diff --git a/Cesium.CodeGen.Tests/verified/CodeGenMethodTests.DoubleConstTest.verified.txt b/Cesium.CodeGen.Tests/verified/CodeGenMethodTests.DoubleConstTest.verified.txt new file mode 100644 index 00000000..0070435f --- /dev/null +++ b/Cesium.CodeGen.Tests/verified/CodeGenMethodTests.DoubleConstTest.verified.txt @@ -0,0 +1,7 @@ +System.Int32 ::main() + Locals: + System.Double V_0 + IL_0000: ldc.r8 1.5 + IL_0009: stloc.0 + IL_000a: ldc.i4.s 42 + IL_000c: ret From fa5155f118958c12ca9f63cc4f8b921d8b10bfdf Mon Sep 17 00:00:00 2001 From: Phantom Date: Wed, 17 Aug 2022 01:10:59 +0400 Subject: [PATCH 07/11] fix attribute name --- Cesium.CodeGen.Tests/CodeGenTestBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cesium.CodeGen.Tests/CodeGenTestBase.cs b/Cesium.CodeGen.Tests/CodeGenTestBase.cs index d4530bf5..c031ee9d 100644 --- a/Cesium.CodeGen.Tests/CodeGenTestBase.cs +++ b/Cesium.CodeGen.Tests/CodeGenTestBase.cs @@ -11,7 +11,7 @@ namespace Cesium.CodeGen.Tests; -[UseCulture("")] +[UseInvariantCulture] public abstract class CodeGenTestBase : VerifyTestBase { protected static AssemblyDefinition GenerateAssembly(TargetRuntimeDescriptor? runtime, params string[] sources) From a10caf4244ee127a5753d04045623aa761698297 Mon Sep 17 00:00:00 2001 From: Phantom Date: Wed, 17 Aug 2022 01:14:20 +0400 Subject: [PATCH 08/11] remove unused verified test file --- .../CodeGenMethodTests.FloatConstTest.verified.txt | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 Cesium.CodeGen.Tests/verified/CodeGenMethodTests.FloatConstTest.verified.txt diff --git a/Cesium.CodeGen.Tests/verified/CodeGenMethodTests.FloatConstTest.verified.txt b/Cesium.CodeGen.Tests/verified/CodeGenMethodTests.FloatConstTest.verified.txt deleted file mode 100644 index 8b76afc2..00000000 --- a/Cesium.CodeGen.Tests/verified/CodeGenMethodTests.FloatConstTest.verified.txt +++ /dev/null @@ -1,7 +0,0 @@ -System.Int32 ::main() - Locals: - System.Single V_0 - IL_0000: ldc.r4 1,5 - IL_0005: stloc.0 - IL_0006: ldc.i4.s 42 - IL_0008: ret From 864f290b904fa3cc0d9cd1d538fce16e5197ec99 Mon Sep 17 00:00:00 2001 From: Phantom Date: Wed, 17 Aug 2022 01:17:17 +0400 Subject: [PATCH 09/11] Change FloatConstant to DoubleConstant --- Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs b/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs index dbac644d..6184df4d 100644 --- a/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs +++ b/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs @@ -35,7 +35,7 @@ private static IConstant GetConstant(Ast.ConstantExpression expression) CTokenType.IntLiteral => new IntegerConstant(constant.Text), CTokenType.CharLiteral => new CharConstant(constant.Text), CTokenType.StringLiteral => new StringConstant(constant), - CTokenType.FloatLiteral => new FloatConstant(constant.Text), + CTokenType.FloatLiteral => new DoubleConstant(constant.Text), _ => throw new WipException(228, $"Constant of kind {constant.Kind} is not supported.") }; } From 24a492cbea5813d93bcbb71b0ca61467626a4d5f Mon Sep 17 00:00:00 2001 From: Friedrich von Never Date: Wed, 17 Aug 2022 18:57:46 +0200 Subject: [PATCH 10/11] (#187) Constants: fix grammar and use the right exception types --- Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs | 6 +++--- Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs b/Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs index 76e64b52..ad81f5d7 100644 --- a/Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs +++ b/Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs @@ -1,8 +1,8 @@ +using System.Globalization; using Cesium.CodeGen.Contexts; using Cesium.CodeGen.Ir.Types; -using Mono.Cecil; +using Cesium.Core; using Mono.Cecil.Cil; -using System.Globalization; namespace Cesium.CodeGen.Ir.Expressions.Constants; @@ -13,7 +13,7 @@ internal class DoubleConstant : IConstant public DoubleConstant(string value) { if (!double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out _value)) - throw new NotSupportedException($"Cannot parse an double literal: {value}."); + throw new CompilationException($"Cannot parse a double literal: {value}."); } public void EmitTo(IDeclarationScope scope) diff --git a/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant.cs b/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant.cs index 52aede03..26366efd 100644 --- a/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant.cs +++ b/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant.cs @@ -1,8 +1,8 @@ +using System.Globalization; using Cesium.CodeGen.Contexts; using Cesium.CodeGen.Ir.Types; -using Mono.Cecil; +using Cesium.Core; using Mono.Cecil.Cil; -using System.Globalization; namespace Cesium.CodeGen.Ir.Expressions.Constants; @@ -13,7 +13,7 @@ internal class FloatConstant : IConstant public FloatConstant(string value) { if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out _value)) - throw new NotSupportedException($"Cannot parse an float literal: {value}."); + throw new CompilationException($"Cannot parse a float literal: {value}."); } public void EmitTo(IDeclarationScope scope) From 8f22da755f43bd379f0ef665c7ffe9e5d0f98e72 Mon Sep 17 00:00:00 2001 From: Friedrich von Never Date: Wed, 17 Aug 2022 19:07:20 +0200 Subject: [PATCH 11/11] (#187) FloatingPointConstant: a new type, more architecturally correct --- .../Ir/Expressions/ConstantExpression.cs | 2 +- .../Ir/Expressions/Constants/FloatConstant.cs | 27 ------------------- ...leConstant.cs => FloatingPointConstant.cs} | 5 ++-- 3 files changed, 4 insertions(+), 30 deletions(-) delete mode 100644 Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant.cs rename Cesium.CodeGen/Ir/Expressions/Constants/{DoubleConstant.cs => FloatingPointConstant.cs} (82%) diff --git a/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs b/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs index 6184df4d..89cb6c3f 100644 --- a/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs +++ b/Cesium.CodeGen/Ir/Expressions/ConstantExpression.cs @@ -35,7 +35,7 @@ private static IConstant GetConstant(Ast.ConstantExpression expression) CTokenType.IntLiteral => new IntegerConstant(constant.Text), CTokenType.CharLiteral => new CharConstant(constant.Text), CTokenType.StringLiteral => new StringConstant(constant), - CTokenType.FloatLiteral => new DoubleConstant(constant.Text), + CTokenType.FloatLiteral => new FloatingPointConstant(constant.Text), _ => throw new WipException(228, $"Constant of kind {constant.Kind} is not supported.") }; } diff --git a/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant.cs b/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant.cs deleted file mode 100644 index 26366efd..00000000 --- a/Cesium.CodeGen/Ir/Expressions/Constants/FloatConstant.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Globalization; -using Cesium.CodeGen.Contexts; -using Cesium.CodeGen.Ir.Types; -using Cesium.Core; -using Mono.Cecil.Cil; - -namespace Cesium.CodeGen.Ir.Expressions.Constants; - -internal class FloatConstant : IConstant -{ - private readonly float _value; - - public FloatConstant(string value) - { - if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out _value)) - throw new CompilationException($"Cannot parse a float literal: {value}."); - } - - public void EmitTo(IDeclarationScope scope) - { - scope.Method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldc_R4, _value)); - } - - public IType GetConstantType(IDeclarationScope scope) => scope.CTypeSystem.Float; - - public override string ToString() => $"float: {_value}"; -} diff --git a/Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs b/Cesium.CodeGen/Ir/Expressions/Constants/FloatingPointConstant.cs similarity index 82% rename from Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs rename to Cesium.CodeGen/Ir/Expressions/Constants/FloatingPointConstant.cs index ad81f5d7..fa36e841 100644 --- a/Cesium.CodeGen/Ir/Expressions/Constants/DoubleConstant.cs +++ b/Cesium.CodeGen/Ir/Expressions/Constants/FloatingPointConstant.cs @@ -6,11 +6,11 @@ namespace Cesium.CodeGen.Ir.Expressions.Constants; -internal class DoubleConstant : IConstant +internal class FloatingPointConstant : IConstant { private readonly double _value; - public DoubleConstant(string value) + public FloatingPointConstant(string value) { if (!double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out _value)) throw new CompilationException($"Cannot parse a double literal: {value}."); @@ -18,6 +18,7 @@ public DoubleConstant(string value) public void EmitTo(IDeclarationScope scope) { + // TODO[#248]: This should support `float` as well. scope.Method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldc_R8, _value)); }