public void SimpleFunction()
        {
            IQMFuncExecutable f = QMFuncUtils.GenerateFunction();
            var lines           = f.CodeItUp().ToArray();

            lines.DumpToConsole();
            Assert.IsTrue(lines.Where(l => l.Contains(string.Format("int {0} ()", f.Name))).Any(), "no decl");
        }
Esempio n. 2
0
        /// <summary>
        /// Emit C++ code for a function
        /// </summary>
        /// <param name="func"></param>
        /// <returns></returns>
        public static IEnumerable <string> CodeItUp(this IQMFuncExecutable func)
        {
            // The header and decl.
            yield return(string.Format("// {0} - {1}", func.Name, func.QueryModelText));

            yield return(string.Format("{0} {1};", func.CacheVariable.Type.AsCPPType(), func.CacheVariable.RawValue));

            yield return(string.Format("{0} {1};", func.CacheVariableGood.Type.AsCPPType(), func.CacheVariableGood.RawValue));

            yield return(string.Format("{0} {1} ()", func.ResultType.AsCPPType(), func.Name));

            foreach (var l in func.StatementBlock.CodeItUp())
            {
                yield return("  " + l);
            }

            yield return("");
        }
Esempio n. 3
0
 /// <summary>
 /// See if this executable function matches another one.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Matches(IQMFuncExecutable other)
 {
     return(QueryModelText == other.QueryModelText);
 }
Esempio n. 4
0
 /// <summary>
 /// See if this executable function matches another one.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Matches(IQMFuncExecutable other)
 {
     return QueryModelText == other.QueryModelText;
 }