Ejemplo n.º 1
0
 public void AddMacro(CodeMemberDeclaration macroDecl)
 {
     if (_specialImplMacroMembers == null)
     {
         _specialImplMacroMembers = new List <CodeMemberDeclaration>();
     }
     _specialImplMacroMembers.Add(macroDecl);
 }
Ejemplo n.º 2
0
        public IEnumerable <CodeFieldDeclaration> GetFieldIter()
        {
            int j = _members.Count;

            for (int i = 0; i < j; ++i)
            {
                CodeMemberDeclaration mb = _members[i];
                switch (mb.MemberKind)
                {
                case CodeMemberKind.Field:
                    yield return((CodeFieldDeclaration)mb);

                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public IEnumerable <CodeMemberDeclaration> GetSubTypeIter()
        {
            int j = _members.Count;

            for (int i = 0; i < j; ++i)
            {
                CodeMemberDeclaration mb = _members[i];
                switch (mb.MemberKind)
                {
                case CodeMemberKind.Type:
                case CodeMemberKind.TypeDef:
                    yield return(mb);

                    break;
                }
            }
        }
Ejemplo n.º 4
0
 public void AddMember(CodeMemberDeclaration mb)
 {
     _members.Add(mb);
     mb.OwnerTypeDecl = new CodeSimpleTypeReference(this.Name);
     //
     mb.OriginalCompilationUnit = this.OriginalCompilationUnit;
     //
     switch (mb.MemberKind)
     {
     case CodeMemberKind.Type:
     case CodeMemberKind.TypeDef:
     {
         if (_subTypeDecls == null)
         {
             _subTypeDecls = new List <CodeMemberDeclaration>();
         }
         _subTypeDecls.Add(mb);
     }
     break;
     }
 }
Ejemplo n.º 5
0
        public int FindMethod(string name, List <CodeMethodDeclaration> results)
        {
            int foundCount = 0;

            if (_members == null)
            {
                return(0);
            }
            //
            int j = _members.Count;

            for (int i = 0; i < j; ++i)
            {
                CodeMemberDeclaration mb = _members[i];
                if (mb.Name == name && mb.MemberKind == CodeMemberKind.Method)
                {
                    foundCount++;
                    results.Add((CodeMethodDeclaration)mb);
                }
            }
            return(foundCount);
        }
Ejemplo n.º 6
0
        public int FindSubType(string name, List <CodeMemberDeclaration> results)
        {
            int foundCount = 0;

            if (_subTypeDecls == null)
            {
                return(0);
            }
            //
            int j = _subTypeDecls.Count;

            for (int i = 0; i < j; ++i)
            {
                CodeMemberDeclaration mb = _subTypeDecls[i];
                if (mb.Name == name)
                {
                    foundCount++;
                    results.Add(mb);
                }
            }
            return(foundCount);
        }
Ejemplo n.º 7
0
        TypeSymbol ResolveType(string typename)
        {
            TypeSymbol foundSymbol = null;

            if (_currentResolvingType != null)
            {
                //1.
                if (_currentResolvingType.IsTemplateTypeDefinition)
                {
                    //
                    //check if this is the template type parameter
                    //if (typename == _currentResolvingType.TemplateNotation.templatePar.ReAssignToTypeName)
                    //{   //found
                    //    return new TemplateParameterTypeSymbol(_currentResolvingType.TemplateNotation.templatePar);
                    //}
                    CodeTemplateParameter foundTemplatePar = null;
                    if (_currentResolvingType.TemplateNotation.TryGetTemplateParByReAssignToName(typename, out foundTemplatePar))
                    {
                        //TODO: resolve template type parameter
                        return(new TemplateParameterTypeSymbol(foundTemplatePar));
                    }

                    if (_currentResolvingType.TemplateNotation.TryGetTemplateParByParameterName(typename, out foundTemplatePar))
                    {
                        //TODO: resolve template type parameter
                        return(new TemplateParameterTypeSymbol(foundTemplatePar));
                    }
                }


                //2.
                //search nest type
                //TODO: review here -> use field
                if (_currentResolvingType.HasSubType)
                {
                    List <CodeMemberDeclaration> tempResults = new List <CodeMemberDeclaration>();
                    int foundCount;
                    if ((foundCount = _currentResolvingType.FindSubType(typename, tempResults)) > 0)
                    {
                        for (int i = 0; i < foundCount; ++i)
                        {
                            CodeMemberDeclaration subtype = tempResults[i];
                            switch (subtype.MemberKind)
                            {
                            default: throw new NotSupportedException();

                            case CodeMemberKind.Type:
                                break;

                            case CodeMemberKind.TypeDef:
                            {
                                CodeCTypeDef ctypedef        = (CodeCTypeDef)subtype;
                                TypeSymbol   resolveFromType = ResolveType(ctypedef.From);
                                if (resolveFromType != null)
                                {
                                    //found
                                    return(resolveFromType);
                                }
                            }
                            break;
                            }
                        }
                    }
                }
                //3
                if (_currentResolvingType.BaseTypes != null)
                {
                    //check if we need to search in other scopes
                    int baseCount = _currentResolvingType.BaseTypes.Count;
                    //we get only 1 base count
                    if (baseCount > 0)
                    {
                        if ((foundSymbol = SearchFromFirstBase(_currentResolvingType.BaseTypes[0] as CodeTypeTemplateTypeReference, typename)) != null)
                        {
                            return(foundSymbol);
                        }
                    }
                }
            }



            //-------

            if (this._typeCollection.TryGetType(typename, out foundSymbol))
            {
                return(foundSymbol);
            }

            //this is convention
            if (typename.StartsWith("cef_") && IsAllLowerLetter(typename))
            {
                //assume this is base c/cpp type
                foundSymbol = new SimpleTypeSymbol(typename);
                this._typeCollection.RegisterType(
                    typename,
                    foundSymbol);
                return(foundSymbol);
            }

            //not found
            return(foundSymbol);
        }