当前位置: 首页>>代码示例>>C#>>正文


C# Scope.FindIdentifier方法代码示例

本文整理汇总了C#中Scope.FindIdentifier方法的典型用法代码示例。如果您正苦于以下问题:C# Scope.FindIdentifier方法的具体用法?C# Scope.FindIdentifier怎么用?C# Scope.FindIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scope的用法示例。


在下文中一共展示了Scope.FindIdentifier方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UndefinedIdentifiersHaveIsDefinedSetToFalse

            public void UndefinedIdentifiersHaveIsDefinedSetToFalse()
            {
                var scope = new Scope();

                var actual = scope.FindIdentifier("TEST");

                Assert.IsFalse(actual.IsDefined);
            }
开发者ID:PeterBassett,项目名称:Parser,代码行数:8,代码来源:ScopeTest.cs

示例2: DefinedIdentifiersAreAbleToBeFound

            public void DefinedIdentifiersAreAbleToBeFound()
            {
                var scope = new Scope();

                scope.DefineIdentifier("TEST", new Value(1));

                var actual = scope.FindIdentifier("TEST");

                Assert.AreEqual(true, actual.IsDefined);
            }
开发者ID:PeterBassett,项目名称:Parser,代码行数:10,代码来源:ScopeTest.cs

示例3: NestedScopesCanStillFindLocallyDefinedIdentifier

            public void NestedScopesCanStillFindLocallyDefinedIdentifier()
            {
                var scope = new Scope();
                var identifier = "A";

                scope.DefineIdentifier(identifier, new Value(1));

                using (scope.PushScope())
                {
                    scope.DefineIdentifier(identifier, new Value(2));

                    var actual = scope.FindIdentifier(identifier);

                    Assert.AreEqual(true, actual.IsDefined);
                }
            }
开发者ID:PeterBassett,项目名称:Parser,代码行数:16,代码来源:ScopeTest.cs

示例4: PopScopeDefinesANewMoreDeeplyNestedScope

            public void PopScopeDefinesANewMoreDeeplyNestedScope()
            {
                var scope = new Scope();
                var identifier = "A";
                var expected = 1234;

                scope.DefineIdentifier(identifier, new Value(expected));

                scope.PushScope();

                scope.DefineIdentifier(identifier, new Value(1));

                scope.PopScope();

                var actual = scope.FindIdentifier(identifier);

                Assert.AreEqual(expected, actual.Value.ToObject());
            }
开发者ID:PeterBassett,项目名称:Parser,代码行数:18,代码来源:ScopeTest.cs

示例5: PushScopeReturnsAnIDisposableWhichPopsScopeAutomatically

            public void PushScopeReturnsAnIDisposableWhichPopsScopeAutomatically()
            {
                var scope = new Scope();
                var identifier = "A";
                var expected = 1234;

                scope.DefineIdentifier(identifier, new Value(expected));

                using (scope.PushScope())
                {
                    scope.DefineIdentifier(identifier, new Value(1));
                }

                var actual = scope.FindIdentifier(identifier);

                Assert.AreEqual(expected, actual.Value.ToObject());
            }
开发者ID:PeterBassett,项目名称:Parser,代码行数:17,代码来源:ScopeTest.cs

示例6: PushArgumentsRemovesTheIdentifiersWithAnIDisposable

            public void PushArgumentsRemovesTheIdentifiersWithAnIDisposable()
            {
                var scope = new Scope();

                var arguments = new[]
                {
                    new VarDefinitionStmt(new IdentifierExpr("A"), new IdentifierExpr("int"), false, new ConstantExpr(1)),
                    new VarDefinitionStmt(new IdentifierExpr("B"), new IdentifierExpr("string"), false, new ConstantExpr("hello")),
                    new VarDefinitionStmt(new IdentifierExpr("C"), new IdentifierExpr("bool"), false, new ConstantExpr(true))
                };

                var values = new Value[]
                {
                    new Value(2),
                    new Value("world"),
                    new Value(false)
                };

                using (scope.PushArguments(arguments, values))
                {
                    foreach (var argument in arguments)
                    {
                        var actual = scope.FindIdentifier(argument.Name.Name);

                        Assert.AreEqual(true, actual.IsDefined);
                    }
                }

                // arguments are no longer available in parent scope.
                foreach (var argument in arguments)
                {
                    var actual = scope.FindIdentifier(argument.Name.Name);

                    Assert.AreEqual(false, actual.IsDefined);
                }
            }
开发者ID:PeterBassett,项目名称:Parser,代码行数:36,代码来源:ScopeTest.cs

示例7: PushArgumentsIsAShortWayToAddIdentifiersIntoANewScopeQuickly

            public void PushArgumentsIsAShortWayToAddIdentifiersIntoANewScopeQuickly()
            {
                var scope = new Scope();

                // colliding identifier in parent scpoe
                scope.DefineIdentifier("A", new Value(1345645));

                var arguments = new[]
                {
                    new VarDefinitionStmt(new IdentifierExpr("A"), new IdentifierExpr("int"), false, new ConstantExpr(1)),
                    new VarDefinitionStmt(new IdentifierExpr("B"), new IdentifierExpr("string"), false, new ConstantExpr("hello")),
                    new VarDefinitionStmt(new IdentifierExpr("C"), new IdentifierExpr("bool"), false, new ConstantExpr(true))
                };

                var values = new Value[]
                {
                    new Value(2),
                    new Value("world"),
                    new Value(false)
                };

                using (scope.PushArguments(arguments, values))
                {
                    for (var i = 0; i < arguments.Length; i++)
                    {
                        var argument = arguments[i];
                        var value = values[i];

                        var actual = scope.FindIdentifier(argument.Name.Name);

                        Assert.AreEqual(true, actual.IsDefined);
                        Assert.AreEqual(value.ToObject(), actual.Value.ToObject());
                    }
                }
            }
开发者ID:PeterBassett,项目名称:Parser,代码行数:35,代码来源:ScopeTest.cs

示例8: NestedScopesReturnsIdentifierFromAncestorIfNotFoundLocally

            public void NestedScopesReturnsIdentifierFromAncestorIfNotFoundLocally()
            {
                var scope = new Scope();
                var identifier = "A";
                var expected = 2;

                scope.DefineIdentifier(identifier, new Value(expected));

                using (scope.PushScope())
                {
                    scope.DefineIdentifier("B", new Value(3));
                    using (scope.PushScope())
                    {
                        scope.DefineIdentifier("C", new Value(4));
                        using (scope.PushScope())
                        {
                            scope.DefineIdentifier("D", new Value(5));
                            using (scope.PushScope())
                            {
                                scope.DefineIdentifier("E", new Value(6));
                                {
                                    scope.DefineIdentifier("F", new Value(7));

                                    var actual = scope.FindIdentifier(identifier);

                                    Assert.AreEqual(expected, actual.Value.ToObject());
                                }
                            }
                        }
                    }
                }
            }
开发者ID:PeterBassett,项目名称:Parser,代码行数:32,代码来源:ScopeTest.cs

示例9: NestedScopesReturnsTheMostDeeplyDefinedInstanceOfAnIdentifier

            public void NestedScopesReturnsTheMostDeeplyDefinedInstanceOfAnIdentifier()
            {
                var scope = new Scope();
                var identifier = "A";
                var expected = 2;

                scope.DefineIdentifier(identifier, new Value(1));

                using (scope.PushScope())
                {
                    scope.DefineIdentifier(identifier, new Value(expected));

                    var actual = scope.FindIdentifier(identifier);

                    Assert.AreEqual(expected, actual.Value.ToObject());
                }
            }
开发者ID:PeterBassett,项目名称:Parser,代码行数:17,代码来源:ScopeTest.cs


注:本文中的Scope.FindIdentifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。