Esempio n. 1
0
 public void Visit(DeclareNode node)
 {
     visitor.OnVisit(
         (n, v) =>
         Result = (n as DeclareNode)?.GetDeclareType() == node.GetDeclareType() && IsSameChildren(n, node));
     reference.Visit(visitor);
 }
Esempio n. 2
0
        private string putAttributes(BaseNode node)
        {
            StringBuilder sb = new StringBuilder();

            if (node is DeclareNode)
            {
                DeclareNode declareNode = (DeclareNode)node;
                sb.Append(" Variable_Name = \"" + declareNode._Var.VarName + "\"");
                sb.Append(" Variable_Type = \"" + declareNode._Var.VarType + "\"");
                sb.Append(" Single_Variable = \"" + declareNode._Var.Single + "\"");
                sb.Append(" Size = \"" + declareNode._Var.Size + "\"");
            }
            if (node is IfElseNode)
            {
                IfElseNode ifElseNode = (IfElseNode)node;
                sb.Append(" True_End_Location = \"" + ifElseNode.BackNode.NodeLocation.X.ToString() + "," + ifElseNode.BackNode.NodeLocation.Y.ToString() + "\" ");
                sb.Append(" False_End_Location = \"" + ifElseNode.BackfalseNode.NodeLocation.X.ToString() + "," + ifElseNode.BackfalseNode.NodeLocation.Y.ToString() + "\" ");
                sb.Append(" Mid_Location = \"" + ifElseNode.MiddleNode.NodeLocation.X.ToString() + "," + ifElseNode.MiddleNode.NodeLocation.Y.ToString() + "\" ");
            }
            else if (node is IfNode)
            {
                IfNode ifNode = (IfNode)node;
                sb.Append(" True_End_Location = \"" + ifNode.BackNode.NodeLocation.X.ToString() + "," + ifNode.BackNode.NodeLocation.Y.ToString() + "\" ");
                sb.Append(" Mid_Location = \"" + ifNode.MiddleNode.NodeLocation.X.ToString() + "," + ifNode.MiddleNode.NodeLocation.Y.ToString() + "\" ");
            }
            else if (node is DecisionNode)
            {
                DecisionNode decisionNode = (DecisionNode)node;
                sb.Append(" True_End_Location = \"" + decisionNode.BackNode.NodeLocation.X.ToString() + "," + decisionNode.BackNode.NodeLocation.Y.ToString() + "\" ");
                if (node is ForNode)
                {
                    ForNode forNode = node as ForNode;
                    sb.Append(" Variable = \"" + forNode.Var + "\" ");
                    sb.Append(" Direction = \"" + forNode.Direction + "\" ");
                    sb.Append(" StartVal = \"" + forNode.StartVal + "\" ");
                    sb.Append(" EndVal = \"" + forNode.EndVal + "\" ");
                    sb.Append(" StepBy = \"" + forNode.StepBy + "\" ");
                }
            }
            sb.Append(" Statment = \"" + xmlWithEscapes(node.Statement) + "\" ");
            sb.Append(" Location = \"" + node.NodeLocation.X.ToString() + "," + node.NodeLocation.Y.ToString() + "\" ");
            return(sb.ToString());
        }
 public void Visit(DeclareNode node)
 {
     node.Value?.Accept(this);
     node.Accept(_visitor);
 }
Esempio n. 4
0
 public void Visit(DeclareNode node)
 {
     _engine.SetVariable(node.Variable.Name, node.Type.ReturnType, null);
     Nodes.Push(new DeclareNode(node.Variable, node.Type));
 }
Esempio n. 5
0
 public virtual void Visit(DeclareNode node)
 {
     node.Accept(_visitor);
 }
Esempio n. 6
0
 public DeclareNode(DeclareNode original)
     : base(original)
 {
     this.ValueProvider = original.ValueProvider;
 }
Esempio n. 7
0
        private void addBlockNodes(XmlNodeList list, BaseNode lastNode, BaseNode parentNode)
        {
            foreach (XmlNode node in list)
            {
                BaseNode newNode = null;
                if (node.Name.Equals("End"))
                {
                    newNode = endNode;
                }
                else if (node.Name.Equals("Start"))
                {
                    newNode = startNode;
                }
                else if (node.Name.Equals("Assign"))
                {
                    newNode = new AssignNode();
                }
                else if (node.Name.Equals("Declare"))
                {
                    newNode = new DeclareNode();
                }
                else if (node.Name.Equals("Input"))
                {
                    newNode = new InputNode();
                }
                else if (node.Name.Equals("Output"))
                {
                    newNode = new OutputNode();
                }
                else if (node.Name.Equals("If"))
                {
                    newNode = new IfNode();
                    setAttributes(node, newNode);
                    addBlockNodes(node.FirstChild.ChildNodes, ((DecisionNode)newNode).TrueNode, newNode);
                }
                else if (node.Name.Equals("IfElse"))
                {
                    newNode = new IfElseNode();
                    setAttributes(node, newNode);
                    addBlockNodes(node.FirstChild.ChildNodes, ((IfElseNode)newNode).TrueNode, newNode);
                    addBlockNodes(node.LastChild.ChildNodes, ((IfElseNode)newNode).FalseNode, newNode);
                }
                else if (node.Name.Equals("While"))
                {
                    newNode = new WhileNode();
                    setAttributes(node, newNode);
                    addBlockNodes(node.FirstChild.ChildNodes, ((DecisionNode)newNode).TrueNode, newNode);
                }
                else if (node.Name.Equals("DoWhile"))
                {
                    newNode = new DoNode();
                    setAttributes(node, newNode);
                    addBlockNodes(node.FirstChild.ChildNodes, ((DecisionNode)newNode).TrueNode, newNode);
                }
                else if (node.Name.Equals("For"))
                {
                    newNode = new ForNode();
                    setAttributes(node, newNode);
                    addBlockNodes(node.FirstChild.ChildNodes, ((DecisionNode)newNode).TrueNode, newNode);
                }
                else
                {
                    showErrorMessage("Error not valid file");
                }

                if (!(node.Name.Equals("Start") || node.Name.Equals("End")))
                {
                    BaseNode oldNode = lastNode.OutConnector.EndNode;
                    lastNode.OutConnector.EndNode = newNode;
                    newNode.OutConnector.EndNode  = oldNode;
                    newNode.addToModel();
                    newNode.ParentNode = parentNode;
                }

                lastNode = newNode;
                blockNodes.Add(new Pair(node, newNode));
                setAttributes(node, newNode);
            }
        }
Esempio n. 8
0
        private static void setAttributes(XmlNode node, BaseNode newNode)
        {
            string statment = node.Attributes["Statment"]?.InnerText;

            statment = escapesToRegular(node.Attributes["Statment"]?.InnerText);
            string location = node.Attributes["Location"]?.InnerText;

            string[] true_end_location  = node.Attributes["True_End_Location"]?.InnerText.Split(',');
            string[] false_end_location = node.Attributes["False_End_Location"]?.InnerText.Split(',');
            string[] mid_location       = node.Attributes["Mid_Location"]?.InnerText.Split(',');

            newNode.Statement = statment;

            if (location != null)
            {
                string[] points = location.Split(',');
                newNode.NodeLocation = new System.Drawing.PointF((float)Double.Parse(points[0]), (float)Double.Parse(points[1]));
            }
            if (newNode is IfElseNode)
            {
                IfElseNode ifElseNode = (IfElseNode)newNode;
                ifElseNode.BackNode.NodeLocation      = new System.Drawing.PointF((float)Double.Parse(true_end_location[0]), (float)Double.Parse(true_end_location[1]));
                ifElseNode.BackfalseNode.NodeLocation = new System.Drawing.PointF((float)Double.Parse(false_end_location[0]), (float)Double.Parse(false_end_location[1]));
                ifElseNode.MiddleNode.NodeLocation    = new System.Drawing.PointF((float)Double.Parse(mid_location[0]), (float)Double.Parse(mid_location[1]));
            }
            else if (newNode is IfNode)
            {
                IfNode ifNode = (IfNode)newNode;
                ifNode.BackNode.NodeLocation   = new System.Drawing.PointF((float)Double.Parse(true_end_location[0]), (float)Double.Parse(true_end_location[1]));
                ifNode.MiddleNode.NodeLocation = new System.Drawing.PointF((float)Double.Parse(mid_location[0]), (float)Double.Parse(mid_location[1]));
            }
            else if (newNode is DecisionNode)
            {
                DecisionNode decisionNode = (DecisionNode)newNode;
                decisionNode.BackNode.NodeLocation = new System.Drawing.PointF((float)Double.Parse(true_end_location[0]), (float)Double.Parse(true_end_location[1]));
                if (newNode is ForNode)
                {
                    ForNode forNode = newNode as ForNode;
                    forNode.Var       = node.Attributes["Variable"].InnerText;
                    forNode.Direction = node.Attributes["Direction"].InnerText;
                    forNode.StartVal  = node.Attributes["StartVal"].InnerText;
                    forNode.EndVal    = node.Attributes["EndVal"].InnerText;
                    forNode.StepBy    = node.Attributes["StepBy"].InnerText;
                }
            }
            else if (newNode is DeclareNode)
            {
                string      variable_name = node.Attributes["Variable_Name"].InnerText;
                string      variable_type = node.Attributes["Variable_Type"].InnerText;
                string      single        = node.Attributes["Single_Variable"].InnerText;
                string      size          = node.Attributes["Size"].InnerText;
                DeclareNode declareNode   = (DeclareNode)newNode;
                declareNode._Var.VarName = variable_name;
                declareNode._Var.Size    = Int32.Parse(size);
                declareNode._Var.Single  = Boolean.Parse(single);
                switch (variable_type)
                {
                case "INTEGER":
                    declareNode._Var.VarType = DeclareNode.Variable.Data_Type.INTEGER;
                    break;

                case "REAL":
                    declareNode._Var.VarType = DeclareNode.Variable.Data_Type.REAL;
                    break;

                case "BOOLEAN":
                    declareNode._Var.VarType = DeclareNode.Variable.Data_Type.BOOLEAN;
                    break;

                case "STRING":
                    declareNode._Var.VarType = DeclareNode.Variable.Data_Type.STRING;
                    break;
                }
            }
        }
Esempio n. 9
0
 public void Visit(DeclareNode node)
 {
     Nodes.Push(new DeclareNode(node.Variable, node.Type, node.Value));
 }
Esempio n. 10
0
 public void Visit(DeclareNode node)
 {
     source.Append(node.GetDeclareType().Identifier + " ");
     node.GetObject().Visit(this);
 }