Ejemplo n.º 1
0
        private string FormatGuardFunction(string objname, Declarations decls, IEnumerable <Rule> rules)
        {
            GuardRule guard = (GuardRule)rules.SingleOrDefault(x => x is GuardRule);

            if (guard == null)
            {
                return(NULL);
            }

            string funcname        = String.Format("guardfunc_{0}", objname);
            ExpressionGenerator eg = new ExpressionGenerator(getUniqueName, decls, StateStructName);

            app("static bool {0}()", funcname);
            app("{{");
            app("    {0}", eg.generate(guard));
            app("}};");
            return(funcname);
        }
Ejemplo n.º 2
0
        private string FormatUpdateFunction(string objname, Declarations decls, IEnumerable <Rule> rules)
        {
            UpdateRule[] urules = (rules.Where(x => x is UpdateRule).Select(x => (UpdateRule)x).ToArray());
            if (urules == null || urules.Length == 0)
            {
                return(NULL);
            }

            string funcname        = String.Format("updatefunc_{0}", objname);
            ExpressionGenerator eg = new ExpressionGenerator(getUniqueName, decls, StateStructName);

            app("static void {0}()", funcname);
            app("{{");
            foreach (UpdateRule ur in urules)
            {
                app("    {0}", eg.generate(ur));
            }
            app("}};");
            return(funcname);
        }