Пример #1
0
        private LiteValue CallFunc(FuncBase Func, SyntaxArgumentListStatementNode ArgList, LiteEnv Env)
        {
            if (Func is FuncNative FN)
            {
                for (var Index = 0; Index < ArgList.GetChildrenNum(); ++Index)
                {
                    var ArgValue = Index >= ArgList.GetChildrenNum()
                        ? LiteValue.Nil
                        : ArgList.GetChild(Index).Accept(this, Env);
                    FN.Push(ArgValue);
                }
                FN.Push(ArgList.GetChildrenNum());
                return(FN.Invoke());
            }
            else if (Func is FuncLite FL)
            {
                var NewEnv    = FL.MakeEnv();
                var ParamList = FL.GetParamList();

                for (var Index = 0; Index < ParamList.GetChildrenNum(); ++Index)
                {
                    var ArgName  = ParamList.GetChild <SyntaxIdentifierNode>(Index).GetValue();
                    var ArgValue = Index >= ArgList.GetChildrenNum()
                        ? LiteValue.Nil
                        : ArgList.GetChild(Index).Accept(this, Env);
                    NewEnv.SetSelf(ArgName, ArgValue);
                }

                var Val = FL.GetBlock().Accept(this, NewEnv);
                //Logger.DInfo($"=> call [{Func.GetName()}] = {Val}");
                return(Val);
            }

            return(LiteValue.Nil);
        }
Пример #2
0
 public void NavigateTo(FuncBase targetFunc)
 {
     try
     {
         page        = System.Activator.CreateInstance(targetFunc.Type) as UserControl;
         Inner.Child = page;
     }
     catch (Exception ex)
     {
         //增加个报错通用的页面
         AppResourceManager.Manager.Loghelper.WriteLogException(ex);
     }
 }