< Summary

Class:NanoCLang.Entities.Program
Assembly:NanoCLang
File(s):C:\GitLab-Runner\builds\JxAESPd8\0\chenmichael\nanoc\src\NanoCLang\Entities\Program\Program.cs
Covered lines:12
Uncovered lines:0
Coverable lines:12
Total lines:46
Line coverage:100% (12 of 12)
Covered branches:4
Total branches:4
Branch coverage:100% (4 of 4)

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_DefaultEnvironemt()100%1100%
WellFormed()100%1100%
.cctor()100%1100%
PrintHeader()100%4100%

File(s)

C:\GitLab-Runner\builds\JxAESPd8\0\chenmichael\nanoc\src\NanoCLang\Entities\Program\Program.cs

#LineLine coverage
 1using NanoCLang.Environemnts;
 2using System;
 3using System.Collections.Generic;
 4
 5namespace NanoCLang.Entities {
 6    /// <summary>
 7    /// Provides a superclass for all program entites.
 8    /// </summary>
 9    public abstract class Program : Base {
 10        /// <summary>
 11        /// Creates the default environment that programs are type checked with.
 12        /// This may contain NanoC support functions or standard libraries as well as includes from functions.
 13        /// </summary>
 1014        public GlobalEnvironment DefaultEnvironemt => new GlobalEnvironment();
 15        /// <summary>
 16        /// Checks if the rogram is well-formed and raises an exception if it is ill-formed.
 17        /// If it is well-formed it returns the type of the program.
 18        /// Uses the <see cref="DefaultEnvironemt"/> to check the program.
 19        /// </summary>
 20        /// <exception cref="IllFormedException">Program is ill-formed.</exception>
 21        /// <returns>Type of the program entity.</returns>
 1022        public virtual World WellFormed() => WellFormed(DefaultEnvironemt);
 23        /// <summary>
 24        /// Checks if the program is well-formed and raises an exception if it is ill-formed.
 25        /// </summary>
 26        /// <param name="phi">Environemt to check the program with.</param>
 27        /// <exception cref="IllFormedException">Program is ill-formed.</exception>
 28        /// <returns>Type of the program entity.</returns>
 29        public abstract World WellFormed(GlobalEnvironment phi);
 130        private static readonly string[] includes = new string[] {
 131            "stdlib.h" /* allocation expressions */,
 132            "stdint.h" /* fixed width integer types */,
 133        };
 34        /// <summary>
 35        /// Print the program header if it is not yet printed.
 36        /// </summary>
 37        /// <param name="args">Arguments that include whether the header was already printed.</param>
 38        /// <returns>Tokens that represent the header.</returns>
 3539        protected static IEnumerable<StringFormatterToken> PrintHeader(CSourceFormat args) {
 6440            if (args.HeaderPrinted) yield break;
 5441            foreach (var include in includes) yield return $"#include <{include}>\n";
 642            yield return "\n";
 643            args.HeaderPrinted = true;
 644        }
 45    }
 46}