Beispiel #1
0
 public void VisitExpressionStatement(ExpressionStatement expressionStatement)
 {
     _generatedCode
     .Append(
         ExpressionCodeGenerator.GenerateExpressionCode(expressionStatement.Expression))
     .Append(";\n");
 }
Beispiel #2
0
 public void VisitReturnStatement(ReturnStatement returnStatement)
 {
     _generatedCode
     .Append("return ")
     .Append(ExpressionCodeGenerator.GenerateExpressionCode(returnStatement.Expression))
     .Append(";\n");
 }
Beispiel #3
0
 public void VisitAssignmentStatement(AssignmentStatement assignmentStatement)
 {
     _generatedCode
     .Append(ExpressionCodeGenerator.GenerateExpressionCode(assignmentStatement.Target))
     .Append(" = ")
     .Append(ExpressionCodeGenerator.GenerateExpressionCode(assignmentStatement.Value))
     .Append(";\n");
 }
Beispiel #4
0
 public void VisitWhileStatement(WhileStatement whileStatement)
 {
     _generatedCode
     .Append("while (")
     .Append(ExpressionCodeGenerator.GenerateExpressionCode(whileStatement.Condition))
     .Append(") ");
     GenerateBlockCode(whileStatement.Body);
 }
Beispiel #5
0
 public void VisitAssertStatement(AssertStatement assertStatement)
 {
     _generatedCode
     .Append("WIRE_ASSERT__(\"")
     .Append(_context.SourceFile.FilePath)
     .Append("\", ")
     .Append(assertStatement.Span.Line)
     .Append(", ")
     .Append(assertStatement.Span.Column)
     .Append(", ")
     .Append(ExpressionCodeGenerator.GenerateExpressionCode(assertStatement.Condition))
     .Append(", \"")
     .Append(_context.SourceFile.ReadSpan(assertStatement.Condition.Span))
     .Append("\");\n");
 }
Beispiel #6
0
        public void VisitVariableDefinition(VariableDefinition variableDefinition)
        {
            _generatedCode
            .Append(
                TypeSignatureGenerator.GenerateTypeSignature(
                    _astContext.GetNodeType(variableDefinition.NodeId)))
            .Append(' ')
            .Append(variableDefinition.Identifier);

            if (variableDefinition.Initializer != null)
            {
                _generatedCode
                .Append(" = ")
                .Append(
                    ExpressionCodeGenerator.GenerateExpressionCode(
                        variableDefinition.Initializer));
            }

            _generatedCode.Append(";\n");
        }
Beispiel #7
0
        public void VisitIfStatement(IfStatement ifStatement)
        {
            _generatedCode
            .Append("if (")
            .Append(ExpressionCodeGenerator.GenerateExpressionCode(ifStatement.Condition))
            .Append(") ");
            GenerateBlockCode(ifStatement.ThenBody);

            foreach (var elif in ifStatement.Elifs)
            {
                _generatedCode
                .Append("else if(")
                .Append(ExpressionCodeGenerator.GenerateExpressionCode(elif.Condition))
                .Append(") ");
                GenerateBlockCode(elif.Body);
            }

            if (ifStatement.ElseBody == null)
            {
                return;
            }
            _generatedCode.Append("else ");
            GenerateBlockCode(ifStatement.ElseBody);
        }