Beispiel #1
0
            internal static IType Disambiguate(IType sourceType, IIntermediateDeclaration originPoint)
            {
                var worker = new SimpleTypeDisambiguationWorker();

                worker.originPoint = originPoint;
                worker.selector    = GetSelector(originPoint);
                return(worker.Disambiguate(sourceType));
            }
Beispiel #2
0
            /// <summary>
            /// Determines whether the <paramref name="declaration"/> is a candidate for a module in
            /// the Visual Basic language.
            /// </summary>
            /// <param name="declaration">The <see cref="IIntermediateDeclaration"/> to check to see if it
            /// is a vb module candidate.</param>
            /// <returns>true if the <paramref name="declaration"/> is a valid candidate.</returns>
            /// <remarks>If the <paramref name="declaration"/> is a valid candidate, the translator
            /// will flatten the partial hierarchy using the options' <see cref="IIntermediateCodeTranslatorOptions.AllowPartials"/> property.</remarks>
            internal static bool DeclarationIsVBModuleCandidate(IIntermediateDeclaration declaration)
            {
                if (!(declaration is IIntermediateClassType))
                {
                    return(false);
                }
                IIntermediateClassType @class = (IIntermediateClassType)declaration;

                if ((@class.TypeParameters == null || @class.TypeParameters.Count == 0) && @class.SpecialModifier != SpecialClassModifier.None)
                {
                    return(@class.Parent is IIntermediateNamespaceDeclaration && @class.Parts.Count == 0);
                }
                return(false);
            }
Beispiel #3
0
 protected void BuildTrailPop(IIntermediateDeclaration declaration)
 {
     CheckBuildTrail();
     if (this.buildTrail.Contains(declaration))
     {
         for (int i = buildTrail.Count - 1; i >= 0; i--)
         {
             if (buildTrail[i] == declaration)
             {
                 buildTrail.RemoveAt(i);
                 break;
             }
         }
     }
 }
Beispiel #4
0
            internal static bool DeclarationIsVBModule(IIntermediateDeclaration declaration, IIntermediateCodeTranslatorOptions options)
            {
                if (!(declaration is IIntermediateClassType))
                {
                    return(false);
                }
                IIntermediateClassType @class = (IIntermediateClassType)declaration;

                if (@class.TypeParameters == null || @class.TypeParameters.Count == 0)
                {
                    if (@class.Parent is IIntermediateNamespaceDeclaration && @class.SpecialModifier != AllenCopeland.Abstraction.Slf.Abstract.SpecialClassModifier.None)
                    {
                        if (options.AllowPartials)
                        {
                            //Basically if all other partials have no members,
                            //Then it means that it is still a module.
                            foreach (IIntermediateClassType ict in @class.GetRoot().Parts)
                            {
                                if (ict == @class)
                                {
                                    continue;
                                }
                                else if (ict.Members.Count > 0 || ict.Types.Count > 0)
                                {
                                    return(false);
                                }
                            }
                            if (@class != @class.GetRoot() && @class.GetRoot().Members.Count > 0)
                            {
                                return(false);
                            }
                        }
                    }
                    return(true);
                }
                return(false);
            }
Beispiel #5
0
 protected void BuildTrailPush(IIntermediateDeclaration declaration)
 {
     CheckBuildTrail();
     this.buildTrail.Add(declaration);
 }