findTypeByName() public method

Provides the type which corresponds to the given name
public findTypeByName ( string name ) : Type
name string
return Type
Exemplo n.º 1
0
        /// <summary>
        ///     Combines two types to create a new one
        /// </summary>
        /// <param name="right"></param>
        /// <returns></returns>
        public override Type CombineType(Type right, BinaryExpression.Operator Operator)
        {
            Type retVal = null;

            if (Operator == BinaryExpression.Operator.Mult)
            {
                if (FullName.CompareTo("Default.BaseTypes.Speed") == 0 &&
                    right.FullName.CompareTo("Default.BaseTypes.Time") == 0)
                {
                    NameSpace nameSpace = EnclosingNameSpaceFinder.find(this);
                    retVal = nameSpace.findTypeByName("Distance");
                }
            }
            else
            {
                if (IsDouble())
                {
                    if (right == EFSSystem.DoubleType)
                    {
                        retVal = this;
                    }
                }
                else
                {
                    if (right == EFSSystem.IntegerType)
                    {
                        retVal = this;
                    }
                }
            }

            return(retVal);
        }
        /// <summary>
        /// Provides the type associated to the name
        /// </summary>
        /// <param name="nameSpace">the namespace in which the name should be found</param>
        /// <param name="name"></param>
        /// <returns></returns>
        public Types.Type findType(Types.NameSpace nameSpace, string name)
        {
            Types.Type retVal = null;

            if (name != null)
            {
                if (nameSpace != null)
                {
                    if (!cache.ContainsKey(nameSpace))
                    {
                        cache[nameSpace] = new Dictionary <string, Types.Type>();
                    }
                    Dictionary <string, Types.Type> subCache = cache[nameSpace];

                    if (!subCache.ContainsKey(name))
                    {
                        Types.Type tmp = null;

                        if (!Utils.Utils.isEmpty(name))
                        {
                            tmp = nameSpace.findTypeByName(name);

                            if (tmp == null)
                            {
                                if (DefinedTypes.ContainsKey(name))
                                {
                                    tmp = DefinedTypes[name];
                                }
                            }

                            if (tmp == null && DefinedTypes.ContainsKey("Default." + name))
                            {
                                tmp = DefinedTypes["Default." + name];
                            }
                        }

                        if (tmp == null)
                        {
                            Log.Error("Cannot find type named " + name);
                        }

                        subCache[name] = tmp;
                    }

                    retVal = subCache[name];
                }
                else
                {
                    if (DefinedTypes.ContainsKey(name))
                    {
                        retVal = DefinedTypes[name];
                    }
                    else if (DefinedTypes.ContainsKey("Default." + name))
                    {
                        retVal = DefinedTypes["Default." + name];
                    }
                }
            }

            return(retVal);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Provides the type associated to the name
        /// </summary>
        /// <param name="nameSpace">the namespace in which the name should be found</param>
        /// <param name="name"></param>
        /// <returns></returns>
        public Type FindType(Types.NameSpace nameSpace, string name)
        {
            Type retVal = null;

            Dictionary <string, Type> definedTypes = DefinedTypes;

            if (name != null)
            {
                if (nameSpace != null)
                {
                    ISubDeclaratorUtils.CriticalSection.WaitOne();
                    try
                    {
                        if (!_cache.ContainsKey(nameSpace))
                        {
                            _cache[nameSpace] = new Dictionary <string, Type>();
                        }
                        Dictionary <string, Type> subCache = _cache[nameSpace];

                        if (!subCache.ContainsKey(name))
                        {
                            Type tmp = null;

                            if (!Utils.Util.isEmpty(name))
                            {
                                tmp = nameSpace.findTypeByName(name);

                                if (tmp == null)
                                {
                                    if (definedTypes.ContainsKey(name))
                                    {
                                        tmp = definedTypes[name];
                                    }
                                }

                                if (tmp == null && definedTypes.ContainsKey("Default." + name))
                                {
                                    tmp = definedTypes["Default." + name];
                                }
                            }

                            subCache[name] = tmp;
                        }

                        retVal = subCache[name];
                    }
                    finally
                    {
                        ISubDeclaratorUtils.CriticalSection.ReleaseMutex();
                    }
                }
                else
                {
                    if (definedTypes.ContainsKey(name))
                    {
                        retVal = definedTypes[name];
                    }
                    else if (definedTypes.ContainsKey("Default." + name))
                    {
                        retVal = definedTypes["Default." + name];
                    }
                }
            }

            return(retVal);
        }