Пример #1
0
        private ElementScope GetParameter(ProcScope func)
        {
            int offset = (int)br.BaseStream.Position - start_pos;

            br.ReadByte();
            string    s  = br.ReadString();
            TypeScope tn = GetTypeReference();
            concrete_parameter_type cpt = (concrete_parameter_type)br.ReadByte();
            ElementScope            p   = new ElementScope(new SymInfo(s, SymbolKind.Parameter, s), tn, null, null);
            bool is_params = br.ReadBoolean();

            if (is_params)
            {
                p.param_kind = parametr_kind.params_parametr;
            }
            else
            {
                switch (cpt)
                {
                case concrete_parameter_type.cpt_const: p.param_kind = parametr_kind.const_parametr; break;

                case concrete_parameter_type.cpt_var: p.param_kind = parametr_kind.var_parametr; break;

                case concrete_parameter_type.cpt_none: p.param_kind = parametr_kind.none; break;
                }
            }
            br.ReadBoolean();
            if (CanReadObject())
            {
                br.ReadInt32(); //CreateExpression();
            }
            br.ReadInt32();     //attributes
            //members[offset] = p;
            return(p);
        }
Пример #2
0
        public static string GetParamNames(ProcScope mi)
        {
            StringBuilder sb = new StringBuilder();

            if (mi.parameters.Count > 0)
            {
                sb.Append("(");
                for (int i = 0; i < mi.parameters.Count; i++)
                {
                    SymScope typ = mi.parameters[i].sc;
                    if (typ is TypeScope)
                    {
                        sb.Append(GetTypeName(typ as TypeScope));
                    }
                    if (mi.parameters[i].param_kind == PascalABCCompiler.SyntaxTree.parametr_kind.var_parametr || mi.parameters[i].param_kind == PascalABCCompiler.SyntaxTree.parametr_kind.const_parametr)
                    {
                        sb.Append('@');
                    }
                    if (i < mi.parameters.Count - 1)
                    {
                        sb.Append(',');
                    }
                }
                sb.Append(")");
            }
            return(sb.ToString());
        }
Пример #3
0
 public static string GetDocumentation(ProcScope mi)
 {
     try
     {
         if (mi.declaringUnit != null)
         {
             CodeCompletionTools.XmlDoc xdoc = (CodeCompletionTools.XmlDoc)ht[mi.declaringUnit];
             if (xdoc != null)
             {
                 string s = "";
                 if (mi.declaringType != null)
                 {
                     if (!mi.is_constructor)
                     {
                         s = GetNormalHint(xdoc.GetDocumentation("M:" + mi.declaringType.si.name + "." + mi.si.name + GetParamNames(mi), true));
                     }
                     else
                     {
                         s = GetNormalHint(xdoc.GetDocumentation("M:" + mi.declaringType.si.name + ".#ctor" + GetParamNames(mi), true));
                     }
                 }
                 else
                 {
                     s = GetNormalHint(xdoc.GetDocumentation("M:" + mi.name + GetParamNames(mi), true));
                 }
                 return(s);
             }
         }
     }
     catch (Exception e)
     {
     }
     return("");
 }
Пример #4
0
        private void GetLocalVariable(ProcScope func)
        {
            int offset = (int)br.BaseStream.Position - start_pos;

            //int tmp=br.ReadByte();
            br.ReadString();
            GetTypeReference();
            br.ReadBoolean();
            //members[offset] = lv;
            if (CanReadObject())
            {
                br.ReadInt32();
            }
            //CreateExpression();
            return;
        }
Пример #5
0
        private static string GetDelegateName(ProcScope value)
        {
            StringBuilder sb = new StringBuilder();

            if (value.return_type != null)
            {
                sb.Append("@function");
            }
            else
            {
                sb.Append("@procedure");
            }
            sb.Append(GetParamNames(value));
            if (value.return_type != null)
            {
                sb.Append(":" + GetTypeName(value.return_type));
            }
            return(sb.ToString());
        }
Пример #6
0
        private ProcScope CreateInterfaceNamespaceFunction(string name, int offset)
        {
            //Console.WriteLine(name);
            ProcScope cnfn = new ProcScope(name, cur_scope);

            cnfn.declaringUnit = root_scope;
            if (CanReadObject())
            {
                br.ReadInt32();
            }
            br.ReadBoolean(); //ïðîïóñêàåì ôëàã - èíòåðôåéñíîñòè
            br.ReadInt32();   //name index
            bool is_generic = br.ReadBoolean();

            if (is_generic)
            {
                throw new NotSupportedException();
            }
            if (br.ReadByte() == 1)
            {
                cnfn.return_type = GetTypeReference();
                GetLocalVariable(cnfn);
            }
            int num_par = br.ReadInt32();

            for (int i = 0; i < num_par; i++)
            {
                cnfn.parameters.Add(GetParameter(cnfn));
            }
            br.ReadInt32();             //namespace
            br.ReadInt32();             //attributes
            cnfn.is_forward = br.ReadBoolean();
            cnfn.Complete();
            AddMember(cnfn, offset);
            return(cnfn);
        }
Пример #7
0
        private ProcScope CreateInterfaceMethod(string name, int offset)
        {
            ProcScope cmn = members[offset] as ProcScope;

            if (cmn != null)
            {
                return(cmn);
            }
            cmn = new ProcScope(name, cur_scope);
            cmn.declaringUnit = root_scope;
            //members[offset] = cmn;
            AddMember(cmn, offset);

            int name_ref = br.ReadInt32();

            br.ReadByte();
            br.ReadByte();
            bool is_generic = br.ReadBoolean();

            if (is_generic)
            {
                throw new NotSupportedException();
            }
            //ssyy

            //\ssyy

            if (br.ReadByte() == 1) //return_value_type
            {
                cmn.return_type = GetTypeReference();
                if (br.ReadByte() == 1)
                {
                    GetLocalVariable(cmn);
                }
            }
            int num_par = br.ReadInt32();

            for (int i = 0; i < num_par; i++)
            {
                cmn.parameters.Add(GetParameter(cmn));
            }
            br.ReadInt32();
            br.ReadInt32();
            cmn.is_constructor = br.ReadBoolean();
            cmn.is_forward     = br.ReadBoolean();
            br.ReadBoolean();
            PascalABCCompiler.SemanticTree.field_access_level fal = (PascalABCCompiler.SemanticTree.field_access_level)br.ReadByte();
            PascalABCCompiler.SemanticTree.polymorphic_state  ps  = (PascalABCCompiler.SemanticTree.polymorphic_state)br.ReadByte();
            switch (fal)
            {
            case PascalABCCompiler.SemanticTree.field_access_level.fal_internal: cmn.acc_mod = access_modifer.internal_modifer; break;

            case PascalABCCompiler.SemanticTree.field_access_level.fal_private: cmn.acc_mod = access_modifer.private_modifer; return(null);

            case PascalABCCompiler.SemanticTree.field_access_level.fal_protected: cmn.acc_mod = access_modifer.protected_modifer; break;

            case PascalABCCompiler.SemanticTree.field_access_level.fal_public: cmn.acc_mod = access_modifer.public_modifer; break;
            }

            switch (ps)
            {
            case PascalABCCompiler.SemanticTree.polymorphic_state.ps_static: cmn.is_static = true; break;

            case PascalABCCompiler.SemanticTree.polymorphic_state.ps_virtual: cmn.is_virtual = true; break;
            }
            br.ReadInt32(); br.ReadInt32();
            cmn.is_override = br.ReadBoolean() == true;
            cmn.Complete();
            return(cmn);
        }
Пример #8
0
 public static void AddDescribeToComplete(ProcScope value)
 {
     elem_cache.Add(value);
 }