Exemplo n.º 1
0
        public decimal Evaluate(CalculatorValue comparingValue)
        {
            var conditionKey = Conditions.Keys
                               .FirstOrDefault(value => value.Evaluate(comparingValue));

            return(conditionKey == null ? DefaultValue : Conditions[conditionKey]);
        }
Exemplo n.º 2
0
 internal static bool OnAction(string action, Query query, Result result, ActionContext e)
 {
     lock (s_PluginLock) {
         //由于Wox实现上的缺陷,这里根据result的Title与SubTitle在结果列表里查找真正的result项再调action
         int ix = s_Results.IndexOf(result);
         if (ix < 0)
         {
             s_Context.API.ShowMsg("Can't find result " + result.Title, result.SubTitle, result.IcoPath);
             return(false);
         }
         if (s_Results[ix].ContextData != result.ContextData || s_Results[ix].Action != result.Action)
         {
             return(s_Results[ix].Action(e));
         }
         var r = BatchScript.Call(action, CalculatorValue.FromObject(query), CalculatorValue.FromObject(result), CalculatorValue.FromObject(e));
         ShowLog("OnAction");
         if (s_NeedReload)
         {
             s_NeedReload = false;
             ReloadDsl();
         }
         if (r.IsBoolean)
         {
             bool ret = r.GetBool();
             return(ret);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 3
0
        protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
        {
            var r = CalculatorValue.NullObject;

            if (operands.Count >= 1)
            {
                var obj = operands[0].As <AndroidJavaObject>();
                if (null != obj)
                {
                    r = CalculatorValue.FromObject(new JavaObject(obj));
                }
                else
                {
                    var str = operands[0].AsString;
                    var al  = new ArrayList();
                    for (int i = 1; i < operands.Count; ++i)
                    {
                        al.Add(operands[i].Get <object>());
                    }
                    if (!string.IsNullOrEmpty(str))
                    {
                        r = CalculatorValue.FromObject(new JavaObject(str, al.ToArray()));
                    }
                }
            }
            return(r);
        }
Exemplo n.º 4
0
 internal static bool OnMenuAction(string action, Query query, Result result, Result menu, ActionContext e)
 {
     lock (s_PluginLock) {
         //由于Wox实现上的缺陷,这里根据menu的Title与SubTitle在菜单列表里查找真正的菜单项再调action
         int ix = s_ContextMenus.IndexOf(menu);
         if (ix < 0)
         {
             s_Context.API.ShowMsg("Can't find menu " + menu.Title, menu.SubTitle, menu.IcoPath);
             return(false);
         }
         if (s_ContextMenus[ix].ContextData != menu.ContextData || s_ContextMenus[ix].Action != menu.Action)
         {
             return(s_ContextMenus[ix].Action(e));
         }
         object r = BatchScript.Call(action, CalculatorValue.FromObject(query), CalculatorValue.FromObject(result), CalculatorValue.FromObject(menu), CalculatorValue.FromObject(e));
         ShowLog("OnMenuAction");
         if (s_NeedReload)
         {
             s_NeedReload = false;
             ReloadDsl();
         }
         if (null != r)
         {
             bool ret = (bool)Convert.ChangeType(r, typeof(bool));
             return(ret);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 5
0
        public ActionResult Calculate(CalculatorValue val)
        {
            List <decimal> result = new List <decimal>();

            for (int i = 0; i < this.dataUnits.Count; i++)
            {
                if (i == val.Type)
                {
                    result.Add(val.Value);
                }
                else
                {
                    if (i < val.Type)
                    {
                        result.Add(val.Value * (decimal)Math.Pow(1024, val.Type - i));
                    }
                    else
                    {
                        result.Add(val.Value / (decimal)Math.Pow(1024, i - val.Type));
                    }
                }
            }
            ViewBag.types = this.dataUnits;
            return(View(result));
        }
        public void Has_to_return_correct_value_irregular_order()
        {
            ISwitch <CalculatorValue> systemUnderTests = new Switch <int>(_switchData, -128M);

            var valueToCompare = new CalculatorValue(11M);

            Assert.AreEqual(0M, systemUnderTests.Evaluate(valueToCompare));
        }
Exemplo n.º 7
0
        protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
        {
            var r = CalculatorValue.NullObject;

#if UNITY_ANDROID
            r = CalculatorValue.FromObject(new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic <AndroidJavaObject>("currentActivity"));
#endif
            return(r);
        }
Exemplo n.º 8
0
 public List <Result> Query(Query query)
 {
     lock (s_PluginLock) {
         s_Results.Clear();
         BatchScript.Call("on_query", CalculatorValue.FromObject(query));
         ShowLog("Query");
         return(s_Results);
     }
 }
Exemplo n.º 9
0
        public void Has_to_return_correct_value_for_less_condition()
        {
            ICondition <CalculatorValue> systemUnderTests = new Condition(new CalculatorValue(10M), LogicalOperator.Less);

            var valueToCompareTrue  = new CalculatorValue(9M);
            var valueToCompareFalse = new CalculatorValue(10M);

            Assert.IsTrue(systemUnderTests.Evaluate(valueToCompareTrue));
            Assert.IsFalse(systemUnderTests.Evaluate(valueToCompareFalse));
        }
        public void Has_to_return_correct_value_for_and_operator()
        {
            ICondition <CalculatorValue> systemUnderTests = new MultiCondition(new[] { _condition1, _condition2 }, BooleanOperator.And);

            var valueToCompareTrue  = new CalculatorValue(15M);
            var valueToCompareFalse = new CalculatorValue(16M);

            Assert.IsTrue(systemUnderTests.Evaluate(valueToCompareTrue));
            Assert.IsFalse(systemUnderTests.Evaluate(valueToCompareFalse));
        }
Exemplo n.º 11
0
 public List <Result> LoadContextMenus(Result selectedResult)
 {
     lock (s_PluginLock) {
         s_ContextMenus.Clear();
         Query query = selectedResult.ContextData as Query;
         BatchScript.Call("on_context_menus", CalculatorValue.FromObject(query), CalculatorValue.FromObject(selectedResult));
         ShowLog("LoadContextMenus");
         return(s_ContextMenus);
     }
 }
Exemplo n.º 12
0
        public void Has_to_return_correct_value_for_band(decimal value, decimal expected, string expectedName)
        {
            var calculatorValue = new CalculatorValue(value, nameof(value));
            var expectedResult  = new CalculatorValue(expected, expectedName);

            var actualResult = SystemUnderTests.Resolve(calculatorValue);

            Assert.AreEqual(expectedResult.Value, actualResult.Value);
            Assert.AreEqual(expectedResult.Name, actualResult.Name);
        }
Exemplo n.º 13
0
        protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
        {
            var r = CalculatorValue.NullObject;

            if (operands.Count >= 1)
            {
                int objId = operands[0].Get <int>();
                return(CalculatorValue.FromObject(new ObjectcObject(objId)));
            }
            return(r);
        }
Exemplo n.º 14
0
        protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
        {
            var r = CalculatorValue.NullObject;

            if (operands.Count >= 1)
            {
                var str = operands[0].AsString;
                r = CalculatorValue.FromObject(new ObjectcClass(str));
            }
            return(r);
        }
Exemplo n.º 15
0
        public void Has_to_return_correct_value_for_greater_or_equal_condition()
        {
            ICondition <CalculatorValue> systemUnderTests = new Condition(new CalculatorValue(10M), LogicalOperator.GreaterOrEqual);

            var valueToCompareFalse = new CalculatorValue(9M);
            var valueToCompareTrue1 = new CalculatorValue(10M);
            var valueToCompareTrue2 = new CalculatorValue(11M);

            Assert.IsTrue(systemUnderTests.Evaluate(valueToCompareTrue1));
            Assert.IsTrue(systemUnderTests.Evaluate(valueToCompareTrue2));
            Assert.IsFalse(systemUnderTests.Evaluate(valueToCompareFalse));
        }
Exemplo n.º 16
0
        protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
        {
            var r = CalculatorValue.NullObject;

            if (operands.Count >= 2)
            {
                var _class    = operands[0].AsString;
                var scpMethod = operands[1].AsString;
                r = CalculatorValue.FromObject(new JavaProxy(_class, scpMethod));
            }
            return(r);
        }
Exemplo n.º 17
0
 internal static void ReloadDsl()
 {
     lock (s_PluginLock) {
         string dslPath = Path.Combine(s_Context.CurrentPluginMetadata.PluginDirectory, "main.dsl");
         var    vargs   = BatchScript.NewCalculatorValueList();
         vargs.Add(s_Context.CurrentPluginMetadata.ID);
         vargs.Add(CalculatorValue.FromObject(s_Context.CurrentPluginMetadata));
         vargs.Add(CalculatorValue.FromObject(s_Context));
         BatchScript.Run(dslPath, vargs);
         BatchScript.RecycleCalculatorValueList(vargs);
         ShowLog("ReloadDsl");
     }
 }
Exemplo n.º 18
0
    public static object Call(string proc, params object[] args)
    {
        if (null == s_Instance)
        {
            return(null);
        }
        var vargs = s_Instance.m_Calculator.NewCalculatorValueList();

        foreach (var arg in args)
        {
            vargs.Add(CalculatorValue.FromObject(arg));
        }
        var r = s_Instance.m_Calculator.Calc(proc, vargs);

        s_Instance.m_Calculator.RecycleCalculatorValueList(vargs);
        return(r.Get <object>());
    }
Exemplo n.º 19
0
        protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
        {
            var r = CalculatorValue.NullObject;

#if UNITY_ANDROID
            if (operands.Count >= 1)
            {
                var str = operands[0].AsString;
                if (!string.IsNullOrEmpty(str))
                {
                    var act    = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic <AndroidJavaObject>("currentActivity");
                    var intent = act.Call <AndroidJavaObject>("getIntent");
                    r = CalculatorValue.FromObject(intent.Call <long[]>("getLongArrayExtra", str));
                }
            }
#endif
            return(r);
        }
Exemplo n.º 20
0
        protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
        {
            var r = CalculatorValue.NullObject;

            if (operands.Count >= 1)
            {
                var obj = operands[0].As <AndroidJavaClass>();
                if (null != obj)
                {
                    r = CalculatorValue.FromObject(new JavaClass(obj));
                }
                else
                {
                    var str = operands[0].AsString;
                    r = CalculatorValue.FromObject(new JavaClass(str));
                }
            }
            return(r);
        }
Exemplo n.º 21
0
 protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
 {
     if (operands.Count >= 1)
     {
         string str      = operands[0].AsString;
         uint   offset   = 0;
         uint   maxCount = 100;
         if (operands.Count >= 2)
         {
             offset = operands[1].Get <uint>();
         }
         if (operands.Count >= 3)
         {
             maxCount = operands[2].Get <uint>();
         }
         if (null != str)
         {
             EveryThingSDK.Everything_SetSearchW(str);
             EveryThingSDK.Everything_SetOffset(offset);
             EveryThingSDK.Everything_SetMax(maxCount);
             EveryThingSDK.Everything_SetRequestFlags(EveryThingSDK.EVERYTHING_REQUEST_FILE_NAME | EveryThingSDK.EVERYTHING_REQUEST_PATH | EveryThingSDK.EVERYTHING_REQUEST_SIZE | EveryThingSDK.EVERYTHING_REQUEST_DATE_MODIFIED);
             if (EveryThingSDK.Everything_QueryW(true))
             {
                 List <object[]> list = new List <object[]>();
                 uint            num  = EveryThingSDK.Everything_GetNumResults();
                 for (uint i = 0; i < num; ++i)
                 {
                     var sb = new StringBuilder(c_Capacity);
                     EveryThingSDK.Everything_GetResultFullPathName(i, sb, c_Capacity);
                     long size;
                     EveryThingSDK.Everything_GetResultSize(i, out size);
                     long time;
                     EveryThingSDK.Everything_GetResultDateModified(i, out time);
                     var dt = new DateTime(1601, 1, 1, 8, 0, 0, DateTimeKind.Utc) + new TimeSpan(time);
                     list.Add(new object[] { sb.ToString(), size, dt.ToString("yyyy-MM-dd HH:mm:ss") });
                 }
                 return(CalculatorValue.FromObject(list));
             }
         }
     }
     return(CalculatorValue.FromObject(s_EmptyList));
 }
Exemplo n.º 22
0
        private void CalButtonClick(object param)
        {
            int    num;
            string s = param.ToString();

            bool result = Int32.TryParse(s, out num);

            if (result)
            {
                CalculatorValue += param;
            }
            else if (s == "Del")
            {
                if (CalculatorValue.Count() > 0)
                {
                    CalculatorValue = CalculatorValue.Remove(CalculatorValue.Count() - 1, 1);
                }
            }
            else if (s == ".")
            {
                if (!CalculatorValue.ToArray().Any(c => c.Equals(Char.Parse("."))))
                {
                    CalculatorValue += param;
                }
            }

            if (CalculatorValue.Count() > 1)
            {
                if (CalculatorValue.ToArray().First().Equals(Char.Parse("0")) && !CalculatorValue.ToArray().Any(c => c.Equals(Char.Parse("."))))
                {
                    CalculatorValue = CalculatorValue.Remove(0, 1);
                }
            }

            if (CalculatorValue == string.Empty)
            {
                CalculatorValue = "0";
            }
        }
Exemplo n.º 23
0
    protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
    {
        CalculatorValue r = CalculatorValue.NullObject;

        if (operands.Count >= 1)
        {
            string code = operands[0].As <string>();
            var    args = BatchScript.NewCalculatorValueList();
            for (int i = 1; i < operands.Count; ++i)
            {
                var arg = operands[i];
                args.Add(arg);
            }
            var id = BatchScript.Eval(code, new string[] { "$query", "$result", "$actionContext" });
            if (null != id)
            {
                r = BatchScript.Call(id, args);
            }
            BatchScript.RecycleCalculatorValueList(args);
        }
        return(r);
    }
Exemplo n.º 24
0
 protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
 {
     return(CalculatorValue.FromObject(Main.s_Context.CurrentPluginMetadata));
 }
Exemplo n.º 25
0
 protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
 {
     return(CalculatorValue.FromObject(Main.s_Context.API));
 }
 protected override bool IsOutOfRange(decimal key, CalculatorValue value) => key > value.Value;
 protected override decimal SelectKey(CalculatorValue value)
 => Bands.LastOrDefault(b => b.Key <= value.Value).Key;
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            Pattern[] testPatternTbl = new Pattern[] {
                new Pattern("PI", Math.PI),
                new Pattern("E", Math.E),

                new Pattern("1 + 2", 1.0 + 2.0),
                new Pattern("2 - 3", 2.0 - 3.0),
                new Pattern("3 * 4", 3.0 * 4.0),
                new Pattern("4 / 5", 4.0 / 5.0),
                new Pattern("7 % 6", 7 % 6),
                new Pattern("7 MAX 8", 8),
                new Pattern("8 MIN 9", 8),
                new Pattern("9 ^ 2", 9 * 9),
                new Pattern("SQRT( 9 )", 3),

                new Pattern("FLOOR( 1.5 )", 1),
                new Pattern("FLOOR( -1.5 )", -2),

                new Pattern("CEILING( 1.4 )", 2),
                new Pattern("CEILING( -1.4 )", -1),

                new Pattern("ROUND( 1.4 )", 1),
                new Pattern("ROUND( 1.5 )", 2),

                new Pattern("TRUNC( 1.9 )", 1),
                new Pattern("TRUNC( -1.9 )", -1),

                new Pattern("SIGN( -2 )", -1),
                new Pattern("SIGN( 0 )", 0),
                new Pattern("SIGN( 2 )", 1),

                new Pattern("ABS( 10 )", 10),
                new Pattern("ABS( -10 )", 10),

                new Pattern("D2R( 180 )", Math.PI),
                new Pattern("R2D( PI )", 180),

                new Pattern("SIN( PI / 2 )", 1),
                new Pattern("COS( 0 )", 1),
                new Pattern("TAN( 1 )", Math.Tan(1)),

                new Pattern("ASIN( 1 )", Math.Asin(1)),
                new Pattern("ACOS( 1 )", Math.Acos(1)),
                new Pattern("ATAN( 1 )", Math.Atan(1)),

                new Pattern("HSIN( 1 )", Math.Sinh(1)),
                new Pattern("HCOS( 1 )", Math.Cosh(1)),
                new Pattern("HTAN( 1 )", Math.Tanh(1)),

                new Pattern("LOG( 100 )", Math.Log(100)),
                new Pattern("LOG10( 100 )", Math.Log10(100)),

                new Pattern("EXP( 0.1 )", Math.Exp(0.1)),

                new Pattern("1 + 2 * 3", 1 + 2 * 3),
                new Pattern("( 1 + 2 ) * 3", (1 + 2) * 3),
            };

            Calculator      calc = new Calculator();
            CalculatorValue ans;

            //----------------------------------------------------------------
            for (int i = 0; i < testPatternTbl.Length; i++)
            {
                Pattern pattern = testPatternTbl[i];
                Console.Write(string.Format("[{0}]:{1} ", i + 1, pattern.Cmd));

                calc.Clear();
                calc.EntryLine(pattern.Cmd);
                ans = calc.GetAnswer();
                Console.Write(string.Format("= {0} ", ans.Value));

                if (ans.Value != pattern.Ans)
                {
                    Console.WriteLine("NG");
                    throw new InvalidProgramException();
                }

                Console.WriteLine("OK");
            }

            //----------------------------------------------------------------
            calc.Clear();

            calc.Entry(new CalculatorOperatorOpen());
            calc.Entry(new CalculatorValue(1.2));
            calc.Entry(new CalculatorOperatorMul());
            calc.Entry(new CalculatorValue(3.4));
            calc.Entry(new CalculatorOperatorClose());

            calc.Entry(OperatorKeyWord.Sub);

            calc.Entry(new CalculatorOperatorOpen());
            calc.Entry(1.2);
            calc.Entry(OperatorKeyWord.Mul);
            calc.Entry(3.4);
            calc.Entry(new CalculatorOperatorClose());

            ans = calc.GetAnswer();
            if (ans.Value != 0)
            {
                Console.WriteLine("NG");
                throw new InvalidProgramException();
            }

            //----------------------------------------------------------------
            {
                CalculatorItemBase item1 = new CalculatorValue(12);
                CalculatorItemBase item2 = new CalculatorOperatorMod();
                CalculatorItemBase item3 = new CalculatorValue(5);

                calc.Clear();
                calc.Entry(item1, item2, item3);

                ans = calc.GetAnswer();
                if (ans.Value != 2)
                {
                    Console.WriteLine("NG");
                    throw new InvalidProgramException();
                }
            }

            //----------------------------------------------------------------
            {
                object item1 = -0.2;
                object item2 = "Max";
                object item3 = -0.1;

                calc.Clear();
                calc.Entry(item1, item2, item3);

                ans = calc.GetAnswer();
                if (ans.Value != -0.1)
                {
                    Console.WriteLine("NG");
                    throw new InvalidProgramException();
                }
            }

            //----------------------------------------------------------------
            {
                Calculator calc2 = new Calculator();
                calc2.GetItemEventHandler += delegate(string pKeyword) {
                    switch (pKeyword)
                    {
                    case "@1":
                        return(new CalculatorValue(10));

                    case "@2":
                        return(new CalculatorValue(20));
                    }

                    throw new NotImplementedException();
                };

                calc2.EntryLine("@1 * @2");

                ans = calc2.GetAnswer();
                if (ans.Value != (10 * 20))
                {
                    Console.WriteLine("NG");
                    throw new InvalidProgramException();
                }
            }

            //----------------------------------------------------------------
            Console.WriteLine("complete");
        }
Exemplo n.º 29
0
 protected override CalculatorValue OnCalc(IList <CalculatorValue> operands)
 {
     return(CalculatorValue.FromObject(ScriptProcessor.GetFileList()));
 }
 internal static void Process(GameObject root, Dsl.DslFile file, Dictionary <string, Color32[, ]> samplers, Dictionary <string, Size> cacheInfos, List <ObjectInfo> objects)
 {
     if (null != file)
     {
         List <TreeInstance>          trees  = new List <TreeInstance>();
         Dictionary <string, int[, ]> caches = new Dictionary <string, int[, ]>();
         foreach (var pair in cacheInfos)
         {
             caches.Add(pair.Key, new int[pair.Value.Width, pair.Value.Height]);
         }
         var   terrain     = root.GetComponent <Terrain>();
         var   terrainData = terrain.terrainData;
         var   datas       = terrainData.GetHeights(0, 0, terrainData.heightmapWidth, terrainData.heightmapHeight);
         var   alphamaps   = terrainData.GetAlphamaps(0, 0, terrainData.alphamapWidth, terrainData.alphamapHeight);
         int   alphanum    = alphamaps.GetLength(2);
         int[] layers      = terrainData.GetSupportedLayers(0, 0, terrainData.detailWidth, terrainData.detailHeight);
         Dictionary <int, int[, ]> details = new Dictionary <int, int[, ]>();
         foreach (int layer in layers)
         {
             var ds = terrainData.GetDetailLayer(0, 0, terrainData.detailWidth, terrainData.detailHeight, layer);
             details.Add(layer, ds);
         }
         var calc = new DslExpression.DslCalculator();
         calc.Init();
         calc.Register("getheight", new DslExpression.ExpressionFactoryHelper <GetHeightExp>());
         calc.Register("getalphamap", new DslExpression.ExpressionFactoryHelper <GetAlphamapExp>());
         calc.Register("getalpha", new DslExpression.ExpressionFactoryHelper <GetAlphaExp>());
         calc.Register("setalpha", new DslExpression.ExpressionFactoryHelper <SetAlphaExp>());
         calc.Register("getdetail", new DslExpression.ExpressionFactoryHelper <GetDetailExp>());
         calc.Register("samplered", new DslExpression.ExpressionFactoryHelper <SampleRedExp>());
         calc.Register("samplegreen", new DslExpression.ExpressionFactoryHelper <SampleGreenExp>());
         calc.Register("sampleblue", new DslExpression.ExpressionFactoryHelper <SampleBlueExp>());
         calc.Register("samplealpha", new DslExpression.ExpressionFactoryHelper <SampleAlphaExp>());
         calc.Register("getcache", new DslExpression.ExpressionFactoryHelper <GetCacheExp>());
         calc.Register("setcache", new DslExpression.ExpressionFactoryHelper <SetCacheExp>());
         calc.Register("addtree", new DslExpression.ExpressionFactoryHelper <AddTreeExp>());
         calc.Register("addobject", new DslExpression.ExpressionFactoryHelper <AddObjectExp>());
         calc.SetGlobalVariable("samplers", CalculatorValue.FromObject(samplers));
         calc.SetGlobalVariable("caches", CalculatorValue.FromObject(caches));
         calc.SetGlobalVariable("trees", CalculatorValue.FromObject(trees));
         calc.SetGlobalVariable("objects", CalculatorValue.FromObject(objects));
         calc.SetGlobalVariable("heightscalex", terrainData.heightmapScale.x);
         calc.SetGlobalVariable("heightscaley", terrainData.heightmapScale.y);
         calc.SetGlobalVariable("heightscalez", terrainData.heightmapScale.z);
         calc.SetGlobalVariable("heights", CalculatorValue.FromObject(datas));
         calc.SetGlobalVariable("alphamaps", CalculatorValue.FromObject(alphamaps));
         calc.SetGlobalVariable("alphanum", CalculatorValue.FromObject(alphanum));
         calc.SetGlobalVariable("details", CalculatorValue.FromObject(details));
         calc.SetGlobalVariable("height", 0.0f);
         calc.SetGlobalVariable("alphas", CalculatorValue.FromObject(new float[alphanum]));
         calc.SetGlobalVariable("detail", 0);
         bool resetTrees  = false;
         bool canContinue = true;
         foreach (var comp in file.DslInfos)
         {
             var info = comp as Dsl.StatementData;
             if (null == info)
             {
                 continue;
             }
             bool check = false;
             int  num   = info.GetFunctionNum();
             if (num >= 2)
             {
                 string firstId = info.First.GetId();
                 if (firstId == "input")
                 {
                     check = true;
                     for (int i = 1; i < info.GetFunctionNum(); ++i)
                     {
                         string id = info.GetFunctionId(i);
                         if (id == "height" || id == "alphamap" || id == "detail")
                         {
                         }
                         else
                         {
                             check = false;
                             break;
                         }
                     }
                 }
             }
             if (!check)
             {
                 canContinue = false;
                 Debug.LogErrorFormat("error script:{0}, {1}", info.GetLine(), info.ToScriptString(false));
             }
         }
         if (canContinue)
         {
             int ix = 0;
             foreach (var comp in file.DslInfos)
             {
                 var info = comp as Dsl.StatementData;
                 if (null == info)
                 {
                     continue;
                 }
                 for (int i = 1; i < info.GetFunctionNum(); ++i)
                 {
                     calc.LoadDsl(ix.ToString(), info.GetFunction(i));
                     ++ix;
                 }
             }
             int ix2 = 0;
             foreach (var comp in file.DslInfos)
             {
                 var info = comp as Dsl.StatementData;
                 if (null == info)
                 {
                     continue;
                 }
                 for (int i = 1; i < info.GetFunctionNum(); ++i)
                 {
                     ProcessWithDsl(info.First, info.GetFunctionId(i), datas, alphamaps, details, calc, ix2.ToString(), ref resetTrees);
                     ++ix2;
                 }
             }
         }
         terrainData.SetHeights(0, 0, datas);
         terrainData.SetAlphamaps(0, 0, alphamaps);
         foreach (var pair in details)
         {
             terrainData.SetDetailLayer(0, 0, pair.Key, pair.Value);
         }
         if (resetTrees)
         {
             terrainData.treeInstances = trees.ToArray();
         }
         else
         {
             trees.AddRange(terrainData.treeInstances);
             terrainData.treeInstances = trees.ToArray();
         }
     }
 }