Commit 35ce1705 authored by Alexander Dietsch's avatar Alexander Dietsch
Browse files

Simulator:

-Fixed minor bugs occuring on rare conditions

Dissertation:
Finished dissertation
parent 8f0d4580
Loading
Loading
Loading
Loading
+200 KiB (590 KiB)

File changed.

No diff preview for this file type.

+18 −15
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ namespace LWSimulatorCons
                         }
                            } },
                {
                    "e|execute",  "automatically run the program; sets clock-rate to 0 and sets parameter '--quarantined'",
                    "r|run",  "automatically run the code; sets clock-rate to 0 and sets parameter '--quarantined'",
                     v => {
                         if(v != null)
                         {
@@ -73,11 +73,11 @@ namespace LWSimulatorCons
                    "q|quarantined",  "disallow the simulator to save the options so they won't carry over to the next start; will be set automatically if paremeter '--run' is set",
                     v => quarantined = v != null },
                {
                    "R|variables=",  "set variable file",
                    "V|variables=",  "set variable file",
                     v => variablePath = v },

                {
                    "r|limit-variables=",  "limit the number of variables that any program is allowed to use at most; default is 100",
                    "v|limit-variables=",  "limit the number of variables that any code is allowed to use at most; default is 100",
                     v => {
                         if (!tryParseValue(v,out limitVariables))
                         {
@@ -86,7 +86,7 @@ namespace LWSimulatorCons
                         }
                             } },
                {
                    "s|limit-steps=",  "limit the number of steps that any program is allowed to do at most before being interrupted; default is 0 (off)",
                    "s|limit-steps=",  "limit the number of steps that any code is allowed to do at most before being interrupted; default is 0 (off)",
                     v => {
                         if (!tryParseValue(v,out limitSteps))
                         {
@@ -159,7 +159,7 @@ namespace LWSimulatorCons

            if (!errors[0] && limitVariables != long.MaxValue)
            {
                if(limitVariables <= 0 || !simulator.setOptionVal("maxRegAm",limitVariables))
                if(limitVariables <= 0 || !simulator.setOptionVal("maxVarAm",limitVariables))
                {
                    errorInd = true;
                    errors[1] = true;
@@ -218,9 +218,9 @@ namespace LWSimulatorCons
                    {
                        if(!simulator.allInitialized())
                        {
                            printLog("WARNING: The LWSimulator DLL uses callback functions unknown to this console application.");
                            printLog(new List<string> { "WARNING: The LWSimulator DLL uses callback functions unknown to this console application." });
                        }
                        simulator.runProgram(program);
                        simulator.runProgram(program,inputPath);
                        waitForFinish.WaitOne();
#if (DEBUG)
                        Console.ReadLine();
@@ -294,15 +294,18 @@ namespace LWSimulatorCons
            return true;
        }

        private static void printLog(string s)
        private static void printLog(List<string> s)
        {
            if (logLevel == 2 && !s.StartsWith("Code returned") && !s.StartsWith("Syntax"))
                return;
            if (logLevel == 1 && !(s.StartsWith("WARNING") || s.StartsWith("ERROR") || s.StartsWith("Code returned") || s.StartsWith("Syntax")))
                return;
            if (logLevel == 0 && s.StartsWith("DEBUG"))
                return;
            Console.WriteLine(s);
            for (int i = 0; i < s.Count; i++)
            {
                if (logLevel == 2 && !s[i].StartsWith("Code returned") && !s[i].StartsWith("Syntax"))
                    continue;
                if (logLevel == 1 && !(s[i].StartsWith("WARNING") || s[i].StartsWith("ERROR") || s[i].StartsWith("Code returned") || s[i].StartsWith("Syntax")))
                    continue;
                if (logLevel == 0 && s[i].StartsWith("DEBUG"))
                    continue;
                Console.WriteLine(s[i]);
            }
        }

        /// <summary>
Loading