示例#1
0
        public Tuple <IIntermediateClassType, IIntermediateInterfaceType> Build(Tuple <ParserCompiler, RuleSymbolBuilder, IIntermediateAssembly> input)
        {
            this.compiler     = input.Item1;
            this.commonSymbol = input.Item2;
            this.assembly     = input.Item3;
            INamespaceDeclaration targetSpace;
            var targetSpaceName = TypeSystemIdentifiers.GetDeclarationIdentifier(string.Format("{0}.Cst", this.assembly.DefaultNamespace.FullName));

            if (!assembly.Namespaces.PathExists(targetSpaceName.Name))
            {
                targetSpace = this.assembly.DefaultNamespace.Namespaces.Add("Cst");
            }
            else
            {
                targetSpace = this.assembly.DefaultNamespace.Namespaces[targetSpaceName];
            }
            var mutableTargetSpace = (IIntermediateNamespaceDeclaration)targetSpace;

            this.resultInterface         = mutableTargetSpace.Parts.Add().Interfaces.Add("I{0}Rule", compiler.Source.Options.AssemblyName);
            this.resultClass             = mutableTargetSpace.Parts.Add().Classes.Add("{0}RuleBase", compiler.Source.Options.AssemblyName);
            this.resultClass.AccessLevel = AccessLevelModifiers.Internal;
            this.resultClass.ImplementedInterfaces.ImplementInterfaceQuick(resultInterface);
            this.resultInterface.AccessLevel = AccessLevelModifiers.Public;
            this.interfaceContext            = this.BuildContext();
            this.interfaceParent             = this.BuildParent();
            this.classContextField           = this.BuildClassContextField();
            this.classParentField            = this.BuildClassParentField();
            this.classContext = BuildClassContext();
            this.classParent  = BuildClassParent();
            this.resultClass.SpecialModifier = SpecialClassModifier.Abstract;
            return(Tuple.Create(resultClass, resultInterface));
        }
示例#2
0
        public IGeneralGenericSignatureMemberUniqueIdentifier GetIdentifier(IIntermediateMethodSignatureMember member)
        {
            var internalHelper = member as _IIntermediateMethodSignatureMember;

            if (internalHelper == null)
            {
                return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(member.Name, member.TypeParameters.Count, member.UserSpecificQualifier, member.Parameters.ParameterTypes.ToArray()));
            }
            else if (internalHelper.IsDisposed)
            {
                throw new InvalidOperationException(Utilities.Properties.Resources.ObjectStateThrowMessage);
            }
            else if (internalHelper.AreTypeParametersInitialized)
            {
                if (internalHelper.AreParametersInitialized)
                {
                    return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(member.Name, member.TypeParameters.Count, member.UserSpecificQualifier, member.Parameters.ParameterTypes.ToArray()));
                }
                else
                {
                    return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(member.Name, member.TypeParameters.Count, member.UserSpecificQualifier));
                }
            }
            else if (internalHelper.AreParametersInitialized)
            {
                return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(member.Name, member.UserSpecificQualifier, member.Parameters.ParameterTypes.ToArray()));
            }
            else
            {
                return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(member.Name, member.UserSpecificQualifier));
            }
        }
示例#3
0
        internal static IUnaryOperatorUniqueIdentifier GetUnaryOperatorIdentifier(ICliMetadataMethodDefinitionTableRow methodDef, IType owner, _ICliManager manager)
        {
            switch (methodDef.Name)
            {
            case CliCommon.UnaryOperatorNames.Decrement:
                return(TypeSystemIdentifiers.GetUnaryOperatorIdentifier(CoercibleUnaryOperators.Decrement));

            case CliCommon.UnaryOperatorNames.False:
                return(TypeSystemIdentifiers.GetUnaryOperatorIdentifier(CoercibleUnaryOperators.EvaluatesToFalse));

            case CliCommon.UnaryOperatorNames.Increment:
                return(TypeSystemIdentifiers.GetUnaryOperatorIdentifier(CoercibleUnaryOperators.Increment));

            case CliCommon.UnaryOperatorNames.LogicalNot:
                return(TypeSystemIdentifiers.GetUnaryOperatorIdentifier(CoercibleUnaryOperators.LogicalInvert));

            case CliCommon.UnaryOperatorNames.Negation:
                return(TypeSystemIdentifiers.GetUnaryOperatorIdentifier(CoercibleUnaryOperators.Negation));

            case CliCommon.UnaryOperatorNames.OnesComplement:
                return(TypeSystemIdentifiers.GetUnaryOperatorIdentifier(CoercibleUnaryOperators.Complement));

            case CliCommon.UnaryOperatorNames.Plus:
                return(TypeSystemIdentifiers.GetUnaryOperatorIdentifier(CoercibleUnaryOperators.Plus));

            case CliCommon.UnaryOperatorNames.True:
                return(TypeSystemIdentifiers.GetUnaryOperatorIdentifier(CoercibleUnaryOperators.EvaluatesToTrue));

            default:
                throw new InvalidOperationException();
            }
        }
示例#4
0
 public IAssemblyUniqueIdentifier GetIdentifier(IIntermediateAssembly assembly)
 {
     //if (assembly.PublicKeyInfo == null || assembly.PublicKeyInfo.PublicToken.Token == null || assembly.PublicKeyInfo.PublicToken.Token.Length == 0)
     return(TypeSystemIdentifiers.GetAssemblyIdentifier(assembly.Name, assembly.AssemblyInformation.AssemblyVersion, assembly.AssemblyInformation.Culture));
     //else
     //    return TypeSystemIdentifiers.GetAssemblyIdentifier(assembly.Name, assembly.AssemblyInformation.AssemblyVersion, assembly.AssemblyInformation.Culture, assembly.PublicKeyInfo.PublicToken.Token);
 }
        public IIntermediateInterfaceType Build(Tuple <ParserCompiler, CommonSymbolBuilder, IIntermediateAssembly> input)
        {
            this.compiler         = input.Item1;
            this.rootSymbol       = input.Item2;
            this.assembly         = input.Item3;
            this._identityManager = (IIntermediateCliManager)this.assembly.IdentityManager;
            INamespaceDeclaration targetSpace;
            var targetSpaceName = TypeSystemIdentifiers.GetDeclarationIdentifier(string.Format("{0}.Cst", this.assembly.DefaultNamespace.FullName));

            if (!assembly.Namespaces.PathExists(targetSpaceName.Name))
            {
                targetSpace = this.assembly.DefaultNamespace.Namespaces.Add("Cst");
            }
            else
            {
                targetSpace = this.assembly.DefaultNamespace.Namespaces[targetSpaceName];
            }
            var mutableTargetSpace = (IIntermediateNamespaceDeclaration)targetSpace;

            this.resultInterface = mutableTargetSpace.Parts.Add().Interfaces.Add("I{0}Token", compiler.Source.Options.AssemblyName);
            this.resultInterface.ImplementedInterfaces.Add(this.rootSymbol.ILanguageSymbol);
            this.resultInterface.AccessLevel = AccessLevelModifiers.Public;
            this.BuildStartPosition();
            this.BuildEndPosition();
            this.BuildStartTokenIndex();
            return(this.resultInterface);
        }
示例#6
0
        public IGeneralSignatureMemberUniqueIdentifier GetIdentifier(IIntermediateConstructorSignatureMember member)
        {
            var internalHelper = member as _IntermediateConstructorSignatureMember;

            if (internalHelper == null)
            {
                return(TypeSystemIdentifiers.GetCtorSignatureIdentifier(member.Parameters.ParameterTypes.ToArray()));
            }
            else if (internalHelper.IsDisposed)
            {
                throw new InvalidOperationException(Utilities.Properties.Resources.ObjectStateThrowMessage);
            }
            else if (internalHelper.IsTypeInitializer)
            {
                return(TypeSystemIdentifiers.GetCtorSignatureIdentifier());
            }
            else if (internalHelper.AreParametersInitialized)
            {
                return(TypeSystemIdentifiers.GetCtorSignatureIdentifier(member.Parameters.ParameterTypes.ToArray()));
            }
            else
            {
                return(TypeSystemIdentifiers.GetCtorSignatureIdentifier(new IType[0]));
            }
        }
示例#7
0
 private static IGeneralGenericSignatureMemberUniqueIdentifier GetIdentifierInternal(IIntermediateMethodMember member, _IIntermediateMethodSignatureMember internalHelper, IType firstImpl)
 {
     if (internalHelper == null)
     {
         return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(member.Name, member.TypeParameters.Count, string.Format("{0}{1}", firstImpl.FullName, member.UserSpecificQualifier), member.Parameters.ParameterTypes.ToArray()));
     }
     else if (internalHelper.IsDisposed)
     {
         throw new InvalidOperationException(Utilities.Properties.Resources.ObjectStateThrowMessage);
     }
     else if (internalHelper.AreTypeParametersInitialized)
     {
         if (internalHelper.AreParametersInitialized)
         {
             return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(member.Name, member.TypeParameters.Count, string.Format("{0}{1}", firstImpl.FullName, member.UserSpecificQualifier), member.Parameters.ParameterTypes.ToArray()));
         }
         else
         {
             return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(member.Name, member.TypeParameters.Count, string.Format("{0}{1}", firstImpl.FullName, member.UserSpecificQualifier), new IType[0]));
         }
     }
     else if (internalHelper.AreParametersInitialized)
     {
         return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(member.Name, 0, string.Format("{0}{1}", firstImpl.FullName, member.UserSpecificQualifier), member.Parameters.ParameterTypes.ToArray()));
     }
     else
     {
         return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(member.Name, 0, string.Format("{0}{1}", firstImpl.FullName, member.UserSpecificQualifier), new IType[0]));
     }
 }
示例#8
0
 public IGeneralMemberUniqueIdentifier GetIdentifier(IIntermediatePropertySignatureMember member)
 {
     if (member is IIntermediateClassPropertyMember || member is IIntermediateStructPropertyMember)
     {
         var classProp = member as IIntermediateClassPropertyMember;
         if (classProp != null)
         {
             var firstImpl = classProp.Implementations.FirstOrDefault();
             if (firstImpl != null)
             {
                 return(TypeSystemIdentifiers.GetMemberIdentifier(member.Name, string.Format("{0}{1}", firstImpl.FullName, member.UserSpecificQualifier)));
             }
         }
         else
         {
             var structProp = member as IIntermediateStructPropertyMember;
             if (structProp != null)
             {
                 var firstImpl = structProp.Implementations.FirstOrDefault();
                 if (firstImpl != null)
                 {
                     return(TypeSystemIdentifiers.GetMemberIdentifier(member.Name, string.Format("{0}{1}", firstImpl.FullName, member.UserSpecificQualifier)));
                 }
             }
         }
     }
     return(IntermediateGateway.DefaultUniqueIdentifierService.GetIdentifier(member));
 }
示例#9
0
        private static void Test <TLanguage, TProvider>(ILanguageProvider <TLanguage, TProvider> provider)
            where TLanguage :
        ILanguage <TLanguage, TProvider>
            where TProvider :
        ILanguageProvider <TLanguage, TProvider>
        {
            IIntermediateAssembly iia = (IIntermediateAssembly)provider.CreateAssembly("TestAssembly");
            var idm                     = iia.IdentityManager;
            var ienumerableType         = (IInterfaceType)idm.ObtainTypeReference(TypeSystemIdentifiers.GetTypeIdentifier("System.Collections.Generic", "IEnumerable", 1));
            var structuralExampleMethod = iia.Methods.Add("StructuralExample");
            var tdataset                = structuralExampleMethod.TypeParameters.Add("TDataset");
            var tdatabase               = structuralExampleMethod.TypeParameters.Add("TDatabase");
            var byteRef                 = idm.ObtainTypeReference(idm.RuntimeEnvironment.Byte);
            var datasetIndex            = tdataset.Indexers.Add(byteRef, new TypedNameSeries(new TypedName("index", idm.ObtainTypeReference(idm.RuntimeEnvironment.Int32))), true, true);
            var database                = tdataset.Properties.Add(new TypedName("Database", tdatabase), true, false);
            var dataCopy                = tdataset.Methods.Add(new TypedName("GetDataCopy", byteRef.MakeArray()));
            var clone                   = tdataset.Methods.Add(new TypedName("Clone", tdataset));
            var ctor                    = tdataset.Constructors.Add(new TypedName("uInst", tdatabase), new TypedName("data", byteRef.MakeArray()));
            var d              = datasetIndex.GetMethod.GetReference(new SpecialReferenceExpression(SpecialReferenceKind.This)).Invoke();
            var gvm            = datasetIndex.GetMethod.UniqueIdentifier;
            var parameters     = datasetIndex.Parameters;
            var nextParameter  = parameters.Add(new TypedName("testIndex", idm.ObtainTypeReference(RuntimeCoreType.Int16)));
            var valueParameter = datasetIndex.SetMethod.ValueParameter;

            nextParameter.ParameterType = idm.ObtainTypeReference(RuntimeCoreType.SByte);

            iia.Dispose();
        }
示例#10
0
        internal static IGeneralSignatureMemberUniqueIdentifier GetIndexerIdentifier(ICliMetadataPropertyTableRow indexerDef, IType owner, _ICliManager manager)
        {
            ICliMetadataMethodDefinitionTableRow targetMethod = null;
            bool knockOffLast = false;
            var  getMethod    = targetMethod = indexerDef.GetMethod;

            if (getMethod == null)
            {
                targetMethod = indexerDef.SetMethod;
                if (targetMethod == null)
                {
                    var semanticMethod = indexerDef.Methods.FirstOrDefault();
                    if (semanticMethod != null)
                    {
                        targetMethod = semanticMethod.Method;
                    }
                }
                else
                {
                    knockOffLast = true;
                }
            }
            if (targetMethod != null)
            {
                return(TypeSystemIdentifiers.GetSignatureIdentifier(indexerDef.Name, (from p in (knockOffLast ? targetMethod.Signature.Parameters.Take(targetMethod.Signature.Parameters.Count - 1) : targetMethod.Signature.Parameters)
                                                                                      select manager.ObtainTypeReference(p.ParameterType, owner, null, owner == null ? null : owner.Assembly)).SinglePass()));
            }
            else
            {
                return(TypeSystemIdentifiers.GetSignatureIdentifier(indexerDef.Name));
            }
        }
示例#11
0
            protected override IntermediateParameterMemberDictionary <IStructMethodMember, IIntermediateStructMethodMember, IMethodParameterMember <IStructMethodMember, IStructType>, IIntermediateMethodParameterMember <IStructMethodMember, IIntermediateStructMethodMember, IStructType, IIntermediateStructType> > InitializeParameters()
            {
                var result = base.InitializeParameters();

                result._Add(TypeSystemIdentifiers.GetMemberIdentifier("value"), this.valueParameter = new _ValueParameter(this));
                return(result);
            }
示例#12
0
        internal static IGeneralMemberUniqueIdentifier GetTypeCoercionOperatorIdentifier(ICliMetadataMethodDefinitionTableRow methodDef, IType owner, _ICliManager manager)
        {
            var coercionParameter = methodDef.Signature.Parameters.FirstOrDefault();

            if (coercionParameter == null)
            {
                return(null);
            }
            var coercionType = manager.ObtainTypeReference(coercionParameter.ParameterType, owner, null, owner == null ? null : owner.Assembly);
            var returnType   = manager.ObtainTypeReference(methodDef.Signature.ReturnType, owner, null, owner == null ? null : owner.Assembly);

            if (coercionType == null || returnType == null)
            {
                return(null);
            }
            var genericOwner = owner as IGenericType;
            TypeConversionRequirement requirement = (methodDef.Name == CliCommon.TypeCoercionNames.Implicit) ? TypeConversionRequirement.Implicit : (methodDef.Name == CliCommon.TypeCoercionNames.Explicit) ? TypeConversionRequirement.Explicit : TypeConversionRequirement.Unknown;

            if (genericOwner == null)
            {
                goto nonGenericResolution;
            }
            else
            {
                if (owner.IsGenericConstruct)
                {
                    if (TypesAreEquivalent(owner, coercionType))
                    {
                        return(TypeSystemIdentifiers.GetTypeOperatorFromIdentifier(requirement, returnType));
                    }
                    else if (TypesAreEquivalent(owner, returnType))
                    {
                        return(TypeSystemIdentifiers.GetTypeOperatorToIdentifier(requirement, coercionType));
                    }
                    else
                    {
                        goto nonGenericResolution;
                    }
                }
                else
                {
                    goto nonGenericResolution;
                }
            }
nonGenericResolution:
            if (owner == coercionType)
            {
                return(TypeSystemIdentifiers.GetTypeOperatorFromIdentifier(requirement, returnType));
            }
            else if (owner == returnType)
            {
                return(TypeSystemIdentifiers.GetTypeOperatorToIdentifier(requirement, coercionType));
            }
            else
            {
                return(null);
            }
        }
示例#13
0
            protected override IntermediateParameterMemberDictionary <IClassMethodMember, IIntermediateClassMethodMember, IMethodParameterMember <IClassMethodMember, IClassType>, IIntermediateMethodParameterMember <IClassMethodMember, IIntermediateClassMethodMember, IClassType, IIntermediateClassType> > InitializeParameters()
            {
                var result = base.InitializeParameters();

                result.Unlock();
                result._Add(TypeSystemIdentifiers.GetMemberIdentifier("value"), this.valueParameter = GetValueParameter());
                result.Lock();
                return(result);
            }
示例#14
0
        protected override bool IsSubclassOfImpl(IType other)
        {
            return(this.IdentityManager.ObtainTypeReference(RuntimeCoreType.RootType).Equals(other)
#if TYPESYSTEM_CLI
                   || this.IdentityManager.ObtainTypeReference(TypeSystemIdentifiers.GetTypeIdentifier("System", "Delegate", 0)).Equals(other) ||
                   this.IdentityManager.ObtainTypeReference(TypeSystemIdentifiers.GetTypeIdentifier("System", "MulticastDelegate", 0)).Equals(other));
#else
                   ;
#endif
        }
示例#15
0
        public INamespaceDeclaration this[string path]
        {
            get
            {
                string ns = path;

                int lastIndex = 0;
                CliNamespaceKeyedTree topLevel         = this.info;
                INamespaceDictionary  topNamespaceDict = this;
                StringBuilder         pathBuilder      = new StringBuilder();
                bool first = true;
nextPart:
                int next = ns.IndexOf('.', lastIndex);
                if (first)
                {
                    first = false;
                }
                else
                {
                    pathBuilder.Append('.');
                }
                if (next != -1)
                {
                    string current = ns.Substring(lastIndex, next - lastIndex);
                    pathBuilder.Append(current);
                    uint currentHash = (uint)current.GetHashCode();
                    if (topLevel.ContainsKey(currentHash))
                    {
                        topLevel         = topLevel[currentHash];
                        topNamespaceDict = topNamespaceDict[TypeSystemIdentifiers.GetDeclarationIdentifier(pathBuilder.ToString())].Namespaces;
                    }
                    else
                    {
                        return(null);
                    }
                    lastIndex = next + 1;
                    goto nextPart;
                }
                else
                {
                    string current = ns.Substring(lastIndex);
                    pathBuilder.Append(current);
                    uint currentHash = (uint)current.GetHashCode();
                    if (topLevel.ContainsKey(currentHash))
                    {
                        topLevel = topLevel[currentHash];
                        return(topNamespaceDict[TypeSystemIdentifiers.GetDeclarationIdentifier(pathBuilder.ToString())]);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
示例#16
0
 public IGenericParameterUniqueIdentifier GetIdentifier(IIntermediateGenericParameter member)
 {
     if (member.Position > -1)
     {
         return(TypeSystemIdentifiers.GetGenericParameterIdentifier(member.Position, member.Name, member is IGenericTypeParameter));
     }
     else
     {
         return(TypeSystemIdentifiers.GetGenericParameterIdentifier(member.Name, member is IGenericTypeParameter));
     }
 }
示例#17
0
        protected override IGeneralDeclarationUniqueIdentifier GetIdentifierFrom(int index, uint metadata)
        {
            var    namespaceInfo = this.info[metadata];
            string fullSpace     = namespaceInfo.StringsSection[namespaceInfo.Value];

            if (namespaceInfo.SubspaceLength != 0)
            {
                fullSpace = fullSpace.Substring(0, namespaceInfo.SubspaceStart + namespaceInfo.SubspaceLength);
            }
            return(TypeSystemIdentifiers.GetDeclarationIdentifier(fullSpace));
        }
示例#18
0
 protected override IGeneralGenericTypeUniqueIdentifier OnGetUniqueIdentifier()
 {
     if (this.uniqueIdentifier == null)
     {
         int typeParamCount;
         lock (this.SyncObject)
             typeParamCount = this.typeParameters == null ? 0 : this.typeParameters.Count;
         this.uniqueIdentifier = TypeSystemIdentifiers.GetTypeIdentifier(this.NamespaceName, this.Name, typeParamCount);
     }
     return(this.uniqueIdentifier);
 }
示例#19
0
        /// <summary>
        /// Inserts a series of new <see cref="ITypedLocalMember"/> instances
        /// with the <see cref="TypedNameSeries"/>, relative to the active
        /// scope, for the <see cref="ITypedLocalMember"/> elements to add.
        /// </summary>
        /// <param name="namesAndTypes">The <see cref="TypedNameSeries"/>
        /// which denotes each element's name and type within the active scope.</param>
        /// <returns>a series of new <see cref="ITypedLocalMember"/> instances
        /// with the <see cref="TypedNameSeries"/> provided.</returns>
        public ITypedLocalMember[] AddRange(TypedNameSeries namesAndTypes)
        {
            var seriesElements = namesAndTypes.ToArray();
            Stack <ILocalMemberDictionary> memberScopes = GetFullScope();

            IGeneralMemberUniqueIdentifier[] ids = new IGeneralMemberUniqueIdentifier[namesAndTypes.Count];
            for (int i = 0; i < seriesElements.Length; i++)
            {
                ids[i] = TypeSystemIdentifiers.GetMemberIdentifier(seriesElements[i].Name);
            }
            for (int i = 0; i < seriesElements.Length; i++)
            {
                var iElementIdentifier = ids[i];

                /* *
                 * First check for name collisions within the series itself.
                 * */
                for (int j = i + 1; j < seriesElements.Length; j++)
                {
                    if (iElementIdentifier.Equals(ids[j]))
                    {
                        throw new ArgumentException("Duplicate name detected");
                    }
                }

                /* *
                 * Next, check for collisions within the scope.
                 * */
                foreach (var scope in memberScopes)
                {
                    if (scope.ContainsKey(iElementIdentifier))
                    {
                        throw new ArgumentException("Duplicate name detected");
                    }
                }
            }
            var parentMember = this.GetTopParent() as IIntermediateMember;

            ITypedLocalMember[] locals = new ITypedLocalMember[seriesElements.Length];
            for (int i = 0; i < seriesElements.Length; i++)
            //Parallel.For(0, seriesElements.Length, i =>
            {
                var current   = seriesElements[i];
                var localType = current.GetTypeRef();
                if (localType.ContainsSymbols())
                {
                    localType = localType.SimpleSymbolDisambiguation(parentMember);
                }
                locals[i] = new TypedLocalMember(current.Name, this.Parent, localType);
            }//**/);
            this._AddRange(from local in locals
                           select new KeyValuePair <IGeneralMemberUniqueIdentifier, ILocalMember>(local.UniqueIdentifier, local));
            return(locals);
        }
 public bool ContainsKey(string key)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     if (key == string.Empty)
     {
         throw ThrowHelper.ObtainArgumentException(ArgumentWithException.key, ExceptionMessageId.ArgumentCannotBeEmpty, ThrowHelper.GetArgumentName(ArgumentWithException.key));
     }
     return(this.ContainsKey(TypeSystemIdentifiers.GetDeclarationIdentifier(key)));
 }
示例#21
0
        internal static IClassPropertyMember GetProperty(this IClassType top, string name)
        {
            var muid = TypeSystemIdentifiers.GetMemberIdentifier(name);

            for (IClassType current = top; current != null; current = current.BaseType)
            {
                if (current.Properties.ContainsKey(muid))
                {
                    return(current.Properties[muid]);
                }
            }
            throw new InvalidOperationException(string.Format("No property {0} found.", name));
        }
示例#22
0
 public GenericParameterDictionary(SymbolType parent, string[] tParamNames)
     : this(parent)
 {
     if (tParamNames != null)
     {
         this.tParamNames = new IGenericParameterUniqueIdentifier[tParamNames.Length];
         for (int i = 0; i < tParamNames.Length; i++)
         {
             this.tParamNames[i] = TypeSystemIdentifiers.GetGenericParameterIdentifier(i, true);
         }
         this.elements = new GenericParameterMember[tParamNames.Length];
     }
 }
示例#23
0
        internal static IGeneralGenericSignatureMemberUniqueIdentifier GetMethodIdentifier(ICliMetadataMethodDefinitionTableRow methodDef, IType owner, _ICliManager manager, Func <IMethodSignatureMember> memberGetter)
        {
            bool typeParamCheck = methodDef.MetadataRoot.TableStream.GenericParameterTable != null;

            if (typeParamCheck)
            {
                return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(methodDef.Name, methodDef.TypeParameters.Count, (from p in methodDef.Signature.Parameters
                                                                                                                            select manager.ObtainTypeReference(p.ParameterType, owner, memberGetter(), owner == null ? null : owner.Assembly)).SinglePass()));
            }
            else
            {
                return(TypeSystemIdentifiers.GetGenericSignatureIdentifier(methodDef.Name, 0, (from p in methodDef.Signature.Parameters
                                                                                               select manager.ObtainTypeReference(p.ParameterType, owner, memberGetter(), owner == null ? null : owner.Assembly)).SinglePass()));
            }
        }
示例#24
0
 protected override IGenericParameterUniqueIdentifier OnGetUniqueIdentifier()
 {
     if (this.uniqueIdentifier == null)
     {
         if (this.Position > -1)
         {
             this.uniqueIdentifier = TypeSystemIdentifiers.GetGenericParameterIdentifier(this.Position, this.Name, true);
         }
         else
         {
             this.uniqueIdentifier = TypeSystemIdentifiers.GetGenericParameterIdentifier(this.Name, true);
         }
     }
     return(this.uniqueIdentifier);
 }
 protected override IGeneralTypeUniqueIdentifier OnGetUniqueIdentifier()
 {
     lock (this.SyncObject)
         if (this.uniqueIdentifier == null)
         {
             if (this.Parent is IType)
             {
                 this.uniqueIdentifier = ((IType)this.Parent).UniqueIdentifier.GetNestedIdentifier(this.Name, 0);
             }
             else if (this.Parent is INamespaceDeclaration)
             {
                 this.uniqueIdentifier = TypeSystemIdentifiers.GetTypeIdentifier(((INamespaceDeclaration)this.Parent).FullName, this.Name, 0);
             }
             else
             {
                 this.uniqueIdentifier = TypeSystemIdentifiers.GetTypeIdentifier((IGeneralDeclarationUniqueIdentifier)null, this.Name, 0);
             }
         }
     return(this.uniqueIdentifier);
 }
        public Tuple <IIntermediateInterfaceType, IIntermediateClassType> Build(Tuple <ParserCompiler, CommonSymbolBuilder, IIntermediateAssembly> input)
        {
            this.assembly            = input.Item3;
            this.compiler            = input.Item1;
            this.commonSymbolBuilder = input.Item2;
            var resultInterface = assembly.DefaultNamespace.Parts.Add().Interfaces.Add("I{0}SymbolStream", this.compiler.Source.Options.AssemblyName);
            var iFaceTParam     = resultInterface.TypeParameters.Add(new GenericParameterData("TSymbol", new IType[] { input.Item2.ILanguageSymbol }));
            var resultClass     = assembly.DefaultNamespace.Parts.Add().Classes.Add("{0}SymbolStream", this.compiler.Source.Options.AssemblyName);
            var classTParam     = resultClass.TypeParameters.Add(new GenericParameterData("TSymbol", new IType[] { input.Item2.ILanguageSymbol }));

            resultClass.ImplementedInterfaces.ImplementInterfaceQuick(resultInterface.MakeGenericClosure(classTParam));
            var readOnlyList = typeof(IReadOnlyList <>).ObtainCILibraryType <IInterfaceType>(assembly.IdentityManager).MakeGenericClosure(iFaceTParam);

            resultInterface.ImplementedInterfaces.Add(readOnlyList);
            var initialIndexer     = readOnlyList.Indexers[0].Value;
            var readOnlyCollection = (IInterfaceType)readOnlyList.ImplementedInterfaces[0];

            EndOFilePresent             = resultInterface.Properties.Add(new TypedName("EndOFilePresent", RuntimeCoreType.Boolean, assembly.IdentityManager), true, false);
            EndOFilePresent.SummaryText = string.Format(@"Returns whether the @s:{0}Symbols.{1}; is present within the @s:{2}{{TSymbol}};", this.compiler.Source.Options.AssemblyName, this.compiler.LexicalSymbolModel.GetEofIdentityField().Name, resultInterface.Name);
            var countProp = readOnlyCollection.Properties[TypeSystemIdentifiers.GetMemberIdentifier("Count")];

            CreateInternalStream(resultClass, classTParam);
            CreateInternalStreamImpl(resultClass, classTParam);
            this.CreateCountImpl(resultClass, countProp);
            CreateEndOfFilePresentImpl(resultClass, initialIndexer, readOnlyCollection, this.CountImpl);
            CreateIndexerImpl(resultClass, initialIndexer);

            var enumeratorTypeOfT = typeof(IEnumerator <>).ObtainCILibraryType <IInterfaceType>(assembly.IdentityManager).MakeGenericClosure(classTParam);
            var enumeratorType    = typeof(IEnumerator).ObtainCILibraryType <IInterfaceType>(assembly.IdentityManager);
            var enumerableType    = typeof(IEnumerable).ObtainCILibraryType <IInterfaceType>(assembly.IdentityManager);

            this.CreateGetEnumerator(resultClass, enumeratorTypeOfT, enumeratorType, enumerableType);
            this.ResultInterface                 = resultInterface;
            this.ResultClass                     = resultClass;
            this.InternalStream.AccessLevel      = AccessLevelModifiers.Private;
            this.EndOFilePresentImpl.AccessLevel = AccessLevelModifiers.Public;
            this.ResultInterface.AccessLevel     = AccessLevelModifiers.Public;
            this.ResultClass.AccessLevel         = AccessLevelModifiers.Internal;
            return(Tuple.Create(this.ResultInterface, this.ResultClass));
        }
示例#27
0
        public static IAssemblyUniqueIdentifier GetVersionedMicrosoftVisualBasicLibrary(VisualBasicVersion languageVersion = VisualBasicVersion.CurrentVersion)
        {
            switch (languageVersion)
            {
            case VisualBasicVersion.Version07:
                return(TypeSystemIdentifiers.GetAssemblyIdentifier(microsoftVisualBasicLibName, vbV7, CultureIdentifiers.None, MicrosoftLanguageVendor.stdLibPublicKeyToken));

            case VisualBasicVersion.Version07_1:
                return(TypeSystemIdentifiers.GetAssemblyIdentifier(microsoftVisualBasicLibName, vbV7_1, CultureIdentifiers.None, MicrosoftLanguageVendor.stdLibPublicKeyToken));

            case VisualBasicVersion.Version08:
            case VisualBasicVersion.Version09:
                return(TypeSystemIdentifiers.GetAssemblyIdentifier(microsoftVisualBasicLibName, vbV8, CultureIdentifiers.None, MicrosoftLanguageVendor.stdLibPublicKeyToken));

            case VisualBasicVersion.Version10:
            case VisualBasicVersion.Version11:
            case VisualBasicVersion.Version12:
                return(TypeSystemIdentifiers.GetAssemblyIdentifier(microsoftVisualBasicLibName, vbV10, CultureIdentifiers.None, MicrosoftLanguageVendor.stdLibPublicKeyToken));

            default:
                goto case VisualBasicVersion.CurrentVersion;
            }
        }
示例#28
0
 public FieldMember(IStructType parent, ICliMetadataFieldTableRow metadataEntry)
     : base(parent, metadataEntry, TypeSystemIdentifiers.GetMemberIdentifier(metadataEntry.Name))
 {
 }
        public TIntermediateGenericParameter[] AddRange(params GenericParameterData[] genericParameterData)
        {
            if (this.Locked)
            {
                throw new InvalidOperationException(Resources.ObjectStateThrowMessage);
            }
            if (genericParameterData == null)
            {
                throw new ArgumentNullException("genericParameterData");
            }
            TIntermediateGenericParameter[]     result      = new TIntermediateGenericParameter[genericParameterData.Length];
            IGenericParameterUniqueIdentifier[] currentKeys = new IGenericParameterUniqueIdentifier[result.Length];

            //Parallel.For(0, genericParameterData.Length, i =>
            for (int i = 0; i < genericParameterData.Length; i++)
            {
                var currentName     = genericParameterData[i].Name;
                var current         = this.GetNew(currentName);
                var currentUniqueId = TypeSystemIdentifiers.GetGenericParameterIdentifier(i + this.Count, currentName, Parent is IType);
                if (this.ContainsKey(currentUniqueId) ||
                    currentKeys.Contains(currentUniqueId))
                {
                    throw new ArgumentException("genericParameterData");
                }
                currentKeys[i] = currentUniqueId;
                result[i]      = current;
            }//**/);
            this._AddRange((from i in 0.RangeTo(genericParameterData.Length)
                            select new KeyValuePair <IGenericParameterUniqueIdentifier, TGenericParameter>(currentKeys[i], result[i])));
            //Parallel.For(0, genericParameterData.Length, i=>
            for (int i = 0; i < genericParameterData.Length; i++)
            {
                var currentParameterData = genericParameterData[i];
                var current = result[i];
                foreach (var constraint in currentParameterData.Constraints)
                {
                    current.Constraints.Add(TransposeType(constraint, current));
                }
                foreach (var ctorSig in currentParameterData.Constructors.Signatures)
                {
                    current.Constructors.Add(TransposeTypedNames(ctorSig.Parameters.ToSeries(), current));
                }
                foreach (var eventGroup in TransposeTypedNames(currentParameterData.Events, current))
                {
                    current.Events.Add(eventGroup);
                }
                foreach (var indexerSig in currentParameterData.Indexers.Signatures)
                {
                    current.Indexers.Add(TransposeTypedName(new TypedName(indexerSig.Name, indexerSig.ReturnType), current), TransposeTypedNames(indexerSig.Parameters.ToSeries(), current));
                }
                //result.Properties.Add
                current.SpecialConstraint = currentParameterData.SpecialConstraint;
                foreach (var method in currentParameterData.Methods.Signatures)
                {
                    current.Methods.Add(TransposeTypedName(new TypedName(method.Name, method.ReturnType), current), TransposeTypedNames(method.Parameters.ToSeries(), current));
                }
            }//*/);

            //Parallel.For(0, genericParameterData.Length, i =>
            //for (int i = 0; i < genericParameterData.Length; i++)
            //{
            //    var currentParameterData = genericParameterData[i];
            //    var current = result[i];
            //    foreach (var constraint in currentParameterData.Constraints)
            //        if (constraint.ContainsSymbols())
            //            current.Constraints.Add(constraint.SimpleSymbolDisambiguation(current));
            //        else
            //            current.Constraints.Add(constraint);
            //    foreach (var ctor in current.Constructors.Values)
            //        foreach (var param in ctor.Parameters.Values)
            //            if (param.ParameterType.ContainsSymbols())
            //                param.ParameterType = param.ParameterType.SimpleSymbolDisambiguation(current);
            //    foreach (var method in current.Methods.Values)
            //    {
            //        foreach (var param in method.Parameters.Values)
            //            if (param.ParameterType.ContainsSymbols())
            //                param.ParameterType = param.ParameterType.SimpleSymbolDisambiguation(current);
            //        if (method.ReturnType.ContainsSymbols())
            //            method.ReturnType = method.ReturnType.SimpleSymbolDisambiguation(current);
            //    }
            //    foreach (var property in current.Properties.Values)
            //        if (property.PropertyType.ContainsSymbols())
            //            property.PropertyType = property.PropertyType.SimpleSymbolDisambiguation(current);

            //    foreach (var indexer in current.Indexers.Values)
            //    {
            //        if (indexer.PropertyType.ContainsSymbols())
            //            indexer.PropertyType = indexer.PropertyType.SimpleSymbolDisambiguation(current);
            //        foreach (var param in indexer.Parameters.Values)
            //            if (param.ParameterType.ContainsSymbols())
            //                param.ParameterType = param.ParameterType.SimpleSymbolDisambiguation(current);
            //    }
            //}//);
            return(result);
        }
        public TIntermediateGenericParameter Add(GenericParameterData genericParameterData)
        {
            if (this.Locked)
            {
                throw new InvalidOperationException(Resources.ObjectStateThrowMessage);
            }
            if (string.IsNullOrEmpty(genericParameterData.Name))
            {
                throw new ArgumentException("genericParameterData");
            }
            int index          = this.Count;
            var defaultParamId = TypeSystemIdentifiers.GetGenericParameterIdentifier(index, this.Parent is IType);
            var result         = this.GetNew(genericParameterData.Name);

            if (this.ContainsKey(defaultParamId))
            {
                throw new ArgumentException("genericParameterData");
            }
            foreach (var ctorSig in genericParameterData.Constructors.Signatures)
            {
                result.Constructors.Add(TransposeTypedNames(ctorSig.Parameters.ToSeries(), result));
            }
            var disambiguatedEvents = TransposeTypedNames(genericParameterData.Events, result);

            foreach (var eventGroup in disambiguatedEvents)
            {
                result.Events.Add(eventGroup);
            }
            IControlledTypeCollection typeParameters       = null;
            IControlledTypeCollection methodTypeParameters = null;

            foreach (var constraint in genericParameterData.Constraints)
            {
                if (constraint.ContainsSymbols())
                {
                    if (constraint.ContainsGenericParameters())
                    {
                        result.Constraints.Add(Disambiguate(constraint).SimpleSymbolDisambiguation(result));
                    }
                    else
                    {
                        result.Constraints.Add(constraint.SimpleSymbolDisambiguation(result));
                    }
                }
                else if (constraint.ContainsGenericParameters())
                {
                    result.Constraints.Add(Disambiguate(constraint));
                }
                else
                {
                    result.Constraints.Add(constraint);
                }
            }
            result.SpecialConstraint = genericParameterData.SpecialConstraint;
            //foreach (var propertyGroup in genericParameterData.Properties)
            //result.Properties.Add
            foreach (var method in genericParameterData.Methods.Signatures)
            {
                result.Methods.Add(new TypedName(method.Name, method.ReturnType), method.Parameters.ToSeries());
            }
            this._Add(defaultParamId, result);
            this.Keys[index] = result.UniqueIdentifier;
            return(result);
        }