Example #1
0
        internal void GenerateDotCode(DotGraph graph)
        {
            switch (graph.GraphType)
            {
            case DotGraphType.StrictDirected:
                TextComposer.Append("strict digraph ");
                break;

            case DotGraphType.Directed:
                TextComposer.Append("digraph ");
                break;

            default:
                TextComposer.Append("graph ");
                break;
            }

            if (String.IsNullOrEmpty(graph.GraphName) == false)
            {
                TextComposer.Append(ToDotId(graph.GraphName));
            }

            TextComposer.AppendLine().Append("{").IncreaseIndentation();

            foreach (var statement in graph.StatementsList)
            {
                GenerateDotCode(statement);
            }

            TextComposer
            .DecreaseIndentation()
            .AppendLine()
            .Append("}");
        }
Example #2
0
        public override void Visit(SteDeclareFixedSizeArray code)
        {
            if (code.LocalDataStore == false)
            {
                AddInternalComment("TODO: Non-local array declaration not yet implemented: ", code.ToString());

                return;
            }

            TextComposer
            .Append(code.DataStoreType)
            .Append(" ")
            .Append(code.DataStoreName)
            .Append(" = ");

            if (code.InitialValue != null)
            {
                code.InitialValue.AcceptVisitor(this);
            }
            else
            {
                TextComposer
                .Append("new ")
                .Append(code.DataStoreType)
                .Append("[")
                .Append(code.ArraySize)
                .Append("]");
            }

            TextComposer.AppendLine(";");
        }
Example #3
0
        public void Visit(SteIfElse code)
        {
            TextComposer.AppendAtNewLine("if (");

            code.Condition.AcceptVisitor(this);

            TextComposer
            .AppendLine(")")
            .AppendLine("{")
            .IncreaseIndentation();

            code.TrueCode.AcceptVisitor(this);

            TextComposer
            .DecreaseIndentation()
            .AppendLineAtNewLine("}");

            if (code.ElseCode == null)
            {
                return;
            }

            TextComposer.AppendLine("else")
            .AppendLine("{")
            .IncreaseIndentation();

            code.ElseCode.AcceptVisitor(this);

            TextComposer
            .DecreaseIndentation()
            .AppendLineAtNewLine("}");
        }
Example #4
0
        public void Visit(SteDeclareMethod code)
        {
            var modifiersText = code.ModifiersList.Concatenate(" ");

            TextComposer
            .Append(modifiersText)
            .Append(code.ReturnType)
            .Append(code.MethodName)
            .Append("(");

            foreach (var item in code.Parameters)
            {
                item.AcceptVisitor(this);
            }

            TextComposer
            .AppendLine(")")
            .Append("{")
            .IncreaseIndentation();

            code.MethodCode.AcceptVisitor(this);

            TextComposer
            .DecreaseIndentation()
            .AppendAtNewLine("}");
        }
Example #5
0
        public void Visit(SteSwitchCase code)
        {
            TextComposer.AppendAtNewLine("switch (");

            code.SwitchExpression.AcceptVisitor(this);

            TextComposer
            .AppendLine(")")
            .AppendLine("{")
            .IncreaseIndentation();

            foreach (var item in code.CasesList)
            {
                item.AcceptVisitor(this);
            }

            if (code.DefaultCode != null)
            {
                TextComposer.AppendLineAtNewLine("default:").IncreaseIndentation();
                code.DefaultCode.AcceptVisitor(this);
                TextComposer.AppendLineAtNewLine("break;");
            }

            TextComposer
            .DecreaseIndentation()
            .AppendLineAtNewLine("}");
        }
        internal void GenerateBladeFileStartCode()
        {
            TextComposer.AppendLine(
                Templates["blade_file_start"].GenerateUsing(CurrentFrameName)
                );

            TextComposer.IncreaseIndentation();
            TextComposer.IncreaseIndentation();
        }
        internal void GenerateOutermorphismFileStartCode()
        {
            TextComposer.AppendLine(
                Templates["om_file_start"],
                "frame", CurrentFrameName,
                "grade", CurrentFrame.VSpaceDimension
                );

            TextComposer.IncreaseIndentation();
            TextComposer.IncreaseIndentation();
        }
Example #8
0
        public override void Visit(SteReturn code)
        {
            if (ReferenceEquals(code.ReturnedValue, null))
            {
                TextComposer.AppendLine("return;");
                return;
            }

            TextComposer.Append("return ");

            code.ReturnedValue.AcceptVisitor(this);

            TextComposer.AppendLine(";");
        }
Example #9
0
        public void Visit(SteIf code)
        {
            TextComposer.AppendAtNewLine("if (");

            code.Condition.AcceptVisitor(this);

            TextComposer
            .AppendLine(")")
            .AppendLine("{")
            .IncreaseIndentation();

            code.TrueCode.AcceptVisitor(this);

            TextComposer
            .DecreaseIndentation()
            .AppendLineAtNewLine("}");
        }
Example #10
0
        public void Visit(TccTryCatchItem code)
        {
            TextComposer.AppendLineAtNewLine("catch (");

            code.CatchException.AcceptVisitor(this);

            TextComposer
            .AppendLine(")")
            .AppendLine("{")
            .IncreaseIndentation();

            code.CatchCode.AcceptVisitor(this);

            TextComposer
            .DecreaseIndentation()
            .AppendLineAtNewLine("}");
        }
Example #11
0
        public override void Visit(SteAssign code)
        {
            if (code.LocalAssignment == false)
            {
                AddInternalComment("TODO: Non-local assignment not yet implemented: ", code.ToString());

                return;
            }

            code.LeftHandSide.AcceptVisitor(this);

            TextComposer.Append(" = ");

            code.RightHandSide.AcceptVisitor(this);

            TextComposer.AppendLine(";");
        }
Example #12
0
        public void Visit(TccSwitchCaseItem code)
        {
            TextComposer.AppendAtNewLine("case ");

            code.CaseValue.AcceptVisitor(this);

            TextComposer.AppendLine(":").IncreaseIndentation();

            code.CaseCode.AcceptVisitor(this);

            if (code.BreakCase)
            {
                TextComposer.AppendLineAtNewLine("break;");
            }

            TextComposer.DecreaseIndentation();
        }
Example #13
0
        public void Visit(SteIfElseIfElse code)
        {
            var flag = false;

            foreach (var item in code.IfList)
            {
                if (flag == false)
                {
                    TextComposer.AppendAtNewLine("if (");
                    flag = true;
                }
                else
                {
                    TextComposer.AppendAtNewLine("else if (");
                }

                item.Condition.AcceptVisitor(this);

                TextComposer
                .AppendLine(")")
                .AppendLine("{")
                .IncreaseIndentation();

                item.TrueCode.AcceptVisitor(this);

                TextComposer
                .DecreaseIndentation()
                .AppendLineAtNewLine("}");
            }

            if (code.ElseCode == null)
            {
                return;
            }

            TextComposer.AppendLine("else")
            .AppendLine("{")
            .IncreaseIndentation();

            code.ElseCode.AcceptVisitor(this);

            TextComposer
            .DecreaseIndentation()
            .AppendLineAtNewLine("}");
        }
Example #14
0
        public override void Visit(SteDeclareDataStore code)
        {
            var modifiersText = code.ModifiersList.Concatenate(" ");

            TextComposer
            .Append(modifiersText)
            .Append(code.DataStoreType)
            .Append(" ")
            .Append(code.DataStoreName);

            if (code.InitialValue != null)
            {
                TextComposer.Append(" = ");
                code.InitialValue.AcceptVisitor(this);
            }

            TextComposer.AppendLine(";");
        }
Example #15
0
        public void Visit(SteForLoop code)
        {
            TextComposer.AppendAtNewLine("for (");

            code.LoopInitialization.AcceptVisitor(this);

            TextComposer.Append("; ");

            code.LoopCondition.AcceptVisitor(this);

            TextComposer.Append("; ");

            code.LoopUpdate.AcceptVisitor(this);

            TextComposer.AppendLine(")").Append("{").IncreaseIndentation();

            code.LoopCode.AcceptVisitor(this);

            TextComposer.DecreaseIndentation().AppendLineAtNewLine("}");
        }
Example #16
0
        public void Visit(SteForEachLoop code)
        {
            TextComposer
            .AppendAtNewLine("foreach (")
            .Append(code.LoopVariableType)
            .Append(code.LoopVariableName)
            .Append(" in ");

            code.LoopCollection.AcceptVisitor(this);

            TextComposer
            .AppendLine(")")
            .Append("{")
            .IncreaseIndentation();

            code.LoopCode.AcceptVisitor(this);

            TextComposer
            .DecreaseIndentation()
            .AppendLineAtNewLine("}");
        }
Example #17
0
        public override void Visit(SteComment code)
        {
            if (code.MultiLineComment)
            {
                TextComposer.AppendLine("/*");

                foreach (var commentLine in code.CommentedTextLines)
                {
                    TextComposer.AppendLine(commentLine);
                }

                TextComposer.AppendLine("*/");

                return;
            }

            foreach (var commentLine in code.CommentedTextLines)
            {
                TextComposer.Append("//").AppendLine(commentLine);
            }
        }
Example #18
0
        public void Visit(SteWhileLoop code)
        {
            if (code.DoLoop)
            {
                TextComposer
                .AppendAtNewLine("do")
                .AppendLine("{")
                .IncreaseIndentation();

                code.LoopCode.AcceptVisitor(this);

                TextComposer
                .DecreaseIndentation()
                .AppendAtNewLine("} while (");

                code.LoopCondition.AcceptVisitor(this);

                TextComposer.AppendNewLine(");");

                return;
            }

            TextComposer.AppendAtNewLine("while (");

            code.LoopCondition.AcceptVisitor(this);

            TextComposer
            .AppendLine(")")
            .AppendLine("{")
            .IncreaseIndentation();

            code.LoopCode.AcceptVisitor(this);

            TextComposer
            .DecreaseIndentation()
            .AppendLineAtNewLine("}");
        }
Example #19
0
        internal void GenerateDotCode(DotSubGraph graph)
        {
            if (String.IsNullOrEmpty(graph.SubGraphName) == false)
            {
                TextComposer
                .Append("subgraph ")
                .Append(ToDotId(graph.SubGraphName));
            }

            TextComposer
            .AppendLine()
            .Append("{")
            .IncreaseIndentation();

            foreach (var statement in graph.StatementsList)
            {
                GenerateDotCode(statement);
            }

            TextComposer
            .DecreaseIndentation()
            .AppendLine()
            .Append("}");
        }