Ejemplo n.º 1
0
        /// <summary>
        /// Adds a new hasArguments edge to the node.
        /// </summary>
        /// <param name="nodeId">[in] The end point of the new hasArguments edge.</param>
        /// <param name="acValue">[in] The value of the association class.</param>
        /// <exception cref="Columbus.Lim.Asg.LimException">Throws LimException if the given nodeId is invalid.</exception>
        public void addHasArguments(uint nodeId, Types.TypeArgumentConstraintKind acValue)
        {
            if (!fact.getExist(nodeId))
            {
                throw new LimException("Columbus.Lim.Asg.Nodes.Logical.MethodGenericSpec.addHasArguments(NodeId)", "The end point of the edge does not exist.");
            }
            Columbus.Lim.Asg.Nodes.Base.Base node = fact.getRef(nodeId);
            if (Common.getIsBaseClassKind(node.NodeKind, Types.NodeKind.ndkType))
            {
                ListIteratorAssoc <Columbus.Lim.Asg.Nodes.Type.Type> .AssocEdge ac = new ListIteratorAssoc <Columbus.Lim.Asg.Nodes.Type.Type> .AssocEdge();

                ac.assocClass = new ListIteratorAssoc <Columbus.Lim.Asg.Nodes.Type.Type> .AssocClass();

                ac.id = nodeId;
                ac.assocClass.acTypeArgumentConstraintKind = acValue;

                hasArgumentsAssocContainer.AddLast(ac);
            }
            else
            {
                throw new LimException("Columbus.Lim.Asg.Nodes.Logical.MethodGenericSpec.setHasArguments(NodeId)", "Invalid NodeKind (" + node.NodeKind.ToString() + ").");
            }
            if (fact.ReverseEdges != null)
            {
                fact.ReverseEdges.insertEdge(nodeId, this.Id, Types.EdgeKind.edkMethodGenericSpec_HasArguments);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the node.
        /// </summary>
        /// <param name="io">[in] The node is read from io.</param>
        /// <exception cref="Columbus.ColumbusIOException">Throws ColumbusIOException if there is something wrong with the file.</exception>
        public override void load(IO binIo)
        {
            base.load(binIo);

            m_specialize = binIo.readUInt4();

            uint _id;

            _id = binIo.readUInt4();
            while (_id != 0)
            {
                Types.TypeArgumentConstraintKind _ac = (Types.TypeArgumentConstraintKind)(binIo.readUByte1());
                ListIteratorAssoc <Columbus.Lim.Asg.Nodes.Type.Type> .AssocEdge hasArgumentsAc = new ListIteratorAssoc <Columbus.Lim.Asg.Nodes.Type.Type> .AssocEdge();

                hasArgumentsAc.assocClass.acTypeArgumentConstraintKind = _ac;
                hasArgumentsAc.id = _id;
                hasArgumentsAssocContainer.AddLast(hasArgumentsAc);
                _id = binIo.readUInt4();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads the node.
        /// </summary>
        /// <param name="io">[in] The node is read from io.</param>
        /// <exception cref="Columbus.ColumbusIOException">Throws ColumbusIOException if there is something wrong with the file.</exception>
        public override void load(IO binIo)
        {
            base.load(binIo);

            byte boolValues = binIo.readUByte1();

            m_isRealInstance = Convert.ToBoolean(boolValues & 1);
            boolValues     >>= 1;

            uint _id;

            _id = binIo.readUInt4();
            while (_id != 0)
            {
                Types.TypeArgumentConstraintKind _ac = (Types.TypeArgumentConstraintKind)(binIo.readUByte1());
                ListIteratorAssoc <Columbus.Lim.Asg.Nodes.Type.Type> .AssocEdge hasArgumentsAc = new ListIteratorAssoc <Columbus.Lim.Asg.Nodes.Type.Type> .AssocEdge();

                hasArgumentsAc.assocClass.acTypeArgumentConstraintKind = _ac;
                hasArgumentsAc.id = _id;
                hasArgumentsAssocContainer.AddLast(hasArgumentsAc);
                _id = binIo.readUInt4();
            }
        }
Ejemplo n.º 4
0
        // ---------- Edge setter function(s) ----------

        /// <summary>
        /// Adds a new hasArguments edge to the node.
        /// </summary>
        /// <param name="node">[in] The end point of the new hasArguments edge.</param>
        /// <param name="acValue">[in] The value of the association class.</param>
        /// <exception cref="Columbus.Lim.Asg.LimException">Throws LimException if there is something wrong with the given node.</exception>
        public void addHasArguments(Columbus.Lim.Asg.Nodes.Type.Type node, Types.TypeArgumentConstraintKind acValue)
        {
            addHasArguments(node.Id, acValue);
        }
Ejemplo n.º 5
0
 public override void visitMethodGenericSpec_HasArguments(uint begin, uint end, Types.TypeArgumentConstraintKind ac)
 {
     revEdges.insertEdge(end, begin, Types.EdgeKind.edkMethodGenericSpec_HasArguments);
 }
Ejemplo n.º 6
0
 public override void visitClassGenericInstance_HasArguments(uint begin, uint end, Types.TypeArgumentConstraintKind ac)
 {
     revEdges.insertEdge(end, begin, Types.EdgeKind.edkClassGenericInstance_HasArguments);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Create MethodGenericInstance and connect to the Method, through the Instance edge.
        /// Furthermore, added GenericParameter to the MethodGenericInstance.
        /// </summary>
        /// <param name="symbol">Called method</param>
        /// <param name="refersTo">Called method definition</param>
        /// <returns>MethodGenericInstance node from the LIM</returns>
        public static MethodGenericInstance GetMGI(this ISymbol symbol, IMethodSymbol refersTo)
        {
            string uName = symbol.ToString();
            MethodGenericInstance mgi;

            if (MainDeclaration.Instance.MgiMap.TryGetValue(uName, out mgi))
            {
                return(mgi);
            }

            mgi = MainDeclaration.Instance.LimFactory.createMethodGenericInstanceNode();
            mgi.IsRealInstance = true;
            mgi.Name           = symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
            mgi.MangledName    = uName;
            mgi.DemangledName  = uName;
            mgi.Language       = Types.LanguageKind.lnkCsharp;

            IMethodSymbol roslynNode = symbol as IMethodSymbol;

            Base owner = refersTo != null?refersTo.ConvertToLimNode() : symbol.OriginalDefinition.ConvertToLimNode();

            if (owner == null)
            {
                return(null);
            }
            if (Lim.Asg.Common.getIsMethod(owner))
            {
                Method ownerMethod = owner as Method;
                Commons.Common.Safe_Edge(ownerMethod, "Instance", mgi.Id);

                if (roslynNode.Arity > 0)
                {
                    int i = 0;
                    foreach (var argument in roslynNode.TypeArguments)
                    {
                        ITypeSymbol arg = null;
                        if (!argument.IsInMetadata() && argument.TypeKind != TypeKind.TypeParameter)
                        {
                            SyntaxNode _tmp = null;
                            arg = (INamedTypeSymbol)argument.GetDefinition(out _tmp);
                        }
                        Columbus.Lim.Asg.Nodes.Type.Type param = (arg != null) ? arg.GetLimType() : argument.GetLimType();
                        MainDeclaration.Instance.UsesStack.Peek().Remove(param.Id);

                        Types.TypeArgumentConstraintKind tack = Types.TypeArgumentConstraintKind.tackUpperBounded;
                        if (roslynNode.TypeParameters[i].ConstraintTypes.Any())
                        {
                            tack = Types.TypeArgumentConstraintKind.tackUnbounded;
                        }

                        bool found = false;
                        ListIteratorAssocTypeArgumentConstraintKind <Columbus.Lim.Asg.Nodes.Type.Type> cIt = mgi.HasArgumentsListIteratorAssocBegin;
                        while (cIt.getValue() != null)
                        {
                            Lim.Asg.Nodes.Type.Type value = cIt.getValue();
                            if (param.Id == value.Id)
                            {
                                found = true;
                                break;
                            }
                            cIt = cIt.getNext();
                        }
                        if (!found)
                        {
                            mgi.addHasArguments(param, tack);
                        }
                        i++;
                    }
                }
            }

            MainDeclaration.Instance.MgiMap.Add(uName, mgi);

            return(mgi);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Create ClassGenericInstance and connect to the Class, through the Instance edge.
        /// Furthermore, added GenericParameter to the ClassGenericInstance.
        /// </summary>
        /// <param name="symbol">Instanced class</param>
        /// <param name="refersTo">Instanced class definiton</param>
        /// <returns>ClassGenericInstnace from the LIM</returns>
        public static ClassGenericInstance GetCGI(this ISymbol symbol, INamedTypeSymbol refersTo)
        {
            string uName = symbol.ToString();
            ClassGenericInstance cgi;

            if (MainDeclaration.Instance.CgiMap.TryGetValue(uName, out cgi))
            {
                return(cgi);
            }

            cgi = MainDeclaration.Instance.LimFactory.createClassGenericInstanceNode();
            cgi.IsRealInstance = true;
            cgi.Name           = symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
            cgi.MangledName    = uName;
            cgi.DemangledName  = uName;
            cgi.Language       = Types.LanguageKind.lnkCsharp;

            INamedTypeSymbol roslynNode = symbol as INamedTypeSymbol;
            bool             isInMeta   = false;

            if (refersTo == null)
            {
                refersTo = (INamedTypeSymbol)symbol.OriginalDefinition; isInMeta = true;
            }
            if (refersTo != null)
            {
                Base owner = refersTo.ConvertToLimNode();
                if (isInMeta)
                {
                    Commons.Common.MetaDataNameFiller(symbol, (Member)owner);
                }

                if (Lim.Asg.Common.getIsClass(owner))
                {
                    Class ownerClass = owner as Class;
                    Commons.Common.Safe_Edge(ownerClass, "Instance", cgi.Id);

                    int i = 0;
                    foreach (var argument in roslynNode.TypeArguments)
                    {
                        ITypeSymbol arg = null;
                        if (!argument.IsInMetadata() && argument.TypeKind != TypeKind.TypeParameter)
                        {
                            SyntaxNode tmp;
                            arg = (INamedTypeSymbol)argument.GetDefinition(out tmp);
                        }
                        Lim.Asg.Nodes.Type.Type param = (arg != null) ? arg.GetLimType() : argument.GetLimType();
                        MainDeclaration.Instance.UsesStack.Peek().Remove(param.Id);

                        Types.TypeArgumentConstraintKind tack = Types.TypeArgumentConstraintKind.tackUpperBounded;
                        if (roslynNode.TypeParameters[i].ConstraintTypes.Length > 0)
                        {
                            tack = Types.TypeArgumentConstraintKind.tackUnbounded;
                        }

                        bool found = false;
                        ListIteratorAssocTypeArgumentConstraintKind <Lim.Asg.Nodes.Type.Type> cIt = cgi.HasArgumentsListIteratorAssocBegin;
                        while (cIt.getValue() != null)
                        {
                            Lim.Asg.Nodes.Type.Type value = cIt.getValue();
                            if (param.Id == value.Id)
                            {
                                found = true;
                                break;
                            }
                            cIt = cIt.getNext();
                        }
                        if (!found)
                        {
                            cgi.addHasArguments(param, tack);
                        }
                        i++;
                    }
                }
            }

            MainDeclaration.Instance.CgiMap.Add(uName, cgi);

            return(cgi);
        }