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());
        }
Example #2
0
        public SymScope CreateInterfaceInClassMember(string name, int offset)
        {
            SymScope dn = members[offset] as SymScope;

            if (dn != null)
            {
                return(dn);
            }
            int tmp = (int)br.BaseStream.Position;

            br.BaseStream.Seek(start_pos + offset, SeekOrigin.Begin);
            semantic_node_type snt = (semantic_node_type)br.ReadByte();

            switch (snt)
            {
            case semantic_node_type.class_field:
                dn = CreateInterfaceClassField(name, offset); break;

            case semantic_node_type.common_property_node:
                dn = CreateInterfaceProperty(name, offset); break;

            case semantic_node_type.common_method_node:
                dn = CreateInterfaceMethod(name, offset); break;
                //case semantic_node_type.class_constant_definition:
                //    dn = CreateInterfaceClassConstantDefinition(name, offset); break;
            }
            br.BaseStream.Seek(tmp, SeekOrigin.Begin);
            //ProcessWaitedToRestoreFields();
            return(dn);
        }
Example #3
0
 public SymScope GetUnit(string FileName)
 {
     try
     {
         root_scope = unit_cache[FileName] as SymScope;
         if (root_scope != null)
         {
             return(root_scope);
         }
         unit_name          = System.IO.Path.GetFileNameWithoutExtension(FileName);
         this.readDebugInfo = true;
         this.FileName      = FileName;
         if (!File.Exists(FileName))
         {
             return(null);
         }
         dir = System.IO.Path.GetDirectoryName(FileName);
         fs  = new FileStream(FileName, FileMode.Open, FileAccess.Read);
         br  = new BinaryReader(fs);
         ReadPCUHeader();
         root_scope           = new InterfaceUnitScope(new SymInfo(unit_name, SymbolKind.Namespace, unit_name), null);
         unit_cache[FileName] = root_scope;
         cur_scope            = root_scope;
         AddReferencedAssemblies();
         ReadInterfacePart();
         fs.Close();
     }
     catch (Exception e)
     {
         fs.Close();
         return(root_scope);
     }
     return(root_scope);
 }
Example #4
0
        private void RestoreAllMembers(TypeScope scope)
        {
            int       num = br.ReadInt32();
            Hashtable ht  = new Hashtable();

            for (int i = 0; i < num; i++)
            {
                string   name   = br.ReadString();
                int      offset = br.ReadInt32();
                SymScope tmp    = cur_scope;
                cur_scope = scope;
                SymScope ss = CreateInterfaceInClassMember(name, offset);
                br.ReadByte();
                br.ReadByte();
                if (ht.ContainsKey(name) && ss is ProcScope)
                {
                    (ht[name] as ProcScope).nextProc = ss as ProcScope;
                    ht[name] = ss;
                }
                else if (ss is ProcScope)
                {
                    ht[name] = ss;
                }
                cur_scope = tmp;
                if (ss != null)
                {
                    scope.AddName(name, ss);
                }
            }
        }
Example #5
0
        private void ReadInterfaceEntity(NameRef nr)
        {
            SymScope ss = CreateInterfaceMember(nr.offset, nr.name);

            if (ss != null)
            {
                cur_scope.AddName(nr.name, ss);
            }
        }
Example #6
0
 public int GetRootScope(out ISymUnmanagedScope retVal)
 {
     _method.GetRootScope(out retVal);
     if (retVal != null)
     {
         retVal = new SymScope(_reader, retVal);
     }
     return(SymUnmanagedReaderExtensions.S_OK);
 }
Example #7
0
 private SymScope(SymScope parent, int endOffset, int startOffset)
 {
     // Create a new child scope.
     this.method      = parent.method;
     this.parent      = parent;
     this.children    = new ISymbolScope [0];
     this.locals      = new ISymbolVariable [0];
     this.endOffset   = endOffset;
     this.startOffset = startOffset;
 }
	private SymScope(SymScope parent, int endOffset, int startOffset)
			{
				// Create a new child scope.
				this.method = parent.method;
				this.parent = parent;
				this.children = new ISymbolScope [0];
				this.locals = new ISymbolVariable [0];
				this.endOffset = endOffset;
				this.startOffset = startOffset;
			}
Example #9
0
        void ChangeInternal()
        {
            bool first_comp;

            CodeCompletion.DomConverter dconv = null;
            bool tmp = true;

            while (true)
            {
                first_comp = false;
                if (this.Visible)
                {
                    try
                    {
                        if (currentCompilationUnit == null && textAreaControl.FileName != null)
                        {
                            dconv = (CodeCompletion.DomConverter)CodeCompletion.CodeCompletionController.comp_modules[textAreaControl.FileName];
                            if (dconv != null && dconv.is_compiled)
                            {
                                currentCompilationUnit = dconv.visitor.entry_scope;
                                first_comp             = true;
                            }
                            if (clicked || tmp)
                            {
                                FillClassComboBox(true);
                                //clicked = false;
                                tmp = false;
                            }
                        }
                        if (currentCompilationUnit != null && (clicked || first_comp))
                        {
                            dconv = (CodeCompletion.DomConverter)CodeCompletion.CodeCompletionController.comp_modules[textAreaControl.FileName];
                            if (dconv != null && dconv.is_compiled)
                            {
                                currentCompilationUnit = dconv.visitor.entry_scope;
                                FillClassComboBox(true);
                            }

                            //FillMembersComboBox();
                            //UpdateClassComboBox();
                            //UpdateMembersComboBox();
                        }
                        //lock(clicked)
                        {
                            clicked = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        //MessageService.ShowError(ex);
                    }
                }
                Thread.Sleep(300);
            }
        }
Example #10
0
        private void PrintFieldValues()
        {
            var names = SymScope.GetSymbolNames();

            for (var ndx = 0; ndx < names.Count; ndx++)
            {
                var name = names[ndx];
                var obj  = Ctx.Memory.Get <object>(name);
                Console.WriteLine(name + ":" + ((LObject)obj).GetValue().ToString());
            }
        }
Example #11
0
 public int GetChildren(int cChildren, out int pcChildren, ISymUnmanagedScope[] children)
 {
     _scope.GetChildren(cChildren, out pcChildren, children);
     if (children != null)
     {
         for (int i = 0; i < pcChildren; i++)
         {
             children[i] = new SymScope(_reader, children[i]);
         }
     }
     return(SymUnmanagedReaderExtensions.S_OK);
 }
Example #12
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.textAreaControl.ActiveTextAreaControl.Caret.PositionChanged -= new EventHandler(CaretPositionChanged);
         this.membersComboBox.Dispose();
         this.classComboBox.Dispose();
         this.currentCompilationUnit = null;
         th.Abort();
     }
     base.Dispose(disposing);
 }
Example #13
0
 public ComboBoxItem(SymScope item, string text, int iconIndex, bool isInCurrentPart, bool is_global)
 {
     this.item = item;
     if (item != null)
     {
         pos = item.GetPosition();
     }
     this.text            = text;
     this.iconIndex       = iconIndex;
     this.isInCurrentPart = true;
     this.is_global       = is_global;
 }
Example #14
0
        // Insert a new scope into this one at a particular position.
        private SymScope InsertScope(int index, int endOffset, int startOffset)
        {
            SymScope scope = new SymScope(this, endOffset, startOffset);

            ISymbolScope[] newChildren;
            newChildren = new ISymbolScope [children.Length + 1];
            Array.Copy(children, 0, newChildren, 0, index);
            Array.Copy(children, index, newChildren, index + 1,
                       children.Length - index);
            newChildren[index] = scope;
            children           = newChildren;
            return(scope);
        }
        public static void LoadWithSources(SymScope unit, string fileName)
        {
            if (ht[unit] != null)
            {
                return;
            }
            string xml_loc = CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(fileName, CodeCompletionController.currentLanguageISO);

            if (xml_loc != null)
            {
                CodeCompletionTools.XmlDoc xdoc = CodeCompletionTools.XmlDoc.Load(xml_loc, Environment.GetEnvironmentVariable("TEMP"), false);
                ht[unit] = xdoc;
            }
        }
Example #16
0
        void GetClassMembers(SymScope ss, ArrayList items)
        {
            if (ss != null && ss.members != null)
            {
                ArrayList meths  = new ArrayList();
                ArrayList fields = new ArrayList();
                ArrayList events = new ArrayList();
                ArrayList vars   = new ArrayList();
                ArrayList props  = new ArrayList();
                ArrayList consts = new ArrayList();
                foreach (SymScope el in ss.members)
                {
                    //if (el.si.kind == SymbolKind.Method || el.si.kind == SymbolKind.Constant || el.si.kind == SymbolKind.Variable || el.si.kind == SymbolKind.Event || el.si.kind == SymbolKind.Field
                    //|| el.si.kind == SymbolKind.Property)
                    if (el.GetPosition().file_name != null)
                    {
                        ComboBoxItem cbi = new ComboBoxItem(el, el.GetDescriptionWithoutDoc(), CodeCompletionProvider.ImagesProvider.GetPictureNum(el.si), true, false);
                        switch (el.si.kind)
                        {
                        case SymbolKind.Method: meths.Add(cbi); break;

                        case SymbolKind.Field: fields.Add(cbi); break;

                        case SymbolKind.Property: props.Add(cbi); break;

                        case SymbolKind.Variable: vars.Add(cbi); break;

                        case SymbolKind.Event: events.Add(cbi); break;

                        case SymbolKind.Constant: consts.Add(cbi); break;
                        }
                        //items.Add(new ComboBoxItem(el,el.GetDescriptionWithoutDoc(),CodeCompletionProvider.ImagesProvider.GetPictureNum(el.si),true));
                    }
                }
                meths.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
                items.AddRange(meths);
                props.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
                items.AddRange(props);
                fields.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
                items.AddRange(fields);
                vars.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
                items.AddRange(vars);
                consts.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
                items.AddRange(consts);
                events.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
                items.AddRange(events);
            }
        }
 public static string GetDocumentation(SymScope unit, string descr)
 {
     try
     {
         CodeCompletionTools.XmlDoc xdoc = (CodeCompletionTools.XmlDoc)ht[unit];
         if (xdoc != null)
         {
             string s = GetNormalHint(xdoc.GetDocumentation(descr, false));
             return(s);
         }
     }
     catch (Exception e)
     {
     }
     return("");
 }
 private static void internalCompleteDocumentation()
 {
     try
     {
         if (dispatcher == null)
         {
             return;
         }
         for (int i = 0; i < elem_cache.Count; i++)
         {
             SymScope ss = elem_cache[i];
             if (ss.si.has_doc)
             {
                 continue;
             }
             if (ss is TypeScope)
             {
                 ss.si.description += "\n" + UnitDocCache.GetDocumentation(ss as TypeScope);
                 ss.si.has_doc      = true;
                 dispatcher.Update(ss.si);
             }
             else if (ss is ElementScope)
             {
                 ss.si.description += "\n" + UnitDocCache.GetDocumentation(ss as ElementScope);
                 ss.si.has_doc      = true;
                 dispatcher.Update(ss.si);
             }
             else if (ss is ProcScope)
             {
                 ss.si.description += "\n" + UnitDocCache.GetDocumentation(ss as ProcScope);
                 ss.si.has_doc      = true;
                 dispatcher.Update(ss.si);
             }
             else if (ss is InterfaceUnitScope)
             {
                 ss.si.description += "\n" + UnitDocCache.GetDocumentation(ss as InterfaceUnitScope);
                 ss.si.has_doc      = true;
                 dispatcher.Update(ss.si);
             }
         }
     }
     catch (Exception)
     {
     }
 }
Example #19
0
        // Find or create a particular scope underneath this one.
        internal SymScope FindScope(int endOffset, int startOffset)
        {
            int posn = 0;

            while (posn < children.Length)
            {
                if (endOffset <= children[posn].StartOffset)
                {
                    // Insert a new scope before this one.
                    return(InsertScope(posn, endOffset, startOffset));
                }
                else if (startOffset >= children[posn].EndOffset)
                {
                    // Insert a new scope after this one.
                    return(InsertScope(posn + 1, endOffset, startOffset));
                }
                else if (startOffset == children[posn].StartOffset &&
                         endOffset == children[posn].EndOffset)
                {
                    // We already have this scope.
                    return((SymScope)(children[posn]));
                }
                else if (startOffset <= children[posn].StartOffset &&
                         endOffset >= children[posn].EndOffset)
                {
                    // The child scope is completely contained,
                    // so we need to insert a new scope level.
                    SymScope scope = new SymScope
                                         (this, endOffset, startOffset);
                    scope.children    = new ISymbolScope [1];
                    scope.children[0] = children[posn];
                    children[posn]    = scope;
                    return(scope);
                }
                else
                {
                    // Insert within a child scope.
                    return(((SymScope)(children[posn]))
                           .FindScope(endOffset, startOffset));
                }
                ++posn;
            }
            return(InsertScope(children.Length, endOffset, startOffset));
        }
 public static void AddDescribeToComplete(SymScope value)
 {
     if (value is TypeScope)
     {
         AddDescribeToComplete(value as TypeScope);
     }
     else if (value is ProcScope)
     {
         AddDescribeToComplete(value as ProcScope);
     }
     else if (value is ElementScope)
     {
         AddDescribeToComplete(value as ElementScope);
     }
     else if (value is InterfaceUnitScope)
     {
         AddDescribeToComplete(value as InterfaceUnitScope);
     }
 }
Example #21
0
        public SymScope CreateInterfaceMember(int offset, string name)
        {
            /*definition_node dn = (definition_node)members[offset];
             * if (dn != null)
             * {
             * //DarkStar Addes 06/03/07
             * PCUWriter.AddExternalMember(dn, offset);
             * return dn;
             * }*/
            SymScope dn = null;

            br.BaseStream.Seek(start_pos + offset, SeekOrigin.Begin);
            semantic_node_type snt = (semantic_node_type)br.ReadByte();

            switch (snt)
            {
            case semantic_node_type.namespace_variable:
                dn = CreateInterfaceNamespaceVariable(name, offset); break;

            case semantic_node_type.common_namespace_function_node:
                dn = CreateInterfaceNamespaceFunction(name, offset); break;

            case semantic_node_type.common_type_node:
                dn = CreateInterfaceCommonType(name, offset); break;

            case semantic_node_type.namespace_constant_definition:
                dn = CreateInterfaceConstantDefinition(name, offset); break;

                /*case semantic_node_type.compiled_type_node:
                 *  dn = CreateCompiledTypeNode(offset); break;
                 * //ssyy
                 * case semantic_node_type.template_type:
                 *  dn = CreateTemplateClass(offset); break;
                 * //\ssyy
                 * case semantic_node_type.ref_type_node:
                 *  dn = CreateRefType(offset); break;*/
            }
            br.BaseStream.Seek(start_pos, SeekOrigin.Begin);
            //PCUWriter.AddExternalMember(dn,offset);//ñîîáùàåì âðàéòåðó íîâîå ñìåùåíèå ñóùíîñòè
            //åñëè áóäåò ñåðèàëèçîâûâàòüñÿ ìîäóëü â êîòîðîì èñïîëüçóþòñÿ ñóùíîñòè .pcu, îí äîëæåí çíàòü èõ ñìåùåíèÿ
            //ProcessWaitedToRestoreFields();
            return(dn);
        }
Example #22
0
        void FillMembersComboBox()
        {
            ArrayList items = new ArrayList();
            SymScope  ss    = GetCurrentSelectedClass();

            if (ss == null)
            {
                GetGlobalUnitMembers(items);
                //items.Sort(0,items.Count,new Comparer(System.Globalization.CultureInfo.InvariantCulture));
            }
            else
            {
                GetClassMembers(ss, items);
                //items.Sort(0,items.Count,new Comparer(System.Globalization.CultureInfo.InvariantCulture));
            }
            membersComboBox.Invoke(new Invoke_del(Member_Invoke_Update));
            membersComboBox.Invoke(new Invoke_del(Member_Invoke_Clear));
            //membersComboBox.Items.AddRange(items.ToArray());
            membersComboBox.Invoke(new Invoke_param_del(AddItemsToMembersComboboxInternal), items);
            UpdateMembersComboBox();
            membersComboBox.Invoke(new Invoke_del(Member_Invoke_EndUpdate));
        }
Example #23
0
 internal SymVariable(String name, int ilOffset, SymScope scope)
 {
     this.name     = name;
     this.ilOffset = ilOffset;
     this.scope    = scope;
 }
Example #24
0
	// Insert a new scope into this one at a particular position.
	private SymScope InsertScope(int index, int endOffset, int startOffset)
			{
				SymScope scope = new SymScope(this, endOffset, startOffset);
				ISymbolScope[] newChildren;
				newChildren = new ISymbolScope [children.Length + 1];
				Array.Copy(children, 0, newChildren, 0, index);
				Array.Copy(children, index, newChildren, index + 1,
						   children.Length - index);
				newChildren[index] = scope;
				children = newChildren;
				return scope;
			}
Example #25
0
	// Find or create a particular scope underneath this one.
	internal SymScope FindScope(int endOffset, int startOffset)
			{
				int posn = 0;
				while(posn < children.Length)
				{
					if(endOffset <= children[posn].StartOffset)
					{
						// Insert a new scope before this one.
						return InsertScope(posn, endOffset, startOffset);
					}
					else if(startOffset >= children[posn].EndOffset)
					{
						// Insert a new scope after this one.
						return InsertScope(posn + 1, endOffset, startOffset);
					}
					else if(startOffset == children[posn].StartOffset &&
							endOffset == children[posn].EndOffset)
					{
						// We already have this scope.
						return (SymScope)(children[posn]);
					}
					else if(startOffset <= children[posn].StartOffset &&
							endOffset >= children[posn].EndOffset)
					{
						// The child scope is completely contained,
						// so we need to insert a new scope level.
						SymScope scope = new SymScope
							(this, endOffset, startOffset);
						scope.children = new ISymbolScope [1];
						scope.children[0] = children[posn];
						children[posn] = scope;
						return scope;
					}
					else
					{
						// Insert within a child scope.
						return ((SymScope)(children[posn]))
							.FindScope(endOffset, startOffset);
					}
					++posn;
				}
				return InsertScope(children.Length, endOffset, startOffset);
			}
Example #26
0
 private void AddMember(SymScope ss, int offset)
 {
     members[offset] = ss;
 }
Example #27
0
        public ISymbolScope[] GetChildren()
        {
            int count;
            m_target.GetChildren(0, out count, null);
            ISymUnmanagedScope[] uScopes = new ISymUnmanagedScope[count];
            m_target.GetChildren(count, out count, uScopes);

            int i;
            ISymbolScope[] scopes = new ISymbolScope[count];
            for (i = 0; i < count; i++)
            {
                scopes[i] = new SymScope(uScopes[i]);
            }
            return scopes;
        }
	internal SymVariable(String name, int ilOffset, SymScope scope)
			{
				this.name = name;
				this.ilOffset = ilOffset;
				this.scope = scope;
			}
 public static void RemoveItem(SymScope item)
 {
     elem_cache.Remove(item);
 }
Example #30
0
        // Parse a function or subroutine parameter declaration and return an
        // array of symbols for all parameters
        Collection<Symbol> ParseParameterDecl(SymbolCollection symbolTable, SymScope scope, out int countOfAlternateReturn)
        {
            SimpleToken token = _ls.GetToken();
            Collection<Symbol> parameters = new Collection<Symbol>();

            countOfAlternateReturn = 0;
            if (token.ID == TokenID.LPAREN) {
                if (_ls.PeekToken().ID != TokenID.RPAREN) {
                    do {
                        if (_ls.PeekToken().ID == TokenID.STAR) {
                            SkipToken(TokenID.STAR);
                            ++countOfAlternateReturn;
                        } else {
                            IdentifierToken identToken = ExpectIdentifierToken();
                            if (identToken != null) {
                                Symbol sym = symbolTable.Get(identToken.Name);
                                if (sym != null) {
                                    _messages.Error(MessageCode.PARAMETERDEFINED, String.Format("Parameter {0} already defined", identToken.Name));
                                } else {
                                    sym = symbolTable.Add(identToken.Name, new SymFullType(), SymClass.VAR, null, _ls.LineNumber);
                                    sym.Scope = scope;
                                    if (!sym.IsArray && !sym.IsMethod && sym.IsValueType) {
                                        sym.Linkage = SymLinkage.BYREF;
                                    }
                                    parameters.Add(sym);
                                }
                                if (countOfAlternateReturn > 0) {
                                    _messages.Error(MessageCode.ALTRETURNORDER, "Alternate return markers must be at the end");
                                }
                            }
                        }
                        token = _ls.GetToken();
                    } while (token.ID == TokenID.COMMA);
                    _ls.BackToken();
                }
                ExpectToken(TokenID.RPAREN);
            } else {
                _ls.BackToken();
            }
            return parameters;
        }