Exemple #1
0
        public override List<SymScope> FindOverloadNames(string name)
        {
            List<SymScope> names = new List<SymScope>();
            PascalABCCompiler.TreeConverter.SymbolInfo si = PascalABCCompiler.NetHelper.NetHelper.FindNameIncludeProtected(ctn, name);
            //IEnumerable<MemberInfo> ext_meths = PascalABCCompiler.NetHelper.NetHelper.GetExtensionMethods(ctn);
            List<ProcScope> pascal_ext_meths = this.GetExtensionMethods(name, this);

            if (si == null && names.Count == 0)
            {
                if (string.Compare(name, "Create", true) == 0 && this.ctn != typeof(object))
                    si = PascalABCCompiler.NetHelper.NetHelper.GetConstructor(ctn);
                if (si == null)
                {
                    if (pascal_ext_meths.Count > 0)
                    {
                        foreach (SymScope ss in pascal_ext_meths)
                            names.Add(ss);
                        return names;
                    }
                    if (members != null)
                    {
                        return base.FindOverloadNames(name);
                    }
                    else
                        return names;
                }
            }
            switch (si.sym_info.semantic_node_type)
            {
                case semantic_node_type.compiled_function_node:
                    {
                        CompiledMethodScope cms = new CompiledMethodScope(new SymInfo(name, SymbolKind.Method, name), (si.sym_info as compiled_function_node).method_info, this);
                        names.Insert(0, cms);
                        si = si.Next;
                        CompiledMethodScope tmp = cms;
                        SortedDictionary<int, List<CompiledMethodScope>> meths = new SortedDictionary<int, List<CompiledMethodScope>>();
                        if (cms.acc_mod != access_modifer.internal_modifer && cms.acc_mod != access_modifer.private_modifer)
                        {
                            int par_num = cms.mi.GetParameters().Length;
                            meths[par_num] = new List<CompiledMethodScope>();
                            meths[par_num].Add(cms);
                        }
                        while (si != null)
                        {
                            if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private && si.sym_info.semantic_node_type == semantic_node_type.compiled_function_node)
                            {
                                tmp = new CompiledMethodScope(new SymInfo(name, SymbolKind.Method, name), (si.sym_info as compiled_function_node).method_info, this);
                                names.Insert(0, tmp);
                                //tmp.nextProc = cms;
                                //cms = tmp;
                                int par_num = tmp.mi.GetParameters().Length;
                                if (!meths.ContainsKey(par_num)) meths[par_num] = new List<CompiledMethodScope>();
                                meths[par_num].Add(tmp);
                            }
                            si = si.Next;
                        }
                        bool beg = false;
                        tmp = null;
                        cms = null;
                        foreach (List<CompiledMethodScope> lst in meths.Values)
                        {
                            foreach (CompiledMethodScope m in lst)
                            {
                                if (beg == false)
                                {
                                    tmp = m;
                                    cms = tmp;
                                    beg = true;
                                }
                                else
                                {
                                    tmp.nextProc = m;
                                    tmp = tmp.nextProc as CompiledMethodScope;
                                }
                            }
                        }
                    }
                    break;
                case semantic_node_type.compiled_constructor_node:
                    {
                        CompiledConstructorScope cms = new CompiledConstructorScope(new SymInfo("Create", SymbolKind.Method, "Create"), (si.sym_info as compiled_constructor_node).constructor_info, this);
                        names.Insert(0, cms);
                        si = si.Next;
                        CompiledConstructorScope tmp = cms;
                        SortedDictionary<int, List<CompiledConstructorScope>> meths = new SortedDictionary<int, List<CompiledConstructorScope>>();
                        if (cms.acc_mod != access_modifer.internal_modifer && cms.acc_mod != access_modifer.private_modifer)
                        {
                            int par_num = cms.mi.GetParameters().Length;
                            meths[par_num] = new List<CompiledConstructorScope>();
                            meths[par_num].Add(cms);
                        }
                        while (si != null)
                        {
                            if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private && si.sym_info.semantic_node_type == semantic_node_type.compiled_constructor_node)
                            {
                                tmp = new CompiledConstructorScope(new SymInfo("Create", SymbolKind.Method, "Create"), (si.sym_info as compiled_constructor_node).constructor_info, this);
                                //tmp.nextProc = cms;
                                //cms = tmp;
                                names.Insert(0, tmp);
                                int par_num = tmp.mi.GetParameters().Length;
                                if (!meths.ContainsKey(par_num)) meths[par_num] = new List<CompiledConstructorScope>();
                                meths[par_num].Add(tmp);
                            }
                            si = si.Next;
                        }
                        bool beg = false;
                        tmp = null;
                        cms = null;
                        foreach (List<CompiledConstructorScope> lst in meths.Values)
                        {
                            foreach (CompiledConstructorScope m in lst)
                            {
                                if (beg == false)
                                {
                                    tmp = m;
                                    cms = tmp;
                                    beg = true;
                                }
                                else
                                {
                                    tmp.nextProc = m;
                                    tmp = tmp.nextProc as CompiledConstructorScope;
                                }
                            }
                        }
                    }
                    break;
                case semantic_node_type.compiled_variable_definition:
                    if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private)
                        names.Add(new CompiledFieldScope(new SymInfo(name, SymbolKind.Field, name), (si.sym_info as compiled_variable_definition).compiled_field, this));
                    break;
                case semantic_node_type.basic_property_node:
                    if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private)
                        names.Add(new CompiledPropertyScope(new SymInfo(name, SymbolKind.Property, name), (si.sym_info as compiled_property_node).property_info, this));
                    break;
                case semantic_node_type.compiled_class_constant_definition:
                    if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private)
                        names.Add(new CompiledFieldScope(new SymInfo(name, SymbolKind.Constant, name), (si.sym_info as compiled_class_constant_definition).field, this));
                    break;
                case semantic_node_type.compiled_event:
                    if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private)
                        names.Add(new CompiledEventScope(new SymInfo(name, SymbolKind.Constant, name), (si.sym_info as compiled_event).event_info, this));
                    break;
                //case semantic_node_type.compiled_event: return new CompiledScope(null,(si.sym_info as compiled_event).event_info.);
                //case semantic_node_type.compiled_event: return new CompiledScope(null,(si.sym_info as compiled_event).
            }
            
            return names;
        }
Exemple #2
0
 public override SymScope FindName(string name)
 {
     PascalABCCompiler.TreeConverter.SymbolInfo si = PascalABCCompiler.NetHelper.NetHelper.FindNameIncludeProtected(ctn, name);
     if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities)
         return null;
     if (si == null)
     {
         if (string.Compare(name, "Create", true) == 0)
             si = PascalABCCompiler.NetHelper.NetHelper.GetConstructor(ctn);
         if (si == null)
         {
             return null;
         }  
     }
     switch (si.sym_info.semantic_node_type)
     {
         case semantic_node_type.compiled_function_node:
             {
                 CompiledMethodScope cms = new CompiledMethodScope(new SymInfo(name, SymbolKind.Method, name), (si.sym_info as compiled_function_node).method_info, this);
                 si = si.Next;
                 CompiledMethodScope tmp = cms;
                 SortedDictionary<int, List<CompiledMethodScope>> meths = new SortedDictionary<int, List<CompiledMethodScope>>();
                 if (cms.acc_mod != access_modifer.internal_modifer && cms.acc_mod != access_modifer.private_modifer)
                 {
                     int par_num = cms.mi.GetParameters().Length;
                     meths[par_num] = new List<CompiledMethodScope>();
                     meths[par_num].Add(cms);
                 }
                 while (si != null)
                 {
                     if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private && si.sym_info.semantic_node_type == semantic_node_type.compiled_function_node)
                     {
                         tmp = new CompiledMethodScope(new SymInfo(name, SymbolKind.Method, name), (si.sym_info as compiled_function_node).method_info, this);
                         //tmp.nextProc = cms;
                         //cms = tmp;
                         int par_num = tmp.mi.GetParameters().Length;
                         if (!meths.ContainsKey(par_num)) meths[par_num] = new List<CompiledMethodScope>();
                         meths[par_num].Add(tmp);
                     }
                     else if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private && si.sym_info is compiled_property_node)
                     {
                         return new CompiledPropertyScope(new SymInfo(name, SymbolKind.Property, name), (si.sym_info as compiled_property_node).property_info, this);
                     }
                     si = si.Next;
                 }
                 bool beg = false;
                 tmp = null;
                 cms = null;
                 foreach (List<CompiledMethodScope> lst in meths.Values)
                 {
                     foreach (CompiledMethodScope m in lst)
                     {
                         if (beg == false)
                         {
                             tmp = m;
                             cms = tmp;
                             beg = true;
                         }
                         else
                         {
                             tmp.nextProc = m;
                             tmp = tmp.nextProc as CompiledMethodScope;
                         }
                     }
                 }
                 return cms;
             }
         case semantic_node_type.compiled_constructor_node:
             {
                 CompiledConstructorScope cms = new CompiledConstructorScope(new SymInfo("Create", SymbolKind.Method, "Create"), (si.sym_info as compiled_constructor_node).constructor_info, this);
                 si = si.Next;
                 CompiledConstructorScope tmp = cms;
                 SortedDictionary<int, List<CompiledConstructorScope>> meths = new SortedDictionary<int, List<CompiledConstructorScope>>();
                 if (cms.acc_mod != access_modifer.internal_modifer && cms.acc_mod != access_modifer.private_modifer)
                 {
                     int par_num = cms.mi.GetParameters().Length;
                     meths[par_num] = new List<CompiledConstructorScope>();
                     meths[par_num].Add(cms);
                 }
                 while (si != null)
                 {
                     if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private && si.sym_info.semantic_node_type == semantic_node_type.compiled_constructor_node)
                     {
                         tmp = new CompiledConstructorScope(new SymInfo("Create", SymbolKind.Method, "Create"), (si.sym_info as compiled_constructor_node).constructor_info, this);
                         //tmp.nextProc = cms;
                         //cms = tmp;
                         int par_num = tmp.mi.GetParameters().Length;
                         if (!meths.ContainsKey(par_num)) meths[par_num] = new List<CompiledConstructorScope>();
                         meths[par_num].Add(tmp);
                     }
                     si = si.Next;
                 }
                 bool beg = false;
                 tmp = null;
                 cms = null;
                 foreach (List<CompiledConstructorScope> lst in meths.Values)
                 {
                     foreach (CompiledConstructorScope m in lst)
                     {
                         if (beg == false)
                         {
                             tmp = m;
                             cms = tmp;
                             beg = true;
                         }
                         else
                         {
                             tmp.nextProc = m;
                             tmp = tmp.nextProc as CompiledConstructorScope;
                         }
                     }
                 }
                 return cms;
             }
         case semantic_node_type.compiled_variable_definition:
             if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private)
                 return new CompiledFieldScope(new SymInfo(name, SymbolKind.Field, name), (si.sym_info as compiled_variable_definition).compiled_field, this);
             break;
         case semantic_node_type.basic_property_node:
             if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private)
                 return new CompiledPropertyScope(new SymInfo(name, SymbolKind.Property, name), (si.sym_info as compiled_property_node).property_info, this);
             break;
         case semantic_node_type.compiled_class_constant_definition:
             if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private)
                 return new CompiledFieldScope(new SymInfo(name, SymbolKind.Constant, name), (si.sym_info as compiled_class_constant_definition).field, this);
             break;
         case semantic_node_type.compiled_event:
             if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private)
                 return new CompiledEventScope(new SymInfo(name, SymbolKind.Constant, name), (si.sym_info as compiled_event).event_info, this);
             break;
         case semantic_node_type.compiled_type_node:
             if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_protected)
                 return TypeTable.get_compiled_type(new SymInfo(name, SymbolKind.Type, name), (si.sym_info as compiled_type_node).compiled_type);
             break;
         //case semantic_node_type.compiled_event: return new CompiledScope(null,(si.sym_info as compiled_event).event_info.);
         //case semantic_node_type.compiled_event: return new CompiledScope(null,(si.sym_info as compiled_event).
     }
     return null;
 }
Exemple #3
0
        public override SymInfo[] GetNames()
        {
            List<SymInfo> syms = new List<SymInfo>();
            if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities)
                return syms.ToArray();
            MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy);
            if (ctn.IsInterface)
            {
                List<MemberInfo> mems = new List<MemberInfo>();
                mems.AddRange(mis);
                mems.AddRange(typeof(object).GetMembers());
                Type[] types = ctn.GetInterfaces();
                foreach (Type t in types)
                    mems.AddRange(t.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy));
                mis = mems.ToArray();
            }
            if (si.kind != SymbolKind.Type)
            {
                foreach (MemberInfo mi in mis)
                    if (!mi.Name.Contains("$"))
                        switch (mi.MemberType)
                        {
                            case MemberTypes.Method: if (!(mi as MethodInfo).IsSpecialName)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                                    si2 = new CompiledMethodScope(si2, mi as MethodInfo, this).si;
                                    syms.Add(si2);
                                }
                                break;
                            case MemberTypes.Field:
                                {
                                    if (!(mi as FieldInfo).IsSpecialName)
                                    {
                                        SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                                        if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                                        si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                                        syms.Add(si2);
                                    }
                                    //syms.Add(new SymInfo(mi.Name,SymbolKind.Field,mi.Name)); break;
                                }
                                break;
                            case MemberTypes.Property:
                                {
                                    PropertyInfo pi = mi as PropertyInfo;
                                    MethodInfo acc_mi = pi.GetGetMethod(true);
                                    if (acc_mi != null && !acc_mi.IsStatic)
                                    {
                                        SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                                        si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                                        syms.Add(si2);
                                    }
                                    //syms.Add(new SymInfo(mi.Name,SymbolKind.Property,mi.Name));
                                }
                                break;
                            case MemberTypes.Event:
                                {
                                    MethodInfo acc_mi = (mi as EventInfo).GetAddMethod(true);
                                    if (acc_mi.IsPublic && !acc_mi.IsStatic)
                                    {
                                        SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                                        si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                                        syms.Add(si2);
                                    }
                                    //syms.Add(new SymInfo(mi.Name,SymbolKind.Event,mi.Name));
                                }
                                break;
                        }
            }
            else
                foreach (MemberInfo mi in mis)
                    switch (mi.MemberType)
                    {
                        case MemberTypes.Method: if (!((mi as MethodInfo).IsSpecialName) && (mi as MethodInfo).IsStatic)
                            {
                                SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                                si2 = new CompiledMethodScope(si2, mi as MethodInfo, this).si;
                                syms.Add(si2);
                            }
                            break;
                        case MemberTypes.Field:
                            {
                                if ((mi as FieldInfo).IsStatic && !(mi as FieldInfo).IsSpecialName)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                                    if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                                    si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                                    syms.Add(si2);
                                }
                            }
                            break;
                        case MemberTypes.Property:
                            {
                                PropertyInfo pi = mi as PropertyInfo;
                                MethodInfo acc_mi = pi.GetGetMethod(true);
                                if (acc_mi != null && acc_mi.IsStatic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                                    si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                                    syms.Add(si2);
                                }
                            }
                            break;
                        case MemberTypes.Event:
                            {
                                MethodInfo acc_mi = (mi as EventInfo).GetAddMethod(true);
                                if (acc_mi.IsPublic && acc_mi.IsStatic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                                    si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                                    syms.Add(si2);
                                }
                                //syms.Add(new SymInfo(mi.Name,SymbolKind.Event,mi.Name));
                            }
                            break;
                    }

            return syms.ToArray();
        }
Exemple #4
0
 public override SymInfo[] GetNamesAsInObject()
 {
     List<SymInfo> syms = new List<SymInfo>();
     if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities)
         return syms.ToArray();
     MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.Instance);
     foreach (MemberInfo mi in mis)
         if (!mi.Name.Contains("$"))
             switch (mi.MemberType)
             {
                 case MemberTypes.Method: if (!(mi as MethodInfo).IsSpecialName)
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                         si2 = new CompiledMethodScope(si2, mi as MethodInfo, this).si;
                         syms.Add(si2);
                     }
                     break;
                 case MemberTypes.Field:
                     {
                         if (!(mi as FieldInfo).IsSpecialName)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                             if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                             si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                             syms.Add(si2);
                         }
                         //syms.Add(new SymInfo(mi.Name,SymbolKind.Field,mi.Name)); break;
                     }
                     break;
                 case MemberTypes.Property:
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                         si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                         syms.Add(si2);
                         //syms.Add(new SymInfo(mi.Name,SymbolKind.Property,mi.Name));
                     }
                     break;
                 case MemberTypes.Event:
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                         si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                         syms.Add(si2);
                         //syms.Add(new SymInfo(mi.Name,SymbolKind.Event,mi.Name));
                     }
                     break;
             }
     return syms.ToArray();
 }
Exemple #5
0
 public override SymInfo[] GetNamesAsInObject(ExpressionVisitor ev)
 {
     List<SymInfo> syms = new List<SymInfo>();
     if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities)
         return syms.ToArray();
     MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
     List<MemberInfo> members = new List<MemberInfo>();
     members.AddRange(mis);
     IEnumerable<MemberInfo> en = PascalABCCompiler.NetHelper.NetHelper.GetExtensionMethods(ctn);
     members.AddRange(en);
     mis = members.ToArray();
     if (ctn.IsInterface)
     {
         List<MemberInfo> mems = new List<MemberInfo>();
         mems.AddRange(mis);
         mems.AddRange(typeof(object).GetMembers(BindingFlags.Public | BindingFlags.Instance));
         Type[] types = ctn.GetInterfaces();
         foreach (Type t in types)
             mems.AddRange(t.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy));
         mis = mems.ToArray();
     }
     foreach (MemberInfo mi in mis)
         if (!mi.Name.Contains("$"))
             switch (mi.MemberType)
             {
                 case MemberTypes.Method: if (!(mi as MethodInfo).IsSpecialName)
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                         si2 = new CompiledMethodScope(si2, mi as MethodInfo, this).si;
                         if (si2.acc_mod == access_modifer.protected_modifer)
                         {
                             if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                 syms.Add(si2);
                         }
                         else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                             syms.Add(si2);
                     }
                     break;
                 case MemberTypes.Field:
                     {
                         if (!(mi as FieldInfo).IsSpecialName)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                             if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                             si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                             if (si2.acc_mod == access_modifer.protected_modifer)
                             {
                                 if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                     syms.Add(si2);
                             }
                             else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                 syms.Add(si2);
                         }
                     }
                     break;
                 case MemberTypes.Property:
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                         si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                         if (si2.acc_mod == access_modifer.protected_modifer)
                         {
                             if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                 syms.Add(si2);
                         }
                         else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                             syms.Add(si2);
                     }
                     break;
                 case MemberTypes.Event:
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                         si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                         if (si2.acc_mod == access_modifer.protected_modifer)
                         {
                             if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                 syms.Add(si2);
                         }
                         else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                             syms.Add(si2);
                     }
                     break;
             }
     if (implemented_interfaces != null && false)
     {
         foreach (TypeScope ts in implemented_interfaces)
             syms.AddRange(ts.GetNamesAsInObject(ev));
     }
     return syms.ToArray();
 }
Exemple #6
0
        public SymInfo[] GetStaticNames()
        {
            List<SymInfo> syms = new List<SymInfo>();
            if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities)
                return syms.ToArray();
            MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic |/*BindingFlags.Instance|*/BindingFlags.Static | BindingFlags.FlattenHierarchy);

            if (ctn.IsInterface)
            {
                return syms.ToArray();
            }
            foreach (MemberInfo mi in mis)
                if (!mi.Name.Contains("$"))
                    switch (mi.MemberType)
                    {
                        case MemberTypes.Method: if (!(mi as MethodInfo).IsSpecialName && (mi as MethodInfo).IsStatic)
                            {
                                SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                                CompiledMethodScope member = new CompiledMethodScope(si2, mi as MethodInfo, this);
                                si2 = member.si;
                                if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                    syms.Add(si2);
                            }
                            break;
                        case MemberTypes.Field:
                            {
                                if (!(mi as FieldInfo).IsSpecialName && (mi as FieldInfo).IsStatic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                                    if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                                    si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                                    if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                        syms.Add(si2);
                                }
                            }
                            break;
                        case MemberTypes.Constructor:
                            {
                                SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                                CompiledConstructorScope member = new CompiledConstructorScope(si2, mi as ConstructorInfo, this);
                                si2 = member.si;
                                if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                    syms.Add(si2);
                            }
                            break;
                        case MemberTypes.Property:
                            {
                                PropertyInfo pi = mi as PropertyInfo;
                                if (pi.GetGetMethod(true) != null && pi.GetGetMethod(true).IsStatic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                                    si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                                    if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                        syms.Add(si2);
                                }
                            }
                            break;
                        case MemberTypes.Event:
                            {
                                MethodInfo acc_mi = (mi as EventInfo).GetAddMethod(true);
                                if (acc_mi != null && acc_mi.IsStatic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                                    si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                                    syms.Add(si2);
                                    if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                        syms.Add(si2);
                                }
                            }
                            break;
                        case MemberTypes.NestedType:
                            {
                                if ((mi as Type).IsNestedPublic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Type, null);
                                    CompiledScope member = TypeTable.get_compiled_type(si2, mi as Type);
                                    si2 = member.si;
                                    syms.Add(si2);
                                }
                            }
                            break;
                    }
            return syms.ToArray();
        }
Exemple #7
0
 public override SymInfo[] GetNames(ExpressionVisitor ev, PascalABCCompiler.Parsers.KeywordKind keyword, bool called_in_base)
 {
     List<SymInfo> syms = new List<SymInfo>();
     if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities)
         return syms.ToArray();
     MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic |/*BindingFlags.Instance|*/BindingFlags.Static | BindingFlags.FlattenHierarchy);
     List<MemberInfo> constrs = new List<MemberInfo>();
     //constrs.AddRange(ctn.GetNestedTypes(BindingFlags.Public));
     //if (ctn != typeof(object))
     ConstructorInfo[] cis = ctn.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
     foreach (ConstructorInfo ci in cis)
         if (!called_in_base)
             constrs.Add(ci);
         else if (ci.GetParameters().Length > 0)
             constrs.Add(ci);
     constrs.AddRange(mis);
     //constrs.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetExtensionMethods(ctn));
     mis = constrs.ToArray();
     if (ctn.IsInterface)
     {
         return syms.ToArray();
     }
     foreach (MemberInfo mi in mis)
         if (!mi.Name.Contains("$"))
             switch (mi.MemberType)
             {
                 case MemberTypes.Method: if (!(mi as MethodInfo).IsSpecialName && (mi as MethodInfo).IsStatic)
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                         CompiledMethodScope member = new CompiledMethodScope(si2, mi as MethodInfo, this);
                         si2 = member.si;
                         if (si2.acc_mod == access_modifer.protected_modifer)
                         {
                             if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                 syms.Add(si2);
                         }
                         else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                             syms.Add(si2);
                     }
                     break;
                 case MemberTypes.Field:
                     {
                         if (!(mi as FieldInfo).IsSpecialName && (mi as FieldInfo).IsStatic)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                             if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                             si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                             if (si2.acc_mod == access_modifer.protected_modifer)
                             {
                                 if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                     syms.Add(si2);
                             }
                             else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                 syms.Add(si2);
                         }
                     }
                     break;
                 case MemberTypes.Constructor:
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                         CompiledConstructorScope member = new CompiledConstructorScope(si2, mi as ConstructorInfo, this);
                         si2 = member.si;
                         if (si2.acc_mod == access_modifer.protected_modifer)
                         {
                             if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                 syms.Add(si2);
                         }
                         else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                             syms.Add(si2);
                     }
                     break;
                 case MemberTypes.Property:
                     {
                         PropertyInfo pi = mi as PropertyInfo;
                         if (pi.GetGetMethod(true) != null && pi.GetGetMethod(true).IsStatic)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                             si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                             if (si2.acc_mod == access_modifer.protected_modifer)
                             {
                                 if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                     syms.Add(si2);
                             }
                             else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                 syms.Add(si2);
                         }
                     }
                     break;
                 case MemberTypes.Event:
                     {
                         MethodInfo acc_mi = (mi as EventInfo).GetAddMethod(true);
                         if (acc_mi != null && acc_mi.IsStatic)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                             si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                             syms.Add(si2);
                             if (si2.acc_mod == access_modifer.protected_modifer)
                             {
                                 if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                     syms.Add(si2);
                             }
                             else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                 syms.Add(si2);
                         }
                     }
                     break;
                 case MemberTypes.NestedType:
                     {
                         if ((mi as Type).IsNestedPublic)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Type, null);
                             CompiledScope member = TypeTable.get_compiled_type(si2, mi as Type);
                             si2 = member.si;
                             syms.Add(si2);
                         }
                     }
                     break;
             }
     return syms.ToArray();
 }
Exemple #8
0
 public override List<ProcScope> GetAbstractMethods()
 {
     List<ProcScope> syms = new List<ProcScope>();
     MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
     if (ctn.IsInterface)
     {
         List<MemberInfo> mems = new List<MemberInfo>();
         mems.AddRange(mis);
         Type[] tt = ctn.GetInterfaces();
         foreach (Type t in tt)
             mems.AddRange(t.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy));
         mis = mems.ToArray();
     }
     foreach (MemberInfo mi in mis)
         if (!mi.Name.Contains("$"))
             switch (mi.MemberType)
             {
                 case MemberTypes.Method: if (!(mi as MethodInfo).IsStatic)
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                         CompiledMethodScope member = new CompiledMethodScope(si2, mi as MethodInfo, this);
                         si2 = member.si;
                         if ((mi as MethodInfo).IsAbstract || (ctn.IsInterface && (mi as MethodInfo).DeclaringType == ctn))
                         {
                             if (si2.acc_mod == access_modifer.protected_modifer)
                             {
                                 syms.Add(member);
                             }
                             else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                 syms.Add(member);
                         }
                     }
                     break;
             }
     return syms;
 }
Exemple #9
0
 public override SymScope FindName(string s)
 {
     string full_name = name + "." + s;
     bool is_ns = PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(full_name);
     if (is_ns)
     {
         return new NamespaceScope(full_name);
     }
     else
     {
         Type t = PascalABCCompiler.NetHelper.NetHelper.FindType(full_name);
         if (t == null) t = PascalABCCompiler.NetHelper.NetHelper.FindType(full_name + PascalABCCompiler.TreeConverter.compiler_string_consts.generic_params_infix + "1");
         if (t == null) t = PascalABCCompiler.NetHelper.NetHelper.FindType(full_name + PascalABCCompiler.TreeConverter.compiler_string_consts.generic_params_infix + "2");
         if (t != null)
         {
             return TypeTable.get_compiled_type(new SymInfo(s, SymbolKind.Type, full_name), t);
         }
         else
         {
             PascalABCCompiler.TreeConverter.SymbolInfo si = null;
             if (entry_type != null)
             {
                 t = PascalABCCompiler.NetHelper.NetHelper.FindType(entry_type.ctn.Namespace + "." + s);
                 if (t != null) return TypeTable.get_compiled_type(new SymInfo(s, SymbolKind.Type, entry_type.ctn.Namespace + "." + s), t);
                 else
                 {
                     object[] attrs = entry_type.ctn.GetCustomAttributes(false);
                     for (int j = 0; j < attrs.Length; j++)
                         if (attrs[j].GetType().Name == "$GlobAttr")
                         {
                             si = PascalABCCompiler.NetHelper.NetHelper.FindName(entry_type.ctn, s);
                             if (si != null) break;
                         }
                 }
             }
             if (si != null)
                 switch (si.sym_info.semantic_node_type)
                 {
                     case semantic_node_type.compiled_function_node:
                         {
                             CompiledMethodScope cms = new CompiledMethodScope(new SymInfo(s, SymbolKind.Method, s), (si.sym_info as compiled_function_node).method_info, entry_type, true);
                             si = si.Next;
                             CompiledMethodScope tmp = cms;
                             SortedDictionary<int, List<CompiledMethodScope>> meths = new SortedDictionary<int, List<CompiledMethodScope>>();
                             if (cms.acc_mod != access_modifer.internal_modifer && cms.acc_mod != access_modifer.private_modifer)
                             {
                                 int par_num = cms.mi.GetParameters().Length;
                                 meths[par_num] = new List<CompiledMethodScope>();
                                 meths[par_num].Add(cms);
                             }
                             while (si != null)
                             {
                                 if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private && si.sym_info.semantic_node_type == semantic_node_type.compiled_function_node)
                                 {
                                     tmp = new CompiledMethodScope(new SymInfo(s, SymbolKind.Method, s), (si.sym_info as compiled_function_node).method_info, entry_type);
                                     tmp.is_global = true;
                                     //tmp.nextProc = cms;
                                     //cms = tmp;
                                     int par_num = tmp.mi.GetParameters().Length;
                                     if (!meths.ContainsKey(par_num))
                                         meths[par_num] = new List<CompiledMethodScope>();
                                     meths[par_num].Add(tmp);
                                 }
                                 si = si.Next;
                             }
                             bool beg = false;
                             tmp = null;
                             cms = null;
                             foreach (List<CompiledMethodScope> lst in meths.Values)
                             {
                                 foreach (CompiledMethodScope m in lst)
                                 {
                                     if (beg == false)
                                     {
                                         tmp = m;
                                         cms = tmp;
                                         beg = true;
                                     }
                                     else
                                     {
                                         tmp.nextProc = m;
                                         tmp = tmp.nextProc as CompiledMethodScope;
                                     }
                                 }
                             }
                             return cms;
                         }
                     case semantic_node_type.compiled_variable_definition:
                         if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private)
                         {
                             CompiledFieldScope fld = new CompiledFieldScope(new SymInfo(s, SymbolKind.Field, s), (si.sym_info as compiled_variable_definition).compiled_field, entry_type, true);
                             return fld;
                         }
                         break;
                     case semantic_node_type.compiled_class_constant_definition:
                         if (si.access_level != PascalABCCompiler.TreeConverter.access_level.al_internal && si.access_level != PascalABCCompiler.TreeConverter.access_level.al_private)
                         {
                             CompiledFieldScope fld = new CompiledFieldScope(new SymInfo(s, SymbolKind.Constant, s), (si.sym_info as compiled_class_constant_definition).field, entry_type, true);
                             return fld;
                         }
                         break;
                 }
         }
         return null;
     }
 }