While.AST.Statements.Call.SanityCheck C# (CSharp) Method

SanityCheck() private method

private SanityCheck ( ) : void
return void
        private void SanityCheck()
        {
            int l = _callToken.line;
            int c = _callToken.col;

            if (!WhileProgram.Instance.Procedures.ContainsProcedure(ProcedureName)) {
                System.Console.Error.WriteLine(string.Format("({0},{1}) ERROR: Procedure '{2}' is not defined", l, c, ProcedureName));
                global::While.Environment.Exit(1);
            }

            Procedure proc = WhileProgram.Instance.Procedures.GetByName(ProcedureName);
            if (this.Expressions.Count != proc.ArgumentCount) {
                System.Console.Error.WriteLine(string.Format("({0},{1}) ERROR: Procedure '{2}' does not take {3} arguments", l, c, ProcedureName, Expressions.Count));
                global::While.Environment.Exit(1);
            }

            if (proc.HasResultArgument && !(Expressions[Expressions.Count - 1] is Variable)) {
                System.Console.Error.WriteLine(string.Format("({0},{1}) ERROR: Only variables are allowed for result arguments", _lastArgToken.line, _lastArgToken.col));
                global::While.Environment.Exit(1);
            }
        }