示例#1
0
        public void TestAstSetGetLValue()
        {
            var AstIndex  = ast.Immediate(777);
            var AstSetGet = ast.SetGetLValue(
                ast.CallStatic((Action <int, int>)TestAstSetGetLValue_Set, AstIndex, ast.SetGetLValuePlaceholder <int>()),
                ast.CallStatic((Func <int, int>)TestAstSetGetLValue_Get, AstIndex)
                );

            Assert.AreEqual("GeneratorCSharpTest.TestAstSetGetLValue_Set(777, 11);", GeneratorCSharp.Reset().GenerateRoot(ast.Assign(AstSetGet, 11)).ToString());
            Assert.AreEqual("GeneratorCSharpTest.TestAstSetGetLValue_Set(777, 12);", GeneratorCSharp.Reset().GenerateRoot(ast.Assign(AstSetGet, 12)).ToString());
            Assert.AreEqual("GeneratorCSharpTest.TestAstSetGetLValue_Set(777, (GeneratorCSharpTest.TestAstSetGetLValue_Get(777) + 1));", GeneratorCSharp.Reset().GenerateRoot(ast.Assign(AstSetGet, AstSetGet + 1)).ToString());
        }
示例#2
0
 public void TestBenchmark()
 {
     var GeneratorCSharp = new GeneratorCSharp();
     var AstNode = ast.Ternary(ast.Unary("-", ast.Binary(ast.Binary(10, "+", 11), "*", 2)), 1, 2);
     for (int n = 0; n < 20000; n++)
     {
         GeneratorCSharp.Reset().GenerateRoot(AstNode);
     }
     Assert.AreEqual(GeneratorCSharp.ToString(), "((-((10 + 11) * 2)) ? 1 : 2)");
 }
示例#3
0
        public void TestBenchmark()
        {
            var generatorCSharp = new GeneratorCSharp();
            var astNode         = ast.Ternary(ast.Unary("-", ast.Binary(ast.Binary(10, "+", 11), "*", 2)), 1, 2);

            for (var n = 0; n < 20000; n++)
            {
                generatorCSharp.Reset().GenerateRoot(astNode);
            }
            Assert.Equal(generatorCSharp.ToString(), "((-((10 + 11) * 2)) ? 1 : 2)");
        }