Ejemplo n.º 1
0
        public ObjectSet(Zio zio, objset_phys_t os)
        {
            if (zio == null)
                throw new ArgumentNullException("zio");

            mZio = zio;
            mType = os.Type;
            mMetaDNode = new DNode(zio, os.MetaDnode);
        }
Ejemplo n.º 2
0
        public IEnumerable<ICell> Process(ICell[,] cellMap, Coordinates start, Coordinates end)
        {
            Contract.Requires(cellMap != null);
            Contract.Requires(start.Inside(new Coordinates(cellMap.GetLength(0), cellMap.GetLength(1))));
            Contract.Requires(end.Inside(new Coordinates(cellMap.GetLength(0), cellMap.GetLength(1))));

            DNode[,] dist = new DNode[cellMap.GetLength(0), cellMap.GetLength(1)];

            int count = cellMap.GetLength(0) * cellMap.GetLength(1);
            for (int i = 0; i < cellMap.GetLength(0); ++i)
                for (int j = 0; j < cellMap.GetLength(1); ++j)
                    dist[i, j] = new DNode();

            dist[start.X, start.Y].val = 0;

            Coordinates? min = null;
            do
            {
                min = FindMin(dist);
                if (min.HasValue)
                {
                    CheckForeign(cellMap, dist, min.Value);
                    dist[min.Value.X, min.Value.Y].visited = true;
                }
            } while (min.HasValue);

            int waylen = 0;
            DNode dnode = dist[end.X, end.Y];
            while (dnode.prev.HasValue)
            {
                ++waylen;
                dnode = dist[dnode.prev.Value.X, dnode.prev.Value.Y];
            }

            if (waylen > 0)
            {
                ICell[] res = new ICell[waylen + 1];
                res[waylen] = cellMap[end.X, end.Y];
                int i = waylen - 1;
                dnode = dist[end.X, end.Y];
                while (dnode.prev.HasValue)
                {
                    res[i--] = cellMap[dnode.prev.Value.X, dnode.prev.Value.Y];
                    dnode = dist[dnode.prev.Value.X, dnode.prev.Value.Y];
                }
                return res;
            }
            else
            {
                return new LinkedList<ICell>();
            }
        }
Ejemplo n.º 3
0
 protected void CheckForeign(ICell[,] cm, DNode[,] d, Coordinates coords)
 {
     int f = coords.X, s = coords.Y;
     double w;
     //left
     if ((f > 0) && (cm[f - 1, s].Weight >= 0))
     {
         w = cm[f - 1, s].Weight + d[f, s].val;
         if (w < d[f - 1, s].val)
         {
             d[f - 1, s].val = w;
             d[f - 1, s].prev = coords;
         }
     }
     //right
     if ((f < cm.GetLength(0) - 1) && (cm[f + 1, s].Weight >= 0))
     {
         w = cm[f + 1, s].Weight + d[f, s].val;
         if (w < d[f + 1, s].val)
         {
             d[f + 1, s].val = w;
             d[f + 1, s].prev = coords;
         }
     }
     //top
     if ((s > 0) && (cm[f, s - 1].Weight >= 0))
     {
         w = cm[f, s - 1].Weight + d[f, s].val;
         if (w < d[f, s - 1].val)
         {
             d[f, s - 1].val = w;
             d[f, s - 1].prev = coords;
         }
     }
     //bottom
     if ((s < cm.GetLength(1) - 1) && (cm[f, s + 1].Weight >= 0))
     {
         w = cm[f, s + 1].Weight + d[f, s].val;
         if (w < d[f, s + 1].val)
         {
             d[f, s + 1].val = w;
             d[f, s + 1].prev = coords;
         }
     }
 }
        private void Nesting_CreateProliferationGraph(DGraph graph)
        {
            DNode inNode = graph.AddNode("Pr_in");

            inNode.DrawingNode.Attr.Shape     = MsaglShape.Circle;
            inNode.DrawingNode.Attr.FillColor = MsaglColor.Red;

            DNode mitosisNode      = Nesting_Cell_AddNode(graph, "Pr_mitosis", null);
            Grid  mitosisContainer = new Grid();

            mitosisContainer.RowDefinitions.Add(new RowDefinition());
            mitosisContainer.RowDefinitions.Add(new RowDefinition());
            mitosisContainer.Children.Add(new TextBlock()
            {
                Text = "Mitosis", TextAlignment = TextAlignment.Center, FontWeight = FontWeights.Bold
            });
            mitosisNode.Label = new DNestedGraphLabel(mitosisNode, mitosisContainer);
            DGraph mitosisGraph = new DGraph(mitosisNode.Label as DNestedGraphLabel)
            {
                Name = "Mitosis"
            };

            Nesting_CreateMitosisGraph(mitosisGraph);
            Grid.SetRow(mitosisGraph, 1);
            mitosisContainer.Children.Add(mitosisGraph);
            (mitosisNode.Label as DNestedGraphLabel).Graphs.Add(mitosisGraph);

            DNode splitterNode = graph.AddNode("Pr_sp");

            splitterNode.DrawingNode.Attr.Shape     = MsaglShape.Circle;
            splitterNode.DrawingNode.Attr.FillColor = MsaglColor.Blue;

            DNode meiosisNode      = Nesting_Cell_AddNode(graph, "Pr_meiosis", null);
            Grid  meiosisContainer = new Grid();

            meiosisContainer.RowDefinitions.Add(new RowDefinition());
            meiosisContainer.RowDefinitions.Add(new RowDefinition());
            meiosisContainer.Children.Add(new TextBlock()
            {
                Text = "Meiosis", TextAlignment = TextAlignment.Center, FontWeight = FontWeights.Bold
            });
            meiosisNode.Label = new DNestedGraphLabel(meiosisNode, meiosisContainer);
            DGraph meiosisGraph = new DGraph(meiosisNode.Label as DNestedGraphLabel)
            {
                Name = "Meiosis"
            };

            Nesting_CreateMeiosisGraph(meiosisGraph);
            Grid.SetRow(meiosisGraph, 1);
            meiosisContainer.Children.Add(meiosisGraph);
            (meiosisNode.Label as DNestedGraphLabel).Graphs.Add(meiosisGraph);

            Nesting_Cell_AddEdge(graph, inNode, mitosisNode, null);
            Nesting_Cell_AddEdge(graph, mitosisNode, splitterNode, "Early Meiosis");

            DEdge splitter_g0_edge = graph.AddEdgeBetweenNodes(splitterNode, mitosisGraph.NodeMap["Mi_g0"]);

            splitter_g0_edge.DrawingEdge.Attr.Color = MsaglColor.Red;
            DEdge splitter_inter_edge = graph.AddEdgeBetweenNodes(splitterNode, meiosisGraph.NodeMap["Me_inter"]);

            splitter_inter_edge.DrawingEdge.Attr.Color = MsaglColor.Red;//*/
        }
Ejemplo n.º 5
0
 protected Coordinates? FindMin(DNode[,] d)
 {
     bool foundfirst = false;
     Coordinates? min = null;
     for (int i = 0; (i < d.GetLength(0)) && !foundfirst; i++)
         for (int j = 0; (j < d.GetLength(1)) && !foundfirst; j++)
             if (!d[i, j].visited)
             {
                 foundfirst = true;
                 min = new Coordinates(i, j);
             }
     if (min.HasValue)
         for (int i = 0; i < d.GetLength(0); i++)
             for (int j = 0; j < d.GetLength(1); j++)
                 if ((!d[i, j].visited) && (d[i, j].val < d[min.Value.X, min.Value.Y].val))
                     min = new Coordinates(i, j);
     return min;
 }
Ejemplo n.º 6
0
 public DBinaryOperation(DNode left, DNode right, BinaryOperator op, Location loc) : this(loc) =>
     (Left, Right, Operator) = (left, right, op);
Ejemplo n.º 7
0
    void DowkerModify()
    {
        int len = nodes.Count;

        //外周は固定する
        for (int a = 0; a < outerCount; a++)
        {
            nodes[outer[a]].x = 400 + 300 * Mathf.Cos(Mathf.PI * 2 * a / outerCount);
            nodes[outer[a]].y = 400 - 300 * Mathf.Sin(Mathf.PI * 2 * a / outerCount);
        }
        float[] dx = new float[len];
        float[] dy = new float[len];
        for (int repeat = 0; repeat < 2000; repeat++)
        {
            for (int n = 0; n < len; n++)
            {
                dx[n] = dy[n] = 0f;
            }
            for (int n = 0; n < len; n++)
            {
                DNode nn    = nodes[n];
                float zx    = 0;
                float zy    = 0;
                int   count = 0;
                for (int e = 0; e < edges.Count; e++)
                {
                    DEdge ee = edges[e];
                    if (ee.s == n)
                    {
                        zx += nodes[ee.t].x;
                        zy += nodes[ee.t].y;
                        count++;
                    }
                    else if (ee.t == n)
                    {
                        zx += nodes[ee.s].x;
                        zy += nodes[ee.s].y;
                        count++;
                    }
                }
                zx /= count;
                zy /= count;
                float ax = zx - nn.x;
                float ay = zy - nn.y;
                ax   *= 0.1f;
                ay   *= 0.1f;
                dx[n] = ax;
                dy[n] = ay;
            }
            for (int n = 0; n < len; n++)
            {
                bool OK = true;
                for (int a = 0; a < outerCount; a++)
                {
                    if (n == outer[a])
                    {
                        OK = false;
                        break;
                    }
                }
                if (OK)
                {
                    DNode nn = nodes[n];
                    nn.x += dx[n];
                    nn.y += dy[n];
                }
            }
        }
    }
Ejemplo n.º 8
0
 public DBinaryOperation(DNode left, DNode right, BinaryOperator op, Location loc) : this(loc)
 {
     Left     = left;
     Right    = right;
     Operator = op;
 }
Ejemplo n.º 9
0
 public DNode(T item, DNode <T> prevNode, DNode <T> nextNode)
 {
     Element = item;
     Prev    = prevNode;
     Next    = nextNode;
 }
 public DNode(T value)
 {
     Value    = value;
     Next     = null;
     Previous = null;
 }
Ejemplo n.º 11
0
 protected string SerializeDNode(DNode node)
 {
     StringBuilder sb = new StringBuilder();
     SerializeDNode(node, sb, 0);
     return sb.ToString();
 }
Ejemplo n.º 12
0
 void ApplyAttributes(DNode n)
 {
     n.Attributes = GetCurrentAttributeSet();
 }
Ejemplo n.º 13
0
        public static Core.IconId GetNodeIcon(DNode n)
        {
            try
            {
                if (n == null)
                {
                    return(null);
                }

                if (n is DClassLike)
                {
                    switch ((n as DClassLike).ClassType)
                    {
                    case DTokens.Template:
                    case DTokens.Class:
                        if (n.ContainsAttribute(DTokens.Package))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("class_internal"));
                        }
                        else if (n.ContainsAttribute(DTokens.Protected))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("class_protected"));
                        }
                        else if (n.ContainsAttribute(DTokens.Private))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("class_private"));
                        }
                        return(DCodeCompletionSupport.GetNodeImage("class"));

                    case DTokens.Union:
                    case DTokens.Struct:
                        if (n.ContainsAttribute(DTokens.Package))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("struct_internal"));
                        }
                        else if (n.ContainsAttribute(DTokens.Protected))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("struct_protected"));
                        }
                        else if (n.ContainsAttribute(DTokens.Private))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("struct_private"));
                        }
                        return(DCodeCompletionSupport.GetNodeImage("struct"));

                    case DTokens.Interface:
                        if (n.ContainsAttribute(DTokens.Package))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("interface_internal"));
                        }
                        else if (n.ContainsAttribute(DTokens.Protected))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("interface_protected"));
                        }
                        else if (n.ContainsAttribute(DTokens.Private))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("interface_private"));
                        }
                        return(DCodeCompletionSupport.GetNodeImage("interface"));
                    }
                }
                else if (n is DEnum)
                {
                    if (n.ContainsAttribute(DTokens.Package))
                    {
                        return(DCodeCompletionSupport.GetNodeImage("enum_internal"));
                    }
                    else if (n.ContainsAttribute(DTokens.Protected))
                    {
                        return(DCodeCompletionSupport.GetNodeImage("enum_protected"));
                    }
                    else if (n.ContainsAttribute(DTokens.Private))
                    {
                        return(DCodeCompletionSupport.GetNodeImage("enum_private"));
                    }
                    return(DCodeCompletionSupport.GetNodeImage("enum"));
                }
                else if (n is DMethod)
                {
                    //TODO: Getter or setter functions should be declared as a >single< property only
                    if (n.ContainsPropertyAttribute())
                    {
                        if (n.ContainsAttribute(DTokens.Package))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("property_internal"));
                        }
                        else if (n.ContainsAttribute(DTokens.Protected))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("property_protected"));
                        }
                        else if (n.ContainsAttribute(DTokens.Private))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("property_private"));
                        }
                        return(DCodeCompletionSupport.GetNodeImage("property"));
                    }

                    if (n.ContainsAttribute(DTokens.Package))
                    {
                        return(DCodeCompletionSupport.GetNodeImage("method_internal"));
                    }
                    else if (n.ContainsAttribute(DTokens.Protected))
                    {
                        return(DCodeCompletionSupport.GetNodeImage("method_protected"));
                    }
                    else if (n.ContainsAttribute(DTokens.Private))
                    {
                        return(DCodeCompletionSupport.GetNodeImage("method_private"));
                    }
                    return(DCodeCompletionSupport.GetNodeImage("method"));
                }
                else if (n is DEnumValue)
                {
                    return(DCodeCompletionSupport.GetNodeImage("literal"));
                }
                else if (n is DVariable)
                {
                    if (n.ContainsPropertyAttribute())
                    {
                        if (n.ContainsAttribute(DTokens.Package))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("property_internal"));
                        }
                        else if (n.ContainsAttribute(DTokens.Protected))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("property_protected"));
                        }
                        else if (n.ContainsAttribute(DTokens.Private))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("property_private"));
                        }
                        return(DCodeCompletionSupport.GetNodeImage("property"));
                    }

                    if (n.Type is DelegateDeclaration)
                    {
                        if (n.ContainsAttribute(DTokens.Package))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("delegate_internal"));
                        }
                        else if (n.ContainsAttribute(DTokens.Protected))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("delegate_protected"));
                        }
                        else if (n.ContainsAttribute(DTokens.Private))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("delegate_private"));
                        }
                        return(DCodeCompletionSupport.GetNodeImage("delegate"));
                    }

                    if (n.ContainsAttribute(DTokens.Const))
                    {
                        return(DCodeCompletionSupport.GetNodeImage("literal"));
                    }

                    var realParent = n.Parent as DNode;

                    if (n.Parent is IAbstractSyntaxTree && !(n as DVariable).IsAlias)
                    {
                        return(DCodeCompletionSupport.GetNodeImage("field"));
                    }

                    if (realParent == null)
                    {
                        return(DCodeCompletionSupport.GetNodeImage("local"));
                    }

                    if (realParent is DClassLike)
                    {
                        if (n.ContainsAttribute(DTokens.Package))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("field_internal"));
                        }
                        else if (n.ContainsAttribute(DTokens.Protected))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("field_protected"));
                        }
                        else if (n.ContainsAttribute(DTokens.Private))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("field_private"));
                        }
                        return(DCodeCompletionSupport.GetNodeImage("field"));
                    }

                    if (realParent is DMethod)
                    {
                        if ((realParent as DMethod).Parameters.Contains(n))
                        {
                            return(DCodeCompletionSupport.GetNodeImage("parameter"));
                        }
                        return(DCodeCompletionSupport.GetNodeImage("local"));
                    }

                    if (realParent.ContainsTemplateParameter(n.Name))
                    {
                        return(DCodeCompletionSupport.GetNodeImage("parameter"));
                    }
                }
            }
            catch (Exception ex) { LoggingService.LogError("Error while getting node icon", ex); }
            return(null);
        }
Ejemplo n.º 14
0
 public InnerAction(DNode dn, DRefactoringContext drefCtxt)
 {
     this.refCtxt = drefCtxt;
     this.dn      = dn;
     this.Title   = "import " + (dn.NodeRoot as DModule).ModuleName + ";";
 }
Ejemplo n.º 15
0
        protected override Tuple <CodeLocation, CodeLocation, string> Process(EditorData editorData, CodeLocation tipEnd)
        {
            var tipStart = editorData.CaretLocation;

            editorData.CaretOffset  += 2;
            editorData.CaretLocation = tipEnd;

            var sr = DResolver.GetScopedCodeObject(editorData);
            var rr = sr != null?LooseResolution.ResolveTypeLoosely(editorData, sr, out _, true) : null;

            var definitionSourceFilename = new StringBuilder();

            if (rr != null)
            {
                if (rr is AliasedType at)
                {
                    // jump to original definition if it is not renamed or the caret is on the import
                    var isRenamed = (at.Definition as ImportSymbolAlias)?.ImportBinding?.Alias != null;
                    if (!isRenamed || at.Definition.Location == sr.Location)
                    {
                        rr = at.Base;
                    }
                }
                DNode n = null;
                foreach (var t in AmbiguousType.TryDissolve(rr))
                {
                    n = ExpressionTypeEvaluation.GetResultMember(t);
                    if (n != null)
                    {
                        break;
                    }
                }

                if (n != null)
                {
                    if (definitionSourceFilename.Length > 0)
                    {
                        definitionSourceFilename.Append("\n");
                    }
                    bool decl = false;
                    if (n is DMethod method)
                    {
                        decl = method.Body == null;
                    }
                    else if (n.ContainsAnyAttribute(DTokens.Extern))
                    {
                        decl = true;
                    }
                    if (decl)
                    {
                        definitionSourceFilename.Append("EXTERN:");
                    }

                    tipStart = n.Location;
                    tipEnd   = n.EndLocation;
                    if (n.NodeRoot is DModule module)
                    {
                        definitionSourceFilename.Append(module.FileName);
                    }
                }
            }

            return(Tuple.Create(tipStart, tipEnd, definitionSourceFilename.ToString()));
        }
Ejemplo n.º 16
0
 internal DNode(String d)
 {
     this.data = d;
     this.next = null;
     this.prev = null;
 }
Ejemplo n.º 17
0
    // This method gets called when a button is pressed through a script on the buttons that
    // sends its sibling index
    public void OptionsButtonClick(int a_buttonIndex)
    {
        // Set the GUI objects to start displaying dialogue text and
        // stop displaying dialogue options
        m_dialogueText.gameObject.SetActive(true);
        m_dialogueButtonsContainer.transform.parent.transform.parent.gameObject.SetActive(false);

        // If the button that has been pressed is last in the list then it is the exit
        // dialogue button so this just exits the dialogue
        if (a_buttonIndex == m_dialogueButtonsContainer.transform.childCount - 1)
        {
            m_dialogueEnum         = dialogueEnumerator.Exit;
            m_dialogueIEnumRunning = false;
            return;
        }

        // We can do the same for the back button here if this is not the
        // first dialogue
        if (!m_dialogue.FirstDialogue && a_buttonIndex == m_dialogueButtonsContainer.transform.childCount - 2)
        {
            m_dialogue             = m_dialoguePrev.Pop();
            m_dialogueEnum         = dialogueEnumerator.Options;
            m_dialogueIEnumRunning = false;
            return;
        }

        // Set the dialogue options so it has been read/selected
        m_dialogue.options[a_buttonIndex].hasBeenRead = true;

        // Invoke the events that are set to this dialogue option
        m_AfterDialogueActions = m_dialogue.options[a_buttonIndex].eventsOnDialogueFinish;

        // If we don't need to return to the dialogue once an option is read then set the next dialogue option
        if (!m_dialogue.options[a_buttonIndex].ReturnOnceRead)
        {
            // We have a stack of dialogues so that we can go back, we add the current one
            // here before it is set to something else
            m_dialoguePrev.Push(m_dialogue);

            // Set the dialogue to the net dialogue
            foreach (DNode dialogue in hitInRange.collider.GetComponent <DialogueNode>().Dialogue)
            {
                if (dialogue._ID == m_dialogue.options[a_buttonIndex].nextID)
                {
                    m_dialogue = dialogue;
                    break;
                }
            }
        }
        // Else set the dialogue text overwrite
        else
        {
            foreach (DNode dialogue in hitInRange.collider.GetComponent <DialogueNode>().Dialogue)
            {
                if (dialogue._ID == m_dialogue.options[a_buttonIndex].nextID)
                {
                    m_dialogueTextOverwrite = dialogue.dialogueText;
                    break;
                }
            }
        }


        // Set the variables
        m_dialogueEnum         = dialogueEnumerator.Talking;
        m_dialogueIEnumRunning = false;
    }
Ejemplo n.º 18
0
        public void GetTip(string filename, int startLine, int startIndex, int endLine, int endIndex)
        {
            filename = normalizePath(filename);
            var ast = GetModule(filename);

            if (ast == null)
            {
                throw new COMException("module not found", 1);
            }

            _tipStart = new CodeLocation(startIndex + 1, startLine);
            _tipEnd   = new CodeLocation(startIndex + 2, startLine);
            _tipText.Clear();

            _setupEditorData();
            _editorData.CaretLocation = _tipStart;
            _editorData.SyntaxTree    = ast as DModule;
            _editorData.ModuleCode    = _sources[filename];
            // codeOffset+1 because otherwise it does not work on the first character
            _editorData.CaretOffset = getCodeOffset(_editorData.ModuleCode, _tipStart) + 1;

            ISyntaxRegion sr = DResolver.GetScopedCodeObject(_editorData);

            LooseResolution.NodeResolutionAttempt attempt;
            var types = sr != null?LooseResolution.ResolveTypeLoosely(_editorData, sr, out attempt) : null;

            _tipText.Clear();

            if (types != null)
            {
                if (sr != null)
                {
                    _tipStart = sr.Location;
                    _tipEnd   = sr.EndLocation;
                }

                DNode dn = null;

                foreach (var t in AmbiguousType.TryDissolve(types))
                {
                    _tipText.Append(NodeToolTipContentGen.Instance.GenTooltipSignature(t)).Append("\a");
                    if (t is DSymbol)
                    {
                        dn = (t as DSymbol).Definition;
                    }
                }

                while (_tipText.Length > 0 && _tipText[_tipText.Length - 1] == '\a')
                {
                    _tipText.Length--;
                }

                if (dn != null)
                {
                    VDServerCompletionDataGenerator.GenerateNodeTooltipBody(dn, _tipText);
                }

                while (_tipText.Length > 0 && _tipText[_tipText.Length - 1] == '\a')
                {
                    _tipText.Length--;
                }
            }
        }
Ejemplo n.º 19
0
        public void GetDefinition(string filename, int startLine, int startIndex, int endLine, int endIndex)
        {
            filename = normalizePath(filename);
            var ast = GetModule(filename);

            if (ast == null)
            {
                throw new COMException("module not found", 1);
            }

            _tipStart = new CodeLocation(startIndex + 1, startLine);
            _tipEnd   = new CodeLocation(endIndex + 1, endLine);
            _tipText.Clear();

            _setupEditorData();
            _editorData.CaretLocation = _tipEnd;
            _editorData.SyntaxTree    = ast as DModule;
            _editorData.ModuleCode    = _sources[filename];
            // codeOffset+1 because otherwise it does not work on the first character
            _editorData.CaretOffset = getCodeOffset(_editorData.ModuleCode, _tipStart) + 2;

            ISyntaxRegion sr = DResolver.GetScopedCodeObject(_editorData);

            LooseResolution.NodeResolutionAttempt attempt;
            var rr = sr != null?LooseResolution.ResolveTypeLoosely(_editorData, sr, out attempt, true) : null;

            _tipText.Clear();
            if (rr != null)
            {
                DNode n = null;
                foreach (var t in AmbiguousType.TryDissolve(rr))
                {
                    n = DResolver.GetResultMember(t, true);
                    if (n != null)
                    {
                        break;
                    }
                }

                if (n != null)
                {
                    if (_tipText.Length > 0)
                    {
                        _tipText.Append("\n");
                    }
                    bool decl = false;
                    var  mthd = n as DMethod;
                    if (mthd != null)
                    {
                        decl = mthd.Body == null;
                    }
                    else if (n.ContainsAttribute(DTokens.Extern))
                    {
                        decl = true;
                    }
                    if (decl)
                    {
                        _tipText.Append("EXTERN:");
                    }

                    _tipStart = n.Location;
                    _tipEnd   = n.EndLocation;
                    INode node = n.NodeRoot;
                    if (node is DModule)
                    {
                        _tipText.Append((node as DModule).FileName);
                    }
                }
            }
        }
Ejemplo n.º 20
0
 public DNode(int data)
 {
     Data = data;
     Prev = null;
     Next = null;
 }
Ejemplo n.º 21
0
        protected void SerializeDNode(DNode node, StringBuilder sb, int level)
        {
            StringBuilder indent = new StringBuilder();
            for (int i = 0; i < level; i++) indent.Append('\t');
            SerializeCodeLocation(node.StartLocation, sb);
            sb.Append("-");
            SerializeCodeLocation(node.EndLocation, sb);
            sb.Append(" ");

            if (node is DModule)
            {
                DModule module = node as DModule;
                sb.Append(indent).Append("ML:").Append(module.ModuleName);
                foreach (ITypeDeclaration td in module.Imports.Keys)
                {
                    sb.Append(indent).Append("~IM:").Append(td.ToString());
                }
                sb.AppendLine();
            }
            else if (node is DMethod)
            {
                DMethod method = node as DMethod;
                sb.Append(indent).Append("MD:").Append(method.Type != null ? method.Type.ToString() : "<NULL>").Append("~").AppendLine(method.Name);
                foreach (DNode paramNode in method.Parameters)
                {
                    SerializeDNode(paramNode, sb, level + 1);
                }
            }
            else if (node is DClassLike)
            {
                DClassLike clss = node as DClassLike;
                sb.Append(indent).Append("CLS:").Append(clss.ClassType).Append("~").AppendLine(clss.Name);
            }
            else if (node is DVariable)
            {
                DVariable variable = node as DVariable;
                sb.Append(indent).Append("VAR:").Append((variable.Type == null) ? "<NULL>" : variable.Type.ToString()).Append("~").Append(variable.Name);
                if (variable.Initializer != null)
                    sb.Append(indent).Append("~INIT:").Append(variable.Initializer.ToString());
                sb.AppendLine();
            }
            else
            {
                object o = node;
            }

            if (node is DStatementBlock)
            {
                DStatementBlock block = node as DStatementBlock;
                //if (block.Expression != null)
                //    sb.Append(indent).Append("EXP:").Append(block.Expression.ToString());
                foreach (DNode childNode in block)
                {
                    SerializeDNode(childNode, sb, level + 1);
                }
            }
            else if (node is DBlockStatement)
            {
                DBlockStatement block = node as DBlockStatement;
                foreach (DNode childNode in block.Children)
                {
                    SerializeDNode(childNode, sb, level + 1);
                }
            }
        }
Ejemplo n.º 22
0
        public static Core.IconId GetNodeIcon(DNode n)
        {
            try
            {
                if (n == null)
                {
                    return(null);
                }

                if (n is DClassLike)
                {
                    switch ((n as DClassLike).ClassType)
                    {
                    case DTokens.Template:
                        return(iconIdWithProtectionAttr(n, "template"));

                    case DTokens.Class:
                        return(classIconIdWithProtectionAttr(n));

                    case DTokens.Union:
                        return(iconIdWithProtectionAttr(n, "union"));

                    case DTokens.Struct:
                        return(iconIdWithProtectionAttr(n, "struct"));

                    case DTokens.Interface:
                        return(iconIdWithProtectionAttr(n, "interface"));
                    }
                }
                else if (n is DEnum)
                {
                    // TODO: does declaring an enum private/protected/package actually have a meaning?
                    return(iconIdWithProtectionAttr(n, "enum"));
                }
                else if (n is DEnumValue)
                {
                    return(DCodeCompletionSupport.GetNodeImage("literal"));
                }
                else if (n is DMethod)
                {
                    //TODO: Getter or setter functions should be declared as a >single< property only
                    if (n.ContainsPropertyAttribute())
                    {
                        return(iconIdWithProtectionAttr(n, "property"));
                    }

                    return(methodIconIdWithProtectionAttr(n));
                }
                else if (n is DVariable)
                {
                    if (((DVariable)n).IsAlias)
                    {
                        // TODO: does declaring an alias private/protected/package actually have a meaning?
                        return(iconIdWithProtectionAttr(n, "alias"));
                    }

                    if (n.ContainsPropertyAttribute())
                    {
                        return(iconIdWithProtectionAttr(n, "property"));
                    }

                    if (n.Type is DelegateDeclaration)
                    {
                        return(iconIdWithProtectionAttr(n, "delegate"));
                    }

                    if (n.ContainsAttribute(DTokens.Const))
                    {
                        return(iconIdWithProtectionAttr(n, "literal", true));
                    }

                    var realParent = n.Parent as DNode;

                    if (realParent == null)
                    {
                        return(DCodeCompletionSupport.GetNodeImage("local"));
                    }

                    if (realParent is DClassLike || n.Parent is DModule)
                    {
                        return(iconIdWithProtectionAttr(n, "field", true));
                    }

                    if (realParent is DMethod)
                    {
                        // FIXME: first parameter of class constructors is always displayed as a local, not a parameter
                        if ((realParent as DMethod).Parameters.Contains(n))
                        {
                            if (n.ContainsAttribute(DTokens.Ref))
                            {
                                return(DCodeCompletionSupport.GetNodeImage("ref_parameter"));
                            }
                            else if (n.ContainsAttribute(DTokens.Lazy))
                            {
                                return(DCodeCompletionSupport.GetNodeImage("lazy_parameter"));
                            }
                            else if (n.ContainsAttribute(DTokens.Out))
                            {
                                return(DCodeCompletionSupport.GetNodeImage("out_parameter"));
                            }
                            else
                            {
                                return(DCodeCompletionSupport.GetNodeImage("parameter"));
                            }
                            // TODO: immutable, scope?
                        }
                        return(DCodeCompletionSupport.GetNodeImage("local"));
                    }

                    TemplateParameter tpar;
                    if (realParent.TryGetTemplateParameter(n.Name, out tpar))
                    {
                        return(DCodeCompletionSupport.GetNodeImage("parameter"));
                    }
                }
            }
            catch (Exception ex) { LoggingService.LogError("Error while getting node icon", ex); }
            return(null);
        }
Ejemplo n.º 23
0
 public DNode(DNode <T> prevNode, DNode <T> nextNode)
 {
     Prev = prevNode;
     Next = nextNode;
 }
Ejemplo n.º 24
0
 public void Add(DNode data)
 {
     data.next  = linkedList;
     linkedList = data;
     count++;
 }
Ejemplo n.º 25
0
 static bool IsConstOrStatic(DNode dn)
 {
     return(dn != null && (dn.IsStatic || ((dn is DVariable) && (dn as DVariable).IsConst)));
 }
Ejemplo n.º 26
0
 public Edge(float weight)
 {
     this.weight   = weight;
     this.nextNode = this.gameObject.GetComponent <DNode> ();
 }
Ejemplo n.º 27
0
    public void MakeKnotFromDowkerCode()
    {
        dowkerCount = 0;
        nodes       = new List <DNode>();
        edges       = new List <DEdge>();
        int len = dowker.Length;

        for (int i = 0; i < len; i++)
        {
            nodes.Add(new DNode(400 + 200 * Mathf.Cos(Mathf.PI * 2 * i / len), 400 - 200 * Mathf.Sin(Mathf.PI * 2 * i / len), 2 * i + 1, Mathf.Abs(dowker[i]), i, 0, (dowker[i] > 0)));      // center
            nodes.Add(new DNode(400 + 200 * Mathf.Cos(Mathf.PI * 2 * i / len) + 30, 400 - 200 * Mathf.Sin(Mathf.PI * 2 * i / len), 2 * i + 1, Mathf.Abs(dowker[i]), i, 1, (dowker[i] > 0))); // right
            nodes.Add(new DNode(400 + 200 * Mathf.Cos(Mathf.PI * 2 * i / len), 400 - 200 * Mathf.Sin(Mathf.PI * 2 * i / len) - 30, 2 * i + 1, Mathf.Abs(dowker[i]), i, 2, (dowker[i] > 0))); // top
            nodes.Add(new DNode(400 + 200 * Mathf.Cos(Mathf.PI * 2 * i / len) - 30, 400 - 200 * Mathf.Sin(Mathf.PI * 2 * i / len), 2 * i + 1, Mathf.Abs(dowker[i]), i, 3, (dowker[i] > 0))); // left
            nodes.Add(new DNode(400 + 200 * Mathf.Cos(Mathf.PI * 2 * i / len), 400 - 200 * Mathf.Sin(Mathf.PI * 2 * i / len) + 30, 2 * i + 1, Mathf.Abs(dowker[i]), i, 4, (dowker[i] > 0))); // bottom
            edges.Add(new DEdge(5 * i, 5 * i + 1, true));
            edges.Add(new DEdge(5 * i, 5 * i + 2, true));
            edges.Add(new DEdge(5 * i, 5 * i + 3, true));
            edges.Add(new DEdge(5 * i, 5 * i + 4, true));
            edges.Add(new DEdge(5 * i + 1, 5 * i + 2, false));
            edges.Add(new DEdge(5 * i + 2, 5 * i + 3, false));
            edges.Add(new DEdge(5 * i + 3, 5 * i + 4, false));
            edges.Add(new DEdge(5 * i + 4, 5 * i + 1, false));
        }
        // a,b は1始まり
        for (int i = 0; i < len; i++)
        {
            for (int j = i + 1; j < len; j++)
            {
                DNode n1 = nodes[5 * i];
                DNode n2 = nodes[5 * j];
                if (n2.b == n1.a - 1 || n2.b == n1.a + 2 * len - 1)
                {
                    edges.Add(new DEdge(5 * i + 1, 5 * j + 4, true));
                }
                else if (n2.b == n1.a + 1)
                {
                    edges.Add(new DEdge(5 * i + 3, 5 * j + 2, true));
                }
                if (n1.b == n2.a - 1 || n1.b == n2.a + 2 * len - 1)
                {
                    edges.Add(new DEdge(5 * i + 4, 5 * j + 1, true));
                }
                else if (n1.b == n2.a + 1)
                {
                    edges.Add(new DEdge(5 * i + 2, 5 * j + 3, true));
                }
            }
        }
        outer = new int[20];
        //一度,三角形の外周で計算する.
        FindTriangle();
        DowkerModify();
        // 改めて外周を探しなおす.
        FindOuter();
        DowkerModify();
        //この点データでdata_graphを構成する.
        for (int i = 0; i < nodes.Count; i++)
        {
            //Debug.Log(nodes[i].ToString());
        }
        for (int i = 0; i < edges.Count; i++)
        {
            //Debug.Log(edges[i].ToString());
        }
        //Debug.Log("Dowker test");
        OutputData();
    }
Ejemplo n.º 28
0
 public void setNextNode(DNode newNextNode)
 {
     this.nextNode = newNextNode;
 }
Ejemplo n.º 29
0
    void OutputData()
    {
        int nodeNumber = nodes.Count;

        thisKnot.ClearAll();
        for (int n = 0; n < nodeNumber; n++)
        {
            DNode nn = nodes[n];
            if (n % 5 == 0)
            {                                                                                             // ジョイント
                Node nd = thisKnot.AddNode(new Vector3((nn.x - 400f) * 0.01f, (nn.y - 400f) * 0.01f), n); // ID = n
                Bead bd = thisKnot.AddBead(new Vector3((nn.x - 400f) * 0.01f, (nn.y - 400f) * 0.01f), n); // ID = n
                if (nn.ou)
                {
                    nd.Theta = Mathf.Atan2(nodes[n + 1].y - nodes[n].y, nodes[n + 1].x - nodes[n].x);
                }
                else
                {
                    nd.Theta = Mathf.Atan2(nodes[n + 2].y - nodes[n].y, nodes[n + 1].x - nodes[n].x);
                }
                nd.R[0]      = nd.R[1] = nd.R[2] = nd.R[3] = 0.1f;
                nd.ID        = n;
                nd.Joint     = true;
                nd.MidJoint  = false;
                bd.NumOfNbhd = 4;            //あとで設定
                bd.N1        = bd.N2 = null; //あとで設定
                bd.U1        = bd.U2 = null; //あとで設定
                bd.ID        = n;
                bd.Joint     = true;
                bd.MidJoint  = false;
                nd.ThisBead  = bd;
            }
            else
            {                                                                                             //非ジョイント
                Bead bd = thisKnot.AddBead(new Vector3((nn.x - 400f) * 0.01f, (nn.y - 400f) * 0.01f), n); // ID = n
                bd.NumOfNbhd = 2;                                                                         //あとで設定
                bd.N1        = bd.N2 = null;                                                              //あとで設定
                bd.U1        = bd.U2 = null;                                                              //あとで設定
                bd.ID        = n;
                bd.Joint     = false;
                bd.MidJoint  = false;
            }
        }
        int BeadLastID = thisKnot.GetMaxIDOfBead();
        // edges
        int A = -1, AR = -1, B = -1, BR = -1;

        for (int e = 0; e < edges.Count; e++)
        {
            DEdge ee = edges[e];
            if (ee.visible)
            {
                A = AR = B = BR = -1;
                if (ee.s % 5 != 0 && ee.t % 5 != 0)
                {
                    for (int es = 0; es < edges.Count; es++)
                    {
                        DEdge ees = edges[es];
                        // ee.sからたどれるジョイントを見つける
                        if (ees.visible && ees.s % 5 == 0 && ees.t == ee.s)
                        {
                            int   s0          = ees.s;
                            float aX          = nodes[s0 + 2].x - nodes[s0 + 1].x;
                            float aY          = nodes[s0 + 2].y - nodes[s0 + 1].y;
                            float bX          = nodes[s0 + 4].x - nodes[s0 + 1].x;
                            float bY          = nodes[s0 + 4].y - nodes[s0 + 1].y;
                            float orientation = aX * bY - aY * bX;
                            int   t           = ees.t - ees.s;
                            if (orientation > 0)
                            {
                                if (nodes[ees.s].ou)
                                {
                                    t = (t + 7) % 4;
                                }
                                else
                                {
                                    t = (t + 6) % 4;
                                }
                            }
                            else
                            {
                                if (nodes[ees.s].ou)
                                {
                                    t = (5 - t) % 4;
                                }
                                else
                                {
                                    t = (6 - t) % 4;
                                }
                            }
                            A  = ees.s;// ee.sからたどれるジョイント
                            AR = t;
                        }
                        // ee.tからたどれるジョイント
                        if (ees.visible && ees.s % 5 == 0 && ees.t == ee.t)
                        {
                            int   s0          = ees.s;
                            float aX          = nodes[s0 + 2].x - nodes[s0 + 1].x;
                            float aY          = nodes[s0 + 2].y - nodes[s0 + 1].y;
                            float bX          = nodes[s0 + 4].x - nodes[s0 + 1].x;
                            float bY          = nodes[s0 + 4].y - nodes[s0 + 1].y;
                            float orientation = aX * bY - aY * bX;
                            int   t           = ees.t - ees.s;
                            if (orientation > 0)
                            {
                                if (nodes[ees.s].ou)
                                {
                                    t = (t + 7) % 4;
                                }
                                else
                                {
                                    t = (t + 6) % 4;
                                }
                            }
                            else
                            {
                                if (nodes[ees.s].ou)
                                {
                                    t = (5 - t) % 4;
                                }
                                else
                                {
                                    t = (6 - t) % 4;
                                }
                            }
                            B  = ees.s;// ee.tからたどれるジョイント
                            BR = t;
                        }
                    }                                                  ////
                    Edge ed       = thisKnot.AddEdge(A, B, AR, BR, e); // iD = e (連番に限らない。)
                    Bead bdJointA = thisKnot.GetBeadByID(A);
                    Bead bdAR     = thisKnot.GetBeadByID(ee.s);
                    Bead bdBR     = thisKnot.GetBeadByID(ee.t);
                    Bead bdJointB = thisKnot.GetBeadByID(B);
                    if (bdJointA == null || bdAR == null || bdBR == null || bdJointB == null)
                    {
                        continue;
                    }
                    bdJointA.SetNU12(AR, bdAR);
                    bdAR.N1 = bdJointA;
                    bdAR.N2 = bdBR;
                    bdBR.N1 = bdJointB;
                    bdBR.N2 = bdAR;
                    bdJointB.SetNU12(BR, bdBR);
                }
            }
        }
        thisKnot.GetAllThings();

        thisKnot.Modify();
        // NodeEdgeからBeadsを整える
        thisKnot.UpdateBeads();
        //グラフの形を整える。現状ではR[]を整えるだけ。
        thisKnot.Modify();
        Display.SetDrawKnotMode();// drawモードの変更
    }
Ejemplo n.º 30
0
 public DNode(T data)
 {
     this.data     = data;
     this.Next     = null;
     this.Previous = null;
 }
Ejemplo n.º 31
0
 public bool MatchesConditions(DNode n)
 {
     return(true);
 }
Ejemplo n.º 32
0
 internal static bool IsDataSet(DNode dn)
 {
     return dn.Type == dmu_object_type_t.DSL_DATASET || (dn.IsNewType && dn.NewType == dmu_object_byteswap.DMU_BSWAP_ZAP);
 }
Ejemplo n.º 33
0
 void Start()
 {
     this.nextNode = this.gameObject.GetComponent <DNode> ();
 }
Ejemplo n.º 34
0
 public void AddTracedFunction(long numCalls, long treeTime, long funcTime, long perCall, DNode symbol)
 {
     traceFunctionsStore.AppendValues(numCalls, treeTime, funcTime, perCall, symbol.ToString(false, true), symbol);
 }
Ejemplo n.º 35
0
 private void removeNode(DNode node)
 {
     node.prev.next = node.next;
     node.next.prev = node.prev;
 }
Ejemplo n.º 36
0
 private DNode(int val)
 {
     value = val;
     prev  = null;
     next  = null;
 }
Ejemplo n.º 37
0
        public DecisionNode(List<LabeledDocumentVector> TrainingData)
        {
            Dictionary<string, int> LabelCount = GetLabelCount(TrainingData);
            double Entropy = GetEntropy(LabelCount, TrainingData.Count );

            int features = TrainingData[0].Document.Vector.Length;
            int samples = 100;  //for 0 and 1 only, choose 1 sample

            int feature = -1;
            double max = double.MinValue;
            double value = -1;
            //cached values to prevent multiple calculations on the same object
            List<LabeledDocumentVector> LeftCandidateData = null;
            List<LabeledDocumentVector> RightCandidateData = null;
            double left_cand_entropy = -1;
            double right_cand_entropy = -1;

            //calculate maximum information gain
            for (int i = 0; i < features; i++)
            {
                for (int j = 1; j < samples; j++)
                {
                    double val = (double) j / (samples*10);
                    List<LabeledDocumentVector>[] Children = Filter(TrainingData, val, i);

                    List<LabeledDocumentVector> Left = Children[0];
                    List<LabeledDocumentVector> Right = Children[1];

                    double left_entropy = GetEntropy(Left);
                    double right_entropy = GetEntropy(Right);

                    double expect_entropy = (Left.Count / TrainingData.Count) * left_entropy +
                                            (Right.Count / TrainingData.Count) * right_entropy;

                    double info_gain = Entropy - expect_entropy;
                    if (info_gain > max)
                    {
                        max = info_gain;
                        feature = i;
                        value = val;
                        LeftCandidateData = Left;
                        RightCandidateData = Right;
                        left_cand_entropy = left_entropy;
                        right_cand_entropy = right_entropy;
                    }
                }
            }

            this.Index = feature;
            this.Value = value;

            if (left_cand_entropy > 0)
                LeftChild = new DecisionNode(LeftCandidateData);
            else
                LeftChild = new DLeafNode(LeftCandidateData[0].Classification);

            if (right_cand_entropy > 0)
                RightChild = new DecisionNode(RightCandidateData);
            else
                RightChild = new DLeafNode(RightCandidateData[0].Classification);
        }
 private Vector2 positionInNode(DNode gameWorld)
 {
     return(Vector2.Zero);
 }