Exemple #1
0
        public virtual string GetFullName()
        {
            Scope  parentScope = GetParentScope();
            string ret         = string.Empty;

            if (parentScope != null)
            {
                string parentFullname = parentScope.GetFullName();
                if (!string.IsNullOrEmpty(parentFullname))
                {
                    ret = parentFullname + "." + GetName();
                }
                else
                {
                    ret = GetName();
                }
            }
            else
            {
                ret = GetName();
            }

            // Add the generic instance.
            GenericInstance instance = GetGenericInstance();

            if (instance != null)
            {
                ret += instance.GetFullName();
            }

            // Add the generic prototype.
            GenericPrototype proto = GetGenericPrototype();

            if (proto != null && (instance == null || instance.GetParameterCount() == 0))
            {
                ret += proto.GetFullName();
            }

            return(ret);
        }
Exemple #2
0
        public override IChelaType InstanceGeneric(GenericInstance args, ChelaModule instModule)
        {
            GenericPrototype prototype = args.GetPrototype();

            for (int i = 0; i < args.GetParameterCount(); ++i)
            {
                if (prototype.GetPlaceHolder(i) == this)
                {
                    IChelaType type = args.GetParameter(i);
                    if (type.IsPassedByReference())
                    {
                        return(ReferenceType.Create(type));
                    }
                    else
                    {
                        return(type);
                    }
                }
            }

            return(this);
        }
Exemple #3
0
        public GenericInstance GetFullGenericInstance()
        {
            // Return the cached instance.
            if (fullGenericInstance != null)
            {
                return(fullGenericInstance);
            }

            // Get the full prototype.
            GenericPrototype fullProto = GetFullGenericPrototype();

            if (fullProto == null)
            {
                return(null);
            }

            // Get the parent full generic instance.
            GenericInstance parentFull = null;
            Scope           parent     = GetParentScope();

            if (parent != null)
            {
                parentFull = parent.GetFullGenericInstance();
            }

            // Get my generic instance.
            GenericInstance myInstance = GetGenericInstance();

            if (myInstance == null || myInstance.GetParameterCount() == 0)
            {
                fullGenericInstance = parentFull;
            }
            else if (parentFull == null || parentFull.GetParameterCount() == 0)
            {
                fullGenericInstance = myInstance;
            }
            else
            {
                // Merge both instances
                int          parentSize  = parentFull.GetParameterCount();
                int          mySize      = myInstance.GetParameterCount();
                IChelaType[] newInstance = new IChelaType[parentSize + mySize];

                // Add the parent prototype components.
                for (int i = 0; i < parentSize; ++i)
                {
                    newInstance[i] = parentFull.GetParameter(i);
                }

                // Add my prototype components.
                for (int i = 0; i < mySize; ++i)
                {
                    newInstance[i + parentSize] = myInstance.GetParameter(i);
                }

                // Store the new complete generic instance.
                fullGenericInstance = new GenericInstance(fullProto, newInstance);
            }

            return(fullGenericInstance);
        }