From 4ba9eb7c6f07a0da87d2d83ceed486a7299465a1 Mon Sep 17 00:00:00 2001 From: Mr-Rm Date: Thu, 25 Dec 2025 16:17:42 +0400 Subject: [PATCH 1/5] =?UTF-8?q?VM:=20=D0=B8=D0=BC=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D0=B2=D0=BE=D0=B9=D1=81=D1=82=D0=B2=20=D0=B8=20=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2=20=D0=B2=20=D0=BE=D1=82?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D1=81=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ScriptEngine/Compiler/ModuleDumpWriter.cs | 7 +++++ .../Compiler/StackMachineCodeGenerator.cs | 30 +++++++++++-------- src/ScriptEngine/Machine/MachineInstance.cs | 10 +++---- .../Machine/StackRuntimeModule.cs | 8 +++-- 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/ScriptEngine/Compiler/ModuleDumpWriter.cs b/src/ScriptEngine/Compiler/ModuleDumpWriter.cs index ea402b1f2..198b13e62 100644 --- a/src/ScriptEngine/Compiler/ModuleDumpWriter.cs +++ b/src/ScriptEngine/Compiler/ModuleDumpWriter.cs @@ -129,6 +129,13 @@ private void WriteImage(TextWriter output, StackRuntimeModule module) output.WriteLine( $"{i,-3}:type: {item.SystemType.Alias}, val: {item}"); } + output.WriteLine(".identifiers"); + for (int i = 0; i < module.Identifiers.Count; i++) + { + var item = module.Identifiers[i]; + output.WriteLine( + $"{i,-3}: {item}"); + } output.WriteLine(".code"); for (int i = 0; i < module.Code.Count; i++) { diff --git a/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs b/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs index 5e2200f49..00b8d955a 100644 --- a/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs +++ b/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs @@ -489,7 +489,7 @@ protected override void VisitReturnNode(BslSyntaxNode node) protected override void VisitRaiseNode(BslSyntaxNode node) { int arg = -1; - if (node.Children.Any()) + if (node.Children.Count != 0) { VisitExpression(node.Children[0]); arg = 0; @@ -728,24 +728,17 @@ private void ResolveObjectMethod(BslSyntaxNode callNode, bool asFunction) PushCallArguments(args); - var cDef = new ConstDefinition(); - cDef.Type = DataType.String; - cDef.Presentation = name.GetIdentifier(); - int lastIdentifierConst = GetConstNumber(cDef); + int lastIdentifierIndex = GetIdentNumber(name.GetIdentifier()); if (asFunction) - AddCommand(OperationCode.ResolveMethodFunc, lastIdentifierConst); + AddCommand(OperationCode.ResolveMethodFunc, lastIdentifierIndex); else - AddCommand(OperationCode.ResolveMethodProc, lastIdentifierConst); + AddCommand(OperationCode.ResolveMethodProc, lastIdentifierIndex); } private void ResolveProperty(string identifier) { - var cDef = new ConstDefinition(); - cDef.Type = DataType.String; - cDef.Presentation = identifier; - var identifierConstIndex = GetConstNumber(cDef); - AddCommand(OperationCode.ResolveProp, identifierConstIndex); + AddCommand(OperationCode.ResolveProp, GetIdentNumber(identifier)); } private int PushVariable(TerminalNode node) @@ -1328,6 +1321,19 @@ private int GetConstNumber(in ConstDefinition cDef) return idx; } + private int GetIdentNumber(string ident) + { + + var idx = _module.Identifiers.IndexOf(ident); + if (idx < 0) + { + idx = _module.Identifiers.Count; + _module.Identifiers.Add(ident); + } + return idx; + } + + private int GetMethodRefNumber(in SymbolBinding methodBinding) { var descriptor = _ctx.GetBinding(methodBinding.ScopeNumber); diff --git a/src/ScriptEngine/Machine/MachineInstance.cs b/src/ScriptEngine/Machine/MachineInstance.cs index 992dbb292..c3aaed25f 100644 --- a/src/ScriptEngine/Machine/MachineInstance.cs +++ b/src/ScriptEngine/Machine/MachineInstance.cs @@ -680,8 +680,8 @@ private void PushConst(int arg) { _operationStack.Push(_module.Constants[arg]); NextInstruction(); - } - + } + private void PushBool(int arg) { _operationStack.Push(BslBooleanValue.Create(arg == 1)); @@ -1011,7 +1011,7 @@ private void ResolveProp(int arg) var objIValue = _operationStack.Pop(); var context = objIValue.AsObject(); - var propName = _module.Constants[arg].ToString(_process); + var propName = _module.Identifiers[arg]; var propNum = context.GetPropertyNumber(propName); var propReference = Variable.CreateContextPropertyReference(context, propNum, "stackvar"); @@ -1048,7 +1048,7 @@ private void PrepareContextCallArguments(int arg, out IRuntimeContextInstance co var objIValue = _operationStack.Pop(); context = objIValue.AsObject(); - var methodName = _module.Constants[arg].ToString(_process); + var methodName = _module.Identifiers[arg]; methodId = context.GetMethodNumber(methodName); if (context.DynamicMethodSignatures) @@ -1191,7 +1191,7 @@ private void NewInstance(int argCount) argValues[i] = RawValue(argValue); } - var typeName = PopRawBslValue().ToString(_process); + var typeName = _operationStack.Pop().ToString(); // is BslStringValue by code generation if (!_typeManager.TryGetType(typeName, out var type)) { throw RuntimeException.TypeIsNotDefined(typeName); diff --git a/src/ScriptEngine/Machine/StackRuntimeModule.cs b/src/ScriptEngine/Machine/StackRuntimeModule.cs index 6f570b49d..ea4d02803 100644 --- a/src/ScriptEngine/Machine/StackRuntimeModule.cs +++ b/src/ScriptEngine/Machine/StackRuntimeModule.cs @@ -26,10 +26,12 @@ public StackRuntimeModule(Type ownerType) public int EntryMethodIndex { get; set; } = -1; public List Constants { get; } = new List(); + + internal List Identifiers { get; } = new List(); - internal IList VariableRefs { get; } = new List(); + internal List VariableRefs { get; } = new List(); - internal IList MethodRefs { get; } = new List(); + internal List MethodRefs { get; } = new List(); #region IExecutableModule members @@ -52,7 +54,7 @@ public BslScriptMethodInfo ModuleBody public IList Methods { get; } = new List(); - public IList Code { get; } = new List(512); + public List Code { get; } = new List(512); public SourceCode Source { get; set; } From 0ff7ea4ecc7a824fa5cbc95ed131bfe3f99e9650 Mon Sep 17 00:00:00 2001 From: Mr-Rm Date: Thu, 25 Dec 2025 19:44:34 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D1=82=D0=B8=D0=BF=D1=8B=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=20-=20=D0=B2=20=D0=B8=D0=B4=D0=B5=D0=BD=D1=82=D0=B8?= =?UTF-8?q?=D1=84=D0=B8=D0=BA=D0=B0=D1=82=D0=BE=D1=80=D1=8B,=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B7=D0=BE=D0=B2=20=D0=BA=D0=B0=D0=BA=20=D1=83=20=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Compiler/StackMachineCodeGenerator.cs | 41 +++++++++---------- src/ScriptEngine/Machine/MachineInstance.cs | 33 +++++++-------- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs b/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs index 00b8d955a..407c573d8 100644 --- a/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs +++ b/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs @@ -856,11 +856,13 @@ private void GlobalCall(CallNode call, bool asFunction) else { // can be defined later - var forwarded = new ForwardedMethodDecl(); - forwarded.identifier = identifier; - forwarded.asFunction = asFunction; - forwarded.location = identifierNode.Location; - forwarded.factArguments = argList; + var forwarded = new ForwardedMethodDecl + { + identifier = identifier, + asFunction = asFunction, + location = identifierNode.Location, + factArguments = argList + }; PushCallArguments(call.ArgumentList); @@ -878,17 +880,17 @@ private void PushCallArguments(BslSyntaxNode argList) private void PushArgumentsList(BslSyntaxNode argList) { - for (int i = 0; i < argList.Children.Count; i++) + var arguments = argList.Children; + for (int i = 0; i < arguments.Count; i++) { - var passedArg = argList.Children[i]; - VisitCallArgument(passedArg); + VisitCallArgument(arguments[i]); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void VisitCallArgument(BslSyntaxNode passedArg) { - if (passedArg.Children.Count > 0) + if (passedArg.Children.Count != 0) { VisitExpression(passedArg.Children[0]); } @@ -1061,21 +1063,17 @@ private void MakeNewObjectDynamic(NewObjectNode node) private void MakeNewObjectStatic(NewObjectNode node) { - var cDef = new ConstDefinition() - { - Type = DataType.String, - Presentation = node.TypeNameNode.GetIdentifier() - }; - AddCommand(OperationCode.PushConst, GetConstNumber(cDef)); - - var callArgs = 0; if (node.ConstructorArguments != default) { - PushArgumentsList(node.ConstructorArguments); - callArgs = node.ConstructorArguments.Children.Count; + PushCallArguments(node.ConstructorArguments); + } + else + { + AddCommand(OperationCode.ArgNum, 0); } - AddCommand(OperationCode.NewInstance, callArgs); + var idNum = GetIdentNumber(node.TypeNameNode.GetIdentifier()); + AddCommand(OperationCode.NewInstance, idNum); } private void ExitTryBlocks() @@ -1322,8 +1320,7 @@ private int GetConstNumber(in ConstDefinition cDef) } private int GetIdentNumber(string ident) - { - + { var idx = _module.Identifiers.IndexOf(ident); if (idx < 0) { diff --git a/src/ScriptEngine/Machine/MachineInstance.cs b/src/ScriptEngine/Machine/MachineInstance.cs index c3aaed25f..17f8f3a02 100644 --- a/src/ScriptEngine/Machine/MachineInstance.cs +++ b/src/ScriptEngine/Machine/MachineInstance.cs @@ -1180,23 +1180,14 @@ private void Inc(int arg) NextInstruction(); } - private void NewInstance(int argCount) - { - IValue[] argValues = new IValue[argCount]; - // fact args - for (int i = argCount - 1; i >= 0; i--) - { - var argValue = _operationStack.Pop(); - if(!argValue.IsSkippedArgument()) - argValues[i] = RawValue(argValue); - } - - var typeName = _operationStack.Pop().ToString(); // is BslStringValue by code generation + private void NewInstance(int arg) + { + var typeName = _module.Identifiers[arg]; if (!_typeManager.TryGetType(typeName, out var type)) { throw RuntimeException.TypeIsNotDefined(typeName); - } - + } + // TODO убрать cast после рефакторинга ITypeFactory var factory = (TypeFactory)_typeManager.GetFactoryFor(type); var context = new TypeActivationContext @@ -1205,8 +1196,18 @@ private void NewInstance(int argCount) TypeManager = _typeManager, Services = _process.Services, CurrentProcess = _process - }; - + }; + + int argCount = (int)_operationStack.Pop().AsNumber(); + IValue[] argValues = new IValue[argCount]; + // fact args + for (int i = argCount - 1; i >= 0; i--) + { + var argValue = _operationStack.Pop(); + if(!argValue.IsSkippedArgument()) + argValues[i] = RawValue(argValue); + } + var instance = (IValue)factory.Activate(context, argValues); _operationStack.Push(instance); NextInstruction(); From 10aa8e113d19a448c6a814795199c031714f163a Mon Sep 17 00:00:00 2001 From: Mr-Rm Date: Thu, 25 Dec 2025 20:28:24 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=B2=D1=8B=D0=BD=D0=B5=D1=81=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=B0=20=D0=BF=D0=BE=20?= =?UTF-8?q?=D0=B8=D0=BC=D0=B5=D0=BD=D0=B8=20=D1=82=D0=B8=D0=BF=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Compiler/StackMachineCodeGenerator.cs | 2 +- src/ScriptEngine/Machine/MachineInstance.cs | 46 +++++++------------ 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs b/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs index 407c573d8..ae8fff066 100644 --- a/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs +++ b/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs @@ -1051,7 +1051,7 @@ private void MakeNewObjectDynamic(NewObjectNode node) var argsPassed = node.ConstructorArguments.Children.Count; if (argsPassed == 1) { - PushArgumentsList(node.ConstructorArguments); + VisitCallArgument(node.ConstructorArguments.Children[0]); ; } else if (argsPassed > 1) { diff --git a/src/ScriptEngine/Machine/MachineInstance.cs b/src/ScriptEngine/Machine/MachineInstance.cs index 17f8f3a02..1ad01370f 100644 --- a/src/ScriptEngine/Machine/MachineInstance.cs +++ b/src/ScriptEngine/Machine/MachineInstance.cs @@ -24,6 +24,7 @@ This Source Code Form is subject to the terms of the using OneScript.Values; using ScriptEngine.Compiler; using ScriptEngine.Machine.Debugger; +using System.Dynamic; namespace ScriptEngine.Machine { @@ -1182,22 +1183,6 @@ private void Inc(int arg) private void NewInstance(int arg) { - var typeName = _module.Identifiers[arg]; - if (!_typeManager.TryGetType(typeName, out var type)) - { - throw RuntimeException.TypeIsNotDefined(typeName); - } - - // TODO убрать cast после рефакторинга ITypeFactory - var factory = (TypeFactory)_typeManager.GetFactoryFor(type); - var context = new TypeActivationContext - { - TypeName = typeName, - TypeManager = _typeManager, - Services = _process.Services, - CurrentProcess = _process - }; - int argCount = (int)_operationStack.Pop().AsNumber(); IValue[] argValues = new IValue[argCount]; // fact args @@ -1206,10 +1191,10 @@ private void NewInstance(int arg) var argValue = _operationStack.Pop(); if(!argValue.IsSkippedArgument()) argValues[i] = RawValue(argValue); - } - - var instance = (IValue)factory.Activate(context, argValues); - _operationStack.Push(instance); + } + + var typeName = _module.Identifiers[arg]; + _operationStack.Push(CreateInstance(typeName, argValues)); NextInstruction(); } @@ -2396,13 +2381,19 @@ private void NewFunc(int argCount) else argValues = Array.Empty(); } - + var typeName = PopRawBslValue().ToString(_process); + _operationStack.Push(CreateInstance(typeName, argValues)); + NextInstruction(); + } + + private IValue CreateInstance(string typeName, IValue[] args) + { if (!_typeManager.TryGetType(typeName, out var type)) { throw RuntimeException.TypeIsNotDefined(typeName); } - + // TODO убрать cast после рефакторинга ITypeFactory var factory = (TypeFactory)_typeManager.GetFactoryFor(type); var context = new TypeActivationContext @@ -2411,17 +2402,14 @@ private void NewFunc(int argCount) TypeManager = _typeManager, Services = _process.Services, CurrentProcess = _process - }; - - var instance = factory.Activate(context, argValues); - _operationStack.Push(instance); - NextInstruction(); + }; + return factory.Activate(context, args); } #endregion - + #endregion - + private StackRuntimeModule CompileExpressionModule(string expression) { var entryId = CurrentCodeEntry().ToString(); From a13d2fe8700ba2ba184fa715b31190f462a0259d Mon Sep 17 00:00:00 2001 From: Mr-Rm Date: Thu, 25 Dec 2025 21:02:12 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=BC=D0=B8=D0=BA=D1=80=D0=BE=D0=BE=D0=BF?= =?UTF-8?q?=D1=82=D0=B8=D0=BC=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8,=20?= =?UTF-8?q?=D0=B3=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/OneScript.Core/Contexts/ClassBuilder.cs | 2 +- .../SyntaxAnalysis/BslSyntaxWalker.cs | 2 +- .../ConditionalDirectiveHandler.cs | 2 +- .../SyntaxAnalysis/DefaultBslParser.cs | 4 +- .../Compiler/MethodCompiler.cs | 10 +- .../Compiler/StatementBlocksWriter.cs | 2 +- .../Collections/Indexes/CollectionIndex.cs | 2 +- .../CustomLineFeedStreamReader.cs | 2 +- .../Tasks/BackgroundTasksManager.cs | 2 +- .../Compiler/StackMachineCodeGenerator.cs | 9 +- src/ScriptEngine/Machine/MachineInstance.cs | 6 +- .../Web/Multipart/BinaryStreamStack.cs | 806 +++++++++--------- 12 files changed, 424 insertions(+), 425 deletions(-) diff --git a/src/OneScript.Core/Contexts/ClassBuilder.cs b/src/OneScript.Core/Contexts/ClassBuilder.cs index 88cf838bb..c402e9591 100644 --- a/src/OneScript.Core/Contexts/ClassBuilder.cs +++ b/src/OneScript.Core/Contexts/ClassBuilder.cs @@ -113,7 +113,7 @@ private static bool MarkedAsContextMethod(MemberInfo member, bool includeDepreca private static bool MarkedAsContextProperty(MemberInfo member, bool includeDeprecations = false) { - return member.GetCustomAttributes(typeof(ContextPropertyAttribute), false).Any(); + return member.GetCustomAttributes(typeof(ContextPropertyAttribute), false).Length != 0; } public ClassBuilder ExportConstructor(MethodInfo info) diff --git a/src/OneScript.Language/SyntaxAnalysis/BslSyntaxWalker.cs b/src/OneScript.Language/SyntaxAnalysis/BslSyntaxWalker.cs index 7c2b352da..1a0c6f8cf 100644 --- a/src/OneScript.Language/SyntaxAnalysis/BslSyntaxWalker.cs +++ b/src/OneScript.Language/SyntaxAnalysis/BslSyntaxWalker.cs @@ -324,7 +324,7 @@ protected virtual void VisitTernaryOperation(BslSyntaxNode node) protected virtual void VisitModuleBody(BslSyntaxNode codeBlock) { - if(codeBlock.Children.Count > 0) + if(codeBlock.Children.Count != 0) VisitCodeBlock(codeBlock.Children[0]); } diff --git a/src/OneScript.Language/SyntaxAnalysis/ConditionalDirectiveHandler.cs b/src/OneScript.Language/SyntaxAnalysis/ConditionalDirectiveHandler.cs index d84e8febc..5a5572dde 100644 --- a/src/OneScript.Language/SyntaxAnalysis/ConditionalDirectiveHandler.cs +++ b/src/OneScript.Language/SyntaxAnalysis/ConditionalDirectiveHandler.cs @@ -297,7 +297,7 @@ private void MarkAsSolved() private void PopBlock() { - if (_blocks.Count > 0) + if (_blocks.Count != 0) _blocks.Pop(); else AddError(LocalizedErrors.DirectiveIsMissing("Если")); diff --git a/src/OneScript.Language/SyntaxAnalysis/DefaultBslParser.cs b/src/OneScript.Language/SyntaxAnalysis/DefaultBslParser.cs index 7f6b980ca..1d1a543c9 100644 --- a/src/OneScript.Language/SyntaxAnalysis/DefaultBslParser.cs +++ b/src/OneScript.Language/SyntaxAnalysis/DefaultBslParser.cs @@ -123,7 +123,7 @@ private void ParseModuleAnnotation() .Cast() .ToList(); - if (!annotationParser.Any()) + if (annotationParser.Count == 0) return; while (_lastExtractedLexem.Type == LexemType.PreprocessorDirective) @@ -1650,7 +1650,7 @@ private void AddError(CodeError err, bool doFastForward = true) if (doFastForward) { - if (_tokenStack.Count > 0) + if (_tokenStack.Count != 0) SkipToNextStatement(_tokenStack.Peek()); else SkipToNextStatement(); diff --git a/src/OneScript.Native/Compiler/MethodCompiler.cs b/src/OneScript.Native/Compiler/MethodCompiler.cs index 3237a29f7..190643ebf 100644 --- a/src/OneScript.Native/Compiler/MethodCompiler.cs +++ b/src/OneScript.Native/Compiler/MethodCompiler.cs @@ -713,7 +713,7 @@ protected override void VisitIfNode(ConditionNode node) { stack.Push(elif); } - else if (stack.Count > 0) + else if (stack.Count != 0) { var cond = stack.Pop(); @@ -726,7 +726,7 @@ protected override void VisitIfNode(ConditionNode node) } } - while (stack.Count > 0) + while (stack.Count != 0) { var elseIfNode = stack.Pop(); VisitElseIfNode(elseIfNode); @@ -1147,7 +1147,7 @@ protected override void VisitObjectProcedureCall(BslSyntaxNode node) private IEnumerable PrepareDynamicCallArguments(BslSyntaxNode argList) { return argList.Children.Select(passedArg => - passedArg.Children.Count > 0 + passedArg.Children.Count != 0 ? ConvertToExpressionTree(passedArg.Children[0]) : Expression.Constant(BslSkippedParameterValue.Instance)); } @@ -1414,7 +1414,7 @@ private List PrepareCallArguments(BslSyntaxNode argList, ParameterIn } var parameters = argList.Children.Select(passedArg => - passedArg.Children.Count > 0 + passedArg.Children.Count != 0 ? ConvertToExpressionTree(passedArg.Children[0]) : null).ToArray(); @@ -1523,7 +1523,7 @@ protected override void VisitNewObjectCreation(NewObjectNode node) if (node.ConstructorArguments != default) { parameters = node.ConstructorArguments.Children.Select(passedArg => - passedArg.Children.Count > 0 ? + passedArg.Children.Count != 0 ? ConvertToExpressionTree(passedArg.Children[0]) : Expression.Default(typeof(BslValue))).ToArray(); } diff --git a/src/OneScript.Native/Compiler/StatementBlocksWriter.cs b/src/OneScript.Native/Compiler/StatementBlocksWriter.cs index f781f1a08..6bf68f434 100644 --- a/src/OneScript.Native/Compiler/StatementBlocksWriter.cs +++ b/src/OneScript.Native/Compiler/StatementBlocksWriter.cs @@ -18,7 +18,7 @@ public class StatementBlocksWriter public void EnterBlock(JumpInformationRecord newJumpStates) { - var current = _blocks.Count > 0 ? GetCurrentBlock() : null; + var current = _blocks.Count != 0 ? GetCurrentBlock() : null; if (current != null) { newJumpStates.MethodReturn ??= current.MethodReturn; diff --git a/src/OneScript.StandardLibrary/Collections/Indexes/CollectionIndex.cs b/src/OneScript.StandardLibrary/Collections/Indexes/CollectionIndex.cs index 71fb5c62b..73f13347e 100644 --- a/src/OneScript.StandardLibrary/Collections/Indexes/CollectionIndex.cs +++ b/src/OneScript.StandardLibrary/Collections/Indexes/CollectionIndex.cs @@ -42,7 +42,7 @@ public CollectionIndex(IIndexCollectionSource source, IEnumerable fields internal bool CanBeUsedFor(IEnumerable searchFields) { - return _fields.Count > 0 && _fields.All(f => searchFields.Contains(f)); + return _fields.Count != 0 && _fields.All(f => searchFields.Contains(f)); } private CollectionIndexKey IndexKey(PropertyNameIndexAccessor source) diff --git a/src/OneScript.StandardLibrary/CustomLineFeedStreamReader.cs b/src/OneScript.StandardLibrary/CustomLineFeedStreamReader.cs index b6933543c..f087c5d26 100644 --- a/src/OneScript.StandardLibrary/CustomLineFeedStreamReader.cs +++ b/src/OneScript.StandardLibrary/CustomLineFeedStreamReader.cs @@ -56,7 +56,7 @@ public int Read () _buffer.Dequeue (); UpdateCharQueue (); - if (_buffer.Count > 0 && _buffer.Peek () == '\n') { + if (_buffer.Count != 0 && _buffer.Peek () == '\n') { _buffer.Dequeue (); UpdateCharQueue (); } diff --git a/src/OneScript.StandardLibrary/Tasks/BackgroundTasksManager.cs b/src/OneScript.StandardLibrary/Tasks/BackgroundTasksManager.cs index 0a875dc84..9999dd86c 100644 --- a/src/OneScript.StandardLibrary/Tasks/BackgroundTasksManager.cs +++ b/src/OneScript.StandardLibrary/Tasks/BackgroundTasksManager.cs @@ -120,7 +120,7 @@ public void WaitCompletionOfTasks() var failedTasks = _tasks.Where(x => x.State == TaskStateEnum.CompletedWithErrors) .ToList(); - if (failedTasks.Any()) + if (failedTasks.Count != 0) { throw new ParametrizedRuntimeException( Locale.NStr("ru = 'Задания завершились с ошибками';en = 'Tasks are completed with errors'"), diff --git a/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs b/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs index ae8fff066..3edae66b7 100644 --- a/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs +++ b/src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs @@ -12,7 +12,6 @@ This Source Code Form is subject to the terms of the using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; -using System.Text; using OneScript.Compilation; using OneScript.Compilation.Binding; using OneScript.Contexts; @@ -126,7 +125,7 @@ private void HandleImportClause(AnnotationNode node) private void CheckForwardedDeclarations() { - if (_forwardedMethods.Count > 0) + if (_forwardedMethods.Count != 0) { foreach (var item in _forwardedMethods) { @@ -477,7 +476,7 @@ protected override void VisitContinueNode(LineMarkerNode node) protected override void VisitReturnNode(BslSyntaxNode node) { - if (node.Children.Count > 0) + if (node.Children.Count != 0) { VisitExpression(node.Children[0]); AddCommand(OperationCode.MakeRawValue); @@ -1085,7 +1084,7 @@ private void ExitTryBlocks() private void PushTryNesting() { - if (_nestedLoops.Count > 0) + if (_nestedLoops.Count != 0) { _nestedLoops.Peek().tryNesting++; } @@ -1093,7 +1092,7 @@ private void PushTryNesting() private void PopTryNesting() { - if (_nestedLoops.Count > 0) + if (_nestedLoops.Count != 0) { _nestedLoops.Peek().tryNesting--; } diff --git a/src/ScriptEngine/Machine/MachineInstance.cs b/src/ScriptEngine/Machine/MachineInstance.cs index 1ad01370f..288b726f5 100644 --- a/src/ScriptEngine/Machine/MachineInstance.cs +++ b/src/ScriptEngine/Machine/MachineInstance.cs @@ -1134,7 +1134,7 @@ private void Return(int arg) if (_currentFrame.DiscardReturnValue) _operationStack.Pop(); - while(_exceptionsStack.Count > 0 && _exceptionsStack.Peek().HandlerFrame == _currentFrame) + while(_exceptionsStack.Count != 0 && _exceptionsStack.Peek().HandlerFrame == _currentFrame) { _exceptionsStack.Pop(); } @@ -1248,7 +1248,7 @@ private void BeginTry(int exceptBlockAddress) private void EndTry(int arg) { - if (_exceptionsStack.Count > 0) + if (_exceptionsStack.Count != 0) { var jmpInfo = _exceptionsStack.Peek(); if (jmpInfo.HandlerFrame == _currentFrame && arg == jmpInfo.HandlerAddress) @@ -1371,7 +1371,7 @@ private void Execute(int arg) { var code = PopRawBslValue().ToString(_process); var module = CompileCached(code, CompileExecutionBatchModule); - if (!module.Methods.Any()) + if (module.Methods.Count == 0) { NextInstruction(); return; diff --git a/src/oscript/Web/Multipart/BinaryStreamStack.cs b/src/oscript/Web/Multipart/BinaryStreamStack.cs index eac9dbb10..3fe42c7fd 100644 --- a/src/oscript/Web/Multipart/BinaryStreamStack.cs +++ b/src/oscript/Web/Multipart/BinaryStreamStack.cs @@ -1,404 +1,404 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2013 Jake Woods -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software -// and associated documentation files (the "Software"), to deal in the Software without restriction, -// including without limitation the rights to use, copy, modify, merge, publish, distribute, -// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -// is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies -// or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR -// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// Jake Woods -// -// Provides character based and byte based stream-like read operations over multiple -// streams and provides methods to add data to the front of the buffer. -// -// -------------------------------------------------------------------------------------------------------------------- - -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; - -namespace HttpMultipartParser -{ - /// - /// Provides character based and byte based stream-like read operations over multiple - /// streams and provides methods to add data to the front of the buffer. - /// - internal class BinaryStreamStack - { - #region Fields - - /// - /// Holds the streams to read from, the stream on the top of the - /// stack will be read first. - /// - private readonly Stack streams = new Stack(); - - #endregion - - #region Constructors and Destructors - - /// - /// Initializes a new instance of the class with the default - /// encoding of UTF8. - /// - public BinaryStreamStack() - : this(Encoding.UTF8) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// The encoding to use for character based operations. - /// - public BinaryStreamStack(Encoding encoding) - { - CurrentEncoding = encoding; - } - - #endregion - - #region Public Properties - - /// - /// Gets or sets the current encoding. - /// - public Encoding CurrentEncoding { get; set; } - - #endregion - - #region Public Methods and Operators - - /// - /// Returns true if there is any data left to read. - /// - /// - /// True or false. - /// - public bool HasData() - { - return streams.Any(); - } - - /// - /// Returns the reader on the top of the stack but does not remove it. - /// - /// - /// The . - /// - public BinaryReader Peek() - { - return streams.Peek(); - } - - /// - /// Returns the reader on the top of the stack and removes it - /// - /// - /// The . - /// - public BinaryReader Pop() - { - return streams.Pop(); - } - - /// - /// Pushes data to the front of the stack. The most recently pushed data will - /// be read first. - /// - /// - /// The data to add to the stack. - /// - public void Push(byte[] data) - { - streams.Push(new BinaryReader(new MemoryStream(data), CurrentEncoding)); - } - - /// - /// Reads a single byte as an integer from the stack. Returns -1 if no - /// data is left to read. - /// - /// - /// The that was read. - /// - public int Read() - { - BinaryReader top = streams.Peek(); - - int value; - while ((value = top.Read()) == -1) - { - top.Dispose(); - streams.Pop(); - - if (!streams.Any()) - { - return -1; - } - - top = streams.Peek(); - } - - return value; - } - - /// - /// Reads the specified number of bytes from the stack, starting from a specified point in the byte array. - /// - /// - /// The buffer to read data into. - /// - /// - /// The index of buffer to start reading into. - /// - /// - /// The number of bytes to read into the buffer. - /// - /// - /// The number of bytes read into buffer. This might be less than the number of bytes requested if that many bytes are not available, - /// or it might be zero if the end of the stream is reached. - /// - public int Read(byte[] buffer, int index, int count) - { - if (!HasData()) - { - return 0; - } - - // Read through all the stream untill we exhaust them - // or untill count is satisfied - int amountRead = 0; - BinaryReader top = streams.Peek(); - while (amountRead < count && streams.Any()) - { - int read = top.Read(buffer, index + amountRead, count - amountRead); - if (read == 0) - { - if ((top = NextStream()) == null) - { - return amountRead; - } - } - else - { - amountRead += read; - } - } - - return amountRead; - } - - /// - /// Reads the specified number of characters from the stack, starting from a specified point in the byte array. - /// - /// - /// The buffer to read data into. - /// - /// - /// The index of buffer to start reading into. - /// - /// - /// The number of characters to read into the buffer. - /// - /// - /// The number of characters read into buffer. This might be less than the number of bytes requested if that many bytes are not available, - /// or it might be zero if the end of the stream is reached. - /// - public int Read(char[] buffer, int index, int count) - { - if (!HasData()) - { - return 0; - } - - // Read through all the stream untill we exhaust them - // or untill count is satisfied - int amountRead = 0; - BinaryReader top = streams.Peek(); - while (amountRead < count && streams.Any()) - { - int read = top.Read(buffer, index + amountRead, count - amountRead); - if (read == 0) - { - if ((top = NextStream()) == null) - { - return amountRead; - } - } - else - { - amountRead += read; - } - } - - return amountRead; - } - - /// - /// Reads the specified number of characters from the stack, starting from a specified point in the byte array. - /// - /// - /// A byte array containing all the data up to but not including the next newline in the stack. - /// - public byte[] ReadByteLine() - { - bool dummy; - return ReadByteLine(out dummy); - } - - /// - /// Reads a line from the stack delimited by the newline for this platform. The newline - /// characters will not be included in the stream - /// - /// - /// This will be set to true if we did not end on a newline but instead found the end of - /// our data. - /// - /// - /// The containing the line. - /// - public byte[] ReadByteLine(out bool hitStreamEnd) - { - hitStreamEnd = false; - if (!HasData()) - { - // No streams, no data! - return null; - } - - // This is horribly inefficient, consider profiling here if - // it becomes an issue. - BinaryReader top = streams.Peek(); - byte[] ignore = CurrentEncoding.GetBytes(new[] {'\r'}); - byte[] search = CurrentEncoding.GetBytes(new[] {'\n'}); - int searchPos = 0; - var builder = new MemoryStream(); - - while (true) - { - // First we need to read a byte from one of the streams - var bytes = new byte[search.Length]; - int amountRead = top.Read(bytes, 0, bytes.Length); - while (amountRead == 0) - { - streams.Pop(); - if (!streams.Any()) - { - hitStreamEnd = true; - return builder.ToArray(); - } - - top.Dispose(); - top = streams.Peek(); - amountRead = top.Read(bytes, 0, bytes.Length); - } - - // Now we've got some bytes, we need to check it against the search array. - foreach (byte b in bytes) - { - if (ignore.Contains(b)) - { - continue; - } - - if (b == search[searchPos]) - { - searchPos += 1; - } - else - { - // We only want to append the information if it's - // not part of the newline sequence - if (searchPos != 0) - { - byte[] append = search.Take(searchPos).ToArray(); - builder.Write(append, 0, append.Length); - } - - builder.Write(new[] {b}, 0, 1); - searchPos = 0; - } - - // Finally if we've found our string - if (searchPos == search.Length) - { - return builder.ToArray(); - } - } - } - } - - /// - /// Reads a line from the stack delimited by the newline for this platform. The newline - /// characters will not be included in the stream - /// - /// - /// The containing the line. - /// - public string ReadLine() - { - bool dummy; - return ReadLine(out dummy); - } - - /// - /// Reads a line from the stack delimited by the newline for this platform. The newline - /// characters will not be included in the stream - /// - /// - /// This will be set to true if we did not end on a newline but instead found the end of - /// our data. - /// - /// - /// The containing the line. - /// - public string ReadLine(out bool hitStreamEnd) - { - bool foundEnd; - byte[] result = ReadByteLine(out foundEnd); - hitStreamEnd = foundEnd; - - if (result == null) - { - return null; - } - - return CurrentEncoding.GetString(result); - } - - #endregion - - #region Methods - - /// - /// Removes the current reader from the stack and ensures it is correctly - /// destroyed and then returns the next available reader. If no reader - /// is available this method returns null. - /// - /// - /// The next reader. - /// - private BinaryReader NextStream() - { - BinaryReader top = streams.Pop(); - top.Dispose(); - - return streams.Any() ? streams.Peek() : null; - } - - #endregion - } +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2013 Jake Woods +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software +// and associated documentation files (the "Software"), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, publish, distribute, +// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +// is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Jake Woods +// +// Provides character based and byte based stream-like read operations over multiple +// streams and provides methods to add data to the front of the buffer. +// +// -------------------------------------------------------------------------------------------------------------------- + +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace HttpMultipartParser +{ + /// + /// Provides character based and byte based stream-like read operations over multiple + /// streams and provides methods to add data to the front of the buffer. + /// + internal class BinaryStreamStack + { + #region Fields + + /// + /// Holds the streams to read from, the stream on the top of the + /// stack will be read first. + /// + private readonly Stack streams = new Stack(); + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class with the default + /// encoding of UTF8. + /// + public BinaryStreamStack() + : this(Encoding.UTF8) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The encoding to use for character based operations. + /// + public BinaryStreamStack(Encoding encoding) + { + CurrentEncoding = encoding; + } + + #endregion + + #region Public Properties + + /// + /// Gets or sets the current encoding. + /// + public Encoding CurrentEncoding { get; set; } + + #endregion + + #region Public Methods and Operators + + /// + /// Returns true if there is any data left to read. + /// + /// + /// True or false. + /// + public bool HasData() + { + return streams.Count != 0; + } + + /// + /// Returns the reader on the top of the stack but does not remove it. + /// + /// + /// The . + /// + public BinaryReader Peek() + { + return streams.Peek(); + } + + /// + /// Returns the reader on the top of the stack and removes it + /// + /// + /// The . + /// + public BinaryReader Pop() + { + return streams.Pop(); + } + + /// + /// Pushes data to the front of the stack. The most recently pushed data will + /// be read first. + /// + /// + /// The data to add to the stack. + /// + public void Push(byte[] data) + { + streams.Push(new BinaryReader(new MemoryStream(data), CurrentEncoding)); + } + + /// + /// Reads a single byte as an integer from the stack. Returns -1 if no + /// data is left to read. + /// + /// + /// The that was read. + /// + public int Read() + { + BinaryReader top = streams.Peek(); + + int value; + while ((value = top.Read()) == -1) + { + top.Dispose(); + streams.Pop(); + + if (streams.Count == 0) + { + return -1; + } + + top = streams.Peek(); + } + + return value; + } + + /// + /// Reads the specified number of bytes from the stack, starting from a specified point in the byte array. + /// + /// + /// The buffer to read data into. + /// + /// + /// The index of buffer to start reading into. + /// + /// + /// The number of bytes to read into the buffer. + /// + /// + /// The number of bytes read into buffer. This might be less than the number of bytes requested if that many bytes are not available, + /// or it might be zero if the end of the stream is reached. + /// + public int Read(byte[] buffer, int index, int count) + { + if (!HasData()) + { + return 0; + } + + // Read through all the stream untill we exhaust them + // or untill count is satisfied + int amountRead = 0; + BinaryReader top = streams.Peek(); + while (amountRead < count && streams.Count != 0) + { + int read = top.Read(buffer, index + amountRead, count - amountRead); + if (read == 0) + { + if ((top = NextStream()) == null) + { + return amountRead; + } + } + else + { + amountRead += read; + } + } + + return amountRead; + } + + /// + /// Reads the specified number of characters from the stack, starting from a specified point in the byte array. + /// + /// + /// The buffer to read data into. + /// + /// + /// The index of buffer to start reading into. + /// + /// + /// The number of characters to read into the buffer. + /// + /// + /// The number of characters read into buffer. This might be less than the number of bytes requested if that many bytes are not available, + /// or it might be zero if the end of the stream is reached. + /// + public int Read(char[] buffer, int index, int count) + { + if (!HasData()) + { + return 0; + } + + // Read through all the stream untill we exhaust them + // or untill count is satisfied + int amountRead = 0; + BinaryReader top = streams.Peek(); + while (amountRead < count && streams.Count != 0) + { + int read = top.Read(buffer, index + amountRead, count - amountRead); + if (read == 0) + { + if ((top = NextStream()) == null) + { + return amountRead; + } + } + else + { + amountRead += read; + } + } + + return amountRead; + } + + /// + /// Reads the specified number of characters from the stack, starting from a specified point in the byte array. + /// + /// + /// A byte array containing all the data up to but not including the next newline in the stack. + /// + public byte[] ReadByteLine() + { + bool dummy; + return ReadByteLine(out dummy); + } + + /// + /// Reads a line from the stack delimited by the newline for this platform. The newline + /// characters will not be included in the stream + /// + /// + /// This will be set to true if we did not end on a newline but instead found the end of + /// our data. + /// + /// + /// The containing the line. + /// + public byte[] ReadByteLine(out bool hitStreamEnd) + { + hitStreamEnd = false; + if (!HasData()) + { + // No streams, no data! + return null; + } + + // This is horribly inefficient, consider profiling here if + // it becomes an issue. + BinaryReader top = streams.Peek(); + byte[] ignore = CurrentEncoding.GetBytes(new[] {'\r'}); + byte[] search = CurrentEncoding.GetBytes(new[] {'\n'}); + int searchPos = 0; + var builder = new MemoryStream(); + + while (true) + { + // First we need to read a byte from one of the streams + var bytes = new byte[search.Length]; + int amountRead = top.Read(bytes, 0, bytes.Length); + while (amountRead == 0) + { + streams.Pop(); + if (!streams.Any()) + { + hitStreamEnd = true; + return builder.ToArray(); + } + + top.Dispose(); + top = streams.Peek(); + amountRead = top.Read(bytes, 0, bytes.Length); + } + + // Now we've got some bytes, we need to check it against the search array. + foreach (byte b in bytes) + { + if (ignore.Contains(b)) + { + continue; + } + + if (b == search[searchPos]) + { + searchPos += 1; + } + else + { + // We only want to append the information if it's + // not part of the newline sequence + if (searchPos != 0) + { + byte[] append = search.Take(searchPos).ToArray(); + builder.Write(append, 0, append.Length); + } + + builder.Write(new[] {b}, 0, 1); + searchPos = 0; + } + + // Finally if we've found our string + if (searchPos == search.Length) + { + return builder.ToArray(); + } + } + } + } + + /// + /// Reads a line from the stack delimited by the newline for this platform. The newline + /// characters will not be included in the stream + /// + /// + /// The containing the line. + /// + public string ReadLine() + { + bool dummy; + return ReadLine(out dummy); + } + + /// + /// Reads a line from the stack delimited by the newline for this platform. The newline + /// characters will not be included in the stream + /// + /// + /// This will be set to true if we did not end on a newline but instead found the end of + /// our data. + /// + /// + /// The containing the line. + /// + public string ReadLine(out bool hitStreamEnd) + { + bool foundEnd; + byte[] result = ReadByteLine(out foundEnd); + hitStreamEnd = foundEnd; + + if (result == null) + { + return null; + } + + return CurrentEncoding.GetString(result); + } + + #endregion + + #region Methods + + /// + /// Removes the current reader from the stack and ensures it is correctly + /// destroyed and then returns the next available reader. If no reader + /// is available this method returns null. + /// + /// + /// The next reader. + /// + private BinaryReader NextStream() + { + BinaryReader top = streams.Pop(); + top.Dispose(); + + return streams.Count != 0 ? streams.Peek() : null; + } + + #endregion + } } \ No newline at end of file From 3262cf92bdaa9fc45fda8ea8571a189919eb0fcb Mon Sep 17 00:00:00 2001 From: Mr-Rm Date: Fri, 26 Dec 2025 01:47:22 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=87=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/OneScript.Core/Contexts/ClassBuilder.cs | 5 +++-- src/ScriptEngine/Machine/MachineInstance.cs | 1 - src/oscript/Web/Multipart/BinaryStreamStack.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OneScript.Core/Contexts/ClassBuilder.cs b/src/OneScript.Core/Contexts/ClassBuilder.cs index c402e9591..3b7839c83 100644 --- a/src/OneScript.Core/Contexts/ClassBuilder.cs +++ b/src/OneScript.Core/Contexts/ClassBuilder.cs @@ -111,9 +111,10 @@ private static bool MarkedAsContextMethod(MemberInfo member, bool includeDepreca .Any(x => includeDeprecations || (x as ContextMethodAttribute)?.IsDeprecated == false); } - private static bool MarkedAsContextProperty(MemberInfo member, bool includeDeprecations = false) + private static bool MarkedAsContextProperty(PropertyInfo member, bool includeDeprecations = false) { - return member.GetCustomAttributes(typeof(ContextPropertyAttribute), false).Length != 0; + return member.GetCustomAttributes(typeof(ContextPropertyAttribute), false) + .Any(x => includeDeprecations || (x as ContextPropertyAttribute)?.IsDeprecated == false); } public ClassBuilder ExportConstructor(MethodInfo info) diff --git a/src/ScriptEngine/Machine/MachineInstance.cs b/src/ScriptEngine/Machine/MachineInstance.cs index 288b726f5..eb5d73bf1 100644 --- a/src/ScriptEngine/Machine/MachineInstance.cs +++ b/src/ScriptEngine/Machine/MachineInstance.cs @@ -24,7 +24,6 @@ This Source Code Form is subject to the terms of the using OneScript.Values; using ScriptEngine.Compiler; using ScriptEngine.Machine.Debugger; -using System.Dynamic; namespace ScriptEngine.Machine { diff --git a/src/oscript/Web/Multipart/BinaryStreamStack.cs b/src/oscript/Web/Multipart/BinaryStreamStack.cs index 3fe42c7fd..bb07961cc 100644 --- a/src/oscript/Web/Multipart/BinaryStreamStack.cs +++ b/src/oscript/Web/Multipart/BinaryStreamStack.cs @@ -295,7 +295,7 @@ public byte[] ReadByteLine(out bool hitStreamEnd) while (amountRead == 0) { streams.Pop(); - if (!streams.Any()) + if (streams.Count == 0) { hitStreamEnd = true; return builder.ToArray();