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


C# IScope.Resolve方法代码示例

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


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

示例1: CheckEvt

        public void CheckEvt(IScope currScope, LSLAst id)
        {   
            EventSymbol evt = (EventSymbol)currScope.Resolve(id.Text + "()");

            Debug.Assert(evt != null);

            //try to find this event in our table
            if (!_supportedEvents.HasEventByName(id.Text))
            {
                _listener.Error("line " + id.Token.Line + ":" +
                    id.Token.CharPositionInLine + " No event evailable with name '" + id.Text + "'");

                return;
            }

            //also try to resolve the arguments
            List<VarType> passedEvtArgs = evt.ExtractArgumentTypes();
            if (!_supportedEvents.HasEventBySig(id.Text, VarType.Void, passedEvtArgs))
            {
                string paramList = this.FormatParamTypeList(_supportedEvents.GetArguments(id.Text));
                _listener.Error("line " + id.Token.Line + ":" +
                    id.Token.CharPositionInLine + " Incorrect parameters for event " + id.Text +
                    paramList);
            }
        }
开发者ID:emperorstarfinder,项目名称:phlox,代码行数:25,代码来源:SymbolTable.cs

示例2: EnsureResolve

        public Symbol EnsureResolve(LSLAst node, IScope scope, string symName)
        {
            Symbol sym = scope.Resolve(symName);

            if (sym == null)
            {
                _listener.Error("line " + node.Token.Line + ":" +
                    node.Token.CharPositionInLine + " Undefined symbol '" + symName + "'");

                return null;
            }

            //globals are always ok to ref, so skip the rest of the checks if this is a global
            if (sym.Scope == Globals)
            {
                return sym;
            }

            //consts are always ok to ref
            if (sym is ConstantSymbol)
            {
                return sym;
            }

            if (sym.Def == null)
            {
                _listener.Error(String.Format("INTERNAL COMPILER ERROR: Symbol definition not set: {0}", sym));
                return sym;
            }

            //if the symbol is local, it cant be used before it's defined
            if (sym.Def.TokenStartIndex > node.TokenStartIndex)
            {
                //if we are in a local scope, check if there is a version of this symbol in the function (parameter) scope
                //then check if there is a version of this symbol on the global scope
                Symbol methodSymbol = FindSymbolInMethodScope(sym, scope);
                Symbol globalSymbol = Globals.Resolve(symName);

                if (methodSymbol == null && globalSymbol == null)
                {
                    //there is no global by this name, it's only defined locally and it's defined after
                    //its use
                    _listener.Error("line " + node.Token.Line + ":" +
                        node.Token.CharPositionInLine + " Symbol '" + symName + "' can not be used before it is defined");
                }

                if (methodSymbol != null) sym = methodSymbol;
                else sym = globalSymbol;
            }
            //also if this symbol is local, it can not be defined in the root of the expression from which it is being used
            else if (IsChildNodeOf((LSLAst)sym.Def.GetAncestor(LSLParser.VAR_DECL), node))
            {
                //the symbol we found is a parent of the declaration and is therefore not valid for use
                //check parent scopes for a valid symbol
                Symbol methodSymbol = FindSymbolInMethodScope(sym, scope);
                Symbol globalSymbol = Globals.Resolve(symName);

                if (methodSymbol == null && globalSymbol == null)
                {
                    //there is no global by this name, it's only defined locally and it's defined after
                    //its use
                    _listener.Error("line " + node.Token.Line + ":" +
                        node.Token.CharPositionInLine + " Symbol '" + symName + "' can not be used before it is defined");
                }

                if (methodSymbol != null) sym = methodSymbol;
                else sym = globalSymbol;
            }

            return sym;
        }
开发者ID:emperorstarfinder,项目名称:phlox,代码行数:71,代码来源:SymbolTable.cs


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