Exemple #1
0
        public override void report(int sh)
        {
            string n = (this is INITIALIZER) ? "INIT " : "ROUTINE ";
            string a = (genericParameters.Count > 0) ? "GENERIC " : "";

            a += isPure ? "PURE " : "";
            a += isSafe ? "SAFE " : "";
            a += isAbstract ? "ABSTRACT " : "";
            a += isForeign ? "FOREIGN " : "";
            a += isOverride ? "OVERRIDE " : "";
            string common = commonAttrs();
            string r      = common + shift(sh) + a + n + name.identifier;

            if (alias != null)
            {
                r += " ALIAS " + alias.identifier;
            }
            System.Console.WriteLine(r);

            if (type != null)
            {
                type.report(sh + constant);
            }
            if (genericParameters.Count > 0)
            {
                System.Console.WriteLine(shift(common.Length + sh) + "GENERIC PARAMETERS");
                foreach (FORMAL_GENERIC generic in genericParameters)
                {
                    generic.report(sh + constant);
                }
            }
            if (parameters.Count > 0)
            {
                System.Console.WriteLine(shift(common.Length + sh) + "PARAMETERS");
                foreach (ENTITY parameter in parameters)
                {
                    parameter.report(sh + constant);
                }
            }
            if (preconditions.Count > 0)
            {
                string pe = "PRECONDITIONS require";
                if (this.requireElse)
                {
                    pe += " else";
                }
                System.Console.WriteLine(shift(common.Length + sh) + pe);
                foreach (EXPRESSION precondition in preconditions)
                {
                    precondition.report(sh + constant);
                }
            }

            if (routineBody != null && routineBody.body.Count > 0)
            {
                routineBody.report(sh);
            }

            if (postconditions.Count > 0)
            {
                string pt = "POSTCONDITIONS ensure";
                if (this.ensureThen)
                {
                    pt += " then";
                }
                System.Console.WriteLine(shift(common.Length + sh) + pt);
                foreach (EXPRESSION postcondition in postconditions)
                {
                    postcondition.report(sh + constant);
                }
            }
        }