Example #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 U2C_BOOL {0}()", funcname);
            app("{{");
            app("    {0}", eg.generate(guard));
            app("}};");
            return(funcname);
        }
 public string generate(GuardRule gr)
 {
     return(String.Format("return ({0});",
                          generate(gr.Expr)));
 }