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 ScriptEngine() { mEngineEnvironment = new StillOneScriptCore.Engine.EngineEnvironment(); mEngineEnvironment.Init(); }
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();*/ }
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; }
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")); }
private static void TSTNameOfObjects() { // disable once ConvertToConstant.Local var tmpStr = "a p ( d) m"; tmpStr = StillOneScriptCore.Common.TypeHelpers.StringHelper.RemoveMultipleSpaces(tmpStr); NLog.LogManager.GetCurrentClassLogger().Info(tmpStr); tmpStr = StillOneScriptCore.Common.TypeHelpers.StringHelper.RemoveSpacesAroundBrackets(tmpStr); NLog.LogManager.GetCurrentClassLogger().Info(tmpStr); var tmpEnvironment = new StillOneScriptCore.Engine.EngineEnvironment(); tmpEnvironment.Init(); var tmpName = new StillOneScriptCore.EntityModel.LngObjectsModel.Support._ObjectName(); tmpName.Environment = tmpEnvironment; tmpName.AbsoluteName = "dog ( e-mail ) "; NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpName, "tmpName")); tmpName.PrecisionName = "cat"; NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpName.Precision, "tmpName.Precision")); NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpName, "tmpName")); var tmpP = tmpName.Precision; tmpP.Name = null; NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpName, "tmpName")); NLog.LogManager.GetCurrentClassLogger().Info(StillOneScriptCore.Common.TypeHelpers.ObjectHelper._ToString(tmpName.Precision, "tmpName.Precision")); }
private static void TSTLexer() { var tmpEnvironment = new StillOneScriptCore.Engine.EngineEnvironment(); tmpEnvironment.Init(); using(var tmpReader = File.OpenText("Script.txt")) { var tmpLexer = new StillOneScriptCore.Parser.Lexer.LexerEngine(); tmpLexer.Run(tmpReader); var tmpSyntaxer = new StillOneScriptCore.Parser.Syntaxer.SyntaxerEngine(); try { tmpSyntaxer.Run(tmpLexer.Tokens); }catch(StillOneScriptCore.Parser.Syntaxer.SyntaxerException e){ NLog.LogManager.GetCurrentClassLogger().Info("e.ToString() = {0}", e.ToString()); NLog.LogManager.GetCurrentClassLogger().Info("e.TokenText = {0}", e.TokenText); NLog.LogManager.GetCurrentClassLogger().Info("e.Line = {0}", e.Line); NLog.LogManager.GetCurrentClassLogger().Info("e.Pos = {0}", e.Pos); return ; } var tmpRez = tmpSyntaxer.Result; if (tmpRez == null) { NLog.LogManager.GetCurrentClassLogger().Info("tmpRez == null"); return; } NLog.LogManager.GetCurrentClassLogger().Info(tmpRez.DisplayAsTree()); var tmpLoader = new StillOneScriptCore.Loader.LoaderEngine(tmpEnvironment); tmpLoader.Load(tmpSyntaxer.Result); var tmpCustomFun = tmpLoader.Result; tmpCustomFun.Call(); NLog.LogManager.GetCurrentClassLogger().Info("Finish"); } }