コード例 #1
0
        /// <summary>
        /// Creates array code
        /// </summary>
        /// <param name="tree">Base tree</param>
        /// <param name="ret">Return</param>
        /// <param name="parameters">Variables</param>
        /// <param name="variables">Parameters</param>
        /// <param name="initializers">Initializers</param>
        /// <returns>List of code strings</returns>
        protected IList <string> CreateTreeCode(ObjectFormulaTree tree, string ret, string[] parameters,
                                                out IList <string> variables, out IList <string> initializers)
        {
            List <string> l = new List <string>();

            if (tree.ReturnType.IsEmpty())
            {
                variables    = new List <string>();
                initializers = new List <string>();
                return(l);
            }
            int    n    = StaticCodeCreator.GetNumber(this, tree);
            string curr = "trees[" + n + "].";
            // l.Add("currentTree = trees[" + n + "];");
            int           count = tree.Count;
            List <string> vari  = new List <string>();

            if (count > 0)
            {
                string ta = "treeArray_" + n;
                l.Add("currentArray = " + ta + ";");
                vari.Add("object[] " + ta + " = new object[" + count + "];");
            }
            for (int i = 0; i < count; i++)
            {
                ObjectFormulaTree t = tree[i];
                if (t == null)
                {
                    continue;
                }
                if (count > 0)
                {
                    string id = codeCreator[t];
                    l.Add("currentArray[" + i + "] = " + id + ";");
                }
            }
            string ss = "";
            string tt = typeCreator.GetType(tree.ReturnType);

            if (!tt.Equals("object"))
            {
                ss = "(" + tt + ")";
            }
            if (count > 0)
            {
                l.Add(ret + " = " + ss + curr + "Calculate(currentArray);");
            }
            else
            {
                l.Add(ret + " = " + ss + curr + "Calculate();");
            }
            initializers = new List <string>();
            variables    = vari;
            return(l);
        }
コード例 #2
0
        private void AddTree(ObjectFormulaTree tree, IList <string> init, IList <string> func)
        {
            int    n   = StaticCodeCreator.GetNumber(local, tree);
            string tid = local[tree];
            string f   = "Get_" + n;

            init.Add("dictionary[trees[" + n + "]] = " + f + ";");
            func.Add("");
            func.Add("object " + f + "()");
            func.Add("{");
            func.Add("\treturn " + tid + ";");
            func.Add("}");
        }