Skip to content

Commit b1b9a15

Browse files
authored
Merge pull request #1642 from Mr-Rm/v2/optim-VM
VM: имена свойств и методов в отдельный список
2 parents 7e7de3a + 3262cf9 commit b1b9a15

File tree

14 files changed

+497
-497
lines changed

14 files changed

+497
-497
lines changed

src/OneScript.Core/Contexts/ClassBuilder.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ private static bool MarkedAsContextMethod(MemberInfo member, bool includeDepreca
111111
.Any(x => includeDeprecations || (x as ContextMethodAttribute)?.IsDeprecated == false);
112112
}
113113

114-
private static bool MarkedAsContextProperty(MemberInfo member, bool includeDeprecations = false)
114+
private static bool MarkedAsContextProperty(PropertyInfo member, bool includeDeprecations = false)
115115
{
116-
return member.GetCustomAttributes(typeof(ContextPropertyAttribute), false).Any();
116+
return member.GetCustomAttributes(typeof(ContextPropertyAttribute), false)
117+
.Any(x => includeDeprecations || (x as ContextPropertyAttribute)?.IsDeprecated == false);
117118
}
118119

119120
public ClassBuilder ExportConstructor(MethodInfo info)

src/OneScript.Language/SyntaxAnalysis/BslSyntaxWalker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ protected virtual void VisitTernaryOperation(BslSyntaxNode node)
324324

325325
protected virtual void VisitModuleBody(BslSyntaxNode codeBlock)
326326
{
327-
if(codeBlock.Children.Count > 0)
327+
if(codeBlock.Children.Count != 0)
328328
VisitCodeBlock(codeBlock.Children[0]);
329329
}
330330

src/OneScript.Language/SyntaxAnalysis/ConditionalDirectiveHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ private void MarkAsSolved()
297297

298298
private void PopBlock()
299299
{
300-
if (_blocks.Count > 0)
300+
if (_blocks.Count != 0)
301301
_blocks.Pop();
302302
else
303303
AddError(LocalizedErrors.DirectiveIsMissing("Если"));

src/OneScript.Language/SyntaxAnalysis/DefaultBslParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private void ParseModuleAnnotation()
123123
.Cast<ModuleAnnotationDirectiveHandler>()
124124
.ToList();
125125

126-
if (!annotationParser.Any())
126+
if (annotationParser.Count == 0)
127127
return;
128128

129129
while (_lastExtractedLexem.Type == LexemType.PreprocessorDirective)
@@ -1650,7 +1650,7 @@ private void AddError(CodeError err, bool doFastForward = true)
16501650

16511651
if (doFastForward)
16521652
{
1653-
if (_tokenStack.Count > 0)
1653+
if (_tokenStack.Count != 0)
16541654
SkipToNextStatement(_tokenStack.Peek());
16551655
else
16561656
SkipToNextStatement();

src/OneScript.Native/Compiler/MethodCompiler.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ protected override void VisitIfNode(ConditionNode node)
713713
{
714714
stack.Push(elif);
715715
}
716-
else if (stack.Count > 0)
716+
else if (stack.Count != 0)
717717
{
718718
var cond = stack.Pop();
719719

@@ -726,7 +726,7 @@ protected override void VisitIfNode(ConditionNode node)
726726
}
727727
}
728728

729-
while (stack.Count > 0)
729+
while (stack.Count != 0)
730730
{
731731
var elseIfNode = stack.Pop();
732732
VisitElseIfNode(elseIfNode);
@@ -1147,7 +1147,7 @@ protected override void VisitObjectProcedureCall(BslSyntaxNode node)
11471147
private IEnumerable<Expression> PrepareDynamicCallArguments(BslSyntaxNode argList)
11481148
{
11491149
return argList.Children.Select(passedArg =>
1150-
passedArg.Children.Count > 0
1150+
passedArg.Children.Count != 0
11511151
? ConvertToExpressionTree(passedArg.Children[0])
11521152
: Expression.Constant(BslSkippedParameterValue.Instance));
11531153
}
@@ -1414,7 +1414,7 @@ private List<Expression> PrepareCallArguments(BslSyntaxNode argList, ParameterIn
14141414
}
14151415

14161416
var parameters = argList.Children.Select(passedArg =>
1417-
passedArg.Children.Count > 0
1417+
passedArg.Children.Count != 0
14181418
? ConvertToExpressionTree(passedArg.Children[0])
14191419
: null).ToArray();
14201420

@@ -1523,7 +1523,7 @@ protected override void VisitNewObjectCreation(NewObjectNode node)
15231523
if (node.ConstructorArguments != default)
15241524
{
15251525
parameters = node.ConstructorArguments.Children.Select(passedArg =>
1526-
passedArg.Children.Count > 0 ?
1526+
passedArg.Children.Count != 0 ?
15271527
ConvertToExpressionTree(passedArg.Children[0]) :
15281528
Expression.Default(typeof(BslValue))).ToArray();
15291529
}

src/OneScript.Native/Compiler/StatementBlocksWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class StatementBlocksWriter
1818

1919
public void EnterBlock(JumpInformationRecord newJumpStates)
2020
{
21-
var current = _blocks.Count > 0 ? GetCurrentBlock() : null;
21+
var current = _blocks.Count != 0 ? GetCurrentBlock() : null;
2222
if (current != null)
2323
{
2424
newJumpStates.MethodReturn ??= current.MethodReturn;

src/OneScript.StandardLibrary/Collections/Indexes/CollectionIndex.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public CollectionIndex(IIndexCollectionSource source, IEnumerable<IValue> fields
4242

4343
internal bool CanBeUsedFor(IEnumerable<IValue> searchFields)
4444
{
45-
return _fields.Count > 0 && _fields.All(f => searchFields.Contains(f));
45+
return _fields.Count != 0 && _fields.All(f => searchFields.Contains(f));
4646
}
4747

4848
private CollectionIndexKey IndexKey(PropertyNameIndexAccessor source)

src/OneScript.StandardLibrary/CustomLineFeedStreamReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public int Read ()
5656
_buffer.Dequeue ();
5757
UpdateCharQueue ();
5858

59-
if (_buffer.Count > 0 && _buffer.Peek () == '\n') {
59+
if (_buffer.Count != 0 && _buffer.Peek () == '\n') {
6060
_buffer.Dequeue ();
6161
UpdateCharQueue ();
6262
}

src/OneScript.StandardLibrary/Tasks/BackgroundTasksManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void WaitCompletionOfTasks()
120120
var failedTasks = _tasks.Where(x => x.State == TaskStateEnum.CompletedWithErrors)
121121
.ToList();
122122

123-
if (failedTasks.Any())
123+
if (failedTasks.Count != 0)
124124
{
125125
throw new ParametrizedRuntimeException(
126126
Locale.NStr("ru = 'Задания завершились с ошибками';en = 'Tasks are completed with errors'"),

src/ScriptEngine/Compiler/ModuleDumpWriter.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ private void WriteImage(TextWriter output, StackRuntimeModule module)
129129
output.WriteLine(
130130
$"{i,-3}:type: {item.SystemType.Alias}, val: {item}");
131131
}
132+
output.WriteLine(".identifiers");
133+
for (int i = 0; i < module.Identifiers.Count; i++)
134+
{
135+
var item = module.Identifiers[i];
136+
output.WriteLine(
137+
$"{i,-3}: {item}");
138+
}
132139
output.WriteLine(".code");
133140
for (int i = 0; i < module.Code.Count; i++)
134141
{

0 commit comments

Comments
 (0)