Esempio n. 1
0
        private static void TSTCustomFunction()
        {
            var tmpEnvironment = new StillOneScriptCore.Engine.EngineEnvironment();

            tmpEnvironment.Init();

            var tmpCustomFun = new StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal._P_CustomFunction(tmpEnvironment);

            var tmpExprStatement = new StillOneScriptCore.EntityModel.CustomFunctionModel.Statements.ExpressionStatement(tmpCustomFun.FunctionContext);

            var tmpCodeBlock = new StillOneScriptCore.EntityModel.CustomFunctionModel.Statements.CodeBlockStatement(tmpCustomFun.FunctionContext);

            tmpCustomFun.Statement = tmpCodeBlock;

            tmpCodeBlock.FirstStatement = tmpExprStatement;

            var tmpObjRef = new StillOneScriptCore.EntityModel.CustomFunctionModel.Operators.VariableReference(tmpCustomFun.FunctionContext, "Console");

            var tmpStringRef = new StillOneScriptCore.EntityModel.CustomFunctionModel.Operators.StringLiteralReference(tmpCustomFun.FunctionContext, "The Beatles");

            var tmpCallOperator = new StillOneScriptCore.EntityModel.CustomFunctionModel.Operators.CallMethodOperator(tmpCustomFun.FunctionContext, "Log");

            tmpCallOperator.Left = tmpObjRef;

            var tmpParam = new StillOneScriptCore.EntityModel.CustomFunctionModel.Operators.FunctionParameter();

            tmpParam.Name = "text";

            tmpParam.Operator = tmpStringRef;

            tmpCallOperator.AddParameter(tmpParam);

            tmpExprStatement.Expression = tmpCallOperator;

            //tmpCustomFun.Call();

            var tmpCustomFunObj = tmpEnvironment.ConvertMember(tmpCustomFun);

            NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpCustomFunObj, "tmpCustomFunObj"));

            var tmpRez = tmpCustomFunObj.Call();

            NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpRez, "tmpRez"));
        }
        public override EntityModel.CustomFunctionModel.Operators.Operator Clone(EntityModel.CustomFunctionModel.Support.FunctionContext functionContext)
        {
            var tmpObj = new StillOneScriptCore.EntityModel.CustomFunctionModel.Operators.CallMethodOperator(functionContext, mMethodName);

            if (!StillOneScriptCore.Common.TypeHelpers.ListHelper.IsEmpty(mParams))
            {
                foreach (var param in mParams)
                {
                    var tmpParam = new StillOneScriptCore.EntityModel.CustomFunctionModel.Operators.FunctionParameter();

                    tmpParam.Name = param.Name;

                    tmpParam.Operator = param.Operator.Clone(functionContext);

                    tmpObj.AddParameter(tmpParam);
                }
            }

            this.UnaryOperator_SupportClone(tmpObj, functionContext);

            return tmpObj;
        }