コード例 #1
0
        private TypeSymbol CreateArrayTypeCore(TypeSymbol itemTypeSymbol)
        {
            TypeSymbol arrayTypeSymbol =
                (TypeSymbol)((ISymbolTable)_systemNamespace).FindSymbol("Array", null, SymbolFilter.Types);

            Debug.Assert(arrayTypeSymbol != null);

            TypeSymbol specificArrayTypeSymbol = new ClassSymbol("Array", _systemNamespace);

            foreach (MemberSymbol memberSymbol in arrayTypeSymbol.Members)
            {
                specificArrayTypeSymbol.AddMember(memberSymbol);
            }

            IndexerSymbol indexerSymbol = new IndexerSymbol(specificArrayTypeSymbol, itemTypeSymbol,
                                                            MemberVisibility.Public);

            indexerSymbol.SetScriptIndexer();
            specificArrayTypeSymbol.AddMember(indexerSymbol);
            specificArrayTypeSymbol.SetIgnoreNamespace();
            specificArrayTypeSymbol.SetArray();

            return(specificArrayTypeSymbol);
        }
コード例 #2
0
        private MemberSymbol CreateGenericMember(MemberSymbol templateMember, IList <TypeSymbol> typeArguments)
        {
            TypeSymbol parentType = (TypeSymbol)templateMember.Parent;
            TypeSymbol instanceAssociatedType;

            if (templateMember.AssociatedType.Type == SymbolType.GenericParameter)
            {
                GenericParameterSymbol genericParameter = (GenericParameterSymbol)templateMember.AssociatedType;
                instanceAssociatedType = typeArguments[genericParameter.Index];
            }
            else
            {
                instanceAssociatedType = typeArguments[0];
            }

            if (templateMember.Type == SymbolType.Indexer)
            {
                IndexerSymbol templateIndexer = (IndexerSymbol)templateMember;
                IndexerSymbol instanceIndexer = new IndexerSymbol(parentType, instanceAssociatedType);

                if (templateIndexer.UseScriptIndexer)
                {
                    instanceIndexer.SetScriptIndexer();
                }
                instanceIndexer.SetVisibility(templateIndexer.Visibility);

                return(instanceIndexer);
            }
            else if (templateMember.Type == SymbolType.Property)
            {
                PropertySymbol templateProperty = (PropertySymbol)templateMember;
                PropertySymbol instanceProperty = new PropertySymbol(templateProperty.Name, parentType, instanceAssociatedType);

                if (templateProperty.IsTransformed)
                {
                    instanceProperty.SetTransformedName(templateProperty.GeneratedName);
                }
                instanceProperty.SetNameCasing(templateProperty.IsCasePreserved);
                instanceProperty.SetVisibility(templateProperty.Visibility);

                return(instanceProperty);
            }
            else if (templateMember.Type == SymbolType.Field)
            {
                FieldSymbol templateField = (FieldSymbol)templateMember;
                FieldSymbol instanceField = new FieldSymbol(templateField.Name, parentType, instanceAssociatedType);

                if (templateField.IsTransformed)
                {
                    instanceField.SetTransformedName(templateField.GeneratedName);
                }
                instanceField.SetNameCasing(templateField.IsCasePreserved);
                instanceField.SetVisibility(templateField.Visibility);

                return(instanceField);
            }
            else if (templateMember.Type == SymbolType.Method)
            {
                MethodSymbol templateMethod = (MethodSymbol)templateMember;
                MethodSymbol instanceMethod = new MethodSymbol(templateMethod.Name, parentType, instanceAssociatedType);

                if (templateMethod.IsAliased)
                {
                    instanceMethod.SetAlias(templateMethod.Alias);
                }
                else if (templateMethod.IsTransformed)
                {
                    instanceMethod.SetTransformedName(templateMethod.GeneratedName);
                }
                if (templateMethod.SkipGeneration)
                {
                    instanceMethod.SetSkipGeneration();
                }
                if (templateMethod.InterfaceMember != null)
                {
                    instanceMethod.SetInterfaceMember(templateMethod.InterfaceMember);
                }
                instanceMethod.SetNameCasing(templateMethod.IsCasePreserved);
                instanceMethod.SetVisibility(templateMethod.Visibility);

                return(instanceMethod);
            }

            Debug.Fail("Unexpected generic member '" + templateMember.Name + " on type '" + ((TypeSymbol)templateMember.Parent).FullName + "'.");
            return(null);
        }
コード例 #3
0
ファイル: SymbolSet.cs プロジェクト: jimmygilles/scriptsharp
        private MemberSymbol CreateGenericMember(MemberSymbol templateMember, IList<TypeSymbol> typeArguments)
        {
            TypeSymbol parentType = (TypeSymbol)templateMember.Parent;
            TypeSymbol instanceAssociatedType;

            if (templateMember.AssociatedType.Type == SymbolType.GenericParameter) {
                GenericParameterSymbol genericParameter = (GenericParameterSymbol)templateMember.AssociatedType;
                instanceAssociatedType = typeArguments[genericParameter.Index];
            }
            else {
                instanceAssociatedType = typeArguments[0];
            }

            if (templateMember.Type == SymbolType.Indexer) {
                IndexerSymbol templateIndexer = (IndexerSymbol)templateMember;
                IndexerSymbol instanceIndexer = new IndexerSymbol(parentType, instanceAssociatedType);

                if (templateIndexer.UseScriptIndexer) {
                    instanceIndexer.SetScriptIndexer();
                }
                instanceIndexer.SetVisibility(templateIndexer.Visibility);

                return instanceIndexer;
            }
            else if (templateMember.Type == SymbolType.Property) {
                PropertySymbol templateProperty = (PropertySymbol)templateMember;
                PropertySymbol instanceProperty = new PropertySymbol(templateProperty.Name, parentType, instanceAssociatedType);

                if (templateProperty.IsTransformed) {
                    instanceProperty.SetTransformedName(templateProperty.GeneratedName);
                }
                instanceProperty.SetNameCasing(templateProperty.IsCasePreserved);
                instanceProperty.SetVisibility(templateProperty.Visibility);

                return instanceProperty;
            }
            else if (templateMember.Type == SymbolType.Field) {
                FieldSymbol templateField = (FieldSymbol)templateMember;
                FieldSymbol instanceField = new FieldSymbol(templateField.Name, parentType, instanceAssociatedType);

                if (templateField.IsTransformed) {
                    instanceField.SetTransformedName(templateField.GeneratedName);
                }
                instanceField.SetNameCasing(templateField.IsCasePreserved);
                instanceField.SetVisibility(templateField.Visibility);

                return instanceField;
            }
            else if (templateMember.Type == SymbolType.Method) {
                MethodSymbol templateMethod = (MethodSymbol)templateMember;
                MethodSymbol instanceMethod = new MethodSymbol(templateMethod.Name, parentType, instanceAssociatedType);

                if (templateMethod.IsAliased) {
                    instanceMethod.SetAlias(templateMethod.Alias);
                }
                else if (templateMethod.IsTransformed) {
                    instanceMethod.SetTransformedName(templateMethod.GeneratedName);
                }
                if (templateMethod.SkipGeneration) {
                    instanceMethod.SetSkipGeneration();
                }
                if (templateMethod.InterfaceMember != null) {
                    instanceMethod.SetInterfaceMember(templateMethod.InterfaceMember);
                }
                instanceMethod.SetNameCasing(templateMethod.IsCasePreserved);
                instanceMethod.SetVisibility(templateMethod.Visibility);

                return instanceMethod;
            }

            Debug.Fail("Unexpected generic member '" + templateMember.Name + " on type '" + ((TypeSymbol)templateMember.Parent).FullName + "'.");
            return null;
        }
コード例 #4
0
ファイル: SymbolSet.cs プロジェクト: jimmygilles/scriptsharp
        private TypeSymbol CreateArrayTypeCore(TypeSymbol itemTypeSymbol)
        {
            TypeSymbol arrayTypeSymbol =
                (TypeSymbol)((ISymbolTable)_systemNamespace).FindSymbol("Array", null, SymbolFilter.Types);
            Debug.Assert(arrayTypeSymbol != null);

            TypeSymbol specificArrayTypeSymbol = new ClassSymbol("Array", _systemNamespace);
            foreach (MemberSymbol memberSymbol in arrayTypeSymbol.Members) {
                specificArrayTypeSymbol.AddMember(memberSymbol);
            }

            IndexerSymbol indexerSymbol = new IndexerSymbol(specificArrayTypeSymbol, itemTypeSymbol,
                                                            MemberVisibility.Public);
            indexerSymbol.SetScriptIndexer();
            specificArrayTypeSymbol.AddMember(indexerSymbol);
            specificArrayTypeSymbol.SetIgnoreNamespace();
            specificArrayTypeSymbol.SetArray();

            return specificArrayTypeSymbol;
        }