public void AddConvertor(StillOneScriptCore.EntityModel.LngObjectsModel._Object obj, bool isRepresentNull)
        {
            lock(LockObj)
            {
                ValidateObj(obj, isRepresentNull);

                var tmpClass = obj.AsClass;

                if (isRepresentNull)
                {
                    if (mNullConverter != null)
                    {
                        throw new System.Exception("Converter Converter for `null` was added yet.");
                    }

                    mNullConverter = tmpClass;
                }
                else
                {
                    if (mConvertorsItems.ContainsKey(obj.MappedType))
                    {
                        throw new System.Exception("Converter Converter for type `" + obj.MappedType.FullName + "` was added yet.");
                    }

                    mConvertorsItems.Add(obj.MappedType, tmpClass);
                }
            }
        }
        public override void Step_1()
        {
            mClass = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            mClass.Environment = this.Environment;

            this.Environment.ObjectsConstants.Number = mClass;

            mClass.AddName("Number");

            mClass.MappedType = typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Number);

            this.Environment.AddConvertor(mClass);

            this.Environment.AddWrappingConvertor(typeof(System.Int16), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Number));
            this.Environment.AddWrappingConvertor(typeof(System.Int32), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Number));
            this.Environment.AddWrappingConvertor(typeof(System.Int64), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Number));
            this.Environment.AddWrappingConvertor(typeof(System.UInt16), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Number));
            this.Environment.AddWrappingConvertor(typeof(System.UInt32), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Number));
            this.Environment.AddWrappingConvertor(typeof(System.UInt64), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Number));
            this.Environment.AddWrappingConvertor(typeof(System.Byte), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Number));
            this.Environment.AddWrappingConvertor(typeof(float), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Number));
            this.Environment.AddWrappingConvertor(typeof(decimal), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Number));
            this.Environment.AddWrappingConvertor(typeof(double), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Number));
        }
        public override void Step_1()
        {
            mClass = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            mClass.Environment = this.Environment;

            this.Environment.ObjectsConstants.Function = mClass;

            mClass.AddName("Function");
        }
        public void Run()
        {
            var tmpClass = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            tmpClass.Environment = mEngineEnvironment;

            tmpClass.AddName("Console");

            tmpClass.ClassBoxingObject = new StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal._P_NativeClass(typeof(StillOneScriptCore.STL.Console), StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal.MappingOption.ByLNGMap, mEngineEnvironment);
        }
示例#5
0
        public override void Step_1()
        {
            mClass = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            mClass.Environment = this.Environment;

            mClass.AddName("null(class)");

            this.Environment.AddConvertor(mClass, true);
        }
        public override void Step_1()
        {
            mClass = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            mClass.Environment = this.Environment;

            mClass.AddName("undefined(class)");

            mClass.MappedType = typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Undefined);

            this.Environment.AddConvertor(mClass);
        }
        public override void Step_1()
        {
            mClass = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            mClass.Environment = this.Environment;

            this.Environment.ObjectsConstants.Boolean = mClass;

            mClass.AddName("Boolean");

            mClass.MappedType = typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Boolean);

            this.Environment.AddConvertor(mClass);

            this.Environment.AddWrappingConvertor(typeof(bool), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._Boolean));
        }
        public override void Step_1()
        {
            mClass = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            mClass.Environment = this.Environment;

            this.Environment.ObjectsConstants.String = mClass;

            mClass.AddName("String");
            mClass.AddName("string");

            mClass.MappedType = typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._String);

            this.Environment.AddConvertor(mClass);

            this.Environment.AddWrappingConvertor(typeof(System.String), typeof(StillOneScriptCore.EntityModel.WorkedObjectsModel._String));
        }
        private void RemoveNullConverter(StillOneScriptCore.EntityModel.LngObjectsModel._Object obj)
        {
            var tmpClass = obj.AsClass;

            if (this.mNullConverter == tmpClass)
            {
                this.mNullConverter = null;
            }
        }
示例#10
0
        private static void TSTCustomOperators()
        {
            var tmpEnvironment = new StillOneScriptCore.Engine.EngineEnvironment();

            tmpEnvironment.Init();

            var tmpPClass = new StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal._P_NativeClass(typeof(WrappedClass), StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal.MappingOption.ByLNGMap, tmpEnvironment);

            var tmpClass = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            tmpClass.Environment = tmpEnvironment;

            tmpClass.AddName("dog");

            tmpClass.ClassBoxingObject = tmpPClass;

            tmpClass.Environment.AddConvertor(tmpClass);

            NLog.LogManager.GetCurrentClassLogger().Info(tmpClass.ToString());

            NLog.LogManager.GetCurrentClassLogger().Info("tmpClass.Name = {0}", tmpClass.Name);

            var tmpExecutedFunctionContext = new StillOneScriptCore.EntityModel.CustomFunctionModel.Support.ExecutedFunctionContext(tmpEnvironment);

            tmpExecutedFunctionContext.AddScope();

            tmpExecutedFunctionContext.AddScope();

            //tmpExecutedFunctionContext.RemoveScope();

            /*var tmpObjVar = new StillOneScriptCore.EntityModel.WorkedObjectsModel._VariableObjectRef("dog");

            tmpObjVar.Environment = tmpEnvironment;

            NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpObjVar.Value, "tmpObjVar.Value"));*/

            //var tmpObjRef = new StillOneScriptCore.EntityModel.CustomFunctionModel.Operators.Executed.VariableReference(tmpExecutedFunctionContext, "Console");

            //tmpObjRef.Run();

            //var tmpRez = tmpObjRef.Result;

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

            //var tmpStringRef = new StillOneScriptCore.EntityModel.CustomFunctionModel.Operators.Executed.StringLiteralReference(tmpExecutedFunctionContext, "The Beatles");

            //tmpStringRef.Run();

            //var tmpStrRez = tmpStringRef.Result;

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

            //var tmpCallOperator = new StillOneScriptCore.EntityModel.CustomFunctionModel.Operators.Executed.CallMethodOperator(tmpExecutedFunctionContext, "Log");

            //tmpCallOperator.Left = tmpObjRef;

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

            //tmpParam.Name = "text";

            //tmpParam.Operator = tmpStringRef;

            //tmpCallOperator.AddParameter(tmpParam);

            //tmpCallOperator.Run();

            //var tmpCallResult = tmpCallOperator.Result;

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

            //var tmpStatement = new StillOneScriptCore.EntityModel.CustomFunctionModel.Statements.Executed.ExpressionStatement(tmpExecutedFunctionContext);

            //tmpStatement.Expression = tmpCallOperator;

            //tmpStatement.Call();

            //var tmpCodeBlock = new StillOneScriptCore.EntityModel.CustomFunctionModel.Statements.Executed.CodeBlockStatement(tmpExecutedFunctionContext);

            //tmpCodeBlock.FirstStatement = tmpStatement;

            //var tmpExecutedCustomFunction = new StillOneScriptCore.EntityModel.CustomFunctionModel.ExecutedCustomFunction(tmpExecutedFunctionContext);

            //tmpExecutedCustomFunction.Statement = tmpCodeBlock;

            //var tmpExecutedCustomFunctionRez = tmpExecutedCustomFunction.Call();

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

            //var tmpCaller = new StillOneScriptCore.EntityModel.CustomFunctionModel.Statements.Executed.StatementsCaller();

            //tmpCaller.Call(tmpStatement);

            //tmpObjRef

            /*var tmpCallFunctionOperator = new StillOneScriptCore.EntityModel.CustomFunctionModel.Operators.CallMethodOperator();

            tmpCallFunctionOperator.Environment = tmpEnvironment;

            tmpCallFunctionOperator.Left = tmpObjRef;

            tmpCallFunctionOperator.Run();*/
        }
示例#11
0
        private static void TSTObjects()
        {
            var tmpEnvironment = new StillOneScriptCore.Engine.EngineEnvironment();

            tmpEnvironment.Init();

            var tmpPClass = new StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal._P_NativeClass(typeof(WrappedClass), StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal.MappingOption.ByLNGMap, tmpEnvironment);

            var tmpClass = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            tmpClass.Environment = tmpEnvironment;

            tmpClass.AddName("dog");

            tmpClass.ClassBoxingObject = tmpPClass;

            tmpClass.Environment.AddConvertor(tmpClass);

            NLog.LogManager.GetCurrentClassLogger().Info(tmpClass.ToString());

            NLog.LogManager.GetCurrentClassLogger().Info("tmpClass.Name = {0}", tmpClass.Name);

            var tmpPInstance = tmpPClass.CreateInstance();

            var tmpMethod = tmpPInstance.GetMethod("Preved").FirstOrDefault();

            if (tmpMethod != null)
            {
                NLog.LogManager.GetCurrentClassLogger().Info("tmpMethod.Call() = {0}", tmpMethod.Call());
            }

            NLog.LogManager.GetCurrentClassLogger().Info(tmpClass.ToString());
            NLog.LogManager.GetCurrentClassLogger().Info("tmpClass.MappedType = {0}", tmpClass.MappedType);

            var tmpI = new WrappedClass();

            uint y = 12;

            tmpI.R("rtfm", y);

            var tmpCInst = tmpEnvironment.Convert(tmpI);

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

            /*tmpCInst = tmpEnvironment.Convert(tmpI);

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

            var tmpBox_1 = new TST_P_Class();

            var tmpClassA = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            tmpClassA.Environment = tmpEnvironment;

            tmpClassA.AddName("A");

            tmpClassA.ClassBoxingObject = tmpBox_1;

            tmpCInst.AddSuperClass(tmpClassA, 0.5F);

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

            //------------------------

            var tmpBox_2 = new TST_P_Class();

            var tmpClassB = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            tmpClassB.Environment = tmpEnvironment;

            tmpClassB.AddName("B");

            tmpClassB.ClassBoxingObject = tmpBox_2;

            tmpClassA.AddSuperClass(tmpClassB, 0.5F);

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

            tmpCInst.RemoveSuperClass(tmpClassA);

            NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpCInst, "tmpCInst"));*/

            var tmpCInstCallResult = tmpCInst.Call("Preved");

            NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpCInstCallResult, "tmpCInst.Call('Preved')"));

            var tmpCInstCallResultBox = tmpCInstCallResult.AsInstance.CastToBoxedObject<StillOneScriptCore.EntityModel.WorkedObjectsModel._String>();

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

            var tmpBox = tmpCInst.AsInstance.CastToBoxedObject<WrappedClass>();

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

            // disable once ConvertToConstant.Local
            var tmpStr = "The Beatles";

            var tmpStrInst = tmpEnvironment.Convert(tmpStr);

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

            var tmpStrBox = tmpStrInst.CastToBoxedObject<StillOneScriptCore.EntityModel.WorkedObjectsModel._String>();

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

            tmpStrInst = tmpEnvironment.Convert(tmpStr);

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

            // disable once ConvertToConstant.Local
            int tmpIntVal = 12;

            var tmpIntInst = tmpEnvironment.Convert(tmpIntVal);

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

            tmpIntInst = tmpEnvironment.Convert(tmpIntVal);

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

            var tmpIntBox = tmpIntInst.CastToBoxedObject<StillOneScriptCore.EntityModel.WorkedObjectsModel._Number>();

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

            object tmpA = true;

            float f = System.Convert.ToSingle(tmpA);

            NLog.LogManager.GetCurrentClassLogger().Info("f = {0}", f);

            var tmpBoolInst = tmpEnvironment.Convert(tmpA);

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

            tmpBoolInst = tmpEnvironment.Convert(tmpA);

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

            var tmpBoolBox = tmpBoolInst.CastToBoxedObject<StillOneScriptCore.EntityModel.WorkedObjectsModel._Boolean>();

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

            var tmpNullInst = tmpEnvironment.Convert(null);

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

            var tmpNullBox = tmpNullInst.CastToBoxedObject<StillOneScriptCore.EntityModel.WorkedObjectsModel._NULL>();

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

            NLog.LogManager.GetCurrentClassLogger().Info(typeof(void));

            var tmpFO = tmpEnvironment.Convert(tmpBoolInst);

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

            var tmpCInstCall_3_Result = tmpCInst.Call("AMD");

            NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpCInstCall_3_Result, "tmpCInst.Call('AMD')"));

            var tmpParamsList = new List<StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal.Parameter>();

            var tmpParameter = new StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal.Parameter();

            tmpParameter.Name = "a";
            //tmpParameter.Type = tmpEnvironment.ObjectsConstants.String;
            tmpParameter.Value = tmpStrInst;

            tmpParamsList.Add(tmpParameter);
            //int b, bool c
            tmpParameter = new StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal.Parameter();

            tmpParameter.Name = "b";
            //tmpParameter.Type = tmpEnvironment.ObjectsConstants.Number;
            tmpParameter.Value = tmpIntInst;

            tmpParamsList.Add(tmpParameter);

            tmpParameter = new StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal.Parameter();

            tmpParameter.Name = "c";
            //tmpParameter.Type = tmpEnvironment.ObjectsConstants.Boolean;
            tmpParameter.Value = tmpBoolInst;

            tmpParamsList.Add(tmpParameter);

            var tmpCInstCall_2_Result = tmpCInst.Call("T", tmpParamsList);

            NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpCInstCall_2_Result, "tmpCInstCall_2_Result.Call('T')"));

            var tmpTMethod = tmpCInst.GetMember("T");

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

            tmpTMethod = tmpCInst.GetMember("T");

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

            var tmpOpPparam = new StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal.Parameter();

            tmpOpPparam.Name = "memberName";
            //tmpOpPparam.Type = tmpEnvironment.ObjectsConstants.String;
            tmpOpPparam.Value = tmpEnvironment.Convert("H");

            var tmpOperatorResult_1 = tmpCInst.CallOperator(".", new List<StillOneScriptCore.EntityModel.LngObjectsModel.Support.Internal.Parameter>() { tmpOpPparam });

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

            var tmpCallResult_1_Rez = tmpOperatorResult_1.Call(tmpParamsList);

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

            //var tmpO = new WTY();

            //var tmpOT = tmpO.GetType();

            //var tmpM_HK = tmpOT.GetMethod("A");

            //var tmpB = (uint)tmpA;
        }
示例#12
0
        private static void TSTObjectName()
        {
            var tmpEnvironment = new StillOneScriptCore.Engine.EngineEnvironment();

            tmpEnvironment.Init();

            var tmpClass = new StillOneScriptCore.EntityModel.LngObjectsModel._Class();

            tmpClass.Environment = tmpEnvironment;

            tmpClass.AddName("dog");

            tmpClass.AddName("cat");

            NLog.LogManager.GetCurrentClassLogger().Info(tmpClass.ToString());

            var tmpRef = new StillOneScriptCore.EntityModel.LngObjectsModel.Support._ObjectRef();

            tmpRef.Environment = tmpEnvironment;

            tmpRef.Name = "dog";

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

            var tmpName = tmpClass.ObjectNames.FirstOrDefault();

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

            tmpName.AbsoluteName = "apple";

            //tmpClass.RemoveName("dog");

            NLog.LogManager.GetCurrentClassLogger().Info(tmpClass.ToString());
            NLog.LogManager.GetCurrentClassLogger().Info("tmpClass.MappedType = {0}", tmpClass.MappedType);

            NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpRef.Value, "tmpRef.Value"));
        }