Beispiel #1
0
            public bool FindIdentifier(string name, IdentifierType type, out IdentifierSearchResult res)
            {
                res = new Assemble.IdentifierSearchResult();
                switch (this.Type)
                {
                case enumStatementType.Instruction:
                {
                    if (Instruction.FindIdentifier(name, type, out res))
                    {
                        return(true);
                    }
                }
                break;

                case enumStatementType.Block:
                {
                    //Don't search sub block's contents
                    if (Block.FindIdentifierOfThis(name, type, out res))
                    {
                        return(true);
                    }
                }
                break;
                }

                return(false);
            }
Beispiel #2
0
        public bool FindIdentifier(string name, IdentifierType type, out IdentifierSearchResult res)
        {
            res = new Assemble.IdentifierSearchResult();
            if (type.HasFlag(IdentifierType.ReferencingAddress) && this.Name == name)
            {
                res.Type = IdentifierType.ReferencingAddress;
                res.AddressIdentifier = this.PlacedInfo;
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        private void RegisterIdentifierToCache(string name, IdentifierSearchResult identifier)
        {
            ConcurrentDictionary <string, IdentifierSearchResult> nameDic;

            if (!this.SymbolFindCacheTable.TryGetValue(identifier.Type, out nameDic))
            {
                nameDic = new ConcurrentDictionary <string, IdentifierSearchResult>();
                this.SymbolFindCacheTable.TryAdd(identifier.Type, nameDic);
            }

            nameDic.TryAdd(name, identifier);
        }
Beispiel #4
0
        public bool FindIdentifier(string name, IdentifierType type, out IdentifierSearchResult res)
        {
            res = new IdentifierSearchResult();

            if (type.HasFlag(IdentifierType.ReferencingSymbol) && name == this.Name)
            {
                res.ImmediateIdentifier = this;
                res.Type = IdentifierType.ReferencingSymbol;
                return(true);
            }

            return(false);
        }
Beispiel #5
0
        public bool FindIdentifier(string name, IdentifierType type, out IdentifierSearchResult res)
        {
            res = new Assemble.IdentifierSearchResult();
            foreach (var sect in Sections)
            {
                if (sect.FindIdentifier(name, type, out res, false)) //Do not re-search this root code
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #6
0
            public bool FindIdentifier(string name, IdentifierType type, out IdentifierSearchResult res)
            {
                res = new Assemble.IdentifierSearchResult();
                //Labels
                foreach (var lbl in Labels)
                {
                    if (lbl.FindIdentifier(name, type, out res))
                    {
                        return(true);
                    }
                }

                return(false);
            }
Beispiel #7
0
        public bool FindIdentifierOfThis(string name, IdentifierType type, out IdentifierSearchResult res)
        {
            res = new Assemble.IdentifierSearchResult();
            if (type.HasFlag(IdentifierType.ReferencingAddress) && this.Name == name)
            {
                res.Type = IdentifierType.ReferencingAddress;
                res.AddressIdentifier = this.PlacedInfo;
                return(true);
            }

            foreach (var lbl in this.Labels)
            {
                if (lbl.FindIdentifier(name, type, out res))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #8
0
        /// <summary>
        /// この命令の中に指定された識別子によって参照されるものがあるか検索します
        /// </summary>
        public bool FindIdentifier(string name, IdentifierType type, out IdentifierSearchResult res)
        {
            res = new Assemble.IdentifierSearchResult();
            //Operands
            foreach (var opr in Operands)
            {
                if (opr.FindIdentifier(name, type, out res))
                {
                    return(true);
                }
            }

            //Labels
            for (int lblIdx = 0; lblIdx < Labels.Count; lblIdx++)
            {
                if (Labels[lblIdx].FindIdentifier(name, type, out res))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #9
0
        public bool FindIdentifier(string name, IdentifierType type, out IdentifierSearchResult res, bool recursiveToRoot)
        {
            res = new IdentifierSearchResult();
            {
                int  typeFlagPos  = 0;
                uint typeFlagRest = (uint)type;
                while (typeFlagRest != 0)
                {
                    ConcurrentDictionary <string, IdentifierSearchResult> nameDic;
                    if (SymbolFindCacheTable.TryGetValue((IdentifierType)(1 << typeFlagPos), out nameDic) &&
                        nameDic.TryGetValue(name, out res))
                    {
                        return(true);
                    }
                    typeFlagRest >>= 1;
                    typeFlagPos++;
                }
            }

            //Statements
            foreach (var stmt in Statements)
            {
                if (stmt.FindIdentifier(name, type, out res))
                {
                    RegisterIdentifierToCache(name, res);
                    return(true);
                }
            }

            //Variables
            foreach (var varbl in Variables)
            {
                if (varbl.FindIdentifier(name, type, out res))
                {
                    RegisterIdentifierToCache(name, res);
                    return(true);
                }
            }

            //Symbols
            foreach (var symbl in Symbols)
            {
                if (symbl.FindIdentifier(name, type, out res))
                {
                    RegisterIdentifierToCache(name, res);
                    return(true);
                }
            }

            //This block (last)
            if (FindIdentifierOfThis(name, type, out res))
            {
                RegisterIdentifierToCache(name, res);
                return(true);
            }

            //Parent block or sections
            if (ParentBlock != null)
            {
                if (ParentBlock.FindIdentifier(name, type, out res))
                {
                    RegisterIdentifierToCache(name, res);
                    return(true);
                }
            }
            else
            {
                if (recursiveToRoot)
                {
                    if (RootCode.FindIdentifier(name, type, out res))
                    {
                        RegisterIdentifierToCache(name, res);
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #10
0
 public bool FindIdentifier(string name, IdentifierType type, out IdentifierSearchResult res)
 {
     return(FindIdentifier(name, type, out res, true));
 }