示例#1
0
文件: SymbolTable.cs 项目: Ryuuke/Ryu
        /* position <= 0 means we don't really care about it */
        public IdentifierInfo LookupIdentifierInfo(string identifier, int scopeId,
                                                   int position, bool isConstant = false)
        {
            IdentifierInfo identifierInfo;
            ScopeInfo      scopeInfo;

            var identLocation = new IdentifierLocation {
                identifierName = identifier, scopeId = scopeId
            };

            while (!IdentInfoDictionary.TryGetValue(identLocation, out identifierInfo) ||
                   (isConstant == true && identifierInfo.isConstant != isConstant) ||
                   (!identifierInfo.isFunctionType && position > 0 && identifierInfo.position > position))
            {
                var scopeExists = ScopeInfoDictionary.
                                  TryGetValue(identLocation.scopeId, out scopeInfo);

                if (!scopeExists || scopeInfo.parent == null)
                {
                    return(null);
                }

                identLocation.scopeId = scopeInfo.parent.id;
            }

            return(identifierInfo);
        }
示例#2
0
文件: SymbolTable.cs 项目: Ryuuke/Ryu
        public IdentifierInfo LookupFunctionInfo(string identifier, int scopeId, List <TypeAST> argsType)
        {
            IdentifierInfo identifierInfo;
            ScopeInfo      scopeInfo;

            var identLocation = new IdentifierLocation {
                identifierName = identifier, scopeId = scopeId
            };

            while (!IdentInfoDictionary.TryGetValue(identLocation, out identifierInfo) ||
                   identifierInfo.isFunctionType == false || InvalidArgs(identifierInfo, argsType))
            {
                var scopeExists = ScopeInfoDictionary.
                                  TryGetValue(identLocation.scopeId, out scopeInfo);

                if (!scopeExists || scopeInfo.parent == null)
                {
                    return(null);
                }

                identLocation.scopeId = scopeInfo.parent.id;
            }

            return(identifierInfo);
        }