示例#1
0
        public Function Find(FunctionType type, bool isStatic)
        {
            MakeConcrete();
            FunctionGroupName gname   = new FunctionGroupName(type, isStatic);
            FunctionGroupName oldName = functions.Find(gname);

            if (oldName != null)
            {
                return(oldName.GetFunction());
            }
            return(null);
        }
示例#2
0
        private void AppendLevelContent(FunctionGroup level, bool isNamespaceLevel)
        {
            level.MakeConcrete();
            foreach (FunctionGroupName gname in level.functions)
            {
                // Check if the object belongs to the included namespace level
                bool isNamespace = gname.IsNamespaceLevel || isNamespaceLevel;

                // Read the name data.
                FunctionType type     = gname.GetFunctionType();
                bool         isStatic = gname.IsStatic();

                // Find a similar group.
                FunctionGroupName old = Find(gname);
                if (old == null)
                {
                    FunctionGroupName newName = new FunctionGroupName(type, isStatic);
                    newName.IsNamespaceLevel = isNamespace;
                    newName.SetFunction(gname.GetFunction());
                    functions.Add(newName);
                    continue;
                }

                // Ignore names of lower scopes.
                if (!isNamespace || !old.IsNamespaceLevel)
                {
                    continue;
                }

                // Now the old name is a namespace level, and we are adding another
                // namespace level function, in other words, we have detected an ambiguity.
                Function          oldFunction = old.GetFunction();
                FunctionAmbiguity amb;
                if (!oldFunction.IsAmbiguity())
                {
                    amb = new FunctionAmbiguity(oldFunction.GetName(), oldFunction.GetFlags(), oldFunction.GetParentScope());
                    amb.AddCandidate(oldFunction);
                    old.SetFunction(amb);
                }
                else
                {
                    amb = (FunctionAmbiguity)oldFunction;
                }

                // Add the new function into the ambiguity list.
                amb.AddCandidate(gname.GetFunction());
            }
        }