diff --git a/StgSharp.Common/Controlling/Controls/DecorationBox.cs b/StgSharp.Common/Controlling/Controls/DecorationBox.cs index cff76f6b..01472dce 100644 --- a/StgSharp.Common/Controlling/Controls/DecorationBox.cs +++ b/StgSharp.Common/Controlling/Controls/DecorationBox.cs @@ -1,39 +1,40 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="DecorationBox" +// file="DecorationBox.cs" // Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. All rights reserved. +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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. +// 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. // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using StgSharp.Controls; using StgSharp.Geometries; using StgSharp.Graphics; -using StgSharp.Mathematics; using StgSharp.Mathematics.Graphic; using System; using System.Collections.Generic; -using System.Text; +using System.Runtime.CompilerServices; namespace StgSharp.Controls { @@ -52,6 +53,7 @@ namespace StgSharp.Controls public ReadOnlySpan TextureBox { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get => renderMesh.TextureCoord; } diff --git a/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs b/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs index f7edfbcd..68e1f193 100644 --- a/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs +++ b/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs @@ -2,8 +2,8 @@ // ----------------------------------------------------------------------- // file="MatrixParallel.Publish" // Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. All rights reserved. +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -830,12 +830,15 @@ namespace StgSharp.Mathematics.Numeric int total = tileCount; List w = new List(Wraps.Count); + int baseTile = 0; + + // TODO 干脆用四个掩ç �分别表示å�„ç§�部分算了。 for (int i = 0; i < Wraps.Count; i++) { MatrixParallelWrap wrap = Wraps.Pop(); wrap.WrapTask = (MatrixParallelTaskPackageNonGeneric*)package; - wrap.WrapTaskCapacity = ; - wrap.WrapTaskSliceCount = ; + wrap.WrapTaskCapacity = tilePerThreadLess + (i < extraTiles ? 1 : 0); + wrap.WrapTaskSliceCount = (i * tilePerThreadLess) + Math.Min(i, extraTiles); w.Add(wrap); } } diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Common.cs b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Common.cs index cb856796..d63414f5 100644 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Common.cs +++ b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Common.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.Common.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.Common" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp.Syntax; using StgSharp.Script; @@ -53,10 +50,10 @@ namespace StgSharp.Model.Step private StepDependencyDetector _dependencyDetector = new StepDependencyDetector(); - [GeneratedRegex( @"^[A-Z0-9_]+$", RegexOptions.Singleline )] + [GeneratedRegex(@"^[A-Z0-9_]+$", RegexOptions.Singleline)] private static partial Regex GetEntityTypeCheckPattern(); - private bool IsSeparatorMatch( Token leftSeparator, Token rightSeparator ) + private bool IsSeparatorMatch(Token leftSeparator, Token rightSeparator) { return leftSeparator.Value switch { @@ -68,234 +65,234 @@ namespace StgSharp.Model.Step }; } - private bool TryAppendIndexLeft( Token t ) + private bool TryAppendIndexLeft(Token t) { - if( t.Flag != TokenFlag.Index_Left ) { + if (t.Flag != TokenFlag.Index_Left) { return false; } - if( _cache.TryPeekOperand( out bool isNode, out _, out ExpSyntaxNode? node ) ) + if (_cache.TryPeekOperand(out bool isNode, out _, out ExpSyntaxNode? node)) { - if( node.EqualityTypeConvert is not ExpCollectionBase ) { - ExpInvalidSyntaxException.ThrowNonCollectionIndex( t ); + if (node.EqualityTypeConvert is not ExpCollectionBase) { + ExpInvalidSyntaxException.ThrowNonCollectionIndex(t); } } - _cache.PushOperator( t ); - _cache.IncreaseDepth( ( int )ExpCompileStateCode.CollectionIndex ); + _cache.PushOperator(t); + _cache.IncreaseDepth((int)ExpCompileStateCode.CollectionIndex); return true; } - private bool TryAppendIndexRight( Token t ) + private bool TryAppendIndexRight(Token t) { - if( t.Flag != TokenFlag.Index_Right ) { + if (t.Flag != TokenFlag.Index_Right) { return false; } - //reverse building - ClosePrefixReverse( t ); + // reverse building + ClosePrefixReverse(t); - //make index node - _cache.PopOperand( out _, out ExpSyntaxNode? expNode ); - if( !_cache.PopOperand( out Token colleToken, out ExpSyntaxNode? colleNode ) ) { } + // make index node + _cache.PopOperand(out _, out ExpSyntaxNode? expNode); + if (!_cache.PopOperand(out Token colleToken, out ExpSyntaxNode? colleNode)) { } _cache.PushOperand( ExpCollectionIndexNode.Create( - t, ( colleNode as ExpCollectionInstanceBase )!, expNode ) ); + t, (colleNode as ExpCollectionInstanceBase)!, expNode)); return true; } - private bool TryAppendMember( Token t ) + private bool TryAppendMember(Token t) { - if( t.Flag != TokenFlag.Member ) { + if (t.Flag != TokenFlag.Member) { return false; } - if( TryParseConstant( t ) ) { + if (TryParseConstant(t)) { return true; } - if( TryParseFunction( t ) ) { + if (TryParseFunction(t)) { return true; } - if( TryParseInstance( t ) ) { + if (TryParseInstance(t)) { return true; } - if( TryParseKeyword( t ) ) { + if (TryParseKeyword(t)) { return true; } - if( TryParseElementName( t ) ) { + if (TryParseElementName(t)) { return true; } - //Many thing miss here - _cache.PushOperand( ExpElementMemberNameNode.Create( t ) ); + // Many thing miss here + _cache.PushOperand(ExpElementMemberNameNode.Create(t)); return true; } - private bool TryAppendMiddleSeparator( Token t ) + private bool TryAppendMiddleSeparator(Token t) { - if( t.Flag != TokenFlag.Separator_Middle ) { + if (t.Flag != TokenFlag.Separator_Middle) { return false; } - while( _cache.OperatorAheadOfDepth > 0 ) + while (_cache.OperatorAheadOfDepth > 0) { - _cache.TryPopOperator( out Token op ); - ExpSyntaxNode node = ConvertAndPushOneOperator( op ); + _cache.TryPopOperator(out Token op); + ExpSyntaxNode node = ConvertAndPushOneOperator(op); } - switch( _cache.OperandAheadOfDepth ) + switch (_cache.OperandAheadOfDepth) { case 0: - if( t.Value == ";" ) { + if (t.Value == ";") { return true; } - _cache.StatementsInDepth.Push( ExpSyntaxNode.Empty ); + _cache.StatementsInDepth.Push(ExpSyntaxNode.Empty); goto case 1; case 1: - _cache.PopOperand( out _, out ExpSyntaxNode? statement ); - if( t.Value == ";" ) + _cache.PopOperand(out _, out ExpSyntaxNode? statement); + if (t.Value == ";") { StepEntityDefineSequence sequence = new StepEntityDefineSequence( - statement, _dependencyDetector.ExportAllDependencies() ); - StepEntityInitStatements.Enqueue( sequence ); + statement, _dependencyDetector.ExportAllDependencies()); + StepEntityInitStatements.Enqueue(sequence); } else { - _cache.StatementsInDepth.Push( statement ); + _cache.StatementsInDepth.Push(statement); } return true; default: - ExpInvalidSyntaxException.ThrowNoOperator( t ); + ExpInvalidSyntaxException.ThrowNoOperator(t); break; } return true; } - private bool TryAppendNumAndStrLiteral( Token t ) + private bool TryAppendNumAndStrLiteral(Token t) { - if( ( t.Flag & ( TokenFlag.String | TokenFlag.Number ) ) == 0 ) { + if ((t.Flag & (TokenFlag.String | TokenFlag.Number)) == 0) { return false; } - _cache.PushOperand( ExpElementInstance.CreateLiteral( t ) ); + _cache.PushOperand(ExpElementInstance.CreateLiteral(t)); return true; } - private bool TryAppendPrefixSeparator( Token t ) + private bool TryAppendPrefixSeparator(Token t) { - if( t.Flag != TokenFlag.Separator_Left ) { + if (t.Flag != TokenFlag.Separator_Left) { return false; } - _cache.PushOperator( t ); - _cache.IncreaseDepth( ( int )ExpCompileStateCode.Common ); + _cache.PushOperator(t); + _cache.IncreaseDepth((int)ExpCompileStateCode.Common); return true; } - private bool TryAppendPrefixSeparatorEnd( Token t ) + private bool TryAppendPrefixSeparatorEnd(Token t) { - if( t.Flag != TokenFlag.Separator_Right ) { + if (t.Flag != TokenFlag.Separator_Right) { return false; } - ClosePrefixReverse( t ); + ClosePrefixReverse(t); return true; } - private bool TryAppendSymbol( Token t ) + private bool TryAppendSymbol(Token t) { - if( ( t.Flag & ( TokenFlag.Symbol_Unary | TokenFlag.Symbol_Binary ) ) == 0 ) { + if ((t.Flag & (TokenFlag.Symbol_Unary | TokenFlag.Symbol_Binary)) == 0) { return false; } int cmp = -1; processPrecedence: - if( _cache.TryPeekOperator( out Token tmp ) ) + if (_cache.TryPeekOperator(out Token tmp)) { - cmp = CompareOperatorPrecedence( t, tmp ); - if( cmp >= 0 ) + cmp = CompareOperatorPrecedence(t, tmp); + if (cmp >= 0) { _cache.PopOperator(); - ExpSyntaxNode node = ConvertAndPushOneOperator( tmp ); + ExpSyntaxNode node = ConvertAndPushOneOperator(tmp); goto processPrecedence; } } - _cache.PushOperator( t ); + _cache.PushOperator(t); return true; } - private bool TryParseConstant( Token t ) + private bool TryParseConstant(Token t) { - switch( t.Value ) + switch (t.Value) { case "$": - _cache.PushOperand( StepEntityInstanceNode.RegisterNull( t ) ); + _cache.PushOperand(StepEntityInstanceNode.RegisterNull(t)); return true; case "*": - _cache.PushOperand( StepEntityInstanceNode.RegisterRuntimeInference( t ) ); + _cache.PushOperand(StepEntityInstanceNode.RegisterRuntimeInference(t)); return true; case ExpKeyword.E: - _cache.PushOperand( new ExpRealNumberNode( t, MathF.E, true ) ); + _cache.PushOperand(new ExpRealNumberNode(t, MathF.E, true)); return true; case ExpKeyword.Pi: - _cache.PushOperand( new ExpRealNumberNode( t, MathF.PI, true ) ); + _cache.PushOperand(new ExpRealNumberNode(t, MathF.PI, true)); return true; default: - if( ExpElementInstance.TryCreateLiteral( t, out ExpElementInstance? node ) ) + if (ExpElementInstance.TryCreateLiteral(t, out ExpElementInstance? node)) { - _cache.PushOperand( node ); + _cache.PushOperand(node); return true; } return false; } } - private bool TryParseElementName( Token t ) + private bool TryParseElementName(Token t) { - if( _context.TryGetType( t.Value, out ExpTypeSource? type ) ) + if (_context.TryGetType(t.Value, out ExpTypeSource? type)) { - _cache.PushOperand( ExpMetaRefNode.RefType( t, type ) ); + _cache.PushOperand(ExpMetaRefNode.RefType(t, type)); return true; } - if( _context.TryGetEntity( t.Value, out ExpEntitySource? entity ) ) + if (_context.TryGetEntity(t.Value, out ExpEntitySource? entity)) { - _cache.PushOperand( ExpMetaRefNode.RefEntity( t, entity ) ); + _cache.PushOperand(ExpMetaRefNode.RefEntity(t, entity)); return true; } return false; } - private bool TryParseFunction( Token t ) + private bool TryParseFunction(Token t) { - if( _entityTypeCheckPattern.IsMatch( t.Value ) ) + if (_entityTypeCheckPattern.IsMatch(t.Value)) { - if( _cache.PeekOperator().Flag == TokenFlag.Member ) + if (_cache.PeekOperator().Flag == TokenFlag.Member) { Token op = _cache.PopOperator(); - ConvertAndPushOneOperator( op ); + ConvertAndPushOneOperator(op); } - _cache.PushOperator( t ); + _cache.PushOperator(t); return true; } return false; } - private bool TryParseInstance( Token t ) + private bool TryParseInstance(Token t) { - if( t.Value[ 0 ] == '#' ) + if (t.Value[0] == '#') { - StepEntityInstanceNode node = StepEntityInstanceNode.Register( t ); - if( t.Column != 0 ) { - _dependencyDetector.AddDependency( node ); + StepEntityInstanceNode node = StepEntityInstanceNode.Register(t); + if (t.Column != 0) { + _dependencyDetector.AddDependency(node); } - _cache.PushOperand( node ); + _cache.PushOperand(node); return true; } return false; } - private bool TryParseKeyword( Token t ) + private bool TryParseKeyword(Token t) { - switch( t.Value ) + switch (t.Value) { case ExpKeyword.Return: - _cache.PushOperator( t ); + _cache.PushOperator(t); return true; case ExpKeyword.Skip: - _cache.PushOperand( ExpProcedureControlNode.Skip( t ) ); + _cache.PushOperand(ExpProcedureControlNode.Skip(t)); return true; default: return false; diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Enum.cs b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Enum.cs index 3fb51c66..8c92e571 100644 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Enum.cs +++ b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Enum.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.Enum.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.Enum" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script; using StgSharp.Script.Express; @@ -42,26 +39,26 @@ namespace StgSharp.Model.Step internal partial class StepExpSyntaxAnalyzer { - private static string ParseStepEnumLiteral( string source ) + private static string ParseStepEnumLiteral(string source) { int length = source.Length; ReadOnlySpan span = source.AsSpan(); - if( length > 2 && span[ 0 ] == '.' && span[ length - 1 ] == '.' ) { - return span.Slice( 1, length - 2 ).ToString(); + if (length > 2 && span[0] == '.' && span[length - 1] == '.') { + return span.Slice(1, length - 2).ToString(); } - throw new ExpInvalidSyntaxException( $"\"{source}\" is not a valid enum syntax" ); + throw new ExpInvalidSyntaxException($"\"{source}\" is not a valid enum syntax"); } - private void TryAppendEnum( Token e ) + private void TryAppendEnum(Token e) { ExpSyntaxNode node = e.Value switch { - ".T." => new ExpBoolNode( e, true, true ), - ".F." => new ExpBoolNode( e, false, true ), - ".U." => new ExpLogicValueNode( e, ExpLogic.Unknown, true ), - _ => ExpEnumLiteralNode.Create( e, ParseStepEnumLiteral ), + ".T." => new ExpBoolNode(e, true, true), + ".F." => new ExpBoolNode(e, false, true), + ".U." => new ExpLogicValueNode(e, ExpLogic.Unknown, true), + _ => ExpEnumLiteralNode.Create(e, ParseStepEnumLiteral), }; - _cache.PushOperand( node ); + _cache.PushOperand(node); } } diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.ErrorProcess.cs b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.ErrorProcess.cs index ef9ab524..0c1e4db0 100644 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.ErrorProcess.cs +++ b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.ErrorProcess.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.ErrorProcess.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.ErrorProcess" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -39,9 +36,9 @@ namespace StgSharp.Model.Step internal partial class StepExpSyntaxAnalyzer { - public void ThrowCompileException( int errorCode ) + public void ThrowCompileException(int errorCode) { - switch( errorCode ) + switch (errorCode) { case 0 or 1: return; diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.OperatorParser.cs b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.OperatorParser.cs index 6396e3ec..0df97bc9 100644 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.OperatorParser.cs +++ b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.OperatorParser.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.OperatorParser.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.OperatorParser" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script; using StgSharp.Script.Express; @@ -44,26 +41,26 @@ namespace StgSharp.Model.Step internal partial class StepExpSyntaxAnalyzer { - public int CompareOperatorPrecedence( Token left, Token right ) + public int CompareOperatorPrecedence(Token left, Token right) { - ExpressCompile.TryGetOperatorPrecedence( left.Value, out int leftPrecedence ); - ExpressCompile.TryGetOperatorPrecedence( right.Value, out int rightPrecedence ); + ExpressCompile.TryGetOperatorPrecedence(left.Value, out int leftPrecedence); + ExpressCompile.TryGetOperatorPrecedence(right.Value, out int rightPrecedence); return leftPrecedence - rightPrecedence; } - public bool TryGenerateUnaryNode( Token t, out ExpSyntaxNode node ) + public bool TryGenerateUnaryNode(Token t, out ExpSyntaxNode node) { ExpSyntaxNode operand = GetNextOperandCache(); - switch( t.Value ) + switch (t.Value) { case ExpKeyword.UnaryPlus: - node = ExpUnaryOperatorNode.UnaryPlus( t, operand ); + node = ExpUnaryOperatorNode.UnaryPlus(t, operand); return true; case ExpKeyword.UnaryMinus: - node = ExpUnaryOperatorNode.UnaryMinus( t, operand ); + node = ExpUnaryOperatorNode.UnaryMinus(t, operand); return true; case ExpKeyword.Not: - node = ExpUnaryOperatorNode.UnaryNot( t, operand ); + node = ExpUnaryOperatorNode.UnaryNot(t, operand); return true; default: node = ExpSyntaxNode.Empty; @@ -75,43 +72,43 @@ namespace StgSharp.Model.Step /// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING /// SYMBOLS. /// - private ExpSyntaxNode ConvertAndPushOneOperator( Token op ) + private ExpSyntaxNode ConvertAndPushOneOperator(Token op) { - switch( op.Flag ) + switch (op.Flag) { case TokenFlag.Symbol_Unary: - TryGenerateUnaryNode( op, out ExpSyntaxNode? node ); - _cache.PushOperand( node ); + TryGenerateUnaryNode(op, out ExpSyntaxNode? node); + _cache.PushOperand(node); return node; case TokenFlag.Symbol_Binary: - TryGenerateBinaryNode( op, out node ); - _cache.PushOperand( node ); + TryGenerateBinaryNode(op, out node); + _cache.PushOperand(node); return node; case TokenFlag.Member: - _cache.PopOperand( out _, out ExpSyntaxNode? p ); - StepEntityInitCaller caller = StepEntityInitCaller.CreateCaller( op.Value ); - node = ExpFunctionCallingNode.CallFunction( op, caller, p ); - _cache.StatementsInDepth.Push( node ); + _cache.PopOperand(out _, out ExpSyntaxNode? p); + StepEntityInitCaller caller = StepEntityInitCaller.CreateCaller(op.Value); + node = ExpFunctionCallingNode.CallFunction(op, caller, p); + _cache.StatementsInDepth.Push(node); return node; default: throw new NotImplementedException(); } } - private bool TryGenerateBinaryNode( Token t, out ExpSyntaxNode node ) + private bool TryGenerateBinaryNode(Token t, out ExpSyntaxNode node) { /* ExpSyntaxNode right = GetNextOperandCache(); ExpSyntaxNode left = GetNextOperandCache(); /**/ - switch( t.Value ) + switch (t.Value) { case "=": ExpSyntaxNode right = GetNextOperandCache(); ExpSyntaxNode left; - if( right is ExpTupleNode tuple ) + if (right is ExpTupleNode tuple) { - right = StepComplexEntityNode.FromTuple( tuple ); + right = StepComplexEntityNode.FromTuple(tuple); left = GetNextOperandCache(); } else { @@ -119,7 +116,7 @@ namespace StgSharp.Model.Step right = _cache.StatementsInDepth.Pop(); } - node = ExpBinaryOperatorNode.Assign( t, left, right ); + node = ExpBinaryOperatorNode.Assign(t, left, right); return true; default: node = ExpSyntaxNode.Empty; diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs index 0f63e985..987732a7 100644 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs +++ b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.PrefixReverseAnalysing" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script; using StgSharp.Script.Express; @@ -45,44 +42,44 @@ namespace StgSharp.Model.Step internal partial class StepExpSyntaxAnalyzer { - private void ClosePrefixReverse( Token rightSeparator ) + private void ClosePrefixReverse(Token rightSeparator) { Token op; ExpSyntaxNode root; - if( _cache.OperatorAheadOfDepth == 0 ) + if (_cache.OperatorAheadOfDepth == 0) { - if( _cache.OperandAheadOfDepth == 1 ) + if (_cache.OperandAheadOfDepth == 1) { - _cache.PopOperand( out _, out ExpSyntaxNode? statement ); - _cache.StatementsInDepth.Push( statement ); + _cache.PopOperand(out _, out ExpSyntaxNode? statement); + _cache.StatementsInDepth.Push(statement); } else { - _cache.StatementsInDepth.Push( ExpSyntaxNode.Empty ); + _cache.StatementsInDepth.Push(ExpSyntaxNode.Empty); } } else { - while( _cache.TryPopOperator( out op ) ) + while (_cache.TryPopOperator(out op)) { - ExpSyntaxNode node = ConvertAndPushOneOperator( op ); + ExpSyntaxNode node = ConvertAndPushOneOperator(op); } - if( _cache.OperandAheadOfDepth == 1 ) + if (_cache.OperandAheadOfDepth == 1) { - _cache.PopOperand( out _, out root ); - _cache.StatementsInDepth.Push( root ); + _cache.PopOperand(out _, out root); + _cache.StatementsInDepth.Push(root); } } root = _cache.PackAllStatements(); _cache.DecreaseDepth(); - if( IsSeparatorMatch( _cache.PeekOperator(), rightSeparator ) ) + if (IsSeparatorMatch(_cache.PeekOperator(), rightSeparator)) { _cache.PopOperator(); - root = ExpTupleNode.Pack( root ); - _cache.PushOperand( root ); + root = ExpTupleNode.Pack(root); + _cache.PushOperand(root); } else { throw new ExpCompileException( - rightSeparator, "Ending of block does not match its begging" ); + rightSeparator, "Ending of block does not match its begging"); } } diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.cs b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.cs index 2c378512..9fd9b3f4 100644 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.cs +++ b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp.Syntax; using StgSharp.Script; @@ -71,37 +68,37 @@ namespace StgSharp.Model.Step /// Append a token to top of cache. This method will automatically convert token to node /// if meets separators or operators. /// - public void AppendToken( Token expToken ) + public void AppendToken(Token expToken) { - switch( expToken.Flag ) + switch (expToken.Flag) { case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary: - TryAppendSymbol( expToken ); + TryAppendSymbol(expToken); break; case TokenFlag.Number or TokenFlag.String: - ExpElementInstance node = ExpElementInstance.CreateLiteral( expToken ); - _cache.PushOperand( node ); + ExpElementInstance node = ExpElementInstance.CreateLiteral(expToken); + _cache.PushOperand(node); break; case TokenFlag.Separator_Left: - TryAppendPrefixSeparator( expToken ); + TryAppendPrefixSeparator(expToken); break; case TokenFlag.Separator_Right: - TryAppendPrefixSeparatorEnd( expToken ); + TryAppendPrefixSeparatorEnd(expToken); break; case TokenFlag.Separator_Middle: - TryAppendMiddleSeparator( expToken ); + TryAppendMiddleSeparator(expToken); break; case TokenFlag.Index_Left: - TryAppendIndexLeft( expToken ); + TryAppendIndexLeft(expToken); break; case TokenFlag.Index_Right: - TryAppendIndexRight( expToken ); + TryAppendIndexRight(expToken); break; case TokenFlag.Member: - TryAppendMember( expToken ); + TryAppendMember(expToken); break; case TokenFlag.Enum: - TryAppendEnum( expToken ); + TryAppendEnum(expToken); break; default: break; @@ -110,7 +107,7 @@ namespace StgSharp.Model.Step public ExpSyntaxNode GetNextOperandCache() { - if( _cache.PopOperand( out Token t, out ExpSyntaxNode? n ) ) + if (_cache.PopOperand(out Token t, out ExpSyntaxNode? n)) { return n; } else diff --git a/StgSharp.Model/Step/Analyser/StepDataSectionsTranmitter.cs b/StgSharp.Model/Step/Analyser/StepDataSectionsTranmitter.cs index 1d417707..23545040 100644 --- a/StgSharp.Model/Step/Analyser/StepDataSectionsTranmitter.cs +++ b/StgSharp.Model/Step/Analyser/StepDataSectionsTranmitter.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepDataSectionsTranmitter.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepDataSectionsTranmitter" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script; using System; @@ -45,13 +42,13 @@ namespace StgSharp.Model.Step private const string EndDataText = "ENDSEC;"; - //private bool _isEmpty; + // private bool _isEmpty; private ConcurrentQueue _cache = new ConcurrentQueue(); private int _line = 0; public StepDataSectionTransmitter() { } - public StepDataSectionTransmitter( int begins ) + public StepDataSectionTransmitter(int begins) { Begin = begins; _line = Begin; @@ -72,7 +69,7 @@ namespace StgSharp.Model.Step public string ReadLine() { - if( _cache.TryDequeue( out string? line ) ) + if (_cache.TryDequeue(out string? line)) { _line++; return line; @@ -80,29 +77,29 @@ namespace StgSharp.Model.Step return string.Empty; } - public string ReadLine( out int position ) + public string ReadLine(out int position) { string ret = ReadLine(); position = _line; return ret; } - public void WriteLine( string line ) + public void WriteLine(string line) { - if( line == "DATA;" ) { + if (line == "DATA;") { return; } - if( line == EndDataText ) + if (line == EndDataText) { EndWriting(); return; } - if( IsWriting ) { - _cache.Enqueue( line ); + if (IsWriting) { + _cache.Enqueue(line); } } - IScriptSourceProvider IScriptSourceProvider.Slice( int location, int count ) + IScriptSourceProvider IScriptSourceProvider.Slice(int location, int count) { throw new NotSupportedException(); } diff --git a/StgSharp.Model/Step/Analyser/StepDataTokenReader.cs b/StgSharp.Model/Step/Analyser/StepDataTokenReader.cs index 1b9074ad..d0354f60 100644 --- a/StgSharp.Model/Step/Analyser/StepDataTokenReader.cs +++ b/StgSharp.Model/Step/Analyser/StepDataTokenReader.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepDataTokenReader.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepDataTokenReader" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -48,15 +45,13 @@ namespace StgSharp.Model.Step private ExpTokenReader _reader; - private HashSet tokenHash = [ - "T","F","UNSPECIFIED" - ]; + private HashSet tokenHash = [ "T", "F", "UNSPECIFIED" ]; private Queue _cache = new Queue(); private StepDataSectionTransmitter _transmitter; - public StepDataTokenReader( StepDataSectionTransmitter transmitter ) + public StepDataTokenReader(StepDataSectionTransmitter transmitter) { - _reader = new ExpTokenReader( transmitter ); + _reader = new ExpTokenReader(transmitter); _reader.TokenReaderPreProcessor = new TokenPreReader(); _transmitter = transmitter; } @@ -65,7 +60,7 @@ namespace StgSharp.Model.Step { get { - if( _reader.IsEmpty ) { + if (_reader.IsEmpty) { return !_transmitter.IsWriting; } return false; @@ -77,9 +72,9 @@ namespace StgSharp.Model.Step return _reader.ReadToken(); } - public bool TryReadToken( out Token t ) + public bool TryReadToken(out Token t) { - return _reader.TryReadToken( out t ); + return _reader.TryReadToken(out t); } private partial class TokenPreReader : ExpTokenReaderPreProcessor @@ -90,61 +85,61 @@ namespace StgSharp.Model.Step _nextEnumPattern = GetNextEnumPattern(), _stringPattern = GetStringPattern(); - public override bool Process( string codeLine, int line, ref int current, out Token t ) + public override bool Process(string codeLine, int line, ref int current, out Token t) { - ReadOnlySpan chars = codeLine.AsSpan( current ); - char c = chars[ 0 ]; + ReadOnlySpan chars = codeLine.AsSpan(current); + char c = chars[0]; Match match; - switch( c ) + switch (c) { case '#': - match = _nextHashtagSymbolPattern.Match( codeLine, current ); - if( match.Success ) + match = _nextHashtagSymbolPattern.Match(codeLine, current); + if (match.Success) { - int begin = match.Groups[ "token" ].Index; - int end = match.Groups[ "end" ].Index; - int rest = match.Groups[ "rest" ].Index; + int begin = match.Groups["token"].Index; + int end = match.Groups["end"].Index; + int rest = match.Groups["rest"].Index; current = rest; t = new( - ExpressCompile.PoolString( chars[ 0..( end - begin ) ] ), line, - begin, TokenFlag.Member ); + ExpressCompile.PoolString(chars[0..(end - begin)]), line, + begin, TokenFlag.Member); return true; } break; case '.': - match = _nextEnumPattern.Match( codeLine, current ); - if( match.Success ) + match = _nextEnumPattern.Match(codeLine, current); + if (match.Success) { - int begin = match.Groups[ "token" ].Index; - int end = match.Groups[ "end" ].Index; - int rest = match.Groups[ "rest" ].Index; + int begin = match.Groups["token"].Index; + int end = match.Groups["end"].Index; + int rest = match.Groups["rest"].Index; current = rest; t = new Token( - match.Groups[ "token" ].Value, line, begin, TokenFlag.Enum ); + match.Groups["token"].Value, line, begin, TokenFlag.Enum); return true; } break; case '$': - t = new Token( "$", line, current, TokenFlag.Member ); + t = new Token("$", line, current, TokenFlag.Member); current++; return true; case '*': - t = new Token( "*", line, current, TokenFlag.Member ); + t = new Token("*", line, current, TokenFlag.Member); current++; return true; case '\'': - match = _stringPattern.Match( codeLine, current ); - if( match.Success ) + match = _stringPattern.Match(codeLine, current); + if (match.Success) { - int begin = match.Groups[ "token" ].Index; - int end = match.Groups[ "end" ].Index; - int rest = match.Groups[ "rest" ].Index; + int begin = match.Groups["token"].Index; + int end = match.Groups["end"].Index; + int rest = match.Groups["rest"].Index; current = rest; - string value = chars.Slice( 1, ( end - begin - 1 ) ).ToString(); - if( string.IsNullOrWhiteSpace( value ) ) { + string value = chars.Slice(1, (end - begin - 1)).ToString(); + if (string.IsNullOrWhiteSpace(value)) { value = string.Empty; } - t = new Token( value, line, begin, TokenFlag.String ); + t = new Token(value, line, begin, TokenFlag.String); return true; } break; @@ -155,19 +150,13 @@ namespace StgSharp.Model.Step return false; } - [GeneratedRegex( - @"(?#[0-9A-Za-z]+)(?\s*?)(?\S|$)", - RegexOptions.Singleline )] + [GeneratedRegex(@"(?#[0-9A-Za-z]+)(?\s*?)(?\S|$)", RegexOptions.Singleline)] private static partial Regex GetEntityTagSymbolPattern(); - [GeneratedRegex( - @"(?\.[A-Za-z_]+\.)(?\s*)(?\S*)", - RegexOptions.Singleline )] + [GeneratedRegex(@"(?\.[A-Za-z_]+\.)(?\s*)(?\S*)", RegexOptions.Singleline)] private static partial Regex GetNextEnumPattern(); - [GeneratedRegex( - @"(?')(?>\\\\|''|(?!')[^'])*(?')\s*?(?\S|$)", - RegexOptions.Singleline )] + [GeneratedRegex(@"(?')(?>\\\\|''|(?!')[^'])*(?')\s*?(?\S|$)", RegexOptions.Singleline)] private static partial Regex GetStringPattern(); } diff --git a/StgSharp.Model/Step/Analyser/StepDependencyDetector.cs b/StgSharp.Model/Step/Analyser/StepDependencyDetector.cs index ea072bb6..eb84b180 100644 --- a/StgSharp.Model/Step/Analyser/StepDependencyDetector.cs +++ b/StgSharp.Model/Step/Analyser/StepDependencyDetector.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepDependencyDetector.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepDependencyDetector" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using System; @@ -45,9 +42,9 @@ namespace StgSharp.Model.Step public List Dependencies { get; private set; } = new(); - public void AddDependency( StepEntityInstanceNode node ) + public void AddDependency(StepEntityInstanceNode node) { - Dependencies.Add( node.Id ); + Dependencies.Add(node.Id); } public IEnumerable ExportAllDependencies() diff --git a/StgSharp.Model/Step/Analyser/StepEntityDefineSequence.cs b/StgSharp.Model/Step/Analyser/StepEntityDefineSequence.cs index 840ed15b..c91844f0 100644 --- a/StgSharp.Model/Step/Analyser/StepEntityDefineSequence.cs +++ b/StgSharp.Model/Step/Analyser/StepEntityDefineSequence.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepEntityDefineSequence.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepEntityDefineSequence" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script.Express; using System; @@ -41,7 +38,8 @@ namespace StgSharp.Model.Step { public record class StepEntityDefineSequence { - public StepEntityDefineSequence( ExpSyntaxNode node, IEnumerable dep ) + + public StepEntityDefineSequence(ExpSyntaxNode node, IEnumerable dep) { Expression = node; Dependencies = dep; @@ -50,5 +48,6 @@ namespace StgSharp.Model.Step public ExpSyntaxNode Expression { get; init; } public IEnumerable Dependencies { get; init; } + } } diff --git a/StgSharp.Model/Step/ExpressStepUtil.cs b/StgSharp.Model/Step/ExpressStepUtil.cs index 3bd04d15..fee9a666 100644 --- a/StgSharp.Model/Step/ExpressStepUtil.cs +++ b/StgSharp.Model/Step/ExpressStepUtil.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpressStepUtil.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpressStepUtil" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using CommunityToolkit.HighPerformance.Buffers; using StgSharp.Model.Step; @@ -65,27 +62,7 @@ namespace StgSharp.Model.Step public const string VertexPointText = "VERTEX_POINT"; private static - HashSet names = [ - AdvancedFaceText, - Axis2Placement2DText, - Axis2Placement3DText, - BSplineCurveWithKnotsText, - CartesianPointText, - CircleText, - CylindricalSurfaceText, - DirectionText, - EdgeCurveText, - EdgeLoopText, - EllipseText, - FaceBoundText, - FaceOuterBoundText, - LineText, - OrientedEdgeText, - PlaneText, - RepresentationItemText, - VectorText, - VertexPointText, - ]; + HashSet names = [ AdvancedFaceText, Axis2Placement2DText, Axis2Placement3DText, BSplineCurveWithKnotsText, CartesianPointText, CircleText, CylindricalSurfaceText, DirectionText, EdgeCurveText, EdgeLoopText, EllipseText, FaceBoundText, FaceOuterBoundText, LineText, OrientedEdgeText, PlaneText, RepresentationItemText, VectorText, VertexPointText, ]; private FrozenDictionary entitiesDefine; private StringPool _entityNamePool = new StringPool(); @@ -93,56 +70,56 @@ namespace StgSharp.Model.Step public ExpressStepUtil() { IEnumerable> defineSource = []; - entitiesDefine = new Dictionary( defineSource ) + entitiesDefine = new Dictionary(defineSource) .ToFrozenDictionary(); - foreach( string item in names ) { - _entityNamePool.Add( item ); + foreach (string item in names) { + _entityNamePool.Add(item); } } internal StepModel Current { get; set; } - public override void LoadFromSource( ExpSchemaSource source ) + public override void LoadFromSource(ExpSchemaSource source) { return; } - public override bool TryGetConst( string name, out ExpElementInstance c ) + public override bool TryGetConst(string name, out ExpElementInstance c) { c = null!; return false; } - public override bool TryGetEntity( string name, out ExpEntitySource e ) + public override bool TryGetEntity(string name, out ExpEntitySource e) { - return entitiesDefine.TryGetValue( name, out e! ); + return entitiesDefine.TryGetValue(name, out e!); } - public override bool TryGetFunction( string name, out ExpFunctionSource f ) + public override bool TryGetFunction(string name, out ExpFunctionSource f) { f = null!; return false; } - public override bool TryGetProcedure( string name, out ExpProcedureSource p ) + public override bool TryGetProcedure(string name, out ExpProcedureSource p) { p = null!; return false; } - public override bool TryGetRule( string name, out ExpRuleSource r ) + public override bool TryGetRule(string name, out ExpRuleSource r) { r = null!; return false; } - public override bool TryGetSchemaInclude( string name, out ExpSchema include ) + public override bool TryGetSchemaInclude(string name, out ExpSchema include) { include = null!; return false; } - public override bool TryGetType( string name, out ExpTypeSource t ) + public override bool TryGetType(string name, out ExpTypeSource t) { t = null!; return false; diff --git a/StgSharp.Model/Step/Items/StepAdvancedFace.cs b/StgSharp.Model/Step/Items/StepAdvancedFace.cs index ae55d32d..92e02e95 100644 --- a/StgSharp.Model/Step/Items/StepAdvancedFace.cs +++ b/StgSharp.Model/Step/Items/StepAdvancedFace.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepAdvancedFace.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepAdvancedFace" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; @@ -40,34 +37,34 @@ namespace StgSharp.Model.Step public class StepAdvancedFace : StepFaceSurface, IExpConvertableFrom { - public StepAdvancedFace( StepModel model ) : base( model ) { } + public StepAdvancedFace(StepModel model) : base(model) { } public override StepItemType ItemType => StepItemType.AdvancedFace; - public void FromInstance( StepAdvancedFace entity ) + public void FromInstance(StepAdvancedFace entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - internal static StepAdvancedFace FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepAdvancedFace FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - StepAdvancedFace face = new StepAdvancedFace( binder ); - enumerator.AssertEnumeratorCount( 4 ); - face.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + StepAdvancedFace face = new StepAdvancedFace(binder); + enumerator.AssertEnumeratorCount(4); + face.Name = (enumerator[0]as ExpStringNode)!.Value; - ExpNodePresidentEnumerator boundsList = enumerator[ 1 ].TupleToPresidentEnumerator(); + ExpNodePresidentEnumerator boundsList = enumerator[1].TupleToPresidentEnumerator(); face.Bounds.Clear(); face.Bounds .AddRange( - Enumerable.Range( 0, enumerator.Count ).Select( _ => ( StepFaceBound )null ) ); - for( int i = 0; i < boundsList.Count; i++ ) + Enumerable.Range(0, enumerator.Count).Select(_ => (StepFaceBound)null)); + for (int i = 0; i < boundsList.Count; i++) { int j = i; // capture to avoid rebinding - face.Bounds[ j ] = binder[ boundsList[ j ] ] as StepFaceBound; + face.Bounds[j] = binder[boundsList[j]] as StepFaceBound; } - face.FaceGeometry = binder[ enumerator[ 2 ] ] as StepSurface; - face.SameSense = ( enumerator[ 3 ] as ExpBoolNode )!.Value; + face.FaceGeometry = binder[enumerator[2]] as StepSurface; + face.SameSense = (enumerator[3] as ExpBoolNode)!.Value; return face; } diff --git a/StgSharp.Model/Step/Items/StepAxis2Placement.cs b/StgSharp.Model/Step/Items/StepAxis2Placement.cs index 05e77c92..58498df9 100644 --- a/StgSharp.Model/Step/Items/StepAxis2Placement.cs +++ b/StgSharp.Model/Step/Items/StepAxis2Placement.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepAxis2Placement.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepAxis2Placement" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; @@ -40,21 +37,21 @@ namespace StgSharp.Model.Step private StepDirection _refDirection; - protected StepAxis2Placement( StepModel model ) : base( model ) { } + protected StepAxis2Placement(StepModel model) : base(model) { } public StepDirection RefDirection { get { return _refDirection; } set { - ArgumentNullException.ThrowIfNull( value ); + ArgumentNullException.ThrowIfNull(value); _refDirection = value; } } - public override bool IsConvertableTo( string entityName ) + public override bool IsConvertableTo(string entityName) { - return base.IsConvertableTo( entityName ) || entityName == "StepAxis2Placement"; + return base.IsConvertableTo(entityName) || entityName == "StepAxis2Placement"; } } diff --git a/StgSharp.Model/Step/Items/StepAxis2Placement2D.cs b/StgSharp.Model/Step/Items/StepAxis2Placement2D.cs index 53e300d6..6e62472d 100644 --- a/StgSharp.Model/Step/Items/StepAxis2Placement2D.cs +++ b/StgSharp.Model/Step/Items/StepAxis2Placement2D.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepAxis2Placement2D.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepAxis2Placement2D" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; @@ -40,13 +37,10 @@ namespace StgSharp.Model.Step public class StepAxis2Placement2D : StepAxis2Placement, IExpConvertableFrom { - private StepAxis2Placement2D( StepModel model ) : base( model ) { } + private StepAxis2Placement2D(StepModel model) : base(model) { } - public StepAxis2Placement2D( - StepModel model, - StepCartesianPoint location, - StepDirection direction ) - : base( model ) + public StepAxis2Placement2D(StepModel model, StepCartesianPoint location, StepDirection direction) + : base(model) { Location = location; RefDirection = direction; @@ -54,23 +48,21 @@ namespace StgSharp.Model.Step public override StepItemType ItemType => StepItemType.AxisPlacement2D; - public void FromInstance( StepAxis2Placement2D entity ) + public void FromInstance(StepAxis2Placement2D entity) { - base.FromInstance( entity ); + base.FromInstance(entity); Location = entity.Location; RefDirection = entity.RefDirection; } - internal static StepAxis2Placement2D FromSyntax( - StepModel binder, - ExpSyntaxNode syntaxList ) + internal static StepAxis2Placement2D FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - StepAxis2Placement2D axis = new StepAxis2Placement2D( binder ); - enumerator.AssertEnumeratorCount( 3 ); - axis.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - axis.Location = binder[ enumerator[ 1 ] ] as StepCartesianPoint; - axis.RefDirection = binder[ enumerator[ 2 ] ] as StepDirection; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + StepAxis2Placement2D axis = new StepAxis2Placement2D(binder); + enumerator.AssertEnumeratorCount(3); + axis.Name = (enumerator[0]as ExpStringNode)!.Value; + axis.Location = binder[enumerator[1]] as StepCartesianPoint; + axis.RefDirection = binder[enumerator[2]] as StepDirection; return axis; } diff --git a/StgSharp.Model/Step/Items/StepAxis2Placement3D.cs b/StgSharp.Model/Step/Items/StepAxis2Placement3D.cs index 395f2d37..00b419f4 100644 --- a/StgSharp.Model/Step/Items/StepAxis2Placement3D.cs +++ b/StgSharp.Model/Step/Items/StepAxis2Placement3D.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepAxis2Placement3D.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepAxis2Placement3D" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -42,14 +39,14 @@ namespace StgSharp.Model.Step private StepDirection _axis; - private StepAxis2Placement3D( StepModel model ) : base( model ) { } + private StepAxis2Placement3D(StepModel model) : base(model) { } public StepAxis2Placement3D( StepModel model, StepCartesianPoint location, StepDirection axis, - StepDirection refDirection ) - : base( model ) + StepDirection refDirection) + : base(model) { Location = location; Axis = axis; @@ -61,33 +58,31 @@ namespace StgSharp.Model.Step get { return _axis; } set { - ArgumentNullException.ThrowIfNull( value ); + ArgumentNullException.ThrowIfNull(value); _axis = value; } } public override StepItemType ItemType => StepItemType.AxisPlacement3D; - public override bool IsConvertableTo( string entityTypeName ) + public override bool IsConvertableTo(string entityTypeName) { throw new NotImplementedException(); } - internal static StepAxis2Placement3D FromSyntax( - StepModel binder, - ExpSyntaxNode syntaxList ) + internal static StepAxis2Placement3D FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - StepAxis2Placement3D axis = new StepAxis2Placement3D( binder ); - enumerator.AssertEnumeratorCount( 4 ); - axis.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - axis.Location = binder[ enumerator[ 1 ] ] as StepCartesianPoint; - axis.Axis = binder[ enumerator[ 2 ] ] as StepDirection; - axis.RefDirection = binder[ enumerator[ 3 ] ] as StepDirection; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + StepAxis2Placement3D axis = new StepAxis2Placement3D(binder); + enumerator.AssertEnumeratorCount(4); + axis.Name = (enumerator[0]as ExpStringNode)!.Value; + axis.Location = binder[enumerator[1]] as StepCartesianPoint; + axis.Axis = binder[enumerator[2]] as StepDirection; + axis.RefDirection = binder[enumerator[3]] as StepDirection; return axis; } - void IExpConvertableFrom.FromInstance( StepAxis2Placement3D entity ) + void IExpConvertableFrom.FromInstance(StepAxis2Placement3D entity) { throw new NotImplementedException(); } diff --git a/StgSharp.Model/Step/Items/StepBSplineCurve.cs b/StgSharp.Model/Step/Items/StepBSplineCurve.cs index 086295b8..8339f555 100644 --- a/StgSharp.Model/Step/Items/StepBSplineCurve.cs +++ b/StgSharp.Model/Step/Items/StepBSplineCurve.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepBSplineCurve.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepBSplineCurve" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -61,27 +58,20 @@ namespace StgSharp.Model.Step internal const string POLYLINE_FORM = "POLYLINE_FORM"; internal const string UNSPECIFIED = "UNSPECIFIED"; - internal static HashSet AllPossibleValue { get; } = [ - CIRCULAR_ARC, - ELLIPTIC_ARC, - HYPERBOLIC_ARC, - PARABOLIC_ARC, - POLYLINE_FORM, - UNSPECIFIED, - ]; + internal static HashSet AllPossibleValue { get; } = [ CIRCULAR_ARC, ELLIPTIC_ARC, HYPERBOLIC_ARC, PARABOLIC_ARC, POLYLINE_FORM, UNSPECIFIED, ]; } public class StepBSplineCurve : StepBoundedCurve, IExpConvertableFrom { - public StepBSplineCurve( StepModel model, params StepCartesianPoint[] controlPoints ) - : this( model, ( IEnumerable )controlPoints ) { } + public StepBSplineCurve(StepModel model, params StepCartesianPoint[] controlPoints) + : this(model, (IEnumerable)controlPoints) { } - public StepBSplineCurve( StepModel model, IEnumerable controlPoints ) - : base( model ) + public StepBSplineCurve(StepModel model, IEnumerable controlPoints) + : base(model) { - ControlPointsList.AddRange( controlPoints ); + ControlPointsList.AddRange(controlPoints); } public bool ClosedCurve { get; set; } @@ -95,21 +85,21 @@ namespace StgSharp.Model.Step public StepBSplineCurveForm CurveForm { get; set; } = StepBSplineCurveForm.Unspecified; - public void FromInstance( StepBSplineCurve entity ) + public void FromInstance(StepBSplineCurve entity) { - base.FromInstance( entity ); + base.FromInstance(entity); this.Degree = entity.Degree; this.ClosedCurve = entity.ClosedCurve; this.ControlPointsList = entity.ControlPointsList; this.SelfIntersect = entity.SelfIntersect; } - public override bool IsConvertableTo( string entityName ) + public override bool IsConvertableTo(string entityName) { - return base.IsConvertableTo( entityName ) || entityName == "StepBSplineCurve"; + return base.IsConvertableTo(entityName) || entityName == "StepBSplineCurve"; } - protected static string GetCurveFormString( StepBSplineCurveForm form ) + protected static string GetCurveFormString(StepBSplineCurveForm form) { return form switch { @@ -123,7 +113,7 @@ namespace StgSharp.Model.Step }; } - protected static StepBSplineCurveForm ParseCurveForm( string enumerationValue ) + protected static StepBSplineCurveForm ParseCurveForm(string enumerationValue) { return enumerationValue.ToUpperInvariant() switch { diff --git a/StgSharp.Model/Step/Items/StepBSplineCurveWithKnots.cs b/StgSharp.Model/Step/Items/StepBSplineCurveWithKnots.cs index 372d15f9..9a1067f0 100644 --- a/StgSharp.Model/Step/Items/StepBSplineCurveWithKnots.cs +++ b/StgSharp.Model/Step/Items/StepBSplineCurveWithKnots.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepBSplineCurveWithKnots.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepBSplineCurveWithKnots" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -60,15 +57,11 @@ namespace StgSharp.Model.Step private const string UNIFORM_KNOTS = "UNIFORM_KNOTS"; private const string UNSPECIFIED = "UNSPECIFIED"; - public StepBSplineCurveWithKnots( - StepModel model, - IEnumerable controlPoints ) - : base( model, controlPoints ) { } + public StepBSplineCurveWithKnots(StepModel model, IEnumerable controlPoints) + : base(model, controlPoints) { } - public StepBSplineCurveWithKnots( - StepModel model, - params StepCartesianPoint[] controlPoints ) - : base( model, controlPoints ) { } + public StepBSplineCurveWithKnots(StepModel model, params StepCartesianPoint[] controlPoints) + : base(model, controlPoints) { } public List KnotMultiplicities { get; } = new List(); @@ -78,59 +71,57 @@ namespace StgSharp.Model.Step public StepKnotType KnotSpec { get; set; } = StepKnotType.Unspecified; - public void FromInstance( StepBSplineCurveWithKnots entity ) + public void FromInstance(StepBSplineCurveWithKnots entity) { - base.FromInstance( entity ); + base.FromInstance(entity); KnotSpec = entity.KnotSpec; KnotMultiplicities.Clear(); - KnotMultiplicities.AddRange( entity.KnotMultiplicities ); + KnotMultiplicities.AddRange(entity.KnotMultiplicities); Knots.Clear(); - Knots.AddRange( entity.Knots ); + Knots.AddRange(entity.Knots); } - internal static StepBSplineCurveWithKnots FromSyntax( - StepModel binder, - ExpSyntaxNode syntaxList ) + internal static StepBSplineCurveWithKnots FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { ExpNodePresidentEnumerator enumerator = syntaxList .ToPresidentEnumerator(); - enumerator.AssertEnumeratorCount( 9 ); - ExpNodePresidentEnumerator controlPointsList = enumerator[ 2 ].TupleToPresidentEnumerator( + enumerator.AssertEnumeratorCount(9); + ExpNodePresidentEnumerator controlPointsList = enumerator[2].TupleToPresidentEnumerator( ); StepBSplineCurveWithKnots spline = new StepBSplineCurveWithKnots( - binder, new StepCartesianPoint[controlPointsList.Count] ); - spline.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - spline.Degree = ( enumerator[ 1 ] as ExpIntNode )!.Value; + binder, new StepCartesianPoint[controlPointsList.Count]); + spline.Name = (enumerator[0]as ExpStringNode)!.Value; + spline.Degree = (enumerator[1] as ExpIntNode)!.Value; - for( int i = 0; i < controlPointsList.Count; i++ ) + for (int i = 0; i < controlPointsList.Count; i++) { int j = i; // capture to avoid rebinding - spline.ControlPointsList[ j ] = binder[ controlPointsList[ j ] ]as StepCartesianPoint; + spline.ControlPointsList[j] = binder[controlPointsList[j]]as StepCartesianPoint; } - spline.CurveForm = ParseCurveForm( enumerator[ 3 ].CodeConvertTemplate ); - spline.ClosedCurve = ( enumerator[ 4 ] as ExpBoolNode )!.Value; - spline.SelfIntersect = ( enumerator[ 5 ]as ExpBoolNode )!.Value; + spline.CurveForm = ParseCurveForm(enumerator[3].CodeConvertTemplate); + spline.ClosedCurve = (enumerator[4] as ExpBoolNode)!.Value; + spline.SelfIntersect = (enumerator[5]as ExpBoolNode)!.Value; - ExpNodePresidentEnumerator knotMultiplicitiesList = enumerator[ 6 ].TupleToPresidentEnumerator( + ExpNodePresidentEnumerator knotMultiplicitiesList = enumerator[6].TupleToPresidentEnumerator( ); spline.KnotMultiplicities.Clear(); - for( int i = 0; i < knotMultiplicitiesList.Count; i++ ) { - spline.KnotMultiplicities.Add( ( knotMultiplicitiesList[ i ]as ExpIntNode )!.Value ); + for (int i = 0; i < knotMultiplicitiesList.Count; i++) { + spline.KnotMultiplicities.Add((knotMultiplicitiesList[i]as ExpIntNode)!.Value); } - ExpNodePresidentEnumerator knotsList = enumerator[ 7 ].TupleToPresidentEnumerator(); + ExpNodePresidentEnumerator knotsList = enumerator[7].TupleToPresidentEnumerator(); spline.Knots.Clear(); - for( int i = 0; i < knotsList.Count; i++ ) { - spline.Knots.Add( ( knotsList[ i ]as ExpRealNumberNode )!.Value ); + for (int i = 0; i < knotsList.Count; i++) { + spline.Knots.Add((knotsList[i]as ExpRealNumberNode)!.Value); } - spline.KnotSpec = ParseKnotSpec( enumerator[ 8 ].CodeConvertTemplate ); + spline.KnotSpec = ParseKnotSpec(enumerator[8].CodeConvertTemplate); return spline; } - private static string GetKnotSpec( StepKnotType spec ) + private static string GetKnotSpec(StepKnotType spec) { return spec switch { @@ -142,7 +133,7 @@ namespace StgSharp.Model.Step }; } - private static StepKnotType ParseKnotSpec( string enumerationValue ) + private static StepKnotType ParseKnotSpec(string enumerationValue) { return enumerationValue.ToUpperInvariant() switch { diff --git a/StgSharp.Model/Step/Items/StepBSplineSurface.cs b/StgSharp.Model/Step/Items/StepBSplineSurface.cs index 38a9092b..49ea259c 100644 --- a/StgSharp.Model/Step/Items/StepBSplineSurface.cs +++ b/StgSharp.Model/Step/Items/StepBSplineSurface.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepBSplineSurface.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepBSplineSurface" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using CommunityToolkit.HighPerformance; using StgSharp.Script.Express; @@ -74,7 +71,7 @@ namespace StgSharp.Model.Step public const string TOROIDAL_SURF_TEXT = "TOROIDAL_SURF"; public const string UNSPECIFIED_TEXT = "UNSPECIFIED"; - public StepBSplineSurface( StepModel model ) : base( model ) { } + public StepBSplineSurface(StepModel model) : base(model) { } public bool UClosed { get; set; } @@ -88,62 +85,62 @@ namespace StgSharp.Model.Step public int UUpper => ControlPointsList.Count - 1; - public int VUpper => ControlPointsList[ 0 ].Count - 1; + public int VUpper => ControlPointsList[0].Count - 1; public List> ControlPointsList { get; set; } = new List>(); public StepBSplineSurfaceForm SurfaceForm { get; set; } - public static StepBSplineSurface CreateFromSyntax( StepModel binder, ExpSyntaxNode syntax ) + public static StepBSplineSurface CreateFromSyntax(StepModel binder, ExpSyntaxNode syntax) { ExpNodePresidentEnumerator enumerator = syntax.ToPresidentEnumerator(); - enumerator.AssertEnumeratorCount( 7 ); - StepBSplineSurface ret = new StepBSplineSurface( binder ); + enumerator.AssertEnumeratorCount(7); + StepBSplineSurface ret = new StepBSplineSurface(binder); - ret.UDegree = ( enumerator[ 0 ] as ExpIntNode ).Value; - ret.VDegree = ( enumerator[ 1 ] as ExpIntNode ).Value; + ret.UDegree = (enumerator[0] as ExpIntNode).Value; + ret.VDegree = (enumerator[1] as ExpIntNode).Value; - ExpNodePresidentEnumerator pointList = enumerator[ 2 ].TupleToPresidentEnumerator(); - pointList.AssertEnumeratorCount( 2, int.MaxValue ); - for( int i = 0; i < pointList.Count; i++ ) + ExpNodePresidentEnumerator pointList = enumerator[2].TupleToPresidentEnumerator(); + pointList.AssertEnumeratorCount(2, int.MaxValue); + for (int i = 0; i < pointList.Count; i++) { - ExpNodePresidentEnumerator points = pointList[ i ].TupleToPresidentEnumerator(); - points.AssertEnumeratorCount( 2, int.MaxValue ); - List pList = new List( points.Count ); - CollectionsMarshal.SetCount( pList, points.Count ); - Span ls = CollectionsMarshal.AsSpan( pList ); + ExpNodePresidentEnumerator points = pointList[i].TupleToPresidentEnumerator(); + points.AssertEnumeratorCount(2, int.MaxValue); + List pList = new List(points.Count); + CollectionsMarshal.SetCount(pList, points.Count); + Span ls = CollectionsMarshal.AsSpan(pList); Span aspan = points.AsSpan(); - for( int j = 0; j < points.Count; j++ ) + for (int j = 0; j < points.Count; j++) { - StepCartesianPoint p = binder[ aspan[ i ] as StepEntityInstanceNode ] as StepCartesianPoint; - ls[ j ] = p; + StepCartesianPoint p = binder[aspan[i] as StepEntityInstanceNode] as StepCartesianPoint; + ls[j] = p; } - ret.ControlPointsList.Add( pList ); + ret.ControlPointsList.Add(pList); } - ret.SurfaceForm = GetSurfaceForm( enumerator[ 3 ].CodeConvertTemplate ); - ret.UClosed = ( enumerator[ 4 ] as ExpBoolNode ).Value; - ret.VClosed = ( enumerator[ 5 ] as ExpBoolNode ).Value; - ret.SelfIntersections = ( enumerator[ 6 ] as ExpBoolNode ).Value; + ret.SurfaceForm = GetSurfaceForm(enumerator[3].CodeConvertTemplate); + ret.UClosed = (enumerator[4] as ExpBoolNode).Value; + ret.VClosed = (enumerator[5] as ExpBoolNode).Value; + ret.SelfIntersections = (enumerator[6] as ExpBoolNode).Value; return ret; } - public void FromInstance( StepBSplineSurface entity ) + public void FromInstance(StepBSplineSurface entity) { - base.FromInstance( entity ); + base.FromInstance(entity); UClosed = entity.UClosed; VClosed = entity.VClosed; UDegree = entity.UDegree; VDegree = entity.VDegree; ControlPointsList.Clear(); - foreach( List list in entity.ControlPointsList ) { - ControlPointsList.Add( new List( list ) ); + foreach (List list in entity.ControlPointsList) { + ControlPointsList.Add(new List(list)); } SurfaceForm = entity.SurfaceForm; } - protected static StepBSplineSurfaceForm GetSurfaceForm( string literal ) + protected static StepBSplineSurfaceForm GetSurfaceForm(string literal) { return literal switch { @@ -162,7 +159,7 @@ namespace StgSharp.Model.Step }; } - protected static string GetSurfaceFormString( StepBSplineSurfaceForm form ) + protected static string GetSurfaceFormString(StepBSplineSurfaceForm form) { return form switch { diff --git a/StgSharp.Model/Step/Items/StepBoundedCurve.cs b/StgSharp.Model/Step/Items/StepBoundedCurve.cs index a292cacd..d9bd4358 100644 --- a/StgSharp.Model/Step/Items/StepBoundedCurve.cs +++ b/StgSharp.Model/Step/Items/StepBoundedCurve.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepBoundedCurve.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepBoundedCurve" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -37,21 +34,21 @@ namespace StgSharp.Model.Step public class StepBoundedCurve : StepCurve, IExpConvertableFrom { - public StepBoundedCurve( StepModel model ) : base( model ) { } + public StepBoundedCurve(StepModel model) : base(model) { } - public void FromInstance( StepBoundedCurve entity ) + public void FromInstance(StepBoundedCurve entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - public override bool IsConvertableTo( string entityName ) + public override bool IsConvertableTo(string entityName) { - return base.IsConvertableTo( entityName ) || entityName == "StepBoundedCurve"; + return base.IsConvertableTo(entityName) || entityName == "StepBoundedCurve"; } - internal static StepBoundedCurve FromSyntax( StepModel binder, ExpSyntaxNode syntax ) + internal static StepBoundedCurve FromSyntax(StepModel binder, ExpSyntaxNode syntax) { - return new StepBoundedCurve( binder ); + return new StepBoundedCurve(binder); } } diff --git a/StgSharp.Model/Step/Items/StepBoundedSurface.cs b/StgSharp.Model/Step/Items/StepBoundedSurface.cs index a2ed60e0..a0ba4ec3 100644 --- a/StgSharp.Model/Step/Items/StepBoundedSurface.cs +++ b/StgSharp.Model/Step/Items/StepBoundedSurface.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepBoundedSurface.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepBoundedSurface" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script.Express; using System; @@ -41,13 +38,13 @@ namespace StgSharp.Model.Step public class StepBoundedSurface : StepSurface, IExpConvertableFrom { - public StepBoundedSurface( StepModel model ) : base( model ) { } + public StepBoundedSurface(StepModel model) : base(model) { } public override StepItemType ItemType => StepItemType.BoundedSurface; - public void FromInstance( StepBoundedSurface entity ) + public void FromInstance(StepBoundedSurface entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } } diff --git a/StgSharp.Model/Step/Items/StepBoundedSurfaceCurve.cs b/StgSharp.Model/Step/Items/StepBoundedSurfaceCurve.cs index ea80dbb4..2ab19f1f 100644 --- a/StgSharp.Model/Step/Items/StepBoundedSurfaceCurve.cs +++ b/StgSharp.Model/Step/Items/StepBoundedSurfaceCurve.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepBoundedSurfaceCurve.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepBoundedSurfaceCurve" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script.Express; using System; @@ -41,18 +38,18 @@ namespace StgSharp.Model.Step internal class StepBoundedSurfaceCurve : StepBoundedCurve, IExpConvertableFrom { - public StepBoundedSurfaceCurve( StepModel model ) : base( model ) { } + public StepBoundedSurfaceCurve(StepModel model) : base(model) { } public StepCurve Parent { get; set; } = null!; - public void FromInstance( StepSurfaceCurve entity ) + public void FromInstance(StepSurfaceCurve entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - public void FromInstance( StepBoundedSurfaceCurve entity ) + public void FromInstance(StepBoundedSurfaceCurve entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } } diff --git a/StgSharp.Model/Step/Items/StepCartesianPoint.cs b/StgSharp.Model/Step/Items/StepCartesianPoint.cs index a18ce5a1..f8ffce8e 100644 --- a/StgSharp.Model/Step/Items/StepCartesianPoint.cs +++ b/StgSharp.Model/Step/Items/StepCartesianPoint.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepCartesianPoint.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepCartesianPoint" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -37,23 +34,22 @@ namespace StgSharp.Model.Step public class StepCartesianPoint : StepTriple, IExpConvertableFrom { - private StepCartesianPoint( StepModel model ) : base( model ) { } + private StepCartesianPoint(StepModel model) : base(model) { } - public StepCartesianPoint( StepModel model, float x, float y, float z ) - : base( model, x, y, z ) { } + public StepCartesianPoint(StepModel model, float x, float y, float z) : base(model, x, y, z) { } public override StepItemType ItemType => StepItemType.CartesianPoint; protected override int MinimumValueCount => 1; - public void FromInstance( StepCartesianPoint entity ) + public void FromInstance(StepCartesianPoint entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - internal static StepCartesianPoint FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepCartesianPoint FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - return AssignTo( new StepCartesianPoint( binder ), syntaxList ); + return AssignTo(new StepCartesianPoint(binder), syntaxList); } } diff --git a/StgSharp.Model/Step/Items/StepCircle.cs b/StgSharp.Model/Step/Items/StepCircle.cs index ad44884e..9f4b91a3 100644 --- a/StgSharp.Model/Step/Items/StepCircle.cs +++ b/StgSharp.Model/Step/Items/StepCircle.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepCircle.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepCircle" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -42,10 +39,10 @@ namespace StgSharp.Model.Step private StepAxis2Placement _position; - public StepCircle( StepModel model ) : base( model ) { } + public StepCircle(StepModel model) : base(model) { } - public StepCircle( StepModel model, StepAxis2Placement position, float radius ) - : base( model ) + public StepCircle(StepModel model, StepAxis2Placement position, float radius) + : base(model) { Position = position; Radius = radius; @@ -58,7 +55,7 @@ namespace StgSharp.Model.Step get { return _position; } set { - if( value == null ) { + if (value == null) { throw new ArgumentNullException(); } @@ -68,20 +65,20 @@ namespace StgSharp.Model.Step public override StepItemType ItemType => StepItemType.Circle; - public void FromInstance( StepCircle entity ) + public void FromInstance(StepCircle entity) { - base.FromInstance( entity ); + base.FromInstance(entity); this._position = entity.Position; } - internal static StepCircle FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepCircle FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - StepCircle circle = new StepCircle( binder ); - enumerator.AssertEnumeratorCount( 3 ); - circle.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - circle.Position = binder[ enumerator[ 1 ] ] as StepAxis2Placement; - circle.Radius = ( enumerator[ 2 ]as ExpRealNumberNode )!.Value; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + StepCircle circle = new StepCircle(binder); + enumerator.AssertEnumeratorCount(3); + circle.Name = (enumerator[0]as ExpStringNode)!.Value; + circle.Position = binder[enumerator[1]] as StepAxis2Placement; + circle.Radius = (enumerator[2]as ExpRealNumberNode)!.Value; return circle; } diff --git a/StgSharp.Model/Step/Items/StepConic.cs b/StgSharp.Model/Step/Items/StepConic.cs index 0dd9c895..c558ae20 100644 --- a/StgSharp.Model/Step/Items/StepConic.cs +++ b/StgSharp.Model/Step/Items/StepConic.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepConic.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepConic" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -37,18 +34,18 @@ namespace StgSharp.Model.Step public class StepConic : StepCurve, IExpConvertableFrom { - public StepConic( StepModel model ) : base( model ) { } + public StepConic(StepModel model) : base(model) { } public override StepItemType ItemType => StepItemType.Conic; - public override bool IsConvertableTo( string entityTypeName ) + public override bool IsConvertableTo(string entityTypeName) { - return base.IsConvertableTo( entityTypeName ) || entityTypeName == "StepConic"; + return base.IsConvertableTo(entityTypeName) || entityTypeName == "StepConic"; } - void IExpConvertableFrom.FromInstance( StepConic entity ) + void IExpConvertableFrom.FromInstance(StepConic entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } } diff --git a/StgSharp.Model/Step/Items/StepCurve.cs b/StgSharp.Model/Step/Items/StepCurve.cs index cdac7a6f..dca2ce23 100644 --- a/StgSharp.Model/Step/Items/StepCurve.cs +++ b/StgSharp.Model/Step/Items/StepCurve.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepCurve.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepCurve" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -37,18 +34,18 @@ namespace StgSharp.Model.Step public class StepCurve : StepGeometricRepresentationItem, IExpConvertableFrom { - public StepCurve( StepModel model ) : base( model ) { } + public StepCurve(StepModel model) : base(model) { } public override StepItemType ItemType => StepItemType.Curve; - public void FromInstance( StepCurve entity ) + public void FromInstance(StepCurve entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - public override bool IsConvertableTo( string entityName ) + public override bool IsConvertableTo(string entityName) { - return base.IsConvertableTo( entityName ) || entityName == "StepCurve"; + return base.IsConvertableTo(entityName) || entityName == "StepCurve"; } } diff --git a/StgSharp.Model/Step/Items/StepCylindricalSurface.cs b/StgSharp.Model/Step/Items/StepCylindricalSurface.cs index 54231eb0..c0c75946 100644 --- a/StgSharp.Model/Step/Items/StepCylindricalSurface.cs +++ b/StgSharp.Model/Step/Items/StepCylindricalSurface.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepCylindricalSurface.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepCylindricalSurface" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; @@ -40,13 +37,10 @@ namespace StgSharp.Model.Step public class StepCylindricalSurface : StepElementarySurface, IExpConvertableFrom { - public StepCylindricalSurface( StepModel model ) : base( model ) { } + public StepCylindricalSurface(StepModel model) : base(model) { } - public StepCylindricalSurface( - StepModel model, - StepAxis2Placement3D position, - float radius ) - : base( model, position ) + public StepCylindricalSurface(StepModel model, StepAxis2Placement3D position, float radius) + : base(model, position) { Radius = radius; } @@ -55,22 +49,20 @@ namespace StgSharp.Model.Step public override StepItemType ItemType => StepItemType.CylindricalSurface; - public void FromInstance( StepCylindricalSurface entity ) + public void FromInstance(StepCylindricalSurface entity) { - base.FromInstance( entity ); + base.FromInstance(entity); Radius = entity.Radius; } - internal static StepRepresentationItem FromSyntax( - StepModel binder, - ExpSyntaxNode syntaxList ) + internal static StepRepresentationItem FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - enumerator.AssertEnumeratorCount( 3 ); - StepCylindricalSurface surface = new StepCylindricalSurface( binder ); - surface.Name = ( enumerator[ 0 ] as ExpStringNode )!.Value; - surface.Position = binder[ enumerator[ 1 ] ]as StepAxis2Placement3D; - surface.Radius = ( enumerator[ 2 ]as ExpRealNumberNode )!.Value; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + enumerator.AssertEnumeratorCount(3); + StepCylindricalSurface surface = new StepCylindricalSurface(binder); + surface.Name = (enumerator[0] as ExpStringNode)!.Value; + surface.Position = binder[enumerator[1]]as StepAxis2Placement3D; + surface.Radius = (enumerator[2]as ExpRealNumberNode)!.Value; return surface; } diff --git a/StgSharp.Model/Step/Items/StepDirection.cs b/StgSharp.Model/Step/Items/StepDirection.cs index d4c4f344..5694eb70 100644 --- a/StgSharp.Model/Step/Items/StepDirection.cs +++ b/StgSharp.Model/Step/Items/StepDirection.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepDirection.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepDirection" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -37,23 +34,22 @@ namespace StgSharp.Model.Step public class StepDirection : StepTriple, IExpConvertableFrom { - private StepDirection( StepModel model ) : base( model ) { } + private StepDirection(StepModel model) : base(model) { } - public StepDirection( StepModel model, float x, float y, float z ) - : base( model, x, y, z ) { } + public StepDirection(StepModel model, float x, float y, float z) : base(model, x, y, z) { } public override StepItemType ItemType => StepItemType.Direction; protected override int MinimumValueCount => 2; - public void FromInstance( StepDirection entity ) + public void FromInstance(StepDirection entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - internal static StepDirection FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepDirection FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - return AssignTo( new StepDirection( binder ), syntaxList ); + return AssignTo(new StepDirection(binder), syntaxList); } } diff --git a/StgSharp.Model/Step/Items/StepEdge.cs b/StgSharp.Model/Step/Items/StepEdge.cs index 4b556c99..33b72a64 100644 --- a/StgSharp.Model/Step/Items/StepEdge.cs +++ b/StgSharp.Model/Step/Items/StepEdge.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepEdge.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepEdge" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; @@ -40,10 +37,10 @@ namespace StgSharp.Model.Step public class StepEdge : StepTopologicalRepresentationItem, IExpConvertableFrom { - protected StepEdge( StepModel model ) : base( model ) { } + protected StepEdge(StepModel model) : base(model) { } - protected StepEdge( StepModel model, StepVertex edgeStart, StepVertex edgeEnd ) - : base( model ) + protected StepEdge(StepModel model, StepVertex edgeStart, StepVertex edgeEnd) + : base(model) { EdgeStart = edgeStart; EdgeEnd = edgeEnd; @@ -53,16 +50,16 @@ namespace StgSharp.Model.Step public StepVertex EdgeEnd { get; set; } - public void FromInstance( StepEdge entity ) + public void FromInstance(StepEdge entity) { - base.FromInstance( entity ); + base.FromInstance(entity); EdgeStart = entity.EdgeStart; EdgeEnd = entity.EdgeEnd; } - public override bool IsConvertableTo( string entityName ) + public override bool IsConvertableTo(string entityName) { - return base.IsConvertableTo( entityName ) || entityName == "StepEdge"; + return base.IsConvertableTo(entityName) || entityName == "StepEdge"; } } diff --git a/StgSharp.Model/Step/Items/StepEdgeCurve.cs b/StgSharp.Model/Step/Items/StepEdgeCurve.cs index fefcfd81..245c2db3 100644 --- a/StgSharp.Model/Step/Items/StepEdgeCurve.cs +++ b/StgSharp.Model/Step/Items/StepEdgeCurve.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepEdgeCurve.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepEdgeCurve" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -42,15 +39,15 @@ namespace StgSharp.Model.Step private StepCurve _edgeGeometry; - private StepEdgeCurve( StepModel model ) : base( model ) { } + private StepEdgeCurve(StepModel model) : base(model) { } public StepEdgeCurve( StepModel model, StepVertex edgeStart, StepVertex edgeEnd, StepCurve edgeGeometry, - bool isSameSense ) - : base( model, edgeStart, edgeEnd ) + bool isSameSense) + : base(model, edgeStart, edgeEnd) { EdgeGeometry = edgeGeometry; IsSameSense = isSameSense; @@ -63,29 +60,29 @@ namespace StgSharp.Model.Step get { return _edgeGeometry; } set { - ArgumentNullException.ThrowIfNull( value ); + ArgumentNullException.ThrowIfNull(value); _edgeGeometry = value; } } public override StepItemType ItemType => StepItemType.EdgeCurve; - public void FromInstance( StepEdgeCurve entity ) + public void FromInstance(StepEdgeCurve entity) { - base.FromInstance( entity ); + base.FromInstance(entity); EdgeGeometry = entity.EdgeGeometry; } - internal static StepEdgeCurve FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepEdgeCurve FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - StepEdgeCurve edgeCurve = new StepEdgeCurve( binder ); - enumerator.AssertEnumeratorCount( 5 ); - edgeCurve.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - edgeCurve.EdgeStart = binder[ enumerator[ 1 ] ] as StepVertex; - edgeCurve.EdgeEnd = binder[ enumerator[ 2 ] ] as StepVertex; - edgeCurve.EdgeGeometry = binder[ enumerator[ 3 ] ] as StepCurve; - edgeCurve.IsSameSense = ( enumerator[ 4 ]as ExpBoolNode )!.Value; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + StepEdgeCurve edgeCurve = new StepEdgeCurve(binder); + enumerator.AssertEnumeratorCount(5); + edgeCurve.Name = (enumerator[0]as ExpStringNode)!.Value; + edgeCurve.EdgeStart = binder[enumerator[1]] as StepVertex; + edgeCurve.EdgeEnd = binder[enumerator[2]] as StepVertex; + edgeCurve.EdgeGeometry = binder[enumerator[3]] as StepCurve; + edgeCurve.IsSameSense = (enumerator[4]as ExpBoolNode)!.Value; return edgeCurve; } diff --git a/StgSharp.Model/Step/Items/StepEdgeLoop.cs b/StgSharp.Model/Step/Items/StepEdgeLoop.cs index a07b0ed1..97fc2091 100644 --- a/StgSharp.Model/Step/Items/StepEdgeLoop.cs +++ b/StgSharp.Model/Step/Items/StepEdgeLoop.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepEdgeLoop.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepEdgeLoop" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -40,36 +37,36 @@ namespace StgSharp.Model.Step public class StepEdgeLoop : StepLoop, IExpConvertableFrom { - public StepEdgeLoop( StepModel model, params StepOrientedEdge[] edgeList ) - : this( model, ( IEnumerable )edgeList ) { } + public StepEdgeLoop(StepModel model, params StepOrientedEdge[] edgeList) + : this(model, (IEnumerable)edgeList) { } - public StepEdgeLoop( StepModel model, IEnumerable edgeList ) - : base( model ) + public StepEdgeLoop(StepModel model, IEnumerable edgeList) + : base(model) { - EdgeList = new List( edgeList ); + EdgeList = new List(edgeList); } public List EdgeList { get; private set; } public override StepItemType ItemType => StepItemType.EdgeLoop; - public void FromInstance( StepEdgeCurve entity ) + public void FromInstance(StepEdgeCurve entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - internal static StepEdgeLoop FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepEdgeLoop FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - enumerator.AssertEnumeratorCount( 2 ); - ExpNodePresidentEnumerator edgeSyntaxList = enumerator[ 1 ].TupleToPresidentEnumerator(); + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + enumerator.AssertEnumeratorCount(2); + ExpNodePresidentEnumerator edgeSyntaxList = enumerator[1].TupleToPresidentEnumerator(); StepEdgeLoop edgeLoop = new StepEdgeLoop( - binder, new StepOrientedEdge[edgeSyntaxList.Count] ); - edgeLoop.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - for( int i = 0; i < edgeSyntaxList.Count; i++ ) + binder, new StepOrientedEdge[edgeSyntaxList.Count]); + edgeLoop.Name = (enumerator[0]as ExpStringNode)!.Value; + for (int i = 0; i < edgeSyntaxList.Count; i++) { int j = i; // capture to avoid rebinding - edgeLoop.EdgeList[ j ] = binder[ edgeSyntaxList[ j ] ] as StepOrientedEdge; + edgeLoop.EdgeList[j] = binder[edgeSyntaxList[j]] as StepOrientedEdge; } return edgeLoop; diff --git a/StgSharp.Model/Step/Items/StepElementarySurface.cs b/StgSharp.Model/Step/Items/StepElementarySurface.cs index eafc668e..067ac14f 100644 --- a/StgSharp.Model/Step/Items/StepElementarySurface.cs +++ b/StgSharp.Model/Step/Items/StepElementarySurface.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepElementarySurface.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepElementarySurface" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -42,10 +39,10 @@ namespace StgSharp.Model.Step private StepAxis2Placement3D _position; - public StepElementarySurface( StepModel model ) : base( model ) { } + public StepElementarySurface(StepModel model) : base(model) { } - public StepElementarySurface( StepModel model, StepAxis2Placement3D position ) - : base( model ) + public StepElementarySurface(StepModel model, StepAxis2Placement3D position) + : base(model) { Position = position; } @@ -55,14 +52,14 @@ namespace StgSharp.Model.Step get { return _position; } set { - ArgumentNullException.ThrowIfNull( value ); + ArgumentNullException.ThrowIfNull(value); _position = value; } } - public void FromInstance( StepElementarySurface entity ) + public void FromInstance(StepElementarySurface entity) { - base.FromInstance( entity ); + base.FromInstance(entity); _position = entity.Position; } diff --git a/StgSharp.Model/Step/Items/StepEllipse.cs b/StgSharp.Model/Step/Items/StepEllipse.cs index e9092a12..5b17912c 100644 --- a/StgSharp.Model/Step/Items/StepEllipse.cs +++ b/StgSharp.Model/Step/Items/StepEllipse.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepEllipse.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepEllipse" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -42,15 +39,10 @@ namespace StgSharp.Model.Step private StepAxis2Placement _position; - private StepEllipse( StepModel model ) : base( model ) { } + private StepEllipse(StepModel model) : base(model) { } - public StepEllipse( - StepModel model, - string name, - StepAxis2Placement position, - float semiAxis1, - float semiAxis2 ) - : base( model ) + public StepEllipse(StepModel model, string name, StepAxis2Placement position, float semiAxis1, float semiAxis2) + : base(model) { Position = position; SemiAxis1 = semiAxis1; @@ -66,7 +58,7 @@ namespace StgSharp.Model.Step get { return _position; } set { - ArgumentNullException.ThrowIfNull( value ); + ArgumentNullException.ThrowIfNull(value); _position = value; } @@ -74,22 +66,22 @@ namespace StgSharp.Model.Step public override StepItemType ItemType => StepItemType.Ellipse; - public void FromInstance( StepEllipse entity ) + public void FromInstance(StepEllipse entity) { - base.FromInstance( entity ); + base.FromInstance(entity); SemiAxis1 = entity.SemiAxis1; SemiAxis2 = entity.SemiAxis2; } - internal static StepEllipse FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepEllipse FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - StepEllipse ellipse = new StepEllipse( binder ); - enumerator.AssertEnumeratorCount( 4 ); - ellipse.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - ellipse.Position = binder[ ( enumerator[ 1 ] as StepEntityInstanceNode )!.Id ]as StepAxis2Placement2D; - ellipse.SemiAxis1 = ( enumerator[ 2 ] as ExpRealNumberNode )!.Value; - ellipse.SemiAxis2 = ( enumerator[ 3 ] as ExpRealNumberNode )!.Value; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + StepEllipse ellipse = new StepEllipse(binder); + enumerator.AssertEnumeratorCount(4); + ellipse.Name = (enumerator[0]as ExpStringNode)!.Value; + ellipse.Position = binder[(enumerator[1] as StepEntityInstanceNode)!.Id]as StepAxis2Placement2D; + ellipse.SemiAxis1 = (enumerator[2] as ExpRealNumberNode)!.Value; + ellipse.SemiAxis2 = (enumerator[3] as ExpRealNumberNode)!.Value; return ellipse; } diff --git a/StgSharp.Model/Step/Items/StepFace.cs b/StgSharp.Model/Step/Items/StepFace.cs index 44fd93c7..ebb7f25b 100644 --- a/StgSharp.Model/Step/Items/StepFace.cs +++ b/StgSharp.Model/Step/Items/StepFace.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepFace.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepFace" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -40,21 +37,21 @@ namespace StgSharp.Model.Step public class StepFace : StepTopologicalRepresentationItem, IExpConvertableFrom { - public StepFace( StepModel model ) : base( model ) { } + public StepFace(StepModel model) : base(model) { } public List Bounds { get; private set; } = new List(); public override StepItemType ItemType => StepItemType.Face; - public void FromInstance( StepFace entity ) + public void FromInstance(StepFace entity) { - base.FromInstance( entity ); + base.FromInstance(entity); Bounds = entity.Bounds; } - public override bool IsConvertableTo( string entityName ) + public override bool IsConvertableTo(string entityName) { - return base.IsConvertableTo( entityName ) || entityName == "StepFace"; + return base.IsConvertableTo(entityName) || entityName == "StepFace"; } } diff --git a/StgSharp.Model/Step/Items/StepFaceBound.cs b/StgSharp.Model/Step/Items/StepFaceBound.cs index 3621c1f1..a4375111 100644 --- a/StgSharp.Model/Step/Items/StepFaceBound.cs +++ b/StgSharp.Model/Step/Items/StepFaceBound.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepFaceBound.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepFaceBound" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; @@ -40,10 +37,10 @@ namespace StgSharp.Model.Step public class StepFaceBound : StepTopologicalRepresentationItem, IExpConvertableFrom { - public StepFaceBound( StepModel model ) : base( model ) { } + public StepFaceBound(StepModel model) : base(model) { } - public StepFaceBound( StepModel model, StepLoop bound, bool orientation ) - : base( model ) + public StepFaceBound(StepModel model, StepLoop bound, bool orientation) + : base(model) { Bound = bound; Orientation = orientation; @@ -55,21 +52,21 @@ namespace StgSharp.Model.Step public StepLoop Bound { get; set; } - public void FromInstance( StepFaceBound entity ) + public void FromInstance(StepFaceBound entity) { - base.FromInstance( entity ); + base.FromInstance(entity); Bound = entity.Bound; Orientation = entity.Orientation; } - internal static StepFaceBound FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepFaceBound FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - enumerator.AssertEnumeratorCount( 3 ); - StepFaceBound faceBound = new StepFaceBound( binder ); - faceBound.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - faceBound.Bound = binder[ enumerator[ 1 ] ] as StepLoop; - faceBound.Orientation = ( enumerator[ 2 ]as ExpBoolNode )!.Value; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + enumerator.AssertEnumeratorCount(3); + StepFaceBound faceBound = new StepFaceBound(binder); + faceBound.Name = (enumerator[0]as ExpStringNode)!.Value; + faceBound.Bound = binder[enumerator[1]] as StepLoop; + faceBound.Orientation = (enumerator[2]as ExpBoolNode)!.Value; return faceBound; } diff --git a/StgSharp.Model/Step/Items/StepFaceOuterBound.cs b/StgSharp.Model/Step/Items/StepFaceOuterBound.cs index 7d06afe6..8a4b7048 100644 --- a/StgSharp.Model/Step/Items/StepFaceOuterBound.cs +++ b/StgSharp.Model/Step/Items/StepFaceOuterBound.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepFaceOuterBound.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepFaceOuterBound" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -37,28 +34,26 @@ namespace StgSharp.Model.Step public class StepFaceOuterBound : StepFaceBound, IExpConvertableFrom { - private StepFaceOuterBound( StepModel model ) : base( model ) { } + private StepFaceOuterBound(StepModel model) : base(model) { } - public StepFaceOuterBound( StepModel model, StepLoop bound, bool orientation ) - : base( model, bound, orientation ) { } + public StepFaceOuterBound(StepModel model, StepLoop bound, bool orientation) + : base(model, bound, orientation) { } public override StepItemType ItemType => StepItemType.FaceOuterBound; - public void FromInstance( StepFaceOuterBound entity ) + public void FromInstance(StepFaceOuterBound entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - internal static new StepFaceOuterBound FromSyntax( - StepModel binder, - ExpSyntaxNode syntaxList ) + internal static new StepFaceOuterBound FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - enumerator.AssertEnumeratorCount( 3 ); - StepFaceOuterBound faceOuterBound = new StepFaceOuterBound( binder ); - faceOuterBound.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - faceOuterBound.Bound = binder[ enumerator[ 1 ] ] as StepLoop; - faceOuterBound.Orientation = ( enumerator[ 2 ]as ExpBoolNode )!.Value; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + enumerator.AssertEnumeratorCount(3); + StepFaceOuterBound faceOuterBound = new StepFaceOuterBound(binder); + faceOuterBound.Name = (enumerator[0]as ExpStringNode)!.Value; + faceOuterBound.Bound = binder[enumerator[1]] as StepLoop; + faceOuterBound.Orientation = (enumerator[2]as ExpBoolNode)!.Value; return faceOuterBound; } diff --git a/StgSharp.Model/Step/Items/StepFaceSurface.cs b/StgSharp.Model/Step/Items/StepFaceSurface.cs index ecacda11..fc1cac0a 100644 --- a/StgSharp.Model/Step/Items/StepFaceSurface.cs +++ b/StgSharp.Model/Step/Items/StepFaceSurface.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepFaceSurface.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepFaceSurface" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; @@ -40,15 +37,15 @@ namespace StgSharp.Model.Step public class StepFaceSurface : StepFace, IExpConvertableFrom { - public StepFaceSurface( StepModel model ) : base( model ) { } + public StepFaceSurface(StepModel model) : base(model) { } public bool SameSense { get; set; } public StepSurface FaceGeometry { get; set; } - public void FromInstance( StepFaceSurface entity ) + public void FromInstance(StepFaceSurface entity) { - base.FromInstance( entity ); + base.FromInstance(entity); SameSense = entity.SameSense; FaceGeometry = entity.FaceGeometry; } diff --git a/StgSharp.Model/Step/Items/StepGeometricRepresentationItem.cs b/StgSharp.Model/Step/Items/StepGeometricRepresentationItem.cs index 26567a09..db17a9c8 100644 --- a/StgSharp.Model/Step/Items/StepGeometricRepresentationItem.cs +++ b/StgSharp.Model/Step/Items/StepGeometricRepresentationItem.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepGeometricRepresentationItem.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepGeometricRepresentationItem" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -37,17 +34,16 @@ namespace StgSharp.Model.Step public class StepGeometricRepresentationItem : StepRepresentationItem, IExpConvertableFrom { - public StepGeometricRepresentationItem( StepModel model ) : base( model ) { } + public StepGeometricRepresentationItem(StepModel model) : base(model) { } - public void FromInstance( StepGeometricRepresentationItem entity ) + public void FromInstance(StepGeometricRepresentationItem entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - public override bool IsConvertableTo( string entityName ) + public override bool IsConvertableTo(string entityName) { - return base.IsConvertableTo( entityName ) || - entityName is "StepGeometricRepresentationItem"; + return base.IsConvertableTo(entityName) || entityName is "StepGeometricRepresentationItem"; } } diff --git a/StgSharp.Model/Step/Items/StepLine.cs b/StgSharp.Model/Step/Items/StepLine.cs index 75281137..534fcc8e 100644 --- a/StgSharp.Model/Step/Items/StepLine.cs +++ b/StgSharp.Model/Step/Items/StepLine.cs @@ -1,30 +1,27 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="StepLine.cs" +// file="StepLine" // Project: StgSharp // AuthorGroup: Nitload Space // Copyright (c) Nitload Space. All rights reserved. // -// 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. +// 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. // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- @@ -82,14 +79,7 @@ namespace StgSharp.Model.Step Vector = entity.Vector; } - public static StepLine FromPoints( - StepModel model, - float x1, - float y1, - float z1, - float x2, - float y2, - float z2) + public static StepLine FromPoints(StepModel model, float x1, float y1, float z1, float x2, float y2, float z2) { StepCartesianPoint start = new StepCartesianPoint(model, x1, y1, z1); float dx = x2 - x1; diff --git a/StgSharp.Model/Step/Items/StepLoop.cs b/StgSharp.Model/Step/Items/StepLoop.cs index 6e0249cd..306f386b 100644 --- a/StgSharp.Model/Step/Items/StepLoop.cs +++ b/StgSharp.Model/Step/Items/StepLoop.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepLoop.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepLoop" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -37,11 +34,11 @@ namespace StgSharp.Model.Step public abstract class StepLoop : StepTopologicalRepresentationItem, IExpConvertableFrom { - protected StepLoop( StepModel model ) : base( model ) { } + protected StepLoop(StepModel model) : base(model) { } - public void FromInstance( StepLoop entity ) + public void FromInstance(StepLoop entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } } diff --git a/StgSharp.Model/Step/Items/StepOrientedEdge.cs b/StgSharp.Model/Step/Items/StepOrientedEdge.cs index 2b45a47a..4add5d2d 100644 --- a/StgSharp.Model/Step/Items/StepOrientedEdge.cs +++ b/StgSharp.Model/Step/Items/StepOrientedEdge.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepOrientedEdge.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepOrientedEdge" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.Win32.SafeHandles; using StgSharp.Model.Step; @@ -44,15 +41,15 @@ namespace StgSharp.Model.Step private StepEdge _edgeElement; - private StepOrientedEdge( StepModel model ) : base( model ) { } + private StepOrientedEdge(StepModel model) : base(model) { } public StepOrientedEdge( StepModel model, StepVertex edgeStart, StepVertex edgeEnd, StepEdge edgeElement, - bool orientation ) - : base( model, edgeStart, edgeEnd ) + bool orientation) + : base(model, edgeStart, edgeEnd) { EdgeElement = edgeElement; Orientation = orientation; @@ -65,7 +62,7 @@ namespace StgSharp.Model.Step get { return _edgeElement; } set { - if( value == null ) { + if (value == null) { throw new ArgumentNullException(); } @@ -75,23 +72,23 @@ namespace StgSharp.Model.Step public override StepItemType ItemType => StepItemType.OrientedEdge; - public void FromInstance( StepOrientedEdge entity ) + public void FromInstance(StepOrientedEdge entity) { - base.FromInstance( entity ); + base.FromInstance(entity); EdgeElement = entity.EdgeElement; Orientation = entity.Orientation; } - internal static StepOrientedEdge FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepOrientedEdge FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - StepOrientedEdge orientedEdge = new StepOrientedEdge( binder ); - enumerator.AssertEnumeratorCount( 5 ); - orientedEdge.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - orientedEdge.EdgeStart = binder[ enumerator[ 1 ] ]as StepVertex; - orientedEdge.EdgeEnd = binder[ enumerator[ 2 ] ] as StepVertex; - orientedEdge.EdgeElement = binder[ enumerator[ 3 ] ] as StepEdge; - orientedEdge.Orientation = ( enumerator[ 4 ]as ExpBoolNode )!.Value; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + StepOrientedEdge orientedEdge = new StepOrientedEdge(binder); + enumerator.AssertEnumeratorCount(5); + orientedEdge.Name = (enumerator[0]as ExpStringNode)!.Value; + orientedEdge.EdgeStart = binder[enumerator[1]]as StepVertex; + orientedEdge.EdgeEnd = binder[enumerator[2]] as StepVertex; + orientedEdge.EdgeElement = binder[enumerator[3]] as StepEdge; + orientedEdge.Orientation = (enumerator[4]as ExpBoolNode)!.Value; return orientedEdge; } diff --git a/StgSharp.Model/Step/Items/StepPcurveOrSurface.cs b/StgSharp.Model/Step/Items/StepPcurveOrSurface.cs index 975ac859..c4f492cc 100644 --- a/StgSharp.Model/Step/Items/StepPcurveOrSurface.cs +++ b/StgSharp.Model/Step/Items/StepPcurveOrSurface.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepPcurveOrSurface.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepPcurveOrSurface" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script.Express; using System; @@ -41,11 +38,11 @@ namespace StgSharp.Model.Step.Items public class StepPCurveOrSurface : StepGeometricRepresentationItem, IExpConvertableFrom { - public StepPCurveOrSurface( StepModel model ) : base( model ) { } + public StepPCurveOrSurface(StepModel model) : base(model) { } - public void FromInstance( StepPCurveOrSurface entity ) + public void FromInstance(StepPCurveOrSurface entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } } diff --git a/StgSharp.Model/Step/Items/StepPlacement.cs b/StgSharp.Model/Step/Items/StepPlacement.cs index 8d78eaf1..ccf4790c 100644 --- a/StgSharp.Model/Step/Items/StepPlacement.cs +++ b/StgSharp.Model/Step/Items/StepPlacement.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepPlacement.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepPlacement" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -41,10 +38,10 @@ namespace StgSharp.Model.Step private StepCartesianPoint _location; - public StepPlacement( StepModel model ) : base( model ) { } + public StepPlacement(StepModel model) : base(model) { } - public StepPlacement( StepModel model, StepCartesianPoint location ) - : base( model ) + public StepPlacement(StepModel model, StepCartesianPoint location) + : base(model) { _location = location; } @@ -54,20 +51,20 @@ namespace StgSharp.Model.Step get { return _location; } set { - ArgumentNullException.ThrowIfNull( value ); + ArgumentNullException.ThrowIfNull(value); _location = value; } } - public void FromInstance( StepPlacement entity ) + public void FromInstance(StepPlacement entity) { - base.FromInstance( entity ); + base.FromInstance(entity); this.Location = entity.Location; } - public override bool IsConvertableTo( string entityName ) + public override bool IsConvertableTo(string entityName) { - return base.IsConvertableTo( entityName ) || entityName == "StepPlacement"; + return base.IsConvertableTo(entityName) || entityName == "StepPlacement"; } } diff --git a/StgSharp.Model/Step/Items/StepPlane.cs b/StgSharp.Model/Step/Items/StepPlane.cs index 62035ede..de3ba7fb 100644 --- a/StgSharp.Model/Step/Items/StepPlane.cs +++ b/StgSharp.Model/Step/Items/StepPlane.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepPlane.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepPlane" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Geometries; using StgSharp.Model.Step; using StgSharp.Script; @@ -38,25 +35,24 @@ namespace StgSharp.Model.Step public class StepPlane : StepElementarySurface, IExpConvertableFrom { - public StepPlane( StepModel model ) : base( model ) { } + public StepPlane(StepModel model) : base(model) { } - public StepPlane( StepModel model, StepAxis2Placement3D position ) - : base( model, position ) { } + public StepPlane(StepModel model, StepAxis2Placement3D position) : base(model, position) { } public override StepItemType ItemType => StepItemType.Plane; - public void FromInstance( StepPlane entity ) + public void FromInstance(StepPlane entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - internal static StepPlane FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepPlane FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - StepPlane plane = new StepPlane( binder ); - enumerator.AssertEnumeratorCount( 2 ); - plane.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - plane.Position = binder[ enumerator[ 1 ] ] as StepAxis2Placement3D; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + StepPlane plane = new StepPlane(binder); + enumerator.AssertEnumeratorCount(2); + plane.Name = (enumerator[0]as ExpStringNode)!.Value; + plane.Position = binder[enumerator[1]] as StepAxis2Placement3D; return plane; } diff --git a/StgSharp.Model/Step/Items/StepPoint.cs b/StgSharp.Model/Step/Items/StepPoint.cs index 89512028..586b7382 100644 --- a/StgSharp.Model/Step/Items/StepPoint.cs +++ b/StgSharp.Model/Step/Items/StepPoint.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepPoint.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepPoint" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -39,18 +36,18 @@ namespace StgSharp.Model.Step public class StepPoint : StepGeometricRepresentationItem, IExpConvertableFrom { - public StepPoint( StepModel model ) : base( model ) { } + public StepPoint(StepModel model) : base(model) { } public override StepItemType ItemType => StepItemType.Point; - public void FromInstance( StepPoint entity ) + public void FromInstance(StepPoint entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - public override bool IsConvertableTo( string entityName ) + public override bool IsConvertableTo(string entityName) { - return base.IsConvertableTo( entityName ) || entityName == "StepPoint"; + return base.IsConvertableTo(entityName) || entityName == "StepPoint"; } } diff --git a/StgSharp.Model/Step/Items/StepRepresentationItem.cs b/StgSharp.Model/Step/Items/StepRepresentationItem.cs index ea5a88a1..c2b0cb23 100644 --- a/StgSharp.Model/Step/Items/StepRepresentationItem.cs +++ b/StgSharp.Model/Step/Items/StepRepresentationItem.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepRepresentationItem.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepRepresentationItem" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp.Syntax; using StgSharp.Model.Step; @@ -42,19 +39,19 @@ namespace StgSharp.Model.Step public class StepRepresentationItem : StepEntityBase, IExpConvertableFrom { - protected StepRepresentationItem( StepModel model ) + protected StepRepresentationItem(StepModel model) { Context = model; } public override StepItemType ItemType => StepItemType.PresentationItem; - public void FromInstance( StepRepresentationItem entity ) + public void FromInstance(StepRepresentationItem entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - public virtual bool IsConvertableTo( string entityName ) + public virtual bool IsConvertableTo(string entityName) { return entityName == "StepRepresentationItem"; } diff --git a/StgSharp.Model/Step/Items/StepSurface.cs b/StgSharp.Model/Step/Items/StepSurface.cs index 34a02c0d..7865895b 100644 --- a/StgSharp.Model/Step/Items/StepSurface.cs +++ b/StgSharp.Model/Step/Items/StepSurface.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepSurface.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepSurface" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -37,16 +34,16 @@ namespace StgSharp.Model.Step public class StepSurface : StepGeometricRepresentationItem, IExpConvertableFrom { - protected StepSurface( StepModel model ) : base( model ) { } + protected StepSurface(StepModel model) : base(model) { } - public void FromInstance( StepSurface entity ) + public void FromInstance(StepSurface entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - public override bool IsConvertableTo( string entityName ) + public override bool IsConvertableTo(string entityName) { - return base.IsConvertableTo( entityName ) || entityName == "StepSurface"; + return base.IsConvertableTo(entityName) || entityName == "StepSurface"; } } diff --git a/StgSharp.Model/Step/Items/StepSurfaceCurve.cs b/StgSharp.Model/Step/Items/StepSurfaceCurve.cs index 73528f24..162e2659 100644 --- a/StgSharp.Model/Step/Items/StepSurfaceCurve.cs +++ b/StgSharp.Model/Step/Items/StepSurfaceCurve.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepSurfaceCurve.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepSurfaceCurve" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script.Express; using System; @@ -41,11 +38,11 @@ namespace StgSharp.Model.Step public class StepSurfaceCurve : StepCurve, IExpConvertableFrom { - public StepSurfaceCurve( StepModel model ) : base( model ) { } + public StepSurfaceCurve(StepModel model) : base(model) { } public StepCurve Curve3D { get; set; } - public void FromInstance( StepSurfaceCurve entity ) + public void FromInstance(StepSurfaceCurve entity) { throw new NotImplementedException(); } diff --git a/StgSharp.Model/Step/Items/StepTopologicalRepresentationItem.cs b/StgSharp.Model/Step/Items/StepTopologicalRepresentationItem.cs index c0562dc5..eef8acc8 100644 --- a/StgSharp.Model/Step/Items/StepTopologicalRepresentationItem.cs +++ b/StgSharp.Model/Step/Items/StepTopologicalRepresentationItem.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepTopologicalRepresentationItem.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepTopologicalRepresentationItem" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -39,17 +36,16 @@ namespace StgSharp.Model.Step public class StepTopologicalRepresentationItem : StepRepresentationItem, IExpConvertableFrom { - protected StepTopologicalRepresentationItem( StepModel model ) : base( model ) { } + protected StepTopologicalRepresentationItem(StepModel model) : base(model) { } - public void FromInstance( StepTopologicalRepresentationItem entity ) + public void FromInstance(StepTopologicalRepresentationItem entity) { - base.FromInstance( entity ); + base.FromInstance(entity); } - public override bool IsConvertableTo( string entityName ) + public override bool IsConvertableTo(string entityName) { - return base.IsConvertableTo( entityName ) || - entityName == "StepTopologicalRepresentationItem"; + return base.IsConvertableTo(entityName) || entityName == "StepTopologicalRepresentationItem"; } } diff --git a/StgSharp.Model/Step/Items/StepTriple.cs b/StgSharp.Model/Step/Items/StepTriple.cs index b57eaef8..c5d6d870 100644 --- a/StgSharp.Model/Step/Items/StepTriple.cs +++ b/StgSharp.Model/Step/Items/StepTriple.cs @@ -1,30 +1,27 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="StepTriple.cs" +// file="StepTriple" // Project: StgSharp // AuthorGroup: Nitload Space // Copyright (c) Nitload Space. All rights reserved. // -// 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. +// 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. // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- diff --git a/StgSharp.Model/Step/Items/StepVector.cs b/StgSharp.Model/Step/Items/StepVector.cs index 8876f3ed..82afeced 100644 --- a/StgSharp.Model/Step/Items/StepVector.cs +++ b/StgSharp.Model/Step/Items/StepVector.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepVector.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepVector" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -42,10 +39,10 @@ namespace StgSharp.Model.Step private StepDirection _direction; - private StepVector( StepModel model ) : base( model ) { } + private StepVector(StepModel model) : base(model) { } - public StepVector( StepModel model, StepDirection direction, double length ) - : base( model ) + public StepVector(StepModel model, StepDirection direction, double length) + : base(model) { Direction = direction; Length = length; @@ -58,7 +55,7 @@ namespace StgSharp.Model.Step get { return _direction; } set { - ArgumentNullException.ThrowIfNull( value ); + ArgumentNullException.ThrowIfNull(value); _direction = value; } @@ -66,20 +63,20 @@ namespace StgSharp.Model.Step public override StepItemType ItemType => StepItemType.Vector; - public void FromInstance( StepVector entity ) + public void FromInstance(StepVector entity) { - base.FromInstance( entity ); + base.FromInstance(entity); _direction = entity.Direction; } - internal static StepVector FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepVector FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - StepVector vector = new StepVector( binder ); - enumerator.AssertEnumeratorCount( 3 ); - vector.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - vector.Direction = binder[ enumerator[ 1 ] ] as StepDirection; - vector.Length = ( enumerator[ 2 ]as ExpRealNumberNode )!.Value; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + StepVector vector = new StepVector(binder); + enumerator.AssertEnumeratorCount(3); + vector.Name = (enumerator[0]as ExpStringNode)!.Value; + vector.Direction = binder[enumerator[1]] as StepDirection; + vector.Length = (enumerator[2]as ExpRealNumberNode)!.Value; return vector; } diff --git a/StgSharp.Model/Step/Items/StepVertex.cs b/StgSharp.Model/Step/Items/StepVertex.cs index b899f65c..105ecba9 100644 --- a/StgSharp.Model/Step/Items/StepVertex.cs +++ b/StgSharp.Model/Step/Items/StepVertex.cs @@ -1,30 +1,27 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="StepVertex.cs" +// file="StepVertex" // Project: StgSharp // AuthorGroup: Nitload Space // Copyright (c) Nitload Space. All rights reserved. // -// 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. +// 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. // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- diff --git a/StgSharp.Model/Step/Items/StepVertexPoint.cs b/StgSharp.Model/Step/Items/StepVertexPoint.cs index aae2da04..a95a4b9a 100644 --- a/StgSharp.Model/Step/Items/StepVertexPoint.cs +++ b/StgSharp.Model/Step/Items/StepVertexPoint.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepVertexPoint.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepVertexPoint" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -42,10 +39,10 @@ namespace StgSharp.Model.Step private StepCartesianPoint _location; - public StepVertexPoint( StepModel model ) : base( model ) { } + public StepVertexPoint(StepModel model) : base(model) { } - public StepVertexPoint( StepModel model, StepCartesianPoint location ) - : base( model ) + public StepVertexPoint(StepModel model, StepCartesianPoint location) + : base(model) { Location = location; } @@ -55,26 +52,26 @@ namespace StgSharp.Model.Step get { return _location; } set { - ArgumentNullException.ThrowIfNull( value ); + ArgumentNullException.ThrowIfNull(value); _location = value; } } public override StepItemType ItemType => StepItemType.VertexPoint; - public void FromInstance( StepVertexPoint entity ) + public void FromInstance(StepVertexPoint entity) { - base.FromInstance( entity ); + base.FromInstance(entity); this.Location = entity.Location; } - internal static StepVertexPoint FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) + internal static StepVertexPoint FromSyntax(StepModel binder, ExpSyntaxNode syntaxList) { - ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); - StepVertexPoint vertex = new StepVertexPoint( binder ); - enumerator.AssertEnumeratorCount( 2 ); - vertex.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; - vertex.Location = binder[ enumerator[ 1 ] ] as StepCartesianPoint; + ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList); + StepVertexPoint vertex = new StepVertexPoint(binder); + enumerator.AssertEnumeratorCount(2); + vertex.Name = (enumerator[0]as ExpStringNode)!.Value; + vertex.Location = binder[enumerator[1]] as StepCartesianPoint; return vertex; } diff --git a/StgSharp.Model/Step/StepDataParser.cs b/StgSharp.Model/Step/StepDataParser.cs index 78db1025..fd2d1e0d 100644 --- a/StgSharp.Model/Step/StepDataParser.cs +++ b/StgSharp.Model/Step/StepDataParser.cs @@ -1,30 +1,27 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="StepDataParser.cs" +// file="StepDataParser" // Project: StgSharp // AuthorGroup: Nitload Space // Copyright (c) Nitload Space. All rights reserved. // -// 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. +// 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. // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- diff --git a/StgSharp.Model/Step/StepEntityBase.cs b/StgSharp.Model/Step/StepEntityBase.cs index 23f36b21..a7956736 100644 --- a/StgSharp.Model/Step/StepEntityBase.cs +++ b/StgSharp.Model/Step/StepEntityBase.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepEntityBase.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepEntityBase" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp.Syntax; using StgSharp.Mathematics; @@ -52,7 +49,7 @@ namespace StgSharp.Model.Step public int Id { get => Label.Id; - protected set { Label = new StepEntityLabel( value ); } + protected set { Label = new StepEntityLabel(value); } } public StepEntityLabel Label { get; protected set; } @@ -65,7 +62,7 @@ namespace StgSharp.Model.Step protected string ExpEntityTypeName { get; set; } - public void FromInstance( StepEntityBase entity ) + public void FromInstance(StepEntityBase entity) { this.Id = entity.Id; this.Label = entity.Label; @@ -73,58 +70,58 @@ namespace StgSharp.Model.Step this.Name = entity.Name; } - public unsafe string[] GetEntityDescription( int depth ) + public unsafe string[] GetEntityDescription(int depth) { List ret = new(); string thisDescription = $"Entity Id: {Id}, type: {ExpEntityTypeName}"; - if( depth <= 0 ) { - return [thisDescription]; + if (depth <= 0) { + return[ thisDescription ]; } - switch( Dependencies.Count() ) + switch (Dependencies.Count()) { case 0: - return [thisDescription]; + return[ thisDescription ]; case 1: - ret.Add( thisDescription ); + ret.Add(thisDescription); int only = Dependencies.First(); - string[] dep = Context[ only ]!.GetEntityDescription( depth - 1 ); - ret.Add( $" ©¸-{dep[0]}" ); - for( int i = 1; i < dep.Length; i++ ) { - ret.Add( $" {dep[i]}" ); + string[] dep = Context[only]!.GetEntityDescription(depth - 1); + ret.Add($" ©¸-{dep[0]}"); + for (int i = 1; i < dep.Length; i++) { + ret.Add($" {dep[i]}"); } return ret.ToArray(); default: - ret.Add( thisDescription ); + ret.Add(thisDescription); int first = Dependencies.First(); - dep = Context[ first ]!.GetEntityDescription( depth - 1 ); - ret.Add( $" ©À-{dep[0]}" ); + dep = Context[first]!.GetEntityDescription(depth - 1); + ret.Add($" ©À-{dep[0]}"); int index = 0; - for( int i = 1; i < dep.Length; i++ ) { - ret.Add( $" | {dep[i]}" ); + for (int i = 1; i < dep.Length; i++) { + ret.Add($" | {dep[i]}"); } - foreach( int item in Dependencies ) + foreach (int item in Dependencies) { index++; - if( index == 1 || index >= Dependencies.Count() ) + if (index == 1 || index >= Dependencies.Count()) { continue; } - dep = Context[ item ]!.GetEntityDescription( depth - 1 ); - ret.Add( $" ©À-{dep[0]}" ); - for( int i = 1; i < dep.Length; i++ ) { - ret.Add( $" | {dep[i]}" ); + dep = Context[item]!.GetEntityDescription(depth - 1); + ret.Add($" ©À-{dep[0]}"); + for (int i = 1; i < dep.Length; i++) { + ret.Add($" | {dep[i]}"); } } - dep = Context[ Dependencies.Last() ].GetEntityDescription( depth - 1 ); - ret.Add( $" ©¸-{dep[0]}" ); - for( int i = 1; i < dep.Length; i++ ) { - ret.Add( $" {dep[i]}" ); + dep = Context[Dependencies.Last()].GetEntityDescription(depth - 1); + ret.Add($" ©¸-{dep[0]}"); + for (int i = 1; i < dep.Length; i++) { + ret.Add($" {dep[i]}"); } return ret.ToArray(); } } - public bool IsConvertableTo( string entityName ) + public bool IsConvertableTo(string entityName) { return false; } diff --git a/StgSharp.Model/Step/StepEntityLabel.cs b/StgSharp.Model/Step/StepEntityLabel.cs index 1d8a6463..8192c7f8 100644 --- a/StgSharp.Model/Step/StepEntityLabel.cs +++ b/StgSharp.Model/Step/StepEntityLabel.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepEntityLabel.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepEntityLabel" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.PipeLine; using System; @@ -40,7 +37,8 @@ namespace StgSharp.Model.Step { public record class StepEntityLabel : PipelineNodeLabel { - public StepEntityLabel( int id ) + + public StepEntityLabel(int id) { Id = id; } @@ -56,5 +54,6 @@ namespace StgSharp.Model.Step { return $"StepEntityLabel: {Id}"; } + } } diff --git a/StgSharp.Model/Step/StepEntityUnsupportedException.cs b/StgSharp.Model/Step/StepEntityUnsupportedException.cs index d48787a6..6b0dc6b8 100644 --- a/StgSharp.Model/Step/StepEntityUnsupportedException.cs +++ b/StgSharp.Model/Step/StepEntityUnsupportedException.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepEntityUnsupportedException.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepEntityUnsupportedException" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; diff --git a/StgSharp.Model/Step/StepHeader.cs b/StgSharp.Model/Step/StepHeader.cs index ea0a22fe..cbe16517 100644 --- a/StgSharp.Model/Step/StepHeader.cs +++ b/StgSharp.Model/Step/StepHeader.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepHeader.cs" -// Project: World -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepHeader" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; @@ -39,6 +36,7 @@ namespace StgSharp.Model.Step /// public record class StepInfo { + private STEPFileDescriptor _header = new(); private STEPFileName _name = new(); private STEPSchema _schema = new(); @@ -126,6 +124,7 @@ namespace StgSharp.Model.Step get => _schema.Data; internal set => _schema.Data = value; } + } /// @@ -133,6 +132,7 @@ namespace StgSharp.Model.Step /// public record class STEPFileName { + public DateTime TimeStamp { get; internal set; } public string Name { get; internal set; } @@ -150,13 +150,16 @@ namespace StgSharp.Model.Step public string OriginatingSystem { get; internal set; } public string Authorization { get; internal set; } + } public record class STEPSchema { + private List _schema = new(); public string Data { get; internal set; } + } /// @@ -164,8 +167,10 @@ namespace StgSharp.Model.Step /// public record class STEPFileDescriptor { + public (int mainLevel,int? subLevel) Level { get; internal set; } public string Description { get; internal set; } + } } diff --git a/StgSharp.Model/Step/StepHeaderLineConstructor.cs b/StgSharp.Model/Step/StepHeaderLineConstructor.cs index 3595fa86..216b65c6 100644 --- a/StgSharp.Model/Step/StepHeaderLineConstructor.cs +++ b/StgSharp.Model/Step/StepHeaderLineConstructor.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepHeaderLineConstructor.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepHeaderLineConstructor" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -43,22 +40,22 @@ namespace StgSharp.Model.Step private static Regex regex = new Regex( @"(?.+?(\)|'\s?\)|'))\s?(?,)\s?(?(.|\(|\(\s?').+)", - RegexOptions.Compiled ); + RegexOptions.Compiled); private readonly int _id; private readonly List _paramList; private string _caller; - public StepHeaderLineConstructor( int id, string caller, string parameters ) + public StepHeaderLineConstructor(int id, string caller, string parameters) { _caller = caller; _paramList = new List(); - SplitParameter( parameters ); + SplitParameter(parameters); } - public string this[ int paramIndex ] + public string this[int paramIndex] { - get => _paramList[ paramIndex ]; + get => _paramList[paramIndex]; } public ReadOnlyCollection ParamList @@ -77,24 +74,24 @@ namespace StgSharp.Model.Step internal set => _caller = value; } - public static StepHeaderLineConstructor CreateTempExpression( int id ) + public static StepHeaderLineConstructor CreateTempExpression(int id) { - return new StepHeaderLineConstructor( id, "TEMPCALLER", string.Empty ); + return new StepHeaderLineConstructor(id, "TEMPCALLER", string.Empty); } - private void SplitParameter( string parameters ) + private void SplitParameter(string parameters) { - if( string.IsNullOrEmpty( parameters ) || string.IsNullOrWhiteSpace( parameters ) ) { + if (string.IsNullOrEmpty(parameters) || string.IsNullOrWhiteSpace(parameters)) { return; } - Match match = regex.Match( parameters ); - while( match.Success ) + Match match = regex.Match(parameters); + while (match.Success) { - _paramList.Add( match.Groups[ "param1" ].Value ); - parameters = match.Groups[ "other" ].Value; - match = regex.Match( parameters ); + _paramList.Add(match.Groups["param1"].Value); + parameters = match.Groups["other"].Value; + match = regex.Match(parameters); } - _paramList.Add( parameters ); + _paramList.Add(parameters); } } diff --git a/StgSharp.Model/Step/StepItemType.cs b/StgSharp.Model/Step/StepItemType.cs index 155533ab..9bc56bab 100644 --- a/StgSharp.Model/Step/StepItemType.cs +++ b/StgSharp.Model/Step/StepItemType.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepItemType.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepItemType" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; diff --git a/StgSharp.Model/Step/StepModel.cs b/StgSharp.Model/Step/StepModel.cs index 65563649..c8d8abe6 100644 --- a/StgSharp.Model/Step/StepModel.cs +++ b/StgSharp.Model/Step/StepModel.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepModel.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepModel" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.PipeLine; using StgSharp.Script.Express; @@ -52,89 +49,89 @@ namespace StgSharp.Model.Step private PipelineScheduler _initScheduler = new PipelineScheduler(); private StepInfo _header; - internal StepModel( StepInfo header ) + internal StepModel(StepInfo header) { _header = header; _builder = new PipelineScheduler(); } - public StepEntityBase? this[ int id ] + public StepEntityBase? this[int id] { get { - if( id == 0 ) { + if (id == 0) { return null; } - if( _nodes.TryGetValue( id, out StepEntityBase? node ) ) + if (_nodes.TryGetValue(id, out StepEntityBase? node)) { - if( node is StepUnsupportedEntity ) { + if (node is StepUnsupportedEntity) { throw new StepEntityUnsupportedException(); } return node; } - node = new StepUninitializedEntity( this, id ); - _nodes.Add( id, node ); + node = new StepUninitializedEntity(this, id); + _nodes.Add(id, node); return node; } - private set { _nodes[ id ] = value!; } + private set { _nodes[id] = value!; } } - internal StepEntityBase? this[ ExpSyntaxNode node ] + internal StepEntityBase? this[ExpSyntaxNode node] { get { - if( node is not StepEntityInstanceNode instance ) { + if (node is not StepEntityInstanceNode instance) { throw new InvalidCastException(); } - return this[ instance.Id ]; + return this[instance.Id]; } set { - if( node is not StepEntityInstanceNode instance ) { + if (node is not StepEntityInstanceNode instance) { throw new InvalidCastException(); } - this[ instance.Id ] = value; + this[instance.Id] = value; } } - public void BindValue( ExpSyntaxNode node, Action action ) { } + public void BindValue(ExpSyntaxNode node, Action action) { } - public StepUninitializedEntity FromInitSequence( StepEntityDefineSequence sequence ) + public StepUninitializedEntity FromInitSequence(StepEntityDefineSequence sequence) { - int id = ( sequence.Expression.Left as StepEntityInstanceNode )!.Id; + int id = (sequence.Expression.Left as StepEntityInstanceNode)!.Id; PipelineNode node; - if( _nodes.TryGetValue( id, out StepEntityBase? e ) && e is StepUninitializedEntity u ) + if (_nodes.TryGetValue(id, out StepEntityBase? e) && e is StepUninitializedEntity u) { - u.FromSequence( sequence ); - node = _initScheduler.GetNode( u.Label ); + u.FromSequence(sequence); + node = _initScheduler.GetNode(u.Label); } else { - u = new StepUninitializedEntity( this, id ); - u.FromSequenceUnsafe( sequence ); - _nodes.Add( id, u ); - node = _initScheduler.Create( u.Label, u ); + u = new StepUninitializedEntity(this, id); + u.FromSequenceUnsafe(sequence); + _nodes.Add(id, u); + node = _initScheduler.Create(u.Label, u); } - PipelineNodeInPort port = node.GetInputPort( StepUninitializedEntity.InName ); - if( sequence.Dependencies.Count() == 0 ) + PipelineNodeInPort port = node.GetInputPort(StepUninitializedEntity.InName); + if (sequence.Dependencies.Count() == 0) { - _initScheduler.LinkToInput( port ); + _initScheduler.LinkToInput(port); } else { - foreach( int i in sequence.Dependencies ) + foreach (int i in sequence.Dependencies) { PipelineNode dNode; - StepEntityLabel label = new StepEntityLabel( i ); - if( _nodes.TryGetValue( i, out e ) ) + StepEntityLabel label = new StepEntityLabel(i); + if (_nodes.TryGetValue(i, out e)) { - dNode = _initScheduler.GetNode( label ); + dNode = _initScheduler.GetNode(label); } else { - u = new StepUninitializedEntity( this, i ); - _nodes.Add( i, u ); - dNode = _initScheduler.Create( u.Label, u ); + u = new StepUninitializedEntity(this, i); + _nodes.Add(i, u); + dNode = _initScheduler.Create(u.Label, u); } - port.Connect( dNode.GetOutputPort( StepUninitializedEntity.OutName ) ); + port.Connect(dNode.GetOutputPort(StepUninitializedEntity.OutName)); } } return u; @@ -142,53 +139,49 @@ namespace StgSharp.Model.Step public void InitEntity() { - if( _initScheduler is null ) { + if (_initScheduler is null) { return; } _initScheduler.ArrangeNodes(); - PipeLineRunner.Run( _initScheduler ); + PipeLineRunner.Run(_initScheduler); _initScheduler = null!; } - public void ReplaceEntity( - StepUninitializedEntity uninitialized, - StepEntityBase accurateEntity ) + public void ReplaceEntity(StepUninitializedEntity uninitialized, StepEntityBase accurateEntity) { - ArgumentNullException.ThrowIfNull( uninitialized ); - if( uninitialized.Context != this || accurateEntity.Context != this ) { + ArgumentNullException.ThrowIfNull(uninitialized); + if (uninitialized.Context != this || accurateEntity.Context != this) { throw new InvalidOperationException(); } - if( uninitialized.Id != accurateEntity.Id ) { + if (uninitialized.Id != accurateEntity.Id) { throw new InvalidOperationException(); } - _nodes[ uninitialized.Id ] = accurateEntity; + _nodes[uninitialized.Id] = accurateEntity; } - public string[] ShowStructure( int depth ) + public string[] ShowStructure(int depth) { _initScheduler.ArrangeNodes(); IEnumerable nodes = PipelineMarshal.GetNodeSortedEnumeration( - _initScheduler ); + _initScheduler); int count = 0; - List info = [ - @$"Step model root", - ]; - foreach( PipelineNode node in nodes ) + List info = [ @$"Step model root", ]; + foreach (PipelineNode node in nodes) { count++; - StepUninitializedEntity uncertain = ( node.NodeOperation as StepUninitializedEntity )!; - string[] strings = uncertain.GetEntityDescription( depth - 1 ); - if( count < nodes.Count() ) + StepUninitializedEntity uncertain = (node.NodeOperation as StepUninitializedEntity)!; + string[] strings = uncertain.GetEntityDescription(depth - 1); + if (count < nodes.Count()) { - info.Add( $" ├-{strings[0]}" ); - for( int i = 1; i < strings.Length; i++ ) { - info.Add( $" | {strings[i]}" ); + info.Add($" ├-{strings[0]}"); + for (int i = 1; i < strings.Length; i++) { + info.Add($" | {strings[i]}"); } } else { - info.Add( $" â””-{strings[0]}" ); - for( int i = 1; i < strings.Length; i++ ) { - info.Add( $" {strings[i]}" ); + info.Add($" â””-{strings[0]}"); + for (int i = 1; i < strings.Length; i++) { + info.Add($" {strings[i]}"); } } } diff --git a/StgSharp.Model/Step/StepReader.DataSectionReader.cs b/StgSharp.Model/Step/StepReader.DataSectionReader.cs index 34901113..51728191 100644 --- a/StgSharp.Model/Step/StepReader.DataSectionReader.cs +++ b/StgSharp.Model/Step/StepReader.DataSectionReader.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepReader.DataSectionReader.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepReader.DataSectionReader" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Model.Step; using StgSharp.Script; @@ -53,15 +50,15 @@ namespace StgSharp.Model.Step internal async void ReadDataSection() { - using( MemoryMappedViewStream ms = _memoryFile.CreateViewStream( - 0, _size, MemoryMappedFileAccess.Read ) ) + using (MemoryMappedViewStream ms = _memoryFile.CreateViewStream( + 0, _size, MemoryMappedFileAccess.Read)) { - StreamReader sr = new StreamReader( ms ); + StreamReader sr = new StreamReader(ms); ms.Position = _dataStart; DataTransmitter.Begin = _dataBeginLine; string line; - while( !string.IsNullOrEmpty( line = sr.ReadLine()! ) ) { - DataTransmitter.WriteLine( line ); + while (!string.IsNullOrEmpty(line = sr.ReadLine()!)) { + DataTransmitter.WriteLine(line); } sr.Dispose(); } @@ -69,7 +66,7 @@ namespace StgSharp.Model.Step [GeneratedRegex( @"^#(?[0-9]+)\s*?=\s*?(?\S.*?)\s*;$", - RegexOptions.Compiled | RegexOptions.Singleline )] + RegexOptions.Compiled | RegexOptions.Singleline)] private static partial Regex GetExpressionSplitter(); } diff --git a/StgSharp.Model/Step/StepReader.HeadReader.cs b/StgSharp.Model/Step/StepReader.HeadReader.cs index 25b2b89f..4aba5eed 100644 --- a/StgSharp.Model/Step/StepReader.HeadReader.cs +++ b/StgSharp.Model/Step/StepReader.HeadReader.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepReader.HeadReader.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepReader.HeadReader" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.IO; @@ -48,53 +45,53 @@ namespace StgSharp.Model.Step public StepInfo GetInfo() { - if( _info is not null ) { + if (_info is not null) { return _info; } StepInfo info = new StepInfo(); List constructorList = new List(); - using( MemoryMappedViewStream ms = _memoryFile.CreateViewStream( - 0, _size, MemoryMappedFileAccess.Read ) ) + using (MemoryMappedViewStream ms = _memoryFile.CreateViewStream( + 0, _size, MemoryMappedFileAccess.Read)) { - using( StreamReader sr = new StreamReader( ms ) ) + using (StreamReader sr = new StreamReader(ms)) { long pos = _headStart; - ms.Seek( _headStart, SeekOrigin.Begin ); - while( pos <= _headEnd ) + ms.Seek(_headStart, SeekOrigin.Begin); + while (pos <= _headEnd) { - string token = ReadToken( sr, ref pos ); - if( token == "HEADER;" ) + string token = ReadToken(sr, ref pos); + if (token == "HEADER;") { continue; } - if( token == "ENDSEC;" ) + if (token == "ENDSEC;") { break; } - GroupCollection match = expressionSplitter.Match( token ).Groups; + GroupCollection match = expressionSplitter.Match(token).Groups; constructorList.Add( new StepHeaderLineConstructor( - 0, match[ "CALLER" ].ToString(), match[ "PARAM" ].ToString() ) ); + 0, match["CALLER"].ToString(), match["PARAM"].ToString())); } - foreach( StepHeaderLineConstructor constructor in constructorList ) + foreach (StepHeaderLineConstructor constructor in constructorList) { - switch( constructor.Caller ) + switch (constructor.Caller) { case "FILE_DESCRIPTION": - info.Description = StepDataParser.ToString( constructor[ 0 ] ); - info.Level = StepDataParser.ToVersion( constructor[ 1 ] ); + info.Description = StepDataParser.ToString(constructor[0]); + info.Level = StepDataParser.ToVersion(constructor[1]); break; case "FILE_NAME": - info.Name = StepDataParser.ToString( constructor[ 0 ] ); - info.TimeStamp = StepDataParser.ToDateTime( constructor[ 1 ] ); - info.Author = StepDataParser.ToString( constructor[ 2 ] ); - info.Organization = StepDataParser.ToString( constructor[ 3 ] ); + info.Name = StepDataParser.ToString(constructor[0]); + info.TimeStamp = StepDataParser.ToDateTime(constructor[1]); + info.Author = StepDataParser.ToString(constructor[2]); + info.Organization = StepDataParser.ToString(constructor[3]); info.PreprocessorVersion = StepDataParser.ToString( - constructor[ 4 ] ); - info.OriginatingSystem = StepDataParser.ToString( constructor[ 5 ] ); - info.Authorization = StepDataParser.ToString( constructor[ 6 ] ); + constructor[4]); + info.OriginatingSystem = StepDataParser.ToString(constructor[5]); + info.Authorization = StepDataParser.ToString(constructor[6]); break; default: break; @@ -105,7 +102,7 @@ namespace StgSharp.Model.Step return info; } - [GeneratedRegex( @"^(?[A-Z_]+)\s?\((?.+)\)\;", RegexOptions.Compiled )] + [GeneratedRegex(@"^(?[A-Z_]+)\s?\((?.+)\)\;", RegexOptions.Compiled)] private static partial Regex GetStepHeadExpressionParser(); /**/ diff --git a/StgSharp.Model/Step/StepReader.ToModel.cs b/StgSharp.Model/Step/StepReader.ToModel.cs index 5677670f..0111bc11 100644 --- a/StgSharp.Model/Step/StepReader.ToModel.cs +++ b/StgSharp.Model/Step/StepReader.ToModel.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepReader.ToModel.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepReader.ToModel" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script; using StgSharp.Script.Express; @@ -55,78 +52,77 @@ namespace StgSharp.Model.Step public StepModel ReadToModel() { - if( Model is not null ) { + if (Model is not null) { return Model; } - if( _version != 0 ) { + if (_version != 0) { throw new InvalidOperationException( - "A ReadToModel method has been called and is running now, use Async version instead" ); + "A ReadToModel method has been called and is running now, use Async version instead"); } - Interlocked.Increment( ref _version ); + Interlocked.Increment(ref _version); GetInfo(); - tokenReader = new StepDataTokenReader( DataTransmitter ); + tokenReader = new StepDataTokenReader(DataTransmitter); analyzer = new StepExpSyntaxAnalyzer(); ConcurrentQueue initStatements = analyzer.StepEntityInitStatements; - Task secTask = Task.Run( ReadDataSection ); - Task anTask = Task.Run( ReadStepToken ); - Model = new StepModel( _info ); - while( initStatements.TryDequeue( out StepEntityDefineSequence? statement ) || - !anTask.IsCompleted ) + Task secTask = Task.Run(ReadDataSection); + Task anTask = Task.Run(ReadStepToken); + Model = new StepModel(_info); + while (initStatements.TryDequeue(out StepEntityDefineSequence? statement) || !anTask.IsCompleted) { - if( statement is null ) + if (statement is null) { - Thread.Sleep( 0 ); + Thread.Sleep(0); continue; } - StepUninitializedEntity entity = Model.FromInitSequence( statement ); + StepUninitializedEntity entity = Model.FromInitSequence(statement); } - Task.WaitAll( secTask, anTask ); + Task.WaitAll(secTask, anTask); return Model; } public async Task ReadToModelAsync() { - if( ReadToModelTask is null ) { - ReadToModelTask = Task.Run( ReadToModel ); + if (ReadToModelTask is null) { + ReadToModelTask = Task.Run(ReadToModel); } return await ReadToModelTask; } public StepModel ReadToModelSingleThread() { - if( Model is not null ) { + if (Model is not null) { return Model; } - if( _version != 0 ) { + if (_version != 0) { throw new InvalidOperationException( - "A ReadToModel method has been called and is running now, use Async version instead" ); + "A ReadToModel method has been called and is running now, use Async version instead"); } - Interlocked.Increment( ref _version ); + Interlocked.Increment(ref _version); GetInfo(); - tokenReader = new StepDataTokenReader( DataTransmitter ); + tokenReader = new StepDataTokenReader(DataTransmitter); analyzer = new StepExpSyntaxAnalyzer(); ConcurrentQueue initStatements = analyzer.StepEntityInitStatements; ReadDataSection(); ReadStepToken(); - Model = new StepModel( _info ); - while( initStatements.TryDequeue( out StepEntityDefineSequence? statement ) ) + Model = new StepModel(_info); + while (initStatements.TryDequeue(out StepEntityDefineSequence? statement)) { - if( statement is null ) + if (statement is null) { - Thread.Sleep( 0 ); + Thread.Sleep(0); continue; } - StepUninitializedEntity entity = Model.FromInitSequence( statement ); + StepUninitializedEntity entity = Model.FromInitSequence(statement); } return Model; } private void ReadStepToken() { - while( !tokenReader.IsEmpty ) + while (!tokenReader.IsEmpty) { Token t = tokenReader.ReadToken(); - analyzer.AppendToken( t ); + analyzer.AppendToken(t); } } diff --git a/StgSharp.Model/Step/StepReader.cs b/StgSharp.Model/Step/StepReader.cs index 5346b162..54ce05cb 100644 --- a/StgSharp.Model/Step/StepReader.cs +++ b/StgSharp.Model/Step/StepReader.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepReader.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepReader" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp; using StgSharp.Script; using StgSharp.Script.Express; @@ -58,43 +55,41 @@ namespace StgSharp.Model.Step private StepReader() { } - private StepReader( FileStream stream, long size ) + private StepReader(FileStream stream, long size) { _fileStream = stream; _size = size; _memoryFile = MemoryMappedFile.CreateFromFile( - stream, mapName: null, size, MemoryMappedFileAccess.Read, HandleInheritability.None, - leaveOpen: true ); + stream, mapName:null, size, MemoryMappedFileAccess.Read, HandleInheritability.None, leaveOpen:true); } // ~StepReader() // { - // Dispose(disposing: false); + // Dispose(disposing: false); // } public void Dispose() { - Dispose( disposing: true ); - GC.SuppressFinalize( this ); + Dispose(disposing:true); + GC.SuppressFinalize(this); } - public static bool FromFile( string path, out StepReader reader ) + public static bool FromFile(string path, out StepReader reader) { - FileInfo info = new FileInfo( path ); - if( !info.Exists ) + FileInfo info = new FileInfo(path); + if (!info.Exists) { reader = null!; return false; } FileStream stream = new FileStream( - path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 4096, - useAsync: true ); + path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize:4096, useAsync:true); byte[] fileHead = new byte[40]; - stream.Read( fileHead, 0, fileLabel.Length ); - if( !Encoding.UTF8.GetString( fileHead ).Contains( fileLabel ) ) { - throw new InvalidDataException( "The given file is not a STEP file" ); + stream.Read(fileHead, 0, fileLabel.Length); + if (!Encoding.UTF8.GetString(fileHead).Contains(fileLabel)) { + throw new InvalidDataException("The given file is not a STEP file"); } - reader = new StepReader( stream, info.Length ); + reader = new StepReader(stream, info.Length); reader.LocateSection(); return reader != null; } @@ -104,62 +99,62 @@ namespace StgSharp.Model.Step long startPos = 0; byte[] buffer = new byte[1024]; Span bufferSpan = buffer, - headerSec = Encoding.UTF8.GetBytes( "HEADER;" ), - endsecSec = Encoding.UTF8.GetBytes( "ENDSEC;" ), - dataSec = Encoding.UTF8.GetBytes( "DATA;" ); + headerSec = Encoding.UTF8.GetBytes("HEADER;"), + endsecSec = Encoding.UTF8.GetBytes("ENDSEC;"), + dataSec = Encoding.UTF8.GetBytes("DATA;"); _fileStream.Position = 0; - for( ; startPos < _size; startPos += 1000 ) + for (; startPos < _size; startPos += 1000) { - _fileStream.Read( buffer ); - if( _headStart == -1 ) + _fileStream.Read(buffer); + if (_headStart == -1) { - long pos = bufferSpan.IndexOf( headerSec ); - if( pos >= 0 ) { + long pos = bufferSpan.IndexOf(headerSec); + if (pos >= 0) { _headStart = startPos + pos; } } - if( _headEnd == -1 ) + if (_headEnd == -1) { - long pos = bufferSpan.IndexOf( endsecSec ); - if( pos >= 0 ) { + long pos = bufferSpan.IndexOf(endsecSec); + if (pos >= 0) { _headEnd = startPos + pos; } } - if( _dataStart == -1 ) + if (_dataStart == -1) { - long pos = bufferSpan.IndexOf( dataSec ); - if( pos >= 0 ) { + long pos = bufferSpan.IndexOf(dataSec); + if (pos >= 0) { _dataStart = startPos + pos; } } else { break; } - _fileStream.Seek( 1000, SeekOrigin.Current ); + _fileStream.Seek(1000, SeekOrigin.Current); } } - private string ReadToken( StreamReader reader, ref long posCache ) + private string ReadToken(StreamReader reader, ref long posCache) { - StringBuilder token = new StringBuilder( 100 ); - while( token.Length == 0 || token[ token.Length - 1 ] != ';' ) + StringBuilder token = new StringBuilder(100); + while (token.Length == 0 || token[token.Length - 1] != ';') { string subString = reader.ReadLine()!; - if( subString == null ) + if (subString == null) { break; } - token.Append( subString.TrimStart() ); + token.Append(subString.TrimStart()); } posCache += token.Length; return token.ToString(); } - private protected virtual void Dispose( bool disposing ) + private protected virtual void Dispose(bool disposing) { - if( !disposedValue ) + if (!disposedValue) { - if( disposing ) + if (disposing) { _fileStream.Dispose(); _memoryFile.Dispose(); diff --git a/StgSharp.Model/Step/StepUncertainEntity.Parse.cs b/StgSharp.Model/Step/StepUncertainEntity.Parse.cs index 3625be4a..bf7a7f6a 100644 --- a/StgSharp.Model/Step/StepUncertainEntity.Parse.cs +++ b/StgSharp.Model/Step/StepUncertainEntity.Parse.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepUncertainElement.Parse.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepUncertainEntity.Parse" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script.Express; using System; @@ -41,40 +38,38 @@ namespace StgSharp.Model.Step public partial class StepUninitializedEntity { - private static StepRepresentationItem ConvertSimpleEntity( - StepModel context, - ExpFunctionCallingNode calling ) + private static StepRepresentationItem ConvertSimpleEntity(StepModel context, ExpFunctionCallingNode calling) { string name = calling.FunctionCaller.Name; return name switch { ExpressStepUtil.AdvancedFaceText => StepAdvancedFace.FromSyntax( - context, calling.Right ), + context, calling.Right), ExpressStepUtil.Axis2Placement2DText => StepAxis2Placement2D.FromSyntax( - context, calling.Right ), + context, calling.Right), ExpressStepUtil.Axis2Placement3DText => StepAxis2Placement3D.FromSyntax( - context, calling.Right ), + context, calling.Right), ExpressStepUtil.BSplineCurveWithKnotsText => StepBSplineCurveWithKnots.FromSyntax( - context, calling.Right ), + context, calling.Right), ExpressStepUtil.CartesianPointText => StepCartesianPoint.FromSyntax( - context, calling.Right ), - ExpressStepUtil.CircleText => StepCircle.FromSyntax( context, calling.Right ), + context, calling.Right), + ExpressStepUtil.CircleText => StepCircle.FromSyntax(context, calling.Right), ExpressStepUtil.CylindricalSurfaceText => StepCylindricalSurface.FromSyntax( - context, calling.Right ), - ExpressStepUtil.DirectionText => StepDirection.FromSyntax( context, calling.Right ), - ExpressStepUtil.EdgeCurveText => StepEdgeCurve.FromSyntax( context, calling.Right ), - ExpressStepUtil.EdgeLoopText => StepEdgeLoop.FromSyntax( context, calling.Right ), - ExpressStepUtil.EllipseText => StepEllipse.FromSyntax( context, calling.Right ), - ExpressStepUtil.FaceBoundText => StepFaceBound.FromSyntax( context, calling.Right ), + context, calling.Right), + ExpressStepUtil.DirectionText => StepDirection.FromSyntax(context, calling.Right), + ExpressStepUtil.EdgeCurveText => StepEdgeCurve.FromSyntax(context, calling.Right), + ExpressStepUtil.EdgeLoopText => StepEdgeLoop.FromSyntax(context, calling.Right), + ExpressStepUtil.EllipseText => StepEllipse.FromSyntax(context, calling.Right), + ExpressStepUtil.FaceBoundText => StepFaceBound.FromSyntax(context, calling.Right), ExpressStepUtil.FaceOuterBoundText => StepFaceOuterBound.FromSyntax( - context, calling.Right ), - ExpressStepUtil.LineText => StepLine.FromSyntax( context, calling.Right ), + context, calling.Right), + ExpressStepUtil.LineText => StepLine.FromSyntax(context, calling.Right), ExpressStepUtil.OrientedEdgeText => StepOrientedEdge.FromSyntax( - context, calling.Right ), - ExpressStepUtil.PlaneText => StepPlane.FromSyntax( context, calling.Right ), - ExpressStepUtil.VectorText => StepVector.FromSyntax( context, calling.Right ), + context, calling.Right), + ExpressStepUtil.PlaneText => StepPlane.FromSyntax(context, calling.Right), + ExpressStepUtil.VectorText => StepVector.FromSyntax(context, calling.Right), ExpressStepUtil.VertexPointText => StepVertexPoint.FromSyntax( - context, calling.Right ), + context, calling.Right), _ => throw new StepEntityUnsupportedException() }; } diff --git a/StgSharp.Model/Step/StepUncertainEntity.cs b/StgSharp.Model/Step/StepUncertainEntity.cs index eb29b2b7..454a7722 100644 --- a/StgSharp.Model/Step/StepUncertainEntity.cs +++ b/StgSharp.Model/Step/StepUncertainEntity.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepUncertainEntity.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepUncertainEntity" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Operations; @@ -60,13 +57,13 @@ namespace StgSharp.Model.Step private ExpSyntaxNode _data; - internal StepUninitializedEntity( StepModel model, int id ) + internal StepUninitializedEntity(StepModel model, int id) { Context = model; Id = id; } - internal StepUninitializedEntity( StepModel model, StepEntityLabel label ) + internal StepUninitializedEntity(StepModel model, StepEntityLabel label) { Context = model; Label = label; @@ -76,12 +73,12 @@ namespace StgSharp.Model.Step StepModel model, int id, ExpSyntaxNode initialization, - IEnumerable dependency ) + IEnumerable dependency) { Context = model; Id = id; _data = initialization; - if( dependency == null ) + if (dependency == null) { Dependencies = []; } else @@ -112,38 +109,38 @@ namespace StgSharp.Model.Step } return null; /**/ - if( _data is ExpFunctionCallingNode initNode ) + if (_data is ExpFunctionCallingNode initNode) { string name = initNode.FunctionCaller.Name; - StepEntityBase? entity = ConvertSimpleEntity( Context, initNode ); - if( entity is null ) + StepEntityBase? entity = ConvertSimpleEntity(Context, initNode); + if (entity is null) { - UnsupportedItemTypes.Add( name ); + UnsupportedItemTypes.Add(name); return null; } return entity; - } else if( _data is StepComplexEntityNode complex ) + } else if (_data is StepComplexEntityNode complex) { /**/ - ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator( complex.Right, true ); + ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator(complex.Right, true); StepRepresentationItem entity = null!; - while( enumerator.MoveNext() ) + while (enumerator.MoveNext()) { - if( enumerator.Current is not ExpFunctionCallingNode init ) { + if (enumerator.Current is not ExpFunctionCallingNode init) { throw new InvalidCastException(); } - StepRepresentationItem? e = ConvertSimpleEntity( Context, init ); - if( e is null ) + StepRepresentationItem? e = ConvertSimpleEntity(Context, init); + if (e is null) { - //throw new NotImplementedException( $"Unknown entity type in sequence {Id}" ); + // throw new NotImplementedException( $"Unknown entity type in sequence {Id}" ); return null; } - if( entity is null ) + if (entity is null) { entity = e; } else { - entity = StepDataParser.Implement( entity, e ); + entity = StepDataParser.Implement(entity, e); } } return entity; @@ -151,54 +148,54 @@ namespace StgSharp.Model.Step return null; } else { - throw new ExpInvalidSyntaxException( "Name of entity is required." ); + throw new ExpInvalidSyntaxException("Name of entity is required."); } } - internal void FromSequence( StepEntityDefineSequence sequence ) + internal void FromSequence(StepEntityDefineSequence sequence) { ExpSyntaxNode node = sequence.Expression; - if( node is not ExpBinaryOperatorNode assign ) { - throw new ExpInvalidSyntaxException( "Not an assign expression " ); + if (node is not ExpBinaryOperatorNode assign) { + throw new ExpInvalidSyntaxException("Not an assign expression "); } StepEntityInstanceNode? idNode = assign.Left as StepEntityInstanceNode; - if( idNode!.Id != this.Id ) { + if (idNode!.Id != this.Id) { throw new InvalidOperationException(); } - FromSequenceUnsafe( sequence ); + FromSequenceUnsafe(sequence); } - internal void FromSequenceUnsafe( StepEntityDefineSequence sequence ) + internal void FromSequenceUnsafe(StepEntityDefineSequence sequence) { - ExpSyntaxNode assign = ( sequence.Expression as ExpBinaryOperatorNode )!; + ExpSyntaxNode assign = (sequence.Expression as ExpBinaryOperatorNode)!; ExpSyntaxNode initNode; - if( ( assign.Right is ExpFunctionCallingNode f ) ) + if ((assign.Right is ExpFunctionCallingNode f)) { initNode = assign.Right; ExpEntityTypeName = f.FunctionCaller.Name; - } else if( ( assign.Right is StepComplexEntityNode c ) ) + } else if ((assign.Right is StepComplexEntityNode c)) { initNode = assign.Right; - ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator( c.Right, false ); + ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator(c.Right, false); StringBuilder sb = new StringBuilder(); - sb.Append( "Complex entity initialization: " ); + sb.Append("Complex entity initialization: "); int count = 0; - while( enumerator.MoveNext() ) + while (enumerator.MoveNext()) { - if( count > 0 ) { - sb.Append( " <-> " ); + if (count > 0) { + sb.Append(" <-> "); } - f = ( enumerator.Current as ExpFunctionCallingNode )!; - sb.Append( $"{f.FunctionCaller.Name}" ); + f = (enumerator.Current as ExpFunctionCallingNode)!; + sb.Append($"{f.FunctionCaller.Name}"); count++; } ExpEntityTypeName = sb.ToString(); } else { throw new ExpInvalidSyntaxException( - "Entity init or complex entity define is required." ); + "Entity init or complex entity define is required."); } - if( _data is not null ) { + if (_data is not null) { return; } _data = initNode!; @@ -207,32 +204,32 @@ namespace StgSharp.Model.Step void IConvertableToPipelineNode.NodeMain( in Dictionary input, - in Dictionary output ) + in Dictionary output) { try { StepEntityBase? entity = ConvertToAccurate(); - if( entity is not null ) + if (entity is not null) { - entity.FromInstance( this ); - Context.ReplaceEntity( this, entity ); + entity.FromInstance(this); + Context.ReplaceEntity(this, entity); } } - catch( StepEntityUnsupportedException ) { } - catch( Exception ex ) + catch (StepEntityUnsupportedException) { } + catch (Exception ex) { - throw new Exception( $"Step decoder crashed when building entity {Id}", ex ); + throw new Exception($"Step decoder crashed when building entity {Id}", ex); } - //Context.ReplaceEntity( this, entity ); - PipelineNodeOutPort.SkipAll( output ); + // Context.ReplaceEntity( this, entity ); + PipelineNodeOutPort.SkipAll(output); } - IEnumerable IConvertableToPipelineNode.InputPortName => [InName]; + IEnumerable IConvertableToPipelineNode.InputPortName => [ InName ]; - PipelineNodeOperation IConvertableToPipelineNode.Operation => ( this as IConvertableToPipelineNode ).NodeMain; + PipelineNodeOperation IConvertableToPipelineNode.Operation => (this as IConvertableToPipelineNode).NodeMain; - IEnumerable IConvertableToPipelineNode.OutputPortName => [OutName]; + IEnumerable IConvertableToPipelineNode.OutputPortName => [ OutName ]; } } \ No newline at end of file diff --git a/StgSharp.Model/Step/StepUnsupportedEntity.cs b/StgSharp.Model/Step/StepUnsupportedEntity.cs index 49f4d046..3d491d9c 100644 --- a/StgSharp.Model/Step/StepUnsupportedEntity.cs +++ b/StgSharp.Model/Step/StepUnsupportedEntity.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepUnsupportedEntity.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepUnsupportedEntity" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script.Express; using System; @@ -43,7 +40,7 @@ namespace StgSharp.Model.Step private ExpSyntaxNode _initSequence; - public StepUnsupportedEntity( StepModel model, int id, string name, ExpSyntaxNode sequence ) + public StepUnsupportedEntity(StepModel model, int id, string name, ExpSyntaxNode sequence) { Id = id; Name = name; diff --git a/StgSharp.Model/Step/SyntaxNode/StepComplexEntityNode.cs b/StgSharp.Model/Step/SyntaxNode/StepComplexEntityNode.cs index 3485f04d..5fb191e9 100644 --- a/StgSharp.Model/Step/SyntaxNode/StepComplexEntityNode.cs +++ b/StgSharp.Model/Step/SyntaxNode/StepComplexEntityNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepComplexEntityNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepComplexEntityNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script.Express; using System; @@ -43,8 +40,8 @@ namespace StgSharp.Model.Step private ExpSyntaxNode _begin; - private StepComplexEntityNode( ExpSyntaxNode node ) - : base( node.Source ) + private StepComplexEntityNode(ExpSyntaxNode node) + : base(node.Source) { _begin = node; } @@ -55,12 +52,12 @@ namespace StgSharp.Model.Step public override IExpElementSource EqualityTypeConvert => StepEntityType.Source; - public static StepComplexEntityNode FromTuple( ExpSyntaxNode node ) + public static StepComplexEntityNode FromTuple(ExpSyntaxNode node) { - if( node is not ExpTupleNode tuple ) { - throw new ExpInvalidSyntaxException( "Node to convert is not a complex" ); + if (node is not ExpTupleNode tuple) { + throw new ExpInvalidSyntaxException("Node to convert is not a complex"); } - return new StepComplexEntityNode( tuple.Right ); + return new StepComplexEntityNode(tuple.Right); } } diff --git a/StgSharp.Model/Step/SyntaxNode/StepEntityInitCaller.cs b/StgSharp.Model/Step/SyntaxNode/StepEntityInitCaller.cs index e7e70cdd..35286c97 100644 --- a/StgSharp.Model/Step/SyntaxNode/StepEntityInitCaller.cs +++ b/StgSharp.Model/Step/SyntaxNode/StepEntityInitCaller.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepEntityInitCaller.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepEntityInitCaller" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp.Syntax; using StgSharp.Script; @@ -47,19 +44,19 @@ namespace StgSharp.Model.Step private static Dictionary _callers = new(); - private StepEntityInitCaller( string name ) - : base( name, null ) + private StepEntityInitCaller(string name) + : base(name, null) { ReturningType = StepEntityType.Source; } - public static StepEntityInitCaller CreateCaller( string name ) + public static StepEntityInitCaller CreateCaller(string name) { - if( _callers.TryGetValue( name, out StepEntityInitCaller? caller ) ) { + if (_callers.TryGetValue(name, out StepEntityInitCaller? caller)) { return caller; } - caller = new StepEntityInitCaller( name ); - _callers.Add( name, caller ); + caller = new StepEntityInitCaller(name); + _callers.Add(name, caller); return caller; } diff --git a/StgSharp.Model/Step/SyntaxNode/StepEntityInstanceNode.cs b/StgSharp.Model/Step/SyntaxNode/StepEntityInstanceNode.cs index 88167be8..3ab07423 100644 --- a/StgSharp.Model/Step/SyntaxNode/StepEntityInstanceNode.cs +++ b/StgSharp.Model/Step/SyntaxNode/StepEntityInstanceNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepEntityInstanceNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepEntityInstanceNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Model.Step; using StgSharp.Script; using StgSharp.Script.Express; @@ -44,7 +41,7 @@ namespace StgSharp.Model.Step public class StepEntityInstanceNode : ExpSyntaxNode { - private StepEntityInstanceNode( Token source ) : base( source ) { } + private StepEntityInstanceNode(Token source) : base(source) { } public override ExpSyntaxNode Left => Empty; @@ -54,38 +51,38 @@ namespace StgSharp.Model.Step public int Id { get; init; } - public static StepEntityInstanceNode Register( Token t ) + public static StepEntityInstanceNode Register(Token t) { - if( t.Value[ 0 ] != '#' ) { - throw new ExpInvalidSyntaxException( "Entity label in STEP should be # + number" ); + if (t.Value[0] != '#') { + throw new ExpInvalidSyntaxException("Entity label in STEP should be # + number"); } - StepEntityInstanceNode node = new StepEntityInstanceNode( t ) + StepEntityInstanceNode node = new StepEntityInstanceNode(t) { - Id = int.Parse( t.Value.AsSpan( 1 ) ), + Id = int.Parse(t.Value.AsSpan(1)), }; return node; } - public static StepEntityInstanceNode RegisterNull( Token t ) + public static StepEntityInstanceNode RegisterNull(Token t) { - if( t.Value != "$" ) { + if (t.Value != "$") { throw new ExpInvalidSyntaxException( - $"Token {t.Value} does not represent a null entity" ); + $"Token {t.Value} does not represent a null entity"); } - StepEntityInstanceNode node = new StepEntityInstanceNode( t ) + StepEntityInstanceNode node = new StepEntityInstanceNode(t) { Id = 0, }; return node; } - public static StepEntityInstanceNode RegisterRuntimeInference( Token t ) + public static StepEntityInstanceNode RegisterRuntimeInference(Token t) { - if( t.Value != "*" ) { + if (t.Value != "*") { throw new ExpInvalidSyntaxException( - $"Token {t.Value} does not represent a runtime inferences entity" ); + $"Token {t.Value} does not represent a runtime inferences entity"); } - StepEntityInstanceNode node = new StepEntityInstanceNode( t ) + StepEntityInstanceNode node = new StepEntityInstanceNode(t) { Id = -1, }; @@ -97,9 +94,9 @@ namespace StgSharp.Model.Step internal class StepEntityType : ExpTypeSource { - private StepEntityType( string typeName ) : base( typeName ) { } + private StepEntityType(string typeName) : base(typeName) { } - public static StepEntityType Source { get; } = new StepEntityType( "ENTITY" ); + public static StepEntityType Source { get; } = new StepEntityType("ENTITY"); } } diff --git a/StgSharp.Model/Step/SyntaxNode/StepExpEnumValueNode.cs b/StgSharp.Model/Step/SyntaxNode/StepExpEnumValueNode.cs index 6a649e39..05b98dce 100644 --- a/StgSharp.Model/Step/SyntaxNode/StepExpEnumValueNode.cs +++ b/StgSharp.Model/Step/SyntaxNode/StepExpEnumValueNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="StepExpEnumValueNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="StepExpEnumValueNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script; using StgSharp.Script.Express; @@ -42,8 +39,8 @@ namespace StgSharp.Model.Step internal class StepExpEnumValueNode : ExpSyntaxNode { - public StepExpEnumValueNode( Token source ) - : base( source ) + public StepExpEnumValueNode(Token source) + : base(source) { EnumValue = source.Value; } diff --git a/StgSharp.Script/Common/AbstractSyntaxTree.cs b/StgSharp.Script/Common/AbstractSyntaxTree.cs index 496c2f93..fa58578f 100644 --- a/StgSharp.Script/Common/AbstractSyntaxTree.cs +++ b/StgSharp.Script/Common/AbstractSyntaxTree.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="AbstractSyntaxTree.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="AbstractSyntaxTree" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Collections; using System; @@ -51,9 +48,9 @@ namespace StgSharp.Script public TNode Root => _root; - public bool Contains( TNode node ) + public bool Contains(TNode node) { - return _allToken.Contains( node ); + return _allToken.Contains(node); } } diff --git a/StgSharp.Script/Common/CodeLineHelper.cs b/StgSharp.Script/Common/CodeLineHelper.cs index 676fe6c2..f8d711f1 100644 --- a/StgSharp.Script/Common/CodeLineHelper.cs +++ b/StgSharp.Script/Common/CodeLineHelper.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="CodeLineHelper.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="CodeLineHelper" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; @@ -37,66 +34,66 @@ namespace StgSharp.Script public static class CodeLineHelper { - public static string SliceAndTrim( this string line, int startIndex ) + public static string SliceAndTrim(this string line, int startIndex) { - if( line == null ) { - throw new ArgumentNullException( nameof( line ) ); + if (line == null) { + throw new ArgumentNullException(nameof(line)); } - if( startIndex < 0 || startIndex >= line.Length ) { - throw new ArgumentOutOfRangeException( nameof( startIndex ) ); + if (startIndex < 0 || startIndex >= line.Length) { + throw new ArgumentOutOfRangeException(nameof(startIndex)); } ReadOnlySpan sourceSpan = line.AsSpan(); - ReadOnlySpan subSpan = sourceSpan.Slice( startIndex ); + ReadOnlySpan subSpan = sourceSpan.Slice(startIndex); int start = 0; - while( start < subSpan.Length && char.IsWhiteSpace( subSpan[ start ] ) ) { + while (start < subSpan.Length && char.IsWhiteSpace(subSpan[start])) { start++; } int end = subSpan.Length - 1; - while( end >= start && char.IsWhiteSpace( subSpan[ end ] ) ) { + while (end >= start && char.IsWhiteSpace(subSpan[end])) { end--; } - if( start > end ) { + if (start > end) { return string.Empty; } int finalLength = end - start + 1; - return new string( subSpan.Slice( start, finalLength ) ); + return new string(subSpan.Slice(start, finalLength)); } - public static string SliceAndTrim( this string line, int startIndex, int length ) + public static string SliceAndTrim(this string line, int startIndex, int length) { - if( line == null ) { - throw new ArgumentNullException( nameof( line ) ); + if (line == null) { + throw new ArgumentNullException(nameof(line)); } - if( startIndex < 0 || startIndex >= line.Length ) { - throw new ArgumentOutOfRangeException( nameof( startIndex ) ); + if (startIndex < 0 || startIndex >= line.Length) { + throw new ArgumentOutOfRangeException(nameof(startIndex)); } - if( length < 0 || startIndex + length > line.Length ) { - throw new ArgumentOutOfRangeException( nameof( length ) ); + if (length < 0 || startIndex + length > line.Length) { + throw new ArgumentOutOfRangeException(nameof(length)); } ReadOnlySpan sourceSpan = line.AsSpan(); - ReadOnlySpan subSpan = sourceSpan.Slice( startIndex, length ); + ReadOnlySpan subSpan = sourceSpan.Slice(startIndex, length); int start = 0; - while( start < subSpan.Length && char.IsWhiteSpace( subSpan[ start ] ) ) { + while (start < subSpan.Length && char.IsWhiteSpace(subSpan[start])) { start++; } int end = subSpan.Length - 1; - while( end >= start && char.IsWhiteSpace( subSpan[ end ] ) ) { + while (end >= start && char.IsWhiteSpace(subSpan[end])) { end--; } - if( start > end ) { + if (start > end) { return string.Empty; } int finalLength = end - start + 1; - return new string( subSpan.Slice( start, finalLength ) ); + return new string(subSpan.Slice(start, finalLength)); } } diff --git a/StgSharp.Script/Common/CompileDepthState.cs b/StgSharp.Script/Common/CompileDepthState.cs index dab93a61..8f071b0a 100644 --- a/StgSharp.Script/Common/CompileDepthState.cs +++ b/StgSharp.Script/Common/CompileDepthState.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="CompileDepthState.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="CompileDepthState" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Data; @@ -47,18 +44,14 @@ namespace StgSharp.Script public class CompileDepthMark { - internal CompileDepthMark( int operatorBegin, int operandBegin, int usage ) + internal CompileDepthMark(int operatorBegin, int operandBegin, int usage) { OperatorBegin = operatorBegin; OperandBegin = operandBegin; Usage = usage; } - internal CompileDepthMark( - int operatorBegin, - int operandBegin, - int usage, - ICompileDepthState stateCache ) + internal CompileDepthMark(int operatorBegin, int operandBegin, int usage, ICompileDepthState stateCache) { OperatorBegin = operatorBegin; OperandBegin = operandBegin; diff --git a/StgSharp.Script/Common/CompileStack.cs b/StgSharp.Script/Common/CompileStack.cs index 31ee35b6..052d0680 100644 --- a/StgSharp.Script/Common/CompileStack.cs +++ b/StgSharp.Script/Common/CompileStack.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="CompileStack.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="CompileStack" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Collections; using System; @@ -55,14 +52,14 @@ namespace StgSharp.Script ); private RandomAccessibleStack _isNode = new RandomAccessibleStack( - 8 ); + 8); private Stack> _statementCache = new Stack>(); private TNode _lastNode; public CompileStack() { - _depthStack.Push( new CompileDepthMark( 0, 0, 0, null! ) ); - _statementCache.Push( new Stack() ); + _depthStack.Push(new CompileDepthMark(0, 0, 0, null!)); + _statementCache.Push(new Stack()); } public bool IsLastAddedOperator { get; private set; } @@ -99,86 +96,82 @@ namespace StgSharp.Script Stack statementsInDepth = _statementCache.Pop(); } - public bool GetOperandAt( Index i, out TNode operandNode, out Token operandToken ) + public bool GetOperandAt(Index i, out TNode operandNode, out Token operandToken) { - OperandIndex index = _isNode[ i ]; - if( index.IsNode ) + OperandIndex index = _isNode[i]; + if (index.IsNode) { - operandNode = _nodeArray[ index.Index ]; + operandNode = _nodeArray[index.Index]; operandToken = Token.Empty; return true; } else { - operandToken = _tokenArray[ index.Index ]; + operandToken = _tokenArray[index.Index]; operandNode = default!; return false; } } - public bool GetOperandAt( - CompileDepthMark depth, - Index i, - out Token operandToken, - out TNode operandNode ) + public bool GetOperandAt(CompileDepthMark depth, Index i, out Token operandToken, out TNode operandNode) { - OperandIndex index = _isNode[ i ]; + OperandIndex index = _isNode[i]; - _depthStack.Contains( depth ); - if( index.IsNode ) + _depthStack.Contains(depth); + if (index.IsNode) { - operandNode = _nodeArray[ index.Index ]; + operandNode = _nodeArray[index.Index]; operandToken = Token.Empty; return true; } else { - operandToken = _tokenArray[ index.Index ]; + operandToken = _tokenArray[index.Index]; operandNode = default!; return false; } } - public CompileDepthMark IncreaseDepth( int usage ) + public CompileDepthMark IncreaseDepth(int usage) { CompileDepthMark mark = - new CompileDepthMark( OperatorCount, OperandCount, usage ); + new CompileDepthMark(OperatorCount, OperandCount, usage); - _depthStack.Push( mark ); - _statementCache.Push( new Stack() ); + _depthStack.Push(mark); + _statementCache.Push(new Stack()); return mark; } public TNode PackAllStatements() { - if( StatementsInDepth.Count == 0 ) { + if (StatementsInDepth.Count == 0) { return TNode.Empty; } TNode end = StatementsInDepth.Peek(); TNode first = end; - while( StatementsInDepth.Count > 0 ) + while (StatementsInDepth.Count > 0) { first = StatementsInDepth.Pop(); - end.PrependNode( first ); + end.PrependNode(first); end = first; } return first; } - public bool PeekOperand( out Token t, out TNode n ) + public bool PeekOperand(out Token t, out TNode n) { - if( OperandAheadOfDepth <= 0 ) + if (OperandAheadOfDepth <= 0) { t = Token.Empty; n = TNode.Empty; return false; } - if( _isNode.Pop().IsNode ) + if (_isNode.Pop().IsNode) { t = Token.Empty; - n = _nodeArray[ _nodeCount - 1 ]; + n = _nodeArray[_nodeCount - 1]; return true; } else { - t = _tokenArray[ _tokenCount - 1 ]; + t = _tokenArray[_tokenCount - 1]; n = TNode.Empty; return false; } @@ -186,28 +179,28 @@ namespace StgSharp.Script public Token PeekOperator() { - if( OperatorAheadOfDepth > 0 ) { - return _operatorArray[ _operatorCount - 1 ]; + if (OperatorAheadOfDepth > 0) { + return _operatorArray[_operatorCount - 1]; } return Token.Empty; } - public bool PopOperand( out Token t, out TNode n ) + public bool PopOperand(out Token t, out TNode n) { - if( OperandAheadOfDepth <= 0 ) + if (OperandAheadOfDepth <= 0) { t = Token.Empty; n = TNode.Empty; return false; } - if( _isNode.Pop().IsNode ) + if (_isNode.Pop().IsNode) { t = Token.Empty; - n = _nodeArray[ --_nodeCount ]; + n = _nodeArray[--_nodeCount]; return true; } else { - t = _tokenArray[ --_tokenCount ]; + t = _tokenArray[--_tokenCount]; n = TNode.Empty; return false; } @@ -215,122 +208,122 @@ namespace StgSharp.Script public Token PopOperator() { - if( OperatorAheadOfDepth > 0 ) + if (OperatorAheadOfDepth > 0) { _operatorCount--; - return _operatorArray[ _operatorCount ]; + return _operatorArray[_operatorCount]; } return Token.Empty; } - public void PushOperand( TNode node ) + public void PushOperand(TNode node) { - if( _nodeArray.Length == _nodeCount ) { - Array.Resize( ref _nodeArray, _nodeArray.Length * 2 ); + if (_nodeArray.Length == _nodeCount) { + Array.Resize(ref _nodeArray, _nodeArray.Length * 2); } - _nodeArray[ _nodeCount ] = node; - _isNode.Push( new( true, _nodeCount ) ); + _nodeArray[_nodeCount] = node; + _isNode.Push(new(true, _nodeCount)); _nodeCount++; IsLastAddedOperator = false; } - public void PushOperand( Token token ) + public void PushOperand(Token token) { - if( _tokenArray.Length == _tokenCount ) { - Array.Resize( ref _tokenArray, _tokenArray.Length * 2 ); + if (_tokenArray.Length == _tokenCount) { + Array.Resize(ref _tokenArray, _tokenArray.Length * 2); } - _tokenArray[ _tokenCount ] = token; - _isNode.Push( new( false, _tokenCount ) ); + _tokenArray[_tokenCount] = token; + _isNode.Push(new(false, _tokenCount)); _tokenCount++; IsLastAddedOperator = false; } - public void PushOperator( Token token ) + public void PushOperator(Token token) { - if( _operatorArray.Length == _operatorCount ) { - Array.Resize( ref _operatorArray, _operatorArray.Length * 2 ); + if (_operatorArray.Length == _operatorCount) { + Array.Resize(ref _operatorArray, _operatorArray.Length * 2); } - _operatorArray[ _operatorCount ] = token; + _operatorArray[_operatorCount] = token; _operatorCount++; IsLastAddedOperator = true; } public T StateOfCurrentDepth() where T: class, ICompileDepthState { - return ( CurrentDepthMark.StateCache as T )!; + return (CurrentDepthMark.StateCache as T)!; } - public bool TryPeekOperand( out bool isNode, out Token t, out TNode n ) + public bool TryPeekOperand(out bool isNode, out Token t, out TNode n) { - if( OperandAheadOfDepth <= 0 ) + if (OperandAheadOfDepth <= 0) { t = Token.Empty; n = TNode.Empty; isNode = false; return false; } - if( _isNode.Pop().IsNode ) + if (_isNode.Pop().IsNode) { t = Token.Empty; - n = _nodeArray[ _nodeCount - 1 ]; + n = _nodeArray[_nodeCount - 1]; isNode = true; return true; } else { - t = _tokenArray[ _tokenCount - 1 ]; + t = _tokenArray[_tokenCount - 1]; n = TNode.Empty; isNode = false; return false; } } - public bool TryPeekOperator( out Token op ) + public bool TryPeekOperator(out Token op) { - if( OperatorAheadOfDepth > 0 ) + if (OperatorAheadOfDepth > 0) { - op = _operatorArray[ _operatorCount - 1 ]; + op = _operatorArray[_operatorCount - 1]; return true; } op = Token.Empty; return false; } - public bool TryPopOperand( out bool isNode, out Token t, out TNode n ) + public bool TryPopOperand(out bool isNode, out Token t, out TNode n) { - if( OperandAheadOfDepth <= 0 ) + if (OperandAheadOfDepth <= 0) { t = Token.Empty; n = TNode.Empty; isNode = false; return false; } - if( _isNode.Pop().IsNode ) + if (_isNode.Pop().IsNode) { t = Token.Empty; - n = _nodeArray[ --_nodeCount ]; + n = _nodeArray[--_nodeCount]; isNode = true; return true; } else { - t = _tokenArray[ --_tokenCount ]; + t = _tokenArray[--_tokenCount]; n = TNode.Empty; isNode = false; return true; } } - public bool TryPopOperator( out Token op ) + public bool TryPopOperator(out Token op) { - if( OperatorAheadOfDepth > 0 ) + if (OperatorAheadOfDepth > 0) { - op = _operatorArray[ --_operatorCount ]; + op = _operatorArray[--_operatorCount]; return true; } op = Token.Empty; return false; } - private record struct OperandIndex( bool IsNode, int Index ); + private record struct OperandIndex(bool IsNode, int Index); } } diff --git a/StgSharp.Script/Common/IScriptSourceProvider.cs b/StgSharp.Script/Common/IScriptSourceProvider.cs index 380d5ee7..fe1c4ba1 100644 --- a/StgSharp.Script/Common/IScriptSourceProvider.cs +++ b/StgSharp.Script/Common/IScriptSourceProvider.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="IScriptSourceProvider.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="IScriptSourceProvider" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; @@ -45,7 +42,7 @@ namespace StgSharp.Script string ReadLine(); - string ReadLine( out int position ); + string ReadLine(out int position); /// /// Return part of current provider. @@ -56,7 +53,7 @@ namespace StgSharp.Script /// /// /// - public IScriptSourceProvider Slice( int location, int count ); + public IScriptSourceProvider Slice(int location, int count); } } diff --git a/StgSharp.Script/Common/IScriptTokenReader.cs b/StgSharp.Script/Common/IScriptTokenReader.cs index 88a3b380..18fc83d7 100644 --- a/StgSharp.Script/Common/IScriptTokenReader.cs +++ b/StgSharp.Script/Common/IScriptTokenReader.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="IScriptTokenReader.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="IScriptTokenReader" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- namespace StgSharp.Script { public interface IScriptTokenReader @@ -37,7 +34,7 @@ namespace StgSharp.Script Token ReadToken(); - bool TryReadToken( out Token t ); + bool TryReadToken(out Token t); } } \ No newline at end of file diff --git a/StgSharp.Script/Common/ISyntaxAnalyzer.cs b/StgSharp.Script/Common/ISyntaxAnalyzer.cs index 67f85156..2f28c33d 100644 --- a/StgSharp.Script/Common/ISyntaxAnalyzer.cs +++ b/StgSharp.Script/Common/ISyntaxAnalyzer.cs @@ -1,39 +1,36 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ISyntaxAnalyzer.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ISyntaxAnalyzer" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- namespace StgSharp.Script { public interface ISyntaxAnalyzer { - void AppendToken( Token t ); + void AppendToken(Token t); } } \ No newline at end of file diff --git a/StgSharp.Script/Common/ISyntaxNode.cs b/StgSharp.Script/Common/ISyntaxNode.cs index 6f82f810..bebf0fb6 100644 --- a/StgSharp.Script/Common/ISyntaxNode.cs +++ b/StgSharp.Script/Common/ISyntaxNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ISyntaxNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ISyntaxNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Collections; using StgSharp.Script.Express; @@ -39,8 +36,7 @@ using System.Text; namespace StgSharp.Script { - public interface ISyntaxNode where TNode: ISyntaxNode - where TType: ITypeSource + public interface ISyntaxNode where TNode: ISyntaxNode where TType: ITypeSource { long NodeFlag { get; } @@ -61,9 +57,9 @@ namespace StgSharp.Script TType EqualityTypeConvert { get; } - void AppendNode( TNode nextToken ); + void AppendNode(TNode nextToken); - void PrependNode( TNode previusNode ); + void PrependNode(TNode previusNode); } } diff --git a/StgSharp.Script/Common/ITypeSource.cs b/StgSharp.Script/Common/ITypeSource.cs index 89c57014..ebae3eec 100644 --- a/StgSharp.Script/Common/ITypeSource.cs +++ b/StgSharp.Script/Common/ITypeSource.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ITypeSource.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ITypeSource" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -39,7 +36,7 @@ namespace StgSharp.Script public interface ITypeSource where TConvert: ITypeSource { - bool IsConvertable( TConvert targetType ); + bool IsConvertable(TConvert targetType); } } diff --git a/StgSharp.Script/Common/ScriptSourceTransmitter.cs b/StgSharp.Script/Common/ScriptSourceTransmitter.cs index 7a4007eb..3778ea37 100644 --- a/StgSharp.Script/Common/ScriptSourceTransmitter.cs +++ b/StgSharp.Script/Common/ScriptSourceTransmitter.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ScriptSourceTransmitter.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ScriptSourceTransmitter" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Concurrent; @@ -46,7 +43,7 @@ namespace StgSharp.Script { private static ScriptSourceTransmitter _empty = new ScriptSourceTransmitter( - string.Empty, 0, 0 ) + string.Empty, 0, 0) { _cache = [], _buffer = [] @@ -58,14 +55,14 @@ namespace StgSharp.Script private List _cache; private readonly string _completeMark; - internal ScriptSourceTransmitter( string[] buffer, int start ) + internal ScriptSourceTransmitter(string[] buffer, int start) { _buffer = buffer; _begin = start; _isWriting = false; } - public ScriptSourceTransmitter( string endMark, int start ) + public ScriptSourceTransmitter(string endMark, int start) { _cache = new List(); _completeMark = endMark; @@ -73,16 +70,15 @@ namespace StgSharp.Script _index = 0; } - public ScriptSourceTransmitter( string endMark, int start, int capacity ) + public ScriptSourceTransmitter(string endMark, int start, int capacity) { - _cache = new List( capacity ); + _cache = new List(capacity); _completeMark = endMark; _begin = start; _index = 0; } - public bool IsEmpty => _isWriting ? - ( _cache.Count == 0 ) : ( _buffer.Length == 0 ) || ( _index >= _buffer.Length ); + public bool IsEmpty => _isWriting ? (_cache.Count == 0) : (_buffer.Length == 0) || (_index >= _buffer.Length); public bool IsFrozen => !_isWriting; @@ -92,7 +88,7 @@ namespace StgSharp.Script public void EndWriting() { - if( !_isWriting ) { + if (!_isWriting) { return; } _isWriting = false; @@ -102,53 +98,53 @@ namespace StgSharp.Script public string ReadLine() { - if( _isWriting ) { - throw new InvalidOperationException( "Cannot read before all writing operation." ); + if (_isWriting) { + throw new InvalidOperationException("Cannot read before all writing operation."); } - if( _index >= _buffer.Length ) { + if (_index >= _buffer.Length) { return string.Empty; } - string str = _buffer[ _index ]; + string str = _buffer[_index]; _index++; return str; } - public string ReadLine( out int position ) + public string ReadLine(out int position) { - if( _isWriting ) { - throw new InvalidOperationException( "Cannot read before all writing operation." ); + if (_isWriting) { + throw new InvalidOperationException("Cannot read before all writing operation."); } - if( _index >= _buffer.Length ) + if (_index >= _buffer.Length) { position = -1; return string.Empty; } position = _begin + _index; - string str = _buffer[ _index ]; + string str = _buffer[_index]; _index++; return str; } - public IScriptSourceProvider Slice( int location, int count ) + public IScriptSourceProvider Slice(int location, int count) { - ArgumentOutOfRangeException.ThrowIfLessThan( location, _begin ); + ArgumentOutOfRangeException.ThrowIfLessThan(location, _begin); ArgumentOutOfRangeException.ThrowIfGreaterThan( - location + count, _begin + _buffer.Length ); + location + count, _begin + _buffer.Length); return new ScriptSourceTransmitter( - _buffer.AsSpan().Slice( location, count ).ToArray(), location ); + _buffer.AsSpan().Slice(location, count).ToArray(), location); } - public void WriteLine( string line ) + public void WriteLine(string line) { - if( !_isWriting ) { + if (!_isWriting) { return; } - if( string.Equals( _completeMark, line ) ) + if (string.Equals(_completeMark, line)) { EndWriting(); return; } - _cache.Add( line ); + _cache.Add(line); } } diff --git a/StgSharp.Script/Common/Token.cs b/StgSharp.Script/Common/Token.cs index 3535722b..9e382fc6 100644 --- a/StgSharp.Script/Common/Token.cs +++ b/StgSharp.Script/Common/Token.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="Token.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="Token" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -47,7 +44,7 @@ namespace StgSharp.Script public readonly string Value; public readonly TokenFlag Flag; - public Token( string chars, int lineNumber, int columnNumber, TokenFlag flag ) + public Token(string chars, int lineNumber, int columnNumber, TokenFlag flag) { Value = chars; Line = lineNumber; @@ -57,10 +54,10 @@ namespace StgSharp.Script public static Token Empty => EmptyToken; - [MethodImpl( MethodImplOptions.AggressiveInlining )] - public Token ReLocate( int line, int column ) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Token ReLocate(int line, int column) { - return new Token( Value, line, column, Flag ); + return new Token(Value, line, column, Flag); } } diff --git a/StgSharp.Script/Express/Builtin/ExpBuiltinType.cs b/StgSharp.Script/Express/Builtin/ExpBuiltinType.cs index a4c4cf7f..ffa350c8 100644 --- a/StgSharp.Script/Express/Builtin/ExpBuiltinType.cs +++ b/StgSharp.Script/Express/Builtin/ExpBuiltinType.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpBuiltinType.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpBuiltinType" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Data; using System; @@ -41,8 +38,8 @@ namespace StgSharp.Script.Express private Type _marshalType; - internal ExpBuiltinType( string name, Type origin ) - : base( name, ScriptSourceTransmitter.Empty ) + internal ExpBuiltinType(string name, Type origin) + : base(name, ScriptSourceTransmitter.Empty) { _marshalType = origin; } @@ -52,7 +49,7 @@ namespace StgSharp.Script.Express return; } - //A method convert value to CLR type - //Used for direct running rather than compiling to C# code. + // A method convert value to CLR type + // Used for direct running rather than compiling to C# code. } } diff --git a/StgSharp.Script/Express/Builtin/ExpCollection.cs b/StgSharp.Script/Express/Builtin/ExpCollection.cs index 3a66ccb2..bfb7a7c1 100644 --- a/StgSharp.Script/Express/Builtin/ExpCollection.cs +++ b/StgSharp.Script/Express/Builtin/ExpCollection.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpCollection.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpCollection" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Concurrent; @@ -42,7 +39,7 @@ namespace StgSharp.Script.Express protected internal string _accurateType; - protected ExpCollectionBase( string accurateType ) + protected ExpCollectionBase(string accurateType) { _accurateType = accurateType; } @@ -51,7 +48,7 @@ namespace StgSharp.Script.Express public abstract int Count { get; } - public override sealed IScriptSourceProvider SourceProvider => ScriptSourceTransmitter.Empty; + public sealed override IScriptSourceProvider SourceProvider => ScriptSourceTransmitter.Empty; public string MemberType { @@ -65,7 +62,7 @@ namespace StgSharp.Script.Express public abstract IEnumerator GetEnumerator(); - public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) + public override bool TryGetMember(string name, out ExpSyntaxNode memberNode) { memberNode = ExpSyntaxNode.Empty; return false; @@ -83,32 +80,32 @@ namespace StgSharp.Script.Express private ExpElementInstance[] _collection; - public ExpArray( string accurateType ) : base( accurateType ) { } + public ExpArray(string accurateType) : base(accurateType) { } - public ExpElementInstance this[ int index ] + public ExpElementInstance this[int index] { - get { return _collection[ index ]; } + get { return _collection[index]; } set { - if( value.TypeName != MemberType ) { - throw new ExpInvalidCollectionMemberTypeException( value, this ); + if (value.TypeName != MemberType) { + throw new ExpInvalidCollectionMemberTypeException(value, this); } - _collection[ index ] = value; + _collection[index] = value; } } public override int Count => _collection.Length; - public override string Name => ExpressCompile.PoolString( "ARRAY" ); + public override string Name => ExpressCompile.PoolString("ARRAY"); - public override ExpSyntaxNode CreateInstanceNode( Token t ) + public override ExpSyntaxNode CreateInstanceNode(Token t) { throw new NotImplementedException(); } public override IEnumerator GetEnumerator() { - return ( ( IEnumerable )_collection ) + return ((IEnumerable)_collection) .GetEnumerator(); } @@ -120,13 +117,13 @@ namespace StgSharp.Script.Express private ConcurrentBag _collection = new ConcurrentBag( ); - public ExpBag( string accurateType ) : base( accurateType ) { } + public ExpBag(string accurateType) : base(accurateType) { } public override int Count => _collection.Count; - public override string Name => ExpressCompile.PoolString( "BAG" ); + public override string Name => ExpressCompile.PoolString("BAG"); - public override ExpSyntaxNode CreateInstanceNode( Token t ) + public override ExpSyntaxNode CreateInstanceNode(Token t) { throw new NotImplementedException(); } @@ -143,13 +140,13 @@ namespace StgSharp.Script.Express private List _collection = new List(); - public ExpList( string accurateType ) : base( accurateType ) { } + public ExpList(string accurateType) : base(accurateType) { } public override int Count => _collection.Count; - public override string Name => ExpressCompile.PoolString( "LIST" ); + public override string Name => ExpressCompile.PoolString("LIST"); - public override ExpSyntaxNode CreateInstanceNode( Token t ) + public override ExpSyntaxNode CreateInstanceNode(Token t) { throw new NotImplementedException(); } @@ -166,28 +163,28 @@ namespace StgSharp.Script.Express private HashSet _collection = new(); - public ExpSet( string accurateType ) : base( accurateType ) { } + public ExpSet(string accurateType) : base(accurateType) { } public override int Count => _collection.Count; - public override string Name => ExpressCompile.PoolString( "SET" ); + public override string Name => ExpressCompile.PoolString("SET"); - public void Add( ExpElementInstance token ) + public void Add(ExpElementInstance token) { - if( token.TypeName != MemberType ) { - throw new ExpInvalidCollectionMemberTypeException( token, this ); + if (token.TypeName != MemberType) { + throw new ExpInvalidCollectionMemberTypeException(token, this); } - _collection.Add( token ); + _collection.Add(token); } - public override ExpSyntaxNode CreateInstanceNode( Token t ) + public override ExpSyntaxNode CreateInstanceNode(Token t) { throw new NotImplementedException(); } - public override sealed IEnumerator GetEnumerator() + public sealed override IEnumerator GetEnumerator() { - return ( ( IEnumerable )_collection ) + return ((IEnumerable)_collection) .GetEnumerator(); } diff --git a/StgSharp.Script/Express/Builtin/ExpCollectionInstance.cs b/StgSharp.Script/Express/Builtin/ExpCollectionInstance.cs index a0715763..59035ea0 100644 --- a/StgSharp.Script/Express/Builtin/ExpCollectionInstance.cs +++ b/StgSharp.Script/Express/Builtin/ExpCollectionInstance.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpCollectionInstance.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpCollectionInstance" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; @@ -40,7 +37,7 @@ namespace StgSharp.Script.Express protected internal (int min, int max) _range; protected internal ExpElementType _memberType; - protected ExpCollectionInstanceBase( Token source ) : base( source ) { } + protected ExpCollectionInstanceBase(Token source) : base(source) { } public abstract ExpCollectionBase CollectionValue { get; } @@ -64,8 +61,8 @@ namespace StgSharp.Script.Express private ExpSet _collection; - public ExpSetInstance( Token source, ExpSet set ) - : base( source ) + public ExpSetInstance(Token source, ExpSet set) + : base(source) { _collection = set; } @@ -82,8 +79,8 @@ namespace StgSharp.Script.Express private ExpBag _collection; - public ExpBagInstance( Token source, ExpBag bag ) - : base( source ) + public ExpBagInstance(Token source, ExpBag bag) + : base(source) { _collection = bag; } @@ -100,8 +97,8 @@ namespace StgSharp.Script.Express private ExpList _collection; - public ExpListInstance( Token source, ExpList list ) - : base( source ) + public ExpListInstance(Token source, ExpList list) + : base(source) { _collection = list; } @@ -118,8 +115,8 @@ namespace StgSharp.Script.Express private ExpArray _collection; - public ExpArrayInstance( Token source, ExpArray array ) - : base( source ) + public ExpArrayInstance(Token source, ExpArray array) + : base(source) { _collection = array; } diff --git a/StgSharp.Script/Express/Builtin/ExpLogic.cs b/StgSharp.Script/Express/Builtin/ExpLogic.cs index fa4a64ce..a833f2c1 100644 --- a/StgSharp.Script/Express/Builtin/ExpLogic.cs +++ b/StgSharp.Script/Express/Builtin/ExpLogic.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpLogic.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpLogic" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Runtime.CompilerServices; @@ -47,14 +44,14 @@ namespace StgSharp.Script.Express public struct ExpLogic { - public static readonly ExpLogic False = new ExpLogic( ExpLogicValue.False ); + public static readonly ExpLogic False = new ExpLogic(ExpLogicValue.False); - public static readonly ExpLogic True = new ExpLogic( ExpLogicValue.True ); - public static readonly ExpLogic Unknown = new ExpLogic( ExpLogicValue.Unknown ); + public static readonly ExpLogic True = new ExpLogic(ExpLogicValue.True); + public static readonly ExpLogic Unknown = new ExpLogic(ExpLogicValue.Unknown); private readonly ExpLogicValue _value; - public ExpLogic( ExpLogicValue value ) + public ExpLogic(ExpLogicValue value) { _value = value; } @@ -65,7 +62,7 @@ namespace StgSharp.Script.Express public bool IsUnknown => _value == ExpLogicValue.Unknown; - [MethodImpl( MethodImplOptions.AggressiveInlining )] + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool ToBoolean() { return _value == ExpLogicValue.True; @@ -73,11 +70,11 @@ namespace StgSharp.Script.Express public override string ToString() => _value.ToString(); - public static bool TryParse( ReadOnlySpan value, out ExpLogic result ) + public static bool TryParse(ReadOnlySpan value, out ExpLogic result) { - if( Enum.TryParse( value, out ExpLogicValue e ) ) + if (Enum.TryParse(value, out ExpLogicValue e)) { - result = new ExpLogic( e ); + result = new ExpLogic(e); return true; } result = default; @@ -85,19 +82,19 @@ namespace StgSharp.Script.Express } // NOT ! - public static ExpLogic operator !( ExpLogic a ) + public static ExpLogic operator !(ExpLogic a) { return a.IsTrue ? False : a.IsFalse ? True : Unknown; } // AND & - public static ExpLogic operator &( ExpLogic a, ExpLogic b ) + public static ExpLogic operator &(ExpLogic a, ExpLogic b) { - if( a.IsFalse || b.IsFalse ) { + if (a.IsFalse || b.IsFalse) { return False; } - if( a.IsUnknown || b.IsUnknown ) { + if (a.IsUnknown || b.IsUnknown) { return Unknown; } @@ -105,23 +102,23 @@ namespace StgSharp.Script.Express } // XOR ^ - public static ExpLogic operator ^( ExpLogic a, ExpLogic b ) + public static ExpLogic operator ^(ExpLogic a, ExpLogic b) { - if( a.IsUnknown || b.IsUnknown ) { + if (a.IsUnknown || b.IsUnknown) { return Unknown; } - return ( a.IsTrue ^ b.IsTrue ) ? True : False; + return (a.IsTrue ^ b.IsTrue) ? True : False; } // OR | - public static ExpLogic operator |( ExpLogic a, ExpLogic b ) + public static ExpLogic operator |(ExpLogic a, ExpLogic b) { - if( a.IsTrue || b.IsTrue ) { + if (a.IsTrue || b.IsTrue) { return True; } - if( a.IsUnknown || b.IsUnknown ) { + if (a.IsUnknown || b.IsUnknown) { return Unknown; } diff --git a/StgSharp.Script/Express/CompileEnv/BuiltinType.cs b/StgSharp.Script/Express/CompileEnv/BuiltinType.cs index 7b036980..0731a975 100644 --- a/StgSharp.Script/Express/CompileEnv/BuiltinType.cs +++ b/StgSharp.Script/Express/CompileEnv/BuiltinType.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="BuiltinType.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="BuiltinType" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; diff --git a/StgSharp.Script/Express/CompileEnv/DefaultSchema.cs b/StgSharp.Script/Express/CompileEnv/DefaultSchema.cs index d4c06811..de7d860e 100644 --- a/StgSharp.Script/Express/CompileEnv/DefaultSchema.cs +++ b/StgSharp.Script/Express/CompileEnv/DefaultSchema.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="DefaultSchema.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="DefaultSchema" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Frozen; @@ -54,80 +51,72 @@ namespace StgSharp.Script.Express get => _onlyInstance; } - public override void LoadFromSource( ExpSchemaSource source ) + public override void LoadFromSource(ExpSchemaSource source) { return; } - public override bool TryGetConst( string name, out ExpElementInstance c ) + public override bool TryGetConst(string name, out ExpElementInstance c) { - return ConstDict.TryGetValue( name, out c ); + return ConstDict.TryGetValue(name, out c); } - public override bool TryGetEntity( string name, out ExpEntitySource e ) + public override bool TryGetEntity(string name, out ExpEntitySource e) { e = null; return false; } - public override bool TryGetFunction( string name, out ExpFunctionSource f ) + public override bool TryGetFunction(string name, out ExpFunctionSource f) { - return FunctionDict.TryGetValue( name, out f! ); + return FunctionDict.TryGetValue(name, out f!); } - public override bool TryGetProcedure( string name, out ExpProcedureSource p ) + public override bool TryGetProcedure(string name, out ExpProcedureSource p) { - return ProcedureDict.TryGetValue( name, out p! ); + return ProcedureDict.TryGetValue(name, out p!); } - public override bool TryGetRule( string name, out ExpRuleSource r ) + public override bool TryGetRule(string name, out ExpRuleSource r) { r = null!; return false; } - public override bool TryGetSchemaInclude( string name, out ExpSchema include ) + public override bool TryGetSchemaInclude(string name, out ExpSchema include) { include = null!; return false; } - public override bool TryGetType( string name, out ExpTypeSource t ) + public override bool TryGetType(string name, out ExpTypeSource t) { - return TypeDict.TryGetValue( name, out t ); + return TypeDict.TryGetValue(name, out t); } internal void Init() { - IEnumerable> builtinTypeSource = [ - new KeyValuePair( - PoolString( Keyword.Integer ), - new ExpBuiltinType( Keyword.Integer, typeof( int ) ) ), - new KeyValuePair( - PoolString( Keyword.Real ), new ExpBuiltinType( Keyword.Real, typeof( float ) ) ), - new KeyValuePair( - PoolString( Keyword.Boolean ), - new ExpBuiltinType( Keyword.Boolean, typeof( bool ) ) ), - new KeyValuePair( - PoolString( Keyword.Logical ), - new ExpBuiltinType( Keyword.Logical, typeof( ExpLogic ) ) ), - new KeyValuePair( - PoolString( Keyword.String ), - new ExpBuiltinType( Keyword.String, typeof( string ) ) ), - new KeyValuePair( - PoolString( Keyword.Binary ), - new ExpBuiltinType( Keyword.Binary, typeof( BitArray ) ) ), - - ]; - TypeDict = new Dictionary( builtinTypeSource, - Multiplexer ).ToFrozenDictionary(); + IEnumerable> builtinTypeSource = [ new KeyValuePair( + PoolString(Keyword.Integer), + new ExpBuiltinType(Keyword.Integer, typeof(int))), new KeyValuePair( + PoolString(Keyword.Real), new ExpBuiltinType(Keyword.Real, typeof(float))), new KeyValuePair( + PoolString(Keyword.Boolean), + new ExpBuiltinType(Keyword.Boolean, typeof(bool))), new KeyValuePair( + PoolString(Keyword.Logical), + new ExpBuiltinType(Keyword.Logical, typeof(ExpLogic))), new KeyValuePair( + PoolString(Keyword.String), + new ExpBuiltinType(Keyword.String, typeof(string))), new KeyValuePair( + PoolString(Keyword.Binary), + new ExpBuiltinType(Keyword.Binary, typeof(BitArray))), ]; + TypeDict = new Dictionary(builtinTypeSource, + Multiplexer).ToFrozenDictionary(); - ConstDict = new Dictionary( Multiplexer ) { - { PoolString( "PI" ), new ExpRealNumberNode( - new Token( PoolString( "PI" ), -1, -1, TokenFlag.Number ), MathF.PI, true ) }, - { PoolString( "E" ), new ExpRealNumberNode( - new Token( PoolString( "E" ), -1, -1, TokenFlag.Number ), MathF.E, true ) }, + ConstDict = new Dictionary(Multiplexer) { + { PoolString("PI"), new ExpRealNumberNode( + new Token(PoolString("PI"), -1, -1, TokenFlag.Number), MathF.PI, true) }, + { PoolString("E"), new ExpRealNumberNode( + new Token(PoolString("E"), -1, -1, TokenFlag.Number), MathF.E, true) }, }.ToFrozenDictionary(); } diff --git a/StgSharp.Script/Express/CompileEnv/ExpCompile.cs b/StgSharp.Script/Express/CompileEnv/ExpCompile.cs index e92a288f..a4272184 100644 --- a/StgSharp.Script/Express/CompileEnv/ExpCompile.cs +++ b/StgSharp.Script/Express/CompileEnv/ExpCompile.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpCompile.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpCompile" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using CommunityToolkit.HighPerformance.Buffers; using StgSharp.Collections; @@ -56,7 +53,7 @@ namespace StgSharp.Script.Express { get { - if( _multiplexer == null ) { + if (_multiplexer == null) { throw new ExpCompileNotInitializedException(); } return _multiplexer; @@ -87,34 +84,23 @@ namespace StgSharp.Script.Express PoolKeywords(); InitPrecedence(); - _operatorsWithLetter = [ - Keyword.Add, - Keyword.Sub, - Keyword.Mul, - Keyword.Div, - Keyword.And, - Keyword.Or, - Keyword.Xor, - Keyword.AndOr, - Keyword.Not, - ]; + _operatorsWithLetter = [ Keyword.Add, Keyword.Sub, Keyword.Mul, Keyword.Div, Keyword.And, Keyword.Or, Keyword.Xor, Keyword.AndOr, Keyword.Not, ]; ExpSchema_Builtin.Only .TryGetType( - PoolString( Keyword.Integer ), out ExpTypeSource? _expInt ); + PoolString(Keyword.Integer), out ExpTypeSource? _expInt); ExpInt = _expInt; - ExpSchema_Builtin.Only - .TryGetType( PoolString( Keyword.Real ), out ExpTypeSource? _expReal ); + ExpSchema_Builtin.Only.TryGetType(PoolString(Keyword.Real), out ExpTypeSource? _expReal); ExpReal = _expReal; ExpSchema_Builtin.Only .TryGetType( - PoolString( Keyword.Boolean ), out ExpTypeSource? _expBool ); + PoolString(Keyword.Boolean), out ExpTypeSource? _expBool); ExpBool = _expBool; ExpSchema_Builtin.Only .TryGetType( - PoolString( Keyword.Boolean ), out ExpTypeSource? _expString ); + PoolString(Keyword.Boolean), out ExpTypeSource? _expString); ExpString = _expString; @@ -126,30 +112,30 @@ namespace StgSharp.Script.Express /**/ } - public static bool LetterIsKeyword( string str ) + public static bool LetterIsKeyword(string str) { - if( char.IsLetter( str[ 0 ] ) ) { - return _keywordSet.Contains( str ); + if (char.IsLetter(str[0])) { + return _keywordSet.Contains(str); } return true; } - public static bool LetterIsOperator( string str ) + public static bool LetterIsOperator(string str) { - if( char.IsLetter( str[ 0 ] ) ) { - return Array.IndexOf( _operatorsWithLetter, str ) != -1; + if (char.IsLetter(str[0])) { + return Array.IndexOf(_operatorsWithLetter, str) != -1; } return true; } - public static string PoolString( string str ) + public static string PoolString(string str) { - return _compileStringCache.GetOrAdd( str ); + return _compileStringCache.GetOrAdd(str); } - public static string PoolString( ReadOnlySpan str ) + public static string PoolString(ReadOnlySpan str) { - return _compileStringCache.GetOrAdd( str ); + return _compileStringCache.GetOrAdd(str); } } diff --git a/StgSharp.Script/Express/CompileEnv/ExpOperatorPrecedence.cs b/StgSharp.Script/Express/CompileEnv/ExpOperatorPrecedence.cs index 88276003..1f599c47 100644 --- a/StgSharp.Script/Express/CompileEnv/ExpOperatorPrecedence.cs +++ b/StgSharp.Script/Express/CompileEnv/ExpOperatorPrecedence.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpOperatorPrecedence.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpOperatorPrecedence" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Frozen; using System.Collections.Generic; @@ -40,59 +37,24 @@ namespace StgSharp.Script.Express public static partial class ExpressCompile { - public static bool TryGetOperatorPrecedence( string operatorName, out int precedence ) + public static bool TryGetOperatorPrecedence(string operatorName, out int precedence) { - return _operatorPrecedence.TryGetValue( operatorName, out precedence ); + return _operatorPrecedence.TryGetValue(operatorName, out precedence); } - public static bool TryGetSuperTypeOperatorPrecedence( - string operatorName, - out int precedence ) + public static bool TryGetSuperTypeOperatorPrecedence(string operatorName, out int precedence) { - return _superTypeOperatorPrecedent.TryGetValue( operatorName, out precedence ); + return _superTypeOperatorPrecedent.TryGetValue(operatorName, out precedence); } private static void InitPrecedence() { - KeyValuePair[] source = [ - new KeyValuePair( PoolString( "[" ), 1 ), - new KeyValuePair( PoolString( "." ), 1 ), - new KeyValuePair( PoolString( "\\" ), 1 ), - new KeyValuePair( PoolString( "unary+" ), 2 ), - new KeyValuePair( PoolString( "unary-" ), 2 ), - new KeyValuePair( PoolString( "NOT" ), 2 ), - new KeyValuePair( PoolString( "**" ), 3 ), - new KeyValuePair( PoolString( "*" ), 4 ), - new KeyValuePair( PoolString( "/" ), 4 ), - new KeyValuePair( PoolString( "AND" ), 4 ), - new KeyValuePair( PoolString( "MOD" ), 4 ), - new KeyValuePair( PoolString( "DIV" ), 4 ), - new KeyValuePair( PoolString( "||" ), 4 ), - new KeyValuePair( PoolString( "+" ), 5 ), - new KeyValuePair( PoolString( "-" ), 5 ), - new KeyValuePair( PoolString( "OR" ), 5 ), - new KeyValuePair( PoolString( "XOR" ), 5 ), - new KeyValuePair( PoolString( "=" ), 6 ), - new KeyValuePair( PoolString( "<>" ), 6 ), - new KeyValuePair( PoolString( "<=" ), 6 ), - new KeyValuePair( PoolString( ">=" ), 6 ), - new KeyValuePair( PoolString( ">" ), 6 ), - new KeyValuePair( PoolString( "<" ), 6 ), - new KeyValuePair( PoolString( ":=:" ), 6 ), - new KeyValuePair( PoolString( ":<>:" ), 6 ), - new KeyValuePair( PoolString( "IN" ), 6 ), - new KeyValuePair( PoolString( "LIKE" ), 6 ), - new KeyValuePair( PoolString( Keyword.Assignment ), 7 ) - ]; - _operatorPrecedence = new Dictionary( source, - _multiplexer ).ToFrozenDictionary(); - source = [ - new KeyValuePair( "ONEOF", 1 ), - new KeyValuePair( "AND", 2 ), - new KeyValuePair( "ANDOR", 3 ), - ]; - _superTypeOperatorPrecedent = new Dictionary( source, - _multiplexer ).ToFrozenDictionary( + KeyValuePair[] source = [ new KeyValuePair(PoolString("["), 1), new KeyValuePair(PoolString("."), 1), new KeyValuePair(PoolString("\\"), 1), new KeyValuePair(PoolString("unary+"), 2), new KeyValuePair(PoolString("unary-"), 2), new KeyValuePair(PoolString("NOT"), 2), new KeyValuePair(PoolString("**"), 3), new KeyValuePair(PoolString("*"), 4), new KeyValuePair(PoolString("/"), 4), new KeyValuePair(PoolString("AND"), 4), new KeyValuePair(PoolString("MOD"), 4), new KeyValuePair(PoolString("DIV"), 4), new KeyValuePair(PoolString("||"), 4), new KeyValuePair(PoolString("+"), 5), new KeyValuePair(PoolString("-"), 5), new KeyValuePair(PoolString("OR"), 5), new KeyValuePair(PoolString("XOR"), 5), new KeyValuePair(PoolString("="), 6), new KeyValuePair(PoolString("<>"), 6), new KeyValuePair(PoolString("<="), 6), new KeyValuePair(PoolString(">="), 6), new KeyValuePair(PoolString(">"), 6), new KeyValuePair(PoolString("<"), 6), new KeyValuePair(PoolString(":=:"), 6), new KeyValuePair(PoolString(":<>:"), 6), new KeyValuePair(PoolString("IN"), 6), new KeyValuePair(PoolString("LIKE"), 6), new KeyValuePair(PoolString(Keyword.Assignment), 7) ]; + _operatorPrecedence = new Dictionary(source, + _multiplexer).ToFrozenDictionary(); + source = [ new KeyValuePair("ONEOF", 1), new KeyValuePair("AND", 2), new KeyValuePair("ANDOR", 3), ]; + _superTypeOperatorPrecedent = new Dictionary(source, + _multiplexer).ToFrozenDictionary( ); } diff --git a/StgSharp.Script/Express/CompileEnv/KeyWord.cs b/StgSharp.Script/Express/CompileEnv/KeyWord.cs index 85205451..711f3d1d 100644 --- a/StgSharp.Script/Express/CompileEnv/KeyWord.cs +++ b/StgSharp.Script/Express/CompileEnv/KeyWord.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="KeyWord.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="KeyWord" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -46,16 +43,16 @@ namespace StgSharp.Script.Express { _keywordSet = new(); - FieldInfo[] fields = typeof( Keyword ).GetFields( BindingFlags.Public ); + FieldInfo[] fields = typeof(Keyword).GetFields(BindingFlags.Public); ParallelLoopResult result = Parallel.ForEach( - fields, static( field ) => { - if( field.FieldType == typeof( string ) && field.GetValue( null ) is string str ) - { - _compileStringCache.GetOrAdd( str ); - _keywordSet.Add( str ); - } - } ); - while( !result.IsCompleted ) { } + fields, static(field) => { + if (field.FieldType == typeof(string) && field.GetValue(null) is string str) + { + _compileStringCache.GetOrAdd(str); + _keywordSet.Add(str); + } + }); + while (!result.IsCompleted) { } } public static class Keyword @@ -65,64 +62,29 @@ namespace StgSharp.Script.Express EndAlias, EndCase, EndConstant, EndEntity, EndFunction, EndIf, EndLocal, EndProcedure, EndRepeat, EndRule, EndSchema, EndSubtypeConstraint, EndType }; - public static HashSet Symbols = [ - Dot, Comma, Semicolon, Colon, Percent, Apostrophe, - Backslash, IndexOf, RightBracket, LeftBrace, - RightBrace, Pipe, LeftParen, RightParen, LeftAsterisk, - Assignment, DoublePipe, ExpSymbol, CommentSingleLine, - CommentStart, CommentEnd, InstanceEqual, InstanceNotEqual - ]; + public static HashSet Symbols = [ Dot, Comma, Semicolon, Colon, Percent, Apostrophe, Backslash, IndexOf, RightBracket, LeftBrace, RightBrace, Pipe, LeftParen, RightParen, LeftAsterisk, Assignment, DoublePipe, ExpSymbol, CommentSingleLine, CommentStart, CommentEnd, InstanceEqual, InstanceNotEqual ]; - public static HashSet DataTypes { get; } = [ - Array, Bag, Binary, Boolean, Enumeration, Integer, List, Logical, Number, Of, Real, Set, String - ]; + public static HashSet DataTypes { get; } = [ Array, Bag, Binary, Boolean, Enumeration, Integer, List, Logical, Number, Of, Real, Set, String ]; - public static HashSet InternalProcess { get; } = [ - Insert, Remove - ]; + public static HashSet InternalProcess { get; } = [ Insert, Remove ]; - public static HashSet BuiltinFunctions { get; } = [ - Abs, Acos, Asin, Atan, BLength, Cos, Exists, Exp, - Format, HiBound, HiIndex, Length, LoBound, Log, - Log2, Log10, LoIndex, Nvl, Odd, Rolesof, Sin, - Sizeof, Sqrt, Tan, Typeof, Usedin, Value, - ValueIn, ValueUnique - ]; + public static HashSet BuiltinFunctions { get; } = [ Abs, Acos, Asin, Atan, BLength, Cos, Exists, Exp, Format, HiBound, HiIndex, Length, LoBound, Log, Log2, Log10, LoIndex, Nvl, Odd, Rolesof, Sin, Sizeof, Sqrt, Tan, Typeof, Usedin, Value, ValueIn, ValueUnique ]; - public static HashSet Literals { get; } = [ - QuestionMark, Self, Const, E, Pi, False, True, Unknown - ]; + public static HashSet Literals { get; } = [ QuestionMark, Self, Const, E, Pi, False, True, Unknown ]; - public static HashSet Operators { get; } = [ - And, AndOr, Div, In, Like, Mod, Not, Or, Xor, - Add, Sub, Mul, Slash, Equal, NotEqual, - LessThan, GreaterThan, LessThanOrEqual, GreaterThanOrEqual - ]; + public static HashSet Operators { get; } = [ And, AndOr, Div, In, Like, Mod, Not, Or, Xor, Add, Sub, Mul, Slash, Equal, NotEqual, LessThan, GreaterThan, LessThanOrEqual, GreaterThanOrEqual ]; - public static HashSet Aliasing { get; } = [ - Alias, Renamed - ]; + public static HashSet Aliasing { get; } = [ Alias, Renamed ]; - public static HashSet ModifiersAttributes { get; } = [ - Abstract, Aggregate, As, BasedOn, By, Escape, Fixed, From, Use, With - ]; + public static HashSet ModifiersAttributes { get; } = [ Abstract, Aggregate, As, BasedOn, By, Escape, Fixed, From, Use, With ]; - public static HashSet QueryReference { get; } = [ - Query, Reference, Select - ]; + public static HashSet QueryReference { get; } = [ Query, Reference, Select ]; - public static HashSet ConstraintsInheritance { get; } = [ - Oneof, Optional, Subtype, SubtypeConstraint, Supertype, TotalOver, Unique, Where - ]; + public static HashSet ConstraintsInheritance { get; } = [ Oneof, Optional, Subtype, SubtypeConstraint, Supertype, TotalOver, Unique, Where ]; - public static HashSet Declarations { get; } = [ - Constant, Derive, Entity, Extensible, Fixed, Function, Generic, - GenericEntity, Inverse, Local, Procedure, Rule, Schema, Type, Var - ]; + public static HashSet Declarations { get; } = [ Constant, Derive, Entity, Extensible, Fixed, Function, Generic, GenericEntity, Inverse, Local, Procedure, Rule, Schema, Type, Var ]; - public static HashSet FlowControl { get; } = [ - Begin, Case, Else, End, For, If, Otherwise, Repeat, Return, Skip, Then, To, Until, While - ]; + public static HashSet FlowControl { get; } = [ Begin, Case, Else, End, For, If, Otherwise, Repeat, Return, Skip, Then, To, Until, While ]; #region Basic Data Type diff --git a/StgSharp.Script/Express/Element/ExpConst.cs b/StgSharp.Script/Express/Element/ExpConst.cs index ac15bba5..308ddc23 100644 --- a/StgSharp.Script/Express/Element/ExpConst.cs +++ b/StgSharp.Script/Express/Element/ExpConst.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpConst.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpConst" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Frozen; @@ -45,10 +42,10 @@ namespace StgSharp.Script.Express private Dictionary _constants; private IScriptSourceProvider _sourceProvider; - public ExpConstantCollectionSource( IScriptSourceProvider sourceProvider ) + public ExpConstantCollectionSource(IScriptSourceProvider sourceProvider) { _sourceProvider = sourceProvider; - _constants = new Dictionary( ExpressCompile.Multiplexer ); + _constants = new Dictionary(ExpressCompile.Multiplexer); } public override ExpElementType ElementType => ExpElementType.Const; @@ -65,28 +62,28 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override ExpSyntaxNode MakeReference( params object[] options ) + public override ExpSyntaxNode MakeReference(params object[] options) { - if( options.Length == 0 || options[ 0 ] is not string str ) { + if (options.Length == 0 || options[0] is not string str) { return null!; } - if( _constants.Count == 0 ) { + if (_constants.Count == 0) { return null!; } - if( _constants.TryGetValue( str, out ExpElementInstance? token ) ) { + if (_constants.TryGetValue(str, out ExpElementInstance? token)) { return token; } return null!; } - public bool TryGetConstant( string name, out ExpElementInstance instance ) + public bool TryGetConstant(string name, out ExpElementInstance instance) { - return _constants.TryGetValue( name, out instance ); + return _constants.TryGetValue(name, out instance); } - public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) + public override bool TryGetMember(string name, out ExpSyntaxNode memberNode) { - if( _constants.TryGetValue( name, out ExpElementInstance? node ) ) + if (_constants.TryGetValue(name, out ExpElementInstance? node)) { memberNode = node; return true; @@ -95,9 +92,9 @@ namespace StgSharp.Script.Express return false; } - internal void AddConstant( string name, ExpElementInstance value ) + internal void AddConstant(string name, ExpElementInstance value) { - _constants.Add( name, value ); + _constants.Add(name, value); } } diff --git a/StgSharp.Script/Express/Element/ExpEntity.cs b/StgSharp.Script/Express/Element/ExpEntity.cs index 937ac379..d0b5188a 100644 --- a/StgSharp.Script/Express/Element/ExpEntity.cs +++ b/StgSharp.Script/Express/Element/ExpEntity.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpEntity.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpEntity" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; @@ -41,7 +38,7 @@ namespace StgSharp.Script.Express private ScriptSourceTransmitter _source; private string _name; - public ExpEntitySource( string name, ScriptSourceTransmitter provider ) + public ExpEntitySource(string name, ScriptSourceTransmitter provider) { _name = name; _source = provider; @@ -58,12 +55,12 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override ExpSyntaxNode CreateInstanceNode( Token t ) + public override ExpSyntaxNode CreateInstanceNode(Token t) { throw new NotImplementedException(); } - public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) + public override bool TryGetMember(string name, out ExpSyntaxNode memberNode) { throw new NotImplementedException(); } diff --git a/StgSharp.Script/Express/Element/ExpFunction.cs b/StgSharp.Script/Express/Element/ExpFunction.cs index 3f5b16a3..9bfa67a0 100644 --- a/StgSharp.Script/Express/Element/ExpFunction.cs +++ b/StgSharp.Script/Express/Element/ExpFunction.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpFunction.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpFunction" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; @@ -40,7 +37,7 @@ namespace StgSharp.Script.Express private ScriptSourceTransmitter _transmitter; private string _name; - public ExpFunctionSource( string name, ScriptSourceTransmitter transmitter ) + public ExpFunctionSource(string name, ScriptSourceTransmitter transmitter) { _name = name; _transmitter = transmitter; @@ -72,19 +69,19 @@ namespace StgSharp.Script.Express */ } - public override ExpSyntaxNode MakeReference( params object[] options ) + public override ExpSyntaxNode MakeReference(params object[] options) { throw new NotImplementedException(); } - public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) + public override bool TryGetMember(string name, out ExpSyntaxNode memberNode) { - if( FuncParams.TryGetValue( name, out ExpElementInstance? param ) ) + if (FuncParams.TryGetValue(name, out ExpElementInstance? param)) { memberNode = param; return true; } - if( LocalVariables.TryGetValue( name, out ExpElementInstance? variable ) ) + if (LocalVariables.TryGetValue(name, out ExpElementInstance? variable)) { memberNode = variable; return true; diff --git a/StgSharp.Script/Express/Element/ExpProcedureSource.cs b/StgSharp.Script/Express/Element/ExpProcedureSource.cs index 3d94a62b..2ea0bf6f 100644 --- a/StgSharp.Script/Express/Element/ExpProcedureSource.cs +++ b/StgSharp.Script/Express/Element/ExpProcedureSource.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpProcedureSource.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpProcedureSource" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -50,12 +47,12 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override ExpSyntaxNode MakeReference( params object[] options ) + public override ExpSyntaxNode MakeReference(params object[] options) { throw new NotImplementedException(); } - public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) + public override bool TryGetMember(string name, out ExpSyntaxNode memberNode) { throw new NotImplementedException(); } diff --git a/StgSharp.Script/Express/Element/ExpRule.cs b/StgSharp.Script/Express/Element/ExpRule.cs index c89a3ac7..49a7cc78 100644 --- a/StgSharp.Script/Express/Element/ExpRule.cs +++ b/StgSharp.Script/Express/Element/ExpRule.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpRule.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpRule" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Data; @@ -41,7 +38,7 @@ namespace StgSharp.Script.Express private ExpRuleSource _source; - public ExpRule( Token source ) : base( source ) { } + public ExpRule(Token source) : base(source) { } public object? value => throw new NotImplementedException(); @@ -62,7 +59,7 @@ namespace StgSharp.Script.Express private ScriptSourceTransmitter _transmitter; private string _name; - public ExpRuleSource( string name, ScriptSourceTransmitter transmitter ) + public ExpRuleSource(string name, ScriptSourceTransmitter transmitter) { _name = name; _transmitter = transmitter; @@ -79,12 +76,12 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override ExpSyntaxNode MakeReference( params object[] options ) + public override ExpSyntaxNode MakeReference(params object[] options) { throw new NotImplementedException(); } - public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) + public override bool TryGetMember(string name, out ExpSyntaxNode memberNode) { memberNode = ExpSyntaxNode.Empty; return false; diff --git a/StgSharp.Script/Express/Element/ExpType.cs b/StgSharp.Script/Express/Element/ExpType.cs index 16184033..55f22c16 100644 --- a/StgSharp.Script/Express/Element/ExpType.cs +++ b/StgSharp.Script/Express/Element/ExpType.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpType.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpType" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script; using System; @@ -42,14 +39,14 @@ namespace StgSharp.Script.Express private string _name; protected bool _isBuiltinType; - protected ExpTypeSource( string name ) + protected ExpTypeSource(string name) { _name = name; _transmitter = ScriptSourceTransmitter.Empty; _isBuiltinType = true; } - public ExpTypeSource( string name, ScriptSourceTransmitter transmitter ) + public ExpTypeSource(string name, ScriptSourceTransmitter transmitter) { _name = name; _transmitter = transmitter; @@ -77,17 +74,17 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override ExpElementInstance CreateInstanceNode( Token t ) + public override ExpElementInstance CreateInstanceNode(Token t) { throw new NotImplementedException(); } - public static bool IsNullOrVoid( IExpElementSource type ) + public static bool IsNullOrVoid(IExpElementSource type) { return type == null || type == ExpVoidType.Only; } - public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) + public override bool TryGetMember(string name, out ExpSyntaxNode memberNode) { memberNode = ExpSyntaxNode.Empty; return false; @@ -98,7 +95,7 @@ namespace StgSharp.Script.Express private static readonly ExpVoidType _onlyInstance = new ExpVoidType(); - private ExpVoidType() : base( string.Empty ) { } + private ExpVoidType() : base(string.Empty) { } public static ExpVoidType Only { diff --git a/StgSharp.Script/Express/ExpAstNode/ExpBinaryOperatorNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpBinaryOperatorNode.cs index 4a615615..97bcf6cb 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpBinaryOperatorNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpBinaryOperatorNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpBinaryOperatorNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpBinaryOperatorNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp; using System; @@ -48,8 +45,8 @@ namespace StgSharp.Script.Express private ExpSyntaxNode _left; private ExpSyntaxNode _right; - private ExpBinaryOperatorNode( Token source, ExpSyntaxNode left, ExpSyntaxNode right ) - : base( source ) + private ExpBinaryOperatorNode(Token source, ExpSyntaxNode left, ExpSyntaxNode right) + : base(source) { _left = left; _right = right; @@ -63,19 +60,16 @@ namespace StgSharp.Script.Express public string Operator { get; private set; } - public static ExpBinaryOperatorNode Add( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode Add(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - if( !left.IsNumber && !right.IsNumber ) { - throw new ExpInvalidTypeException( source, "Number", - left.EqualityTypeConvert.Name ); + if (!left.IsNumber && !right.IsNumber) { + throw new ExpInvalidTypeException(source, "Number", + left.EqualityTypeConvert.Name); } bool isFloat = - ( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || - ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; - return new ExpBinaryOperatorNode( source, left, right ) + (left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 || + (right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0; + return new ExpBinaryOperatorNode(source, left, right) { _returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt, _nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number, @@ -83,16 +77,13 @@ namespace StgSharp.Script.Express }; } - public static ExpBinaryOperatorNode Assign( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode Assign(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - if( left.EqualityTypeConvert != right.EqualityTypeConvert ) { + if (left.EqualityTypeConvert != right.EqualityTypeConvert) { throw new ExpInvalidTypeException( - source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name ); + source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name); } - return new ExpBinaryOperatorNode( source, left, right ) + return new ExpBinaryOperatorNode(source, left, right) { _returnType = ExpInstantiableElement.Void, _nodeFlag = ExpNodeFlag.Operator_Binary | left._nodeFlag, @@ -101,12 +92,9 @@ namespace StgSharp.Script.Express }; } - public static ExpBinaryOperatorNode CompareInstanceEqual( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode CompareInstanceEqual(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - return new ExpBinaryOperatorNode( source, left, right ) + return new ExpBinaryOperatorNode(source, left, right) { _returnType = ExpressCompile.ExpBool, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, @@ -117,9 +105,9 @@ namespace StgSharp.Script.Express public static ExpBinaryOperatorNode CompareInstanceNotEqual( Token source, ExpSyntaxNode left, - ExpSyntaxNode right ) + ExpSyntaxNode right) { - return new ExpBinaryOperatorNode( source, left, right ) + return new ExpBinaryOperatorNode(source, left, right) { _returnType = ExpressCompile.ExpBool, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, @@ -127,16 +115,13 @@ namespace StgSharp.Script.Express }; } - public static ExpBinaryOperatorNode ConvertElement( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode ConvertElement(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - if( right is not ExpMetaRefNode metaRef ) { + if (right is not ExpMetaRefNode metaRef) { throw new ExpInvalidTypeException( - source, "", right.EqualityTypeConvert.Name ); + source, "", right.EqualityTypeConvert.Name); } - return new ExpBinaryOperatorNode( source, left, right ) + return new ExpBinaryOperatorNode(source, left, right) { _returnType = metaRef.SourceRef, _nodeFlag = ExpNodeFlag.Operator_Binary, @@ -148,19 +133,16 @@ namespace StgSharp.Script.Express }; } - public static ExpBinaryOperatorNode Div( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode Div(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - if( !left.IsNumber && !right.IsNumber ) { - throw new ExpInvalidTypeException( source, "Number", - left.EqualityTypeConvert.Name ); + if (!left.IsNumber && !right.IsNumber) { + throw new ExpInvalidTypeException(source, "Number", + left.EqualityTypeConvert.Name); } bool isFloat = - ( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || - ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; - return new ExpBinaryOperatorNode( source, left, right ) + (left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 || + (right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0; + return new ExpBinaryOperatorNode(source, left, right) { _returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt, _nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number, @@ -168,16 +150,13 @@ namespace StgSharp.Script.Express }; } - public static ExpBinaryOperatorNode EqualTo( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode EqualTo(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - if( left.EqualityTypeConvert != right.EqualityTypeConvert ) { + if (left.EqualityTypeConvert != right.EqualityTypeConvert) { throw new ExpInvalidTypeException( - source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name ); + source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name); } - return new ExpBinaryOperatorNode( source, left, right ) + return new ExpBinaryOperatorNode(source, left, right) { _returnType = ExpressCompile.ExpBool, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, @@ -185,16 +164,13 @@ namespace StgSharp.Script.Express }; } - public static ExpBinaryOperatorNode GreaterThan( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode GreaterThan(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - if( !left.IsNumber && !right.IsNumber ) { - throw new ExpInvalidTypeException( source, "Number", - left.EqualityTypeConvert.Name ); + if (!left.IsNumber && !right.IsNumber) { + throw new ExpInvalidTypeException(source, "Number", + left.EqualityTypeConvert.Name); } - return new ExpBinaryOperatorNode( source, left, right ) + return new ExpBinaryOperatorNode(source, left, right) { _returnType = ExpressCompile.ExpBool, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, @@ -202,16 +178,13 @@ namespace StgSharp.Script.Express }; } - public static ExpBinaryOperatorNode LessThan( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode LessThan(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - if( !left.IsNumber && !right.IsNumber ) { - throw new ExpInvalidTypeException( source, "Number", - left.EqualityTypeConvert.Name ); + if (!left.IsNumber && !right.IsNumber) { + throw new ExpInvalidTypeException(source, "Number", + left.EqualityTypeConvert.Name); } - return new ExpBinaryOperatorNode( source, left, right ) + return new ExpBinaryOperatorNode(source, left, right) { _returnType = ExpressCompile.ExpBool, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, @@ -219,19 +192,16 @@ namespace StgSharp.Script.Express }; } - public static ExpBinaryOperatorNode Mul( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode Mul(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - if( !left.IsNumber && !right.IsNumber ) { - throw new ExpInvalidTypeException( source, "Number", - left.EqualityTypeConvert.Name ); + if (!left.IsNumber && !right.IsNumber) { + throw new ExpInvalidTypeException(source, "Number", + left.EqualityTypeConvert.Name); } bool isFloat = - ( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || - ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; - return new ExpBinaryOperatorNode( source, left, right ) + (left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 || + (right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0; + return new ExpBinaryOperatorNode(source, left, right) { _returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt, _nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number, @@ -239,16 +209,13 @@ namespace StgSharp.Script.Express }; } - public static ExpBinaryOperatorNode NotEqualTo( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode NotEqualTo(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - if( left.EqualityTypeConvert != right.EqualityTypeConvert ) { + if (left.EqualityTypeConvert != right.EqualityTypeConvert) { throw new ExpInvalidTypeException( - source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name ); + source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name); } - return new ExpBinaryOperatorNode( source, left, right ) + return new ExpBinaryOperatorNode(source, left, right) { _returnType = ExpressCompile.ExpBool, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, @@ -256,16 +223,13 @@ namespace StgSharp.Script.Express }; } - public static ExpBinaryOperatorNode SmallerThan( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode SmallerThan(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - if( !left.IsNumber && !right.IsNumber ) { - throw new ExpInvalidTypeException( source, "Number", - left.EqualityTypeConvert.Name ); + if (!left.IsNumber && !right.IsNumber) { + throw new ExpInvalidTypeException(source, "Number", + left.EqualityTypeConvert.Name); } - return new ExpBinaryOperatorNode( source, left, right ) + return new ExpBinaryOperatorNode(source, left, right) { _returnType = ExpressCompile.ExpBool, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, @@ -273,19 +237,16 @@ namespace StgSharp.Script.Express }; } - public static ExpBinaryOperatorNode Sub( - Token source, - ExpSyntaxNode left, - ExpSyntaxNode right ) + public static ExpBinaryOperatorNode Sub(Token source, ExpSyntaxNode left, ExpSyntaxNode right) { - if( !left.IsNumber && !right.IsNumber ) { - throw new ExpInvalidTypeException( source, "Number", - left.EqualityTypeConvert.Name ); + if (!left.IsNumber && !right.IsNumber) { + throw new ExpInvalidTypeException(source, "Number", + left.EqualityTypeConvert.Name); } bool isFloat = - ( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || - ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; - return new ExpBinaryOperatorNode( source, left, right ) + (left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 || + (right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0; + return new ExpBinaryOperatorNode(source, left, right) { _returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt, _nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number, diff --git a/StgSharp.Script/Express/ExpAstNode/ExpCollectionIndexNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpCollectionIndexNode.cs index ffaa0923..d4543867 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpCollectionIndexNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpCollectionIndexNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpCollectionIndexNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpCollectionIndexNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -43,11 +40,8 @@ namespace StgSharp.Script.Express private ExpSyntaxNode _indexExpression; - private ExpCollectionIndexNode( - Token source, - ExpCollectionInstanceBase instance, - ExpSyntaxNode indexExpression ) - : base( source ) + private ExpCollectionIndexNode(Token source, ExpCollectionInstanceBase instance, ExpSyntaxNode indexExpression) + : base(source) { _collection = instance; _indexExpression = indexExpression; @@ -63,13 +57,13 @@ namespace StgSharp.Script.Express public static ExpCollectionIndexNode Create( Token source, ExpCollectionInstanceBase instance, - ExpSyntaxNode indexExpression ) + ExpSyntaxNode indexExpression) { - if( !indexExpression.IsNumber ) { + if (!indexExpression.IsNumber) { throw new ExpInvalidTypeException( - source, "Number", indexExpression.EqualityTypeConvert.Name ); + source, "Number", indexExpression.EqualityTypeConvert.Name); } - return new ExpCollectionIndexNode( source, instance, indexExpression ); + return new ExpCollectionIndexNode(source, instance, indexExpression); } } diff --git a/StgSharp.Script/Express/ExpAstNode/ExpElementInitializingNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpElementInitializingNode.cs index de80c358..4d0a5ff3 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpElementInitializingNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpElementInitializingNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpElementInitializingNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpElementInitializingNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -43,11 +40,8 @@ namespace StgSharp.Script.Express private ExpMetaRefNode _type; private ExpSyntaxNode _init; - private ExpElementInitializingNode( - Token source, - ExpMetaRefNode type, - ExpSyntaxNode initParameter ) - : base( source ) + private ExpElementInitializingNode(Token source, ExpMetaRefNode type, ExpSyntaxNode initParameter) + : base(source) { _type = type; _init = initParameter; @@ -59,16 +53,13 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert => _type.SourceRef; - [MethodImpl( MethodImplOptions.AggressiveInlining )] - public ExpElementInitializingNode InitializeElement( - Token source, - ExpMetaRefNode type, - ExpSyntaxNode init ) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public ExpElementInitializingNode InitializeElement(Token source, ExpMetaRefNode type, ExpSyntaxNode init) { - if( init is ExpTupleNode tupleNode ) { + if (init is ExpTupleNode tupleNode) { init = tupleNode.Right; } - ExpElementInitializingNode node = new ExpElementInitializingNode( source, type, init ); + ExpElementInitializingNode node = new ExpElementInitializingNode(source, type, init); return node; } diff --git a/StgSharp.Script/Express/ExpAstNode/ExpElementMemberNameNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpElementMemberNameNode.cs index 5936d4ce..4afddc5a 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpElementMemberNameNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpElementMemberNameNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpElementMemberNameNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpElementMemberNameNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -39,8 +36,8 @@ namespace StgSharp.Script.Express public class ExpElementMemberNameNode : ExpSyntaxNode { - internal ExpElementMemberNameNode( Token source ) - : base( source ) + internal ExpElementMemberNameNode(Token source) + : base(source) { _nodeFlag = ExpNodeFlag.Name_Operator; CodeConvertTemplate = source.Value; @@ -54,15 +51,14 @@ namespace StgSharp.Script.Express { get { - ExpSchema.BuiltinSchema - .TryGetType( ExpressCompile.Keyword.String, out ExpTypeSource? strType ); + ExpSchema.BuiltinSchema.TryGetType(ExpressCompile.Keyword.String, out ExpTypeSource? strType); return strType; } } - public static ExpElementMemberNameNode Create( Token t ) + public static ExpElementMemberNameNode Create(Token t) { - return new ExpElementMemberNameNode( t ); + return new ExpElementMemberNameNode(t); } } diff --git a/StgSharp.Script/Express/ExpAstNode/ExpEnumLiteralNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpEnumLiteralNode.cs index 4b7b69c7..ce6c9875 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpEnumLiteralNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpEnumLiteralNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpEnumLiteralNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpEnumLiteralNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script; using System; @@ -37,7 +34,7 @@ namespace StgSharp.Script.Express public class ExpEnumLiteralNode : ExpSyntaxNode { - private ExpEnumLiteralNode( Token t ) : base( t ) { } + private ExpEnumLiteralNode(Token t) : base(t) { } public override ExpSyntaxNode Left => Empty; @@ -47,17 +44,17 @@ namespace StgSharp.Script.Express public string Literal { get; private set; } - public static ExpEnumLiteralNode Create( Token t, Func parser ) + public static ExpEnumLiteralNode Create(Token t, Func parser) { string l; - if( parser is null ) + if (parser is null) { l = t.Value; } else { - l = parser( t.Value ); + l = parser(t.Value); } - return new ExpEnumLiteralNode( t ) + return new ExpEnumLiteralNode(t) { Literal = l, CodeConvertTemplate = l diff --git a/StgSharp.Script/Express/ExpAstNode/ExpFunctionCallingNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpFunctionCallingNode.cs index f78ebf11..96ac07d6 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpFunctionCallingNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpFunctionCallingNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpFunctionCallingNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpFunctionCallingNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -43,13 +40,10 @@ namespace StgSharp.Script.Express private ExpSyntaxNode _parameter; - private ExpFunctionCallingNode( - Token source, - ExpFunctionSource function, - ExpSyntaxNode parameterEnumeration ) - : base( source ) + private ExpFunctionCallingNode(Token source, ExpFunctionSource function, ExpSyntaxNode parameterEnumeration) + : base(source) { - if( parameterEnumeration is ExpTupleNode tuple ) { + if (parameterEnumeration is ExpTupleNode tuple) { parameterEnumeration = tuple.Right; } _function = function; @@ -64,20 +58,17 @@ namespace StgSharp.Script.Express public override ExpSyntaxNode Right => _parameter; - public void AppendParameter( ExpSyntaxNode parameter ) + public void AppendParameter(ExpSyntaxNode parameter) { - _parameter.AppendNode( parameter ); + _parameter.AppendNode(parameter); } - public static ExpFunctionCallingNode CallFunction( - Token source, - ExpFunctionSource function, - ExpSyntaxNode param ) + public static ExpFunctionCallingNode CallFunction(Token source, ExpFunctionSource function, ExpSyntaxNode param) { - if( param is ExpTupleNode ) { + if (param is ExpTupleNode) { param = param.Right; } - return new ExpFunctionCallingNode( source, function, param ); + return new ExpFunctionCallingNode(source, function, param); } } diff --git a/StgSharp.Script/Express/ExpAstNode/ExpIfNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpIfNode.cs index 6eea568d..f04f5972 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpIfNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpIfNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpIfNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpIfNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Script.Express; using System; @@ -43,8 +40,8 @@ namespace StgSharp.Script.Express private ExpSyntaxNode _rule; private ExpSyntaxNode _trueOpBegin ; - public ExpIfNode( Token source, ExpSyntaxNode rule, ExpSyntaxNode trueOpBegin ) - : base( source ) + public ExpIfNode(Token source, ExpSyntaxNode rule, ExpSyntaxNode trueOpBegin) + : base(source) { _rule = rule; _trueOpBegin = trueOpBegin; @@ -54,15 +51,15 @@ namespace StgSharp.Script.Express { {1} } - """ ); + """); } public ExpIfNode( Token source, ExpSyntaxNode rule, ExpSyntaxNode rootOperationIfTrue, - ExpSyntaxNode rootOperationIfFalse ) - : base( source ) + ExpSyntaxNode rootOperationIfFalse) + : base(source) { _rule = rule; _trueOpBegin = rootOperationIfFalse; @@ -75,7 +72,7 @@ namespace StgSharp.Script.Express } else { {2} } - """ ); + """); } public override ExpSyntaxNode Left => _trueOpBegin; @@ -84,14 +81,14 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert => null!; - public void AppendFalseOperation( ExpSyntaxNode expressionRoot ) + public void AppendFalseOperation(ExpSyntaxNode expressionRoot) { - _falseOpBegin.AppendNode( expressionRoot ); + _falseOpBegin.AppendNode(expressionRoot); } - public void AppendTrueOperation( ExpSyntaxNode expressionRoot ) + public void AppendTrueOperation(ExpSyntaxNode expressionRoot) { - _trueOpBegin.AppendNode( expressionRoot ); + _trueOpBegin.AppendNode(expressionRoot); } } diff --git a/StgSharp.Script/Express/ExpAstNode/ExpInstanceMemberNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpInstanceMemberNode.cs index 7c5d3299..b5ad12d0 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpInstanceMemberNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpInstanceMemberNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpInstanceMemberNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpInstanceMemberNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using CommunityToolkit.HighPerformance.Helpers; using System; @@ -45,15 +42,12 @@ namespace StgSharp.Script.Express private ExpElementMemberNameNode _memberName; private ExpSyntaxNode _member; - public ExpInstanceMemberNode( - Token source, - ExpElementInstance instance, - ExpElementMemberNameNode memberName ) - : base( source ) + public ExpInstanceMemberNode(Token source, ExpElementInstance instance, ExpElementMemberNameNode memberName) + : base(source) { _instance = instance; _memberName = memberName; - _instance.TryGetMember( memberName.CodeConvertTemplate, out _member ); + _instance.TryGetMember(memberName.CodeConvertTemplate, out _member); } public override ExpSyntaxNode Left => _instance; diff --git a/StgSharp.Script/Express/ExpAstNode/ExpInstanceReferenceNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpInstanceReferenceNode.cs index c634772c..917e35e7 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpInstanceReferenceNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpInstanceReferenceNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpInstanceReferenceNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpInstanceReferenceNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -40,19 +37,19 @@ namespace StgSharp.Script.Express public class ExpInstanceReferenceNode : ExpSyntaxNode { - internal ExpInstanceReferenceNode( Token source, ExpElementInstance instance ) - : base( source ) + internal ExpInstanceReferenceNode(Token source, ExpElementInstance instance) + : base(source) { OriginObject = instance; - _nodeFlag = ( OriginObject._nodeFlag | ( ExpNodeFlag.Name_Any | ExpNodeFlag.Collection_Any ) ); + _nodeFlag = (OriginObject._nodeFlag | (ExpNodeFlag.Name_Any | ExpNodeFlag.Collection_Any)); CodeConvertTemplate = source.Value; } - internal ExpInstanceReferenceNode( Token source, ExpInstanceReferenceNode reference ) - : base( source ) + internal ExpInstanceReferenceNode(Token source, ExpInstanceReferenceNode reference) + : base(source) { OriginObject = reference.OriginObject; - _nodeFlag = ( OriginObject._nodeFlag | ( ExpNodeFlag.Name_Any | ExpNodeFlag.Collection_Any ) ); + _nodeFlag = (OriginObject._nodeFlag | (ExpNodeFlag.Name_Any | ExpNodeFlag.Collection_Any)); CodeConvertTemplate = source.Value; } @@ -64,21 +61,19 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert => OriginObject.EqualityTypeConvert; - [MethodImpl( MethodImplOptions.AggressiveInlining )] - public static ExpInstanceReferenceNode MakeReferenceFrom( - Token source, - ExpElementInstance instance ) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ExpInstanceReferenceNode MakeReferenceFrom(Token source, ExpElementInstance instance) { /**/ - if( instance.IsLiteral ) + if (instance.IsLiteral) { - throw new ExpCompileException( source, "Cannot make reference to a literal." ); + throw new ExpCompileException(source, "Cannot make reference to a literal."); } - if( instance.CodeConvertTemplate != source.Value ) { - throw new ExpCompileException( source, "Token point at a wrong instance" ); + if (instance.CodeConvertTemplate != source.Value) { + throw new ExpCompileException(source, "Token point at a wrong instance"); } /**/ - return new ExpInstanceReferenceNode( source, instance ); + return new ExpInstanceReferenceNode(source, instance); } } diff --git a/StgSharp.Script/Express/ExpAstNode/ExpLiteralNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpLiteralNode.cs index 98e043d0..f7c3be85 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpLiteralNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpLiteralNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpLiteralNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpLiteralNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Data; using System; @@ -43,8 +40,8 @@ namespace StgSharp.Script.Express private int _value; - public ExpIntNode( Token source, int value, bool isLiteral ) - : base( source ) + public ExpIntNode(Token source, int value, bool isLiteral) + : base(source) { this.IsLiteral = isLiteral; _value = value; @@ -68,8 +65,8 @@ namespace StgSharp.Script.Express private readonly string _value; - public ExpStringNode( Token source, string value, bool isLiteral ) - : base( source ) + public ExpStringNode(Token source, string value, bool isLiteral) + : base(source) { this.IsLiteral = IsLiteral; _value = value; @@ -100,8 +97,8 @@ namespace StgSharp.Script.Express private readonly bool _value; - public ExpBoolNode( Token source, bool value, bool isLiteral ) - : base( source ) + public ExpBoolNode(Token source, bool value, bool isLiteral) + : base(source) { this.IsLiteral = isLiteral; _value = value; @@ -113,22 +110,22 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert { - get => ExpSchema.BuiltinSchema - .TryGetType( ExpressCompile.Keyword.Boolean, out ExpTypeSource? type ) ? - type : throw new ExpCompileNotInitializedException(); + get => ExpSchema.BuiltinSchema.TryGetType(ExpressCompile.Keyword.Boolean, out ExpTypeSource? type) ? + type : + throw new ExpCompileNotInitializedException(); } public override string TypeName => EqualityTypeConvert.Name; - public static ExpBoolNode False( Token? t ) + public static ExpBoolNode False(Token? t) { - return new( t ?? new Token( "FALSE", 0, -1, TokenFlag.Member ), false, - isLiteral: true ); + return new(t ?? new Token("FALSE", 0, -1, TokenFlag.Member), false, + isLiteral:true); } - public static ExpBoolNode True( Token? t ) + public static ExpBoolNode True(Token? t) { - return new( t ?? new Token( "TRUE", 0, -1, TokenFlag.Member ), true, isLiteral: true ); + return new(t ?? new Token("TRUE", 0, -1, TokenFlag.Member), true, isLiteral:true); } } @@ -138,8 +135,8 @@ namespace StgSharp.Script.Express private readonly float _value; - public ExpRealNumberNode( Token source, float value, bool isLiteral ) - : base( source ) + public ExpRealNumberNode(Token source, float value, bool isLiteral) + : base(source) { _value = value; _nodeFlag = ExpNodeFlag.BuiltinType_Real | ExpNodeFlag.Element_Type; @@ -150,9 +147,9 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert { - get => ExpSchema.BuiltinSchema - .TryGetType( ExpressCompile.Keyword.String, out ExpTypeSource? type ) ? - type : throw new ExpCompileNotInitializedException(); + get => ExpSchema.BuiltinSchema.TryGetType(ExpressCompile.Keyword.String, out ExpTypeSource? type) ? + type : + throw new ExpCompileNotInitializedException(); } public override string TypeName => EqualityTypeConvert.Name; @@ -164,8 +161,8 @@ namespace StgSharp.Script.Express private readonly ExpLogic _value; - public ExpLogicValueNode( Token source, ExpLogic value, bool isLiteral ) - : base( source ) + public ExpLogicValueNode(Token source, ExpLogic value, bool isLiteral) + : base(source) { this.IsLiteral = isLiteral; _value = value; @@ -177,9 +174,9 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert { - get => ExpSchema.BuiltinSchema - .TryGetType( ExpressCompile.Keyword.Logical, out ExpTypeSource? type ) ? - type : throw new ExpCompileNotInitializedException(); + get => ExpSchema.BuiltinSchema.TryGetType(ExpressCompile.Keyword.Logical, out ExpTypeSource? type) ? + type : + throw new ExpCompileNotInitializedException(); } public override string TypeName => EqualityTypeConvert.Name; diff --git a/StgSharp.Script/Express/ExpAstNode/ExpMetaRefNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpMetaRefNode.cs index 9e9ff7ca..aad65c74 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpMetaRefNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpMetaRefNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpMetaRefNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpMetaRefNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis; using System; @@ -41,8 +38,8 @@ namespace StgSharp.Script.Express public class ExpMetaRefNode : ExpSyntaxNode { - internal ExpMetaRefNode( Token source, ExpInstantiableElement element ) - : base( source ) + internal ExpMetaRefNode(Token source, ExpInstantiableElement element) + : base(source) { SourceRef = element; } @@ -55,28 +52,28 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert => ExpInstantiableElement.Void; - public static ExpMetaRefNode RefEntity( Token position, ExpEntitySource entity ) + public static ExpMetaRefNode RefEntity(Token position, ExpEntitySource entity) { - if( position.Value != entity.Name ) { + if (position.Value != entity.Name) { throw new ExpCompileException( position, - $"Meta data does not match, name of source to match is {entity.Name}, but token is {position.Value}" ); + $"Meta data does not match, name of source to match is {entity.Name}, but token is {position.Value}"); } - ExpMetaRefNode node = new ExpMetaRefNode( position, entity ) + ExpMetaRefNode node = new ExpMetaRefNode(position, entity) { CodeConvertTemplate = entity.Name, }; return node; } - public static ExpMetaRefNode RefType( Token position, ExpTypeSource type ) + public static ExpMetaRefNode RefType(Token position, ExpTypeSource type) { - if( position.Value != type.Name ) { + if (position.Value != type.Name) { throw new ExpCompileException( position, - $"Meta data does not match, name of source to match is {type.Name}, but token is {position.Value}" ); + $"Meta data does not match, name of source to match is {type.Name}, but token is {position.Value}"); } - ExpMetaRefNode node = new ExpMetaRefNode( position, type ) + ExpMetaRefNode node = new ExpMetaRefNode(position, type) { CodeConvertTemplate = type.Name, }; diff --git a/StgSharp.Script/Express/ExpAstNode/ExpProcedureCallingNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpProcedureCallingNode.cs index cf7b06b6..896f5cb2 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpProcedureCallingNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpProcedureCallingNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpProcedureCallingNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpProcedureCallingNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -42,11 +39,8 @@ namespace StgSharp.Script.Express private ExpSyntaxNode _params; - public ExpProcedureCallingNode( - Token source, - ExpProcedureSource caller, - ExpSyntaxNode param ) - : base( source ) + public ExpProcedureCallingNode(Token source, ExpProcedureSource caller, ExpSyntaxNode param) + : base(source) { _params = param; CalledProcedure = caller; @@ -63,14 +57,15 @@ namespace StgSharp.Script.Express public static ExpProcedureCallingNode CallProcedure( Token postion, ExpProcedureSource caller, - ExpSyntaxNode input ) + ExpSyntaxNode input) { - ExpProcedureCallingNode node = new ExpProcedureCallingNode( postion, caller, input ) + ExpProcedureCallingNode node = new ExpProcedureCallingNode(postion, caller, input) { /* * 0. parameters */ - CodeConvertTemplate = $$""" + CodeConvertTemplate = + $$""" {{caller.Name}}( {0} ) """ }; diff --git a/StgSharp.Script/Express/ExpAstNode/ExpProcedureControlNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpProcedureControlNode.cs index 4c4878a0..76148610 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpProcedureControlNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpProcedureControlNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpProcedureControlNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpProcedureControlNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp.Syntax; using System; @@ -45,7 +42,7 @@ namespace StgSharp.Script.Express private ExpSyntaxNode _additional; - internal ExpProcedureControlNode( Token source ) : base( source ) { } + internal ExpProcedureControlNode(Token source) : base(source) { } public override ExpSyntaxNode Left => Empty; @@ -53,23 +50,22 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert => ExpTypeSource.Void; - public static ExpProcedureControlNode Return( Token t, ExpSyntaxNode valueToReturn ) + public static ExpProcedureControlNode Return(Token t, ExpSyntaxNode valueToReturn) { - if( t.Value != ExpKeyword.Return ) { + if (t.Value != ExpKeyword.Return) { throw new InvalidCastException(); } - ExpProcedureControlNode ret = new ExpProcedureControlNode( t ) + ExpProcedureControlNode ret = new ExpProcedureControlNode(t) { _additional = valueToReturn ?? Empty, - CodeConvertTemplate = IsNullOrEmpty( valueToReturn! ) ? - ExpKeyword.Return : "return {0}", + CodeConvertTemplate = IsNullOrEmpty(valueToReturn!) ? ExpKeyword.Return : "return {0}", }; return ret; } - public static ExpProcedureControlNode Skip( Token t ) + public static ExpProcedureControlNode Skip(Token t) { - ExpProcedureControlNode ret = new ExpProcedureControlNode( t ) + ExpProcedureControlNode ret = new ExpProcedureControlNode(t) { _additional = Empty, CodeConvertTemplate = "break" diff --git a/StgSharp.Script/Express/ExpAstNode/ExpRangeAndIndexNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpRangeAndIndexNode.cs index 3a3041a1..9cec7dba 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpRangeAndIndexNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpRangeAndIndexNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpRangeAndIndexNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpRangeAndIndexNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -44,8 +41,8 @@ namespace StgSharp.Script.Express private ExpSyntaxNode _index; - internal ExpIndexNode( Token t, ExpSyntaxNode node ) - : base( t ) + internal ExpIndexNode(Token t, ExpSyntaxNode node) + : base(t) { _index = node; CodeConvertTemplate = _codeTemplate; @@ -57,14 +54,14 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException(); - public static ExpIndexNode IndexAt( Token position, ExpSyntaxNode expression ) + public static ExpIndexNode IndexAt(Token position, ExpSyntaxNode expression) { - ArgumentNullException.ThrowIfNull( expression ); - if( ExpNodeFlag.BuiltinType_Int.IsNotInFlag( expression.NodeFlag ) ) { + ArgumentNullException.ThrowIfNull(expression); + if (ExpNodeFlag.BuiltinType_Int.IsNotInFlag(expression.NodeFlag)) { throw new ExpInvalidTypeException( - position, "Integer", expression.EqualityTypeConvert.Name ); + position, "Integer", expression.EqualityTypeConvert.Name); } - return new ExpIndexNode( position, expression ); + return new ExpIndexNode(position, expression); } } @@ -76,8 +73,8 @@ namespace StgSharp.Script.Express private ExpSyntaxNode _begin, _end; - internal ExpRangeNode( Token t, ExpSyntaxNode begin, ExpSyntaxNode end ) - : base( t ) + internal ExpRangeNode(Token t, ExpSyntaxNode begin, ExpSyntaxNode end) + : base(t) { _begin = begin; _end = end; @@ -90,22 +87,19 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert => ExpInstantiableElement.Void; - public static ExpRangeNode RangeNode( - Token position, - ExpSyntaxNode beginNode, - ExpSyntaxNode endNode ) + public static ExpRangeNode RangeNode(Token position, ExpSyntaxNode beginNode, ExpSyntaxNode endNode) { - ArgumentNullException.ThrowIfNull( beginNode ); - ArgumentNullException.ThrowIfNull( endNode ); - if( ExpNodeFlag.BuiltinType_Int.IsNotInFlag( beginNode.NodeFlag ) ) { + ArgumentNullException.ThrowIfNull(beginNode); + ArgumentNullException.ThrowIfNull(endNode); + if (ExpNodeFlag.BuiltinType_Int.IsNotInFlag(beginNode.NodeFlag)) { throw new ExpInvalidTypeException( - position, "Integer", beginNode.EqualityTypeConvert.Name ); + position, "Integer", beginNode.EqualityTypeConvert.Name); } - if( ExpNodeFlag.BuiltinType_Int.IsNotInFlag( endNode.NodeFlag ) ) { + if (ExpNodeFlag.BuiltinType_Int.IsNotInFlag(endNode.NodeFlag)) { throw new ExpInvalidTypeException( - position, "Integer", endNode.EqualityTypeConvert.Name ); + position, "Integer", endNode.EqualityTypeConvert.Name); } - return new ExpRangeNode( position, beginNode, endNode ); + return new ExpRangeNode(position, beginNode, endNode); } } @@ -113,7 +107,7 @@ namespace StgSharp.Script.Express public class ExpCollectionExpressionNode : ExpSyntaxNode { - internal ExpCollectionExpressionNode( Token t, ExpTupleNode tupleNode ) : base( t ) { } + internal ExpCollectionExpressionNode(Token t, ExpTupleNode tupleNode) : base(t) { } public override ExpSyntaxNode Left => throw new NotImplementedException(); diff --git a/StgSharp.Script/Express/ExpAstNode/ExpRepeatNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpRepeatNode.cs index bf78fa10..d47162f6 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpRepeatNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpRepeatNode.cs @@ -1,30 +1,27 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="ExpRepeatNode.cs" +// file="ExpRepeatNode" // Project: StgSharp // AuthorGroup: Nitload Space // Copyright (c) Nitload Space. All rights reserved. // -// 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. +// 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. // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- @@ -147,7 +144,8 @@ namespace StgSharp.Script.Express * 6: until */ - CodeConvertTemplate = $$""" + CodeConvertTemplate = + $$""" for( {0} = {1}; {0} <= {2}; {0} += {3}) { if(!( {5} )) break; @@ -171,8 +169,7 @@ namespace StgSharp.Script.Express { whileRule = IsNullOrEmpty(whileRule) ? ExpBoolNode.True(t) : whileRule; untilRule = IsNullOrEmpty(untilRule) ? ExpBoolNode.False(t) : untilRule; - ExpRepeatNode ret = new ExpRepeatNode( - t, repeatVariable, begin, end, increment, body, whileRule, untilRule) + ExpRepeatNode ret = new ExpRepeatNode(t, repeatVariable, begin, end, increment, body, whileRule, untilRule) { /* * 0: variable name @@ -184,7 +181,8 @@ namespace StgSharp.Script.Express * 6: until */ - CodeConvertTemplate = $$""" + CodeConvertTemplate = + $$""" for({{repeatVariable.TypeName}} {0} = {1}; {0} <= {2}; {0} += {3}) { if(!( {5} )) break; diff --git a/StgSharp.Script/Express/ExpAstNode/ExpSwitchNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpSwitchNode.cs index baa47f64..5c912964 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpSwitchNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpSwitchNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSwitchNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSwitchNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Frozen; using System.Collections.Generic; @@ -47,21 +44,21 @@ namespace StgSharp.Script.Express Token source, ExpSyntaxNode target, ExpSyntaxNode defaultCase, - params (ExpSyntaxNode label, ExpSyntaxNode op)[] cases ) - : base( source ) + params (ExpSyntaxNode label, ExpSyntaxNode op)[] cases) + : base(source) { _target = target; _default = defaultCase; Dictionary casesDic = new Dictionary( ); - foreach( (ExpSyntaxNode label, ExpSyntaxNode op ) item in cases ) + foreach ((ExpSyntaxNode label, ExpSyntaxNode op ) item in cases) { - if( item.op == null ) + if (item.op == null) { - casesDic.Add( item.label, null! ); + casesDic.Add(item.label, null!); } else { - casesDic.Add( item.label, item.op ); + casesDic.Add(item.label, item.op); } } _cases = casesDic.ToFrozenDictionary(); @@ -69,8 +66,8 @@ namespace StgSharp.Script.Express string str = @"switch( {0} ){"; StringBuilder codeFormatBuilder = new StringBuilder(); - codeFormatBuilder.AppendLine( str ); - for( int i = 0; i < casesDic.Count; i++ ) + codeFormatBuilder.AppendLine(str); + for (int i = 0; i < casesDic.Count; i++) { int index = i * 2 + 1; codeFormatBuilder.AppendLine( @@ -78,7 +75,7 @@ namespace StgSharp.Script.Express case {{{index}}}: {{{index + 1}}} break; - """ ); + """); } CodeConvertTemplate = codeFormatBuilder.ToString(); } @@ -87,8 +84,8 @@ namespace StgSharp.Script.Express Token source, ExpSyntaxNode target, ExpSyntaxNode defaultCase, - IDictionary cases ) - : base( source ) + IDictionary cases) + : base(source) { _target = target; _default = defaultCase; @@ -96,8 +93,8 @@ namespace StgSharp.Script.Express string str = @"switch( {0} ){"; StringBuilder codeFormatBuilder = new StringBuilder(); - codeFormatBuilder.AppendLine( str ); - for( int i = 0; i < cases.Count; i++ ) + codeFormatBuilder.AppendLine(str); + for (int i = 0; i < cases.Count; i++) { int index = i * 2 + 1; codeFormatBuilder.AppendLine( @@ -105,16 +102,16 @@ namespace StgSharp.Script.Express case {{{index}}}: {{{index + 1}}} break; - """ ); + """); } CodeConvertTemplate = codeFormatBuilder.ToString(); } - public ExpSyntaxNode this[ ExpSyntaxNode index ] + public ExpSyntaxNode this[ExpSyntaxNode index] { get { - if( _cases.TryGetValue( index, out ExpSyntaxNode? ret ) ) { + if (_cases.TryGetValue(index, out ExpSyntaxNode? ret)) { return ret; } return _default; @@ -127,9 +124,9 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert => null!; - public bool ContainsCase( ExpSyntaxNode token ) + public bool ContainsCase(ExpSyntaxNode token) { - return _cases.ContainsKey( token ); + return _cases.ContainsKey(token); } } diff --git a/StgSharp.Script/Express/ExpAstNode/ExpTupleNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpTupleNode.cs index c502366e..a4bb97f9 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpTupleNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpTupleNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpTupleNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpTupleNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -42,8 +39,8 @@ namespace StgSharp.Script.Express private ExpSyntaxNode node; - private ExpTupleNode( ExpSyntaxNode node ) - : base( node._source ) + private ExpTupleNode(ExpSyntaxNode node) + : base(node._source) { this.node = node; } @@ -54,10 +51,10 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException(); - [MethodImpl( MethodImplOptions.AggressiveInlining )] - public static ExpTupleNode Pack( ExpSyntaxNode node ) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ExpTupleNode Pack(ExpSyntaxNode node) { - return new ExpTupleNode( node ); + return new ExpTupleNode(node); } public ExpNodePresidentEnumerator TupleAsEnumerator() diff --git a/StgSharp.Script/Express/ExpAstNode/ExpUnaryOperatorNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpUnaryOperatorNode.cs index 99e9e9c1..80777523 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpUnaryOperatorNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpUnaryOperatorNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpUnaryOperatorNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpUnaryOperatorNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -41,10 +38,10 @@ namespace StgSharp.Script.Express private ExpSyntaxNode _operand; - private ExpUnaryOperatorNode( Token source ) : base( source ) { } + private ExpUnaryOperatorNode(Token source) : base(source) { } - public ExpUnaryOperatorNode( Token source, ExpSyntaxNode operand, ExpSchema context ) - : base( source ) + public ExpUnaryOperatorNode(Token source, ExpSyntaxNode operand, ExpSchema context) + : base(source) { _operand = operand; } @@ -55,44 +52,43 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert => _operand.EqualityTypeConvert; - public static ExpUnaryOperatorNode UnaryMinus( Token source, ExpSyntaxNode operand ) + public static ExpUnaryOperatorNode UnaryMinus(Token source, ExpSyntaxNode operand) { - if( !operand.IsNumber ) { + if (!operand.IsNumber) { throw new ExpInvalidTypeException( - source, "Number", operand.EqualityTypeConvert.Name ); + source, "Number", operand.EqualityTypeConvert.Name); } bool isFloat = - ( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; - return new ExpUnaryOperatorNode( source ) + (operand._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0; + return new ExpUnaryOperatorNode(source) { _nodeFlag = ExpNodeFlag.Operator_Unary | ExpNodeFlag.BuiltinType_Number, CodeConvertTemplate = "- {0}", }; } - public static ExpUnaryOperatorNode UnaryNot( Token source, ExpSyntaxNode operand ) + public static ExpUnaryOperatorNode UnaryNot(Token source, ExpSyntaxNode operand) { - if( ( operand._nodeFlag | ( ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.BuiltinType_Logic ) ) == - 0 ) { + if ((operand._nodeFlag | (ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.BuiltinType_Logic)) == 0) { throw new ExpInvalidTypeException( - source, "Bool or Logic", operand.EqualityTypeConvert.Name ); + source, "Bool or Logic", operand.EqualityTypeConvert.Name); } - return new ExpUnaryOperatorNode( source ) + return new ExpUnaryOperatorNode(source) { _nodeFlag = ExpNodeFlag.Operator_Unary | ExpNodeFlag.BuiltinType_Logic, CodeConvertTemplate = "! {0}", }; } - public static ExpUnaryOperatorNode UnaryPlus( Token source, ExpSyntaxNode operand ) + public static ExpUnaryOperatorNode UnaryPlus(Token source, ExpSyntaxNode operand) { - if( !operand.IsNumber ) { + if (!operand.IsNumber) { throw new ExpInvalidTypeException( - source, "Number", operand.EqualityTypeConvert.Name ); + source, "Number", operand.EqualityTypeConvert.Name); } bool isFloat = - ( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; - return new ExpUnaryOperatorNode( source ) + (operand._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0; + return new ExpUnaryOperatorNode(source) { _nodeFlag = ExpNodeFlag.Operator_Unary | ExpNodeFlag.BuiltinType_Number, CodeConvertTemplate = "+ {0}", diff --git a/StgSharp.Script/Express/ExpAstNode/_ExpNode.cs b/StgSharp.Script/Express/ExpAstNode/_ExpNode.cs index 1242a021..65828290 100644 --- a/StgSharp.Script/Express/ExpAstNode/_ExpNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/_ExpNode.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="_ExpNode.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="_ExpNode" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using CommunityToolkit.HighPerformance.Buffers; using System; @@ -45,7 +42,7 @@ namespace StgSharp.Script.Express protected internal ExpNodeFlag _nodeFlag; protected internal Token _source; - protected ExpSyntaxNode( Token source ) + protected ExpSyntaxNode(Token source) { _source = source; Next = this; @@ -54,7 +51,7 @@ namespace StgSharp.Script.Express public bool IsNumber { - get { return ( _nodeFlag | ExpNodeFlag.BuiltinType_Number ) != 0; } + get { return (_nodeFlag | ExpNodeFlag.BuiltinType_Number) != 0; } } public abstract ExpSyntaxNode Left { get; } @@ -76,7 +73,7 @@ namespace StgSharp.Script.Express public int Column => _source.Column; - public long NodeFlag => ( long )_nodeFlag; + public long NodeFlag => (long)_nodeFlag; public string CodeConvertTemplate { get; init; } @@ -85,7 +82,7 @@ namespace StgSharp.Script.Express get => _source; } - public void AppendNode( ExpSyntaxNode nextNode ) + public void AppendNode(ExpSyntaxNode nextNode) { Next.Previous = nextNode; nextNode.Next = Next; @@ -93,24 +90,24 @@ namespace StgSharp.Script.Express Next.Previous = this; } - public static bool IsNullOrEmpty( [AllowNull]ExpSyntaxNode node ) + public static bool IsNullOrEmpty([AllowNull]ExpSyntaxNode node) { return node == ExpEmptyNode._only || node == null; } - [MethodImpl( MethodImplOptions.AggressiveInlining )] - public static ExpSyntaxNode NonOperation( Token source ) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ExpSyntaxNode NonOperation(Token source) { - return new ExpEmptyNode( source.Line, source.Column ); + return new ExpEmptyNode(source.Line, source.Column); } - [MethodImpl( MethodImplOptions.AggressiveInlining )] - public static ExpSyntaxNode NonOperation( int line, int column ) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ExpSyntaxNode NonOperation(int line, int column) { - return new ExpEmptyNode( line, column ); + return new ExpEmptyNode(line, column); } - public void PrependNode( ExpSyntaxNode previousNode ) + public void PrependNode(ExpSyntaxNode previousNode) { Previous.Next = previousNode; previousNode.Previous = Previous; @@ -118,19 +115,17 @@ namespace StgSharp.Script.Express previousNode.Next = this; } - public static bool VerifyTypeConvertable( ExpSyntaxNode left, ExpSyntaxNode right ) + public static bool VerifyTypeConvertable(ExpSyntaxNode left, ExpSyntaxNode right) { IExpElementSource tLeft = left.EqualityTypeConvert, tRight = right.EqualityTypeConvert; - if( tLeft is not ExpInstantiableElement tLeftIns || - tRight is not ExpInstantiableElement tRightIns ) { + if (tLeft is not ExpInstantiableElement tLeftIns || tRight is not ExpInstantiableElement tRightIns) { return false; } - if( ExpInstantiableElement.IsNullOrVoid( tLeftIns ) || - ExpInstantiableElement.IsNullOrVoid( tLeftIns ) ) { + if (ExpInstantiableElement.IsNullOrVoid(tLeftIns) || ExpInstantiableElement.IsNullOrVoid(tLeftIns)) { return false; } - return tLeft.IsConvertable( tRight ); + return tLeft.IsConvertable(tRight); } private class ExpEmptyNode : ExpSyntaxNode @@ -138,10 +133,9 @@ namespace StgSharp.Script.Express internal static readonly ExpEmptyNode _only = new(); - public ExpEmptyNode() : base( Token.Empty ) { } + public ExpEmptyNode() : base(Token.Empty) { } - public ExpEmptyNode( int line, int column ) - : base( new Token( string.Empty, line, column, TokenFlag.None ) ) { } + public ExpEmptyNode(int line, int column) : base(new Token(string.Empty, line, column, TokenFlag.None)) { } public override ExpInstantiableElement EqualityTypeConvert => ExpInstantiableElement.Void; diff --git a/StgSharp.Script/Express/ExpElementInstance.cs b/StgSharp.Script/Express/ExpElementInstance.cs index 4a3f4c33..b0492952 100644 --- a/StgSharp.Script/Express/ExpElementInstance.cs +++ b/StgSharp.Script/Express/ExpElementInstance.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpElementInstance.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpElementInstance" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.IO; @@ -56,8 +53,8 @@ namespace StgSharp.Script.Express public abstract class ExpElementInstance : ExpSyntaxNode { - protected ExpElementInstance( Token source ) - : base( source ) + protected ExpElementInstance(Token source) + : base(source) { CodeConvertTemplate = source.Value; } @@ -72,61 +69,61 @@ namespace StgSharp.Script.Express public abstract string TypeName { get; } - public static ExpElementInstance CreateLiteral( Token t ) + public static ExpElementInstance CreateLiteral(Token t) { - if( int.TryParse( t.Value, out int _int ) ) + if (int.TryParse(t.Value, out int _int)) { - return new ExpIntNode( t, _int, true ); - } else if( float.TryParse( t.Value, out float _float ) ) + return new ExpIntNode(t, _int, true); + } else if (float.TryParse(t.Value, out float _float)) { - return new ExpRealNumberNode( t, _float, true ); - } else if( bool.TryParse( t.Value, out bool _bool ) ) + return new ExpRealNumberNode(t, _float, true); + } else if (bool.TryParse(t.Value, out bool _bool)) { - return new ExpBoolNode( t, _bool, true ); - } else if( ExpLogic.TryParse( t.Value, out ExpLogic _logic ) ) + return new ExpBoolNode(t, _bool, true); + } else if (ExpLogic.TryParse(t.Value, out ExpLogic _logic)) { - return new ExpLogicValueNode( t, _logic, true ); + return new ExpLogicValueNode(t, _logic, true); } else { - return new ExpStringNode( t, t.Value, true ); + return new ExpStringNode(t, t.Value, true); } } - public ExpInstanceReferenceNode MakeReference( Token t ) + public ExpInstanceReferenceNode MakeReference(Token t) { - return new ExpInstanceReferenceNode( t, this ); + return new ExpInstanceReferenceNode(t, this); } - public static bool TryCreateLiteral( Token t, out ExpElementInstance instance ) + public static bool TryCreateLiteral(Token t, out ExpElementInstance instance) { - if( int.TryParse( t.Value, out int _int ) ) + if (int.TryParse(t.Value, out int _int)) { - instance = new ExpIntNode( t, _int, true ); + instance = new ExpIntNode(t, _int, true); return true; - } else if( float.TryParse( t.Value, out float _float ) ) + } else if (float.TryParse(t.Value, out float _float)) { - instance = new ExpRealNumberNode( t, _float, true ); + instance = new ExpRealNumberNode(t, _float, true); return true; - } else if( bool.TryParse( t.Value, out bool _bool ) ) + } else if (bool.TryParse(t.Value, out bool _bool)) { - instance = new ExpBoolNode( t, _bool, true ); + instance = new ExpBoolNode(t, _bool, true); return true; - } else if( ExpLogic.TryParse( t.Value, out ExpLogic _logic ) ) + } else if (ExpLogic.TryParse(t.Value, out ExpLogic _logic)) { - instance = new ExpLogicValueNode( t, _logic, true ); + instance = new ExpLogicValueNode(t, _logic, true); return true; - } else if( t.Flag == TokenFlag.String ) + } else if (t.Flag == TokenFlag.String) { - instance = new ExpStringNode( t, t.Value, true ); + instance = new ExpStringNode(t, t.Value, true); return true; } instance = null!; return false; } - public bool TryGetMember( string name, out ExpSyntaxNode node ) + public bool TryGetMember(string name, out ExpSyntaxNode node) { - return EqualityTypeConvert.TryGetMember( name, out node ); + return EqualityTypeConvert.TryGetMember(name, out node); } } diff --git a/StgSharp.Script/Express/ExpElmentSource.cs b/StgSharp.Script/Express/ExpElmentSource.cs index f06c890a..94913d8c 100644 --- a/StgSharp.Script/Express/ExpElmentSource.cs +++ b/StgSharp.Script/Express/ExpElmentSource.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpElmentSource.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpElmentSource" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -45,11 +42,11 @@ namespace StgSharp.Script.Express string Name { get; } - public void AddMember( string name, ExpSyntaxNode memberNode ); + public void AddMember(string name, ExpSyntaxNode memberNode); public void Analyse(); - public bool TryGetMember( string name, out ExpSyntaxNode memberNode ); + public bool TryGetMember(string name, out ExpSyntaxNode memberNode); } @@ -70,29 +67,29 @@ namespace StgSharp.Script.Express public abstract string Name { get; } - public void AddMember( string name, ExpSyntaxNode memberNode ) + public void AddMember(string name, ExpSyntaxNode memberNode) { throw new NotImplementedException(); } public abstract void Analyse(); - public abstract ExpSyntaxNode CreateInstanceNode( Token t ); + public abstract ExpSyntaxNode CreateInstanceNode(Token t); - public bool IsConvertable( IExpElementSource targetType ) + public bool IsConvertable(IExpElementSource targetType) { - if( targetType == null ) { + if (targetType == null) { return false; } throw new NotImplementedException(); } - public static bool IsNullOrVoid( ExpInstantiableElement element ) + public static bool IsNullOrVoid(ExpInstantiableElement element) { return element == null || element == ExpVoidElement.Only; } - public abstract bool TryGetMember( string name, out ExpSyntaxNode memberNode ); + public abstract bool TryGetMember(string name, out ExpSyntaxNode memberNode); private sealed class ExpVoidElement : ExpInstantiableElement { @@ -112,12 +109,12 @@ namespace StgSharp.Script.Express return; } - public override ExpSyntaxNode CreateInstanceNode( Token t ) + public override ExpSyntaxNode CreateInstanceNode(Token t) { return ExpSyntaxNode.Empty; } - public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) + public override bool TryGetMember(string name, out ExpSyntaxNode memberNode) { memberNode = ExpSyntaxNode.Empty; return false; @@ -136,21 +133,21 @@ namespace StgSharp.Script.Express public abstract string Name { get; } - public void AddMember( string name, ExpSyntaxNode memberNode ) + public void AddMember(string name, ExpSyntaxNode memberNode) { throw new NotImplementedException(); } public abstract void Analyse(); - public bool IsConvertable( IExpElementSource targetType ) + public bool IsConvertable(IExpElementSource targetType) { return false; } - public abstract ExpSyntaxNode MakeReference( params object[] options ); + public abstract ExpSyntaxNode MakeReference(params object[] options); - public abstract bool TryGetMember( string name, out ExpSyntaxNode memberNode ); + public abstract bool TryGetMember(string name, out ExpSyntaxNode memberNode); } } diff --git a/StgSharp.Script/Express/ExpExceptions.cs b/StgSharp.Script/Express/ExpExceptions.cs index d6cb855f..ff08f6a7 100644 --- a/StgSharp.Script/Express/ExpExceptions.cs +++ b/StgSharp.Script/Express/ExpExceptions.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpExceptions.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpExceptions" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.ComponentModel; @@ -44,17 +41,17 @@ namespace StgSharp.Script.Express private Token _pos; - public ExpException( string message ) : base( message ) { } + public ExpException(string message) : base(message) { } - public ExpException( Token position, string message ) - : base( $"Express compile error at {position.Line}-{position.Column}:\n{message}" ) + public ExpException(Token position, string message) + : base($"Express compile error at {position.Line}-{position.Column}:\n{message}") { _pos = position; } - public ExpException( ExpSyntaxNode node, string message ) + public ExpException(ExpSyntaxNode node, string message) : base( - $"Express compile error at {node.Source.Line}-{node.Source.Column}:\n{message}" ) + $"Express compile error at {node.Source.Line}-{node.Source.Column}:\n{message}") { _pos = node._source; } @@ -64,36 +61,34 @@ namespace StgSharp.Script.Express public class ExpInvalidCharException : ExpException { - public ExpInvalidCharException( char c ) : base( $"An unknown char {c} occurred." ) { } + public ExpInvalidCharException(char c) : base($"An unknown char {c} occurred.") { } - public ExpInvalidCharException( int index ) - : base( $"Cannot read a token from line at {index}" ) { } + public ExpInvalidCharException(int index) : base($"Cannot read a token from line at {index}") { } } public class ExpStringNotCloseException : ExpException { - public ExpStringNotCloseException( int linenum ) - : base( $"A string does not closed at end of line {linenum}." ) { } + public ExpStringNotCloseException(int linenum) : base($"A string does not closed at end of line {linenum}.") { } } public class ExpInvalidSyntaxException : ExpException { - public ExpInvalidSyntaxException( string message ) : base( message ) { } + public ExpInvalidSyntaxException(string message) : base(message) { } - public static void ThrowNonCollectionIndex( Token t ) + public static void ThrowNonCollectionIndex(Token t) { throw new ExpInvalidSyntaxException( - $"Use a collection indexer to a non-collection variable at line {t.Line} column {t.Column}" ); + $"Use a collection indexer to a non-collection variable at line {t.Line} column {t.Column}"); } - public static void ThrowNoOperator( Token t ) + public static void ThrowNoOperator(Token t) { throw new ExpInvalidSyntaxException( - $"No operator but more than one operand before line {t.Line} column {t.Column}" ); + $"No operator but more than one operand before line {t.Line} column {t.Column}"); } } @@ -101,70 +96,68 @@ namespace StgSharp.Script.Express public class ExpInvalidElementDeclareEndingExceptions : ExpException { - public ExpInvalidElementDeclareEndingExceptions( string declaredName, string endedName ) + public ExpInvalidElementDeclareEndingExceptions(string declaredName, string endedName) : base( - $"The datatype is declared with name {declaredName} but ended with {endedName}" ) { } + $"The datatype is declared with name {declaredName} but ended with {endedName}") { } } public class ExpInvalidElementNameException : ExpException { - public ExpInvalidElementNameException( string elementName, ExpSchema schema ) - : base( $"Cannot find any element named {elementName} in {schema.Name}" ) { } + public ExpInvalidElementNameException(string elementName, ExpSchema schema) + : base($"Cannot find any element named {elementName} in {schema.Name}") { } } public class ExpInvalidTypeException : ExpException { - public ExpInvalidTypeException( ExpSyntaxNode node, string required, string provided ) + public ExpInvalidTypeException(ExpSyntaxNode node, string required, string provided) : base( node, - $"Type {required} is required at position, but a {provided} instance is provided." ) { } + $"Type {required} is required at position, but a {provided} instance is provided.") { } - public ExpInvalidTypeException( Token t, string required, string provided ) + public ExpInvalidTypeException(Token t, string required, string provided) : base( t, - $"Type {required} is required at position, but a {provided} instance is provided." ) { } + $"Type {required} is required at position, but a {provided} instance is provided.") { } } public class ExpCaseNotFoundException : ArgumentOutOfRangeException { - public ExpCaseNotFoundException( ExpSwitchNode token, ExpSyntaxNode label ) + public ExpCaseNotFoundException(ExpSwitchNode token, ExpSyntaxNode label) : base( - $"Attempt to read or write the label at ({token.Line},{token.Column}), that does not exist in SWITCH expression at ({token.Line},{token.Column})" ) { } + $"Attempt to read or write the label at ({token.Line},{token.Column}), that does not exist in SWITCH expression at ({token.Line},{token.Column})") { } } public class ExpInvalidCollectionMemberTypeException : InvalidCastException { - public ExpInvalidCollectionMemberTypeException( - ExpElementInstance elementInstance, - ExpCollectionBase collection ) + public ExpInvalidCollectionMemberTypeException(ExpElementInstance elementInstance, ExpCollectionBase collection) : base( - $"Attempt to add or remove an element of type: {elementInstance.ElementType} from a collection collects {collection.MemberType}" ) { } + $"Attempt to add or remove an element of type: {elementInstance.ElementType} from a collection collects {collection.MemberType}") { } } public class ExpInvalidSchemaIncludeException : InvalidOperationException { - public ExpInvalidSchemaIncludeException( ExpSchema context, ExpSchema source ) + public ExpInvalidSchemaIncludeException(ExpSchema context, ExpSchema source) : base( - $"Attempted to refer to an EXPRESS language expression in the current schema context '{context.Name}', but this expression comes from another schema '{source.Name}' that has not been included." ) { } + $"Attempted to refer to an EXPRESS language expression in the current schema context '{context.Name}', but this expression comes from another schema '{source.Name}' that has not been included.") { } } public class ExpElementLoadException : TypeLoadException { - public ExpElementLoadException( string typeName, ExpSchema context ) + public ExpElementLoadException(string typeName, ExpSchema context) : base( - $"Cannot find the element {typeName} in schema {context.Name} and its included schemas" ) { } + $"Cannot find the element {typeName} in schema {context.Name} and its included schemas") { } } @@ -172,16 +165,16 @@ namespace StgSharp.Script.Express { public ExpCompileNotInitializedException() - : base( "Attempt to compile an EXPRESS script before the init of compiler." ) { } + : base("Attempt to compile an EXPRESS script before the init of compiler.") { } } public class ExpCompileException : ExpException { - public ExpCompileException( Token pos, string message ) + public ExpCompileException(Token pos, string message) : base( - $"Compiler exception occur when processing token at line {pos.Line}, column {pos.Column}. Detailed message:{Environment.NewLine}{message} " ) { } + $"Compiler exception occur when processing token at line {pos.Line}, column {pos.Column}. Detailed message:{Environment.NewLine}{message} ") { } } } diff --git a/StgSharp.Script/Express/ExpNodeFlag.cs b/StgSharp.Script/Express/ExpNodeFlag.cs index 6a34ba70..9d85bab4 100644 --- a/StgSharp.Script/Express/ExpNodeFlag.cs +++ b/StgSharp.Script/Express/ExpNodeFlag.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpNodeFlag.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpNodeFlag" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.ComponentModel; @@ -37,28 +34,28 @@ using System.Threading.Tasks; namespace StgSharp.Script.Express { - [EditorBrowsable( EditorBrowsableState.Never )] + [EditorBrowsable(EditorBrowsableState.Never)] public static class ExpNodeFlagHelper { - public static bool IsInFlag( this ExpNodeFlag flag, long target ) + public static bool IsInFlag(this ExpNodeFlag flag, long target) { - return ( ( long )flag & target ) != 0; + return ((long)flag & target) != 0; } - public static bool IsInFlag( this ExpNodeFlag flag, ExpNodeFlag target ) + public static bool IsInFlag(this ExpNodeFlag flag, ExpNodeFlag target) { - return ( long )( flag & target ) != 0; + return (long)(flag & target) != 0; } - public static bool IsNotInFlag( this ExpNodeFlag flag, long target ) + public static bool IsNotInFlag(this ExpNodeFlag flag, long target) { - return ( ( long )flag & target ) == 0; + return ((long)flag & target) == 0; } - public static bool IsNotInFlag( this ExpNodeFlag flag, ExpNodeFlag target ) + public static bool IsNotInFlag(this ExpNodeFlag flag, ExpNodeFlag target) { - return ( long )( flag & target ) == 0; + return (long)(flag & target) == 0; } } @@ -67,7 +64,7 @@ namespace StgSharp.Script.Express public enum ExpNodeFlag : long { - //string as name of non-builtin variables + // string as name of non-builtin variables None = 0, Name_Element = 1, Name_Param = 2, @@ -76,14 +73,14 @@ namespace StgSharp.Script.Express Name_Operator = 16, Name_Any = Name_Block | Name_Element | Name_Keyword | Name_Param | Name_Operator, - //any type of collections, also has NAME flag + // any type of collections, also has NAME flag Collection_Set = 32, Collection_Bag = 64, Collection_Array = 128, Collection_List = 256, Collection_Any = Collection_Set | Collection_Bag | Collection_Array | Collection_List, - //the variable is type of element, both builtin and non-builtin has this flag + // the variable is type of element, both builtin and non-builtin has this flag Element_Const = 512, Element_Entity = 1024, Element_Type = 2048, @@ -91,7 +88,7 @@ namespace StgSharp.Script.Express Element_Function = 8192, Element_Any = Element_Entity | Element_Const | Element_Function | Element_Rule | Element_Type, - //variable is one of these builtin type + // variable is one of these builtin type BuiltinType_Int = 16384, BuiltinType_Real = 32768, BuiltinType_String = 65536, @@ -101,20 +98,20 @@ namespace StgSharp.Script.Express BuiltinType_Number = BuiltinType_Real | BuiltinType_Int, BuiltinType_Any = BuiltinType_Int | BuiltinType_Real | BuiltinType_String | BuiltinType_Boolean | BuiltinType_Binary | BuiltinType_Logic, - //the token is root of a branch + // the token is root of a branch Branch_If = 0x1_000, Branch_Switch = 0x2_0000, Branch_Repeat = 0x4_0000, Branch_Any = Branch_If | Branch_Repeat | Branch_Switch, - //the token is one of separators + // the token is one of separators Separator_Inline = 0x8_0000, //, or sth else Separator_Line = 0x10_0000, //; or eth else Separator_Block = 0x20_0000, //{}or sth else Separator_Range = 0x40_0000, //()or sth else Separator_Any = Separator_Inline | Separator_Line | Separator_Block | Separator_Range, - //the token is a kind of operator + // the token is a kind of operator Operator_Unary = 0x40_0000, Operator_Binary = 0x80_0000, Operator_SuperType = 0x100_0000, diff --git a/StgSharp.Script/Express/ExpNodeTempEnumerator.cs b/StgSharp.Script/Express/ExpNodeTempEnumerator.cs index c52b277f..10ffe319 100644 --- a/StgSharp.Script/Express/ExpNodeTempEnumerator.cs +++ b/StgSharp.Script/Express/ExpNodeTempEnumerator.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpNodeTempEnumerator.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpNodeTempEnumerator" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp.Syntax; using System; @@ -45,31 +42,28 @@ namespace StgSharp.Script.Express public static class ExpNodeNextEnumeratorExtensions { - public static ExpNodeTempEnumerator AsCollectionEnumerator( - this ExpSyntaxNode token, - bool unpack ) + public static ExpNodeTempEnumerator AsCollectionEnumerator(this ExpSyntaxNode token, bool unpack) { - ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator( token, unpack ); + ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator(token, unpack); IExpElementSource type = token.EqualityTypeConvert; - while( enumerator.MoveNext() ) + while (enumerator.MoveNext()) { - if( enumerator. Current != type ) { + if (enumerator. Current != type) { throw new InvalidCastException(); } } return enumerator; } - [MethodImpl( MethodImplOptions.AggressiveInlining )] - public static ExpNodePresidentEnumerator ToPresidentEnumerator( this ExpSyntaxNode node ) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ExpNodePresidentEnumerator ToPresidentEnumerator(this ExpSyntaxNode node) { - return new ExpNodePresidentEnumerator( node ); + return new ExpNodePresidentEnumerator(node); } - public static ExpNodePresidentEnumerator TupleToPresidentEnumerator( - this ExpSyntaxNode tuple ) + public static ExpNodePresidentEnumerator TupleToPresidentEnumerator(this ExpSyntaxNode tuple) { - return new ExpNodePresidentEnumerator( tuple.Right ); + return new ExpNodePresidentEnumerator(tuple.Right); } } @@ -80,50 +74,50 @@ namespace StgSharp.Script.Express private int _index = -1; private List _begin = new List(); - public ExpNodePresidentEnumerator( ExpSyntaxNode token ) + public ExpNodePresidentEnumerator(ExpSyntaxNode token) { - _begin.Add( token ); + _begin.Add(token); ExpSyntaxNode t = token; - while( !ReferenceEquals( t.Next, token ) && t.Next != null ) + while (!ReferenceEquals(t.Next, token) && t.Next != null) { t = t.Next; - _begin.Add( t ); + _begin.Add(t); } } - public ExpSyntaxNode this[ int index ] + public ExpSyntaxNode this[int index] { get { - ArgumentOutOfRangeException.ThrowIfNegative( index ); - ArgumentOutOfRangeException.ThrowIfGreaterThan( index, _begin.Count ); - return _begin[ index ]; + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThan(index, _begin.Count); + return _begin[index]; } } - public ExpSyntaxNode Current => _begin[ _index ]; + public ExpSyntaxNode Current => _begin[_index]; public int Count => _begin.Count; - public void AssertEnumeratorCount( int count ) + public void AssertEnumeratorCount(int count) { - if( _begin.Count != count ) { + if (_begin.Count != count) { throw new InvalidOperationException( - $"Enumerator count mismatch. Expected {count}, but got {_begin.Count}." ); + $"Enumerator count mismatch. Expected {count}, but got {_begin.Count}."); } } - public void AssertEnumeratorCount( int min, int max ) + public void AssertEnumeratorCount(int min, int max) { - if( _begin.Count < min || _begin.Count > max ) { + if (_begin.Count < min || _begin.Count > max) { throw new InvalidOperationException( - $"Enumerator count mismatch. Expected between {min} and {max}, but got {_begin.Count}." ); + $"Enumerator count mismatch. Expected between {min} and {max}, but got {_begin.Count}."); } } public Span AsSpan() { - return CollectionsMarshal.AsSpan( _begin ); + return CollectionsMarshal.AsSpan(_begin); } public void Dispose() @@ -133,7 +127,7 @@ namespace StgSharp.Script.Express public bool MoveNext() { - if( _index < _begin.Count - 1 ) + if (_index < _begin.Count - 1) { _index++; return true; @@ -155,13 +149,13 @@ namespace StgSharp.Script.Express private ExpSyntaxNode? _current,_begin; - public ExpNodeTempEnumerator( ExpSyntaxNode node ) + public ExpNodeTempEnumerator(ExpSyntaxNode node) { _current = null; _begin = node; } - public ExpNodeTempEnumerator( ExpSyntaxNode node, bool unpack ) + public ExpNodeTempEnumerator(ExpSyntaxNode node, bool unpack) { _current = null; _begin = unpack ? node.Right : node; @@ -171,13 +165,13 @@ namespace StgSharp.Script.Express public bool MoveNext() { - if( _current == null ) + if (_current == null) { _current = _begin; return true; } ExpSyntaxNode next = _current.Next; - if( ReferenceEquals( next, _begin ) || next == null ) { + if (ReferenceEquals(next, _begin) || next == null) { return false; } _current = next; diff --git a/StgSharp.Script/Express/ExpPostProcessor.cs b/StgSharp.Script/Express/ExpPostProcessor.cs index fa6b18cd..ab1af4a5 100644 --- a/StgSharp.Script/Express/ExpPostProcessor.cs +++ b/StgSharp.Script/Express/ExpPostProcessor.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpPostProcessor.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpPostProcessor" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -48,26 +45,26 @@ namespace StgSharp.Script.Express private readonly string _interfaceName /*= typeof( )/**/; private readonly string _sourcePath; - public string Process( string filePath ) + public string Process(string filePath) { Dictionary factoryMethods = new Dictionary(); - FileStream file = File.OpenRead( filePath ); - SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText( File.ReadAllText( filePath ) ); + FileStream file = File.OpenRead(filePath); + SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText(filePath)); - CSharpCompilation compilation = CSharpCompilation.Create( "Analysis" ) - .AddSyntaxTrees( syntaxTree ) + CSharpCompilation compilation = CSharpCompilation.Create("Analysis") + .AddSyntaxTrees(syntaxTree) .AddReferences( MetadataReference.CreateFromFile( - typeof( object ).Assembly.Location ) ); + typeof(object).Assembly.Location)); - INamedTypeSymbol? interfaceSymbol = compilation.GetTypeByMetadataName( _interfaceName ); + INamedTypeSymbol? interfaceSymbol = compilation.GetTypeByMetadataName(_interfaceName); - if( interfaceSymbol == null ) { - throw new InvalidOperationException( $"Interface '{_interfaceName}' not found." ); + if (interfaceSymbol == null) { + throw new InvalidOperationException($"Interface '{_interfaceName}' not found."); } - SemanticModel semanticModel = compilation.GetSemanticModel( syntaxTree ); + SemanticModel semanticModel = compilation.GetSemanticModel(syntaxTree); SyntaxNode root = syntaxTree.GetRoot(); IEnumerable classDeclarations = root.DescendantNodes() @@ -78,28 +75,27 @@ namespace StgSharp.Script.Express t => SymbolEqualityComparer.Default .Equals( semanticModel.GetTypeInfo( - t.Type ) + t.Type) .Type, - interfaceSymbol ) ) ?? - false ); + interfaceSymbol)) ?? + false); - foreach( ClassDeclarationSyntax classDeclaration in classDeclarations ) + foreach (ClassDeclarationSyntax classDeclaration in classDeclarations) { string className = classDeclaration.Identifier.Text; IMethodSymbol? factoryMethod = interfaceSymbol.GetMembers() .OfType() .FirstOrDefault( - m => m.IsStatic && - m.Name == "CreateInstance" ); + m => m.IsStatic && m.Name == "CreateInstance"); - if( factoryMethod != null ) { - factoryMethods[ className ] = $"() => {interfaceSymbol.Name}.CreateInstance()"; + if (factoryMethod != null) { + factoryMethods[className] = $"() => {interfaceSymbol.Name}.CreateInstance()"; } } string code = "var factoryMethods = new Dictionary>\n{\n"; code += string.Join( - ",\n", factoryMethods.Select( kvp => $" {{ \"{kvp.Key}\", {kvp.Value} }}" ) ); + ",\n", factoryMethods.Select(kvp => $" {{ \"{kvp.Key}\", {kvp.Value} }}")); code += "\n};"; return code; diff --git a/StgSharp.Script/Express/ExpSchemaBase.cs b/StgSharp.Script/Express/ExpSchemaBase.cs index d7bc9fd3..ffcb062a 100644 --- a/StgSharp.Script/Express/ExpSchemaBase.cs +++ b/StgSharp.Script/Express/ExpSchemaBase.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSchemaBase.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSchemaBase" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Collections; using System; @@ -49,21 +46,21 @@ namespace StgSharp.Script.Express public string Name { get; internal set; } - public abstract void LoadFromSource( ExpSchemaSource source ); + public abstract void LoadFromSource(ExpSchemaSource source); - public abstract bool TryGetConst( string name, out ExpElementInstance c ); + public abstract bool TryGetConst(string name, out ExpElementInstance c); - public abstract bool TryGetEntity( string name, out ExpEntitySource e ); + public abstract bool TryGetEntity(string name, out ExpEntitySource e); - public abstract bool TryGetFunction( string name, out ExpFunctionSource f ); + public abstract bool TryGetFunction(string name, out ExpFunctionSource f); - public abstract bool TryGetProcedure( string name, out ExpProcedureSource p ); + public abstract bool TryGetProcedure(string name, out ExpProcedureSource p); - public abstract bool TryGetRule( string name, out ExpRuleSource r ); + public abstract bool TryGetRule(string name, out ExpRuleSource r); - public abstract bool TryGetSchemaInclude( string name, out ExpSchema include ); + public abstract bool TryGetSchemaInclude(string name, out ExpSchema include); - public abstract bool TryGetType( string name, out ExpTypeSource t ); + public abstract bool TryGetType(string name, out ExpTypeSource t); #pragma warning disable CS8618 protected FrozenDictionary ConstDict { get; set; } diff --git a/StgSharp.Script/Express/ExpSchemaSource.Compile.cs b/StgSharp.Script/Express/ExpSchemaSource.Compile.cs index 950e0835..96195e09 100644 --- a/StgSharp.Script/Express/ExpSchemaSource.Compile.cs +++ b/StgSharp.Script/Express/ExpSchemaSource.Compile.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSchemaSource.Compile.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSchemaSource.Compile" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -48,14 +45,14 @@ namespace StgSharp.Script.Express public partial class ExpSchemaSource { - public ExpSchema Compile( ExpressCompileOption option ) + public ExpSchema Compile(ExpressCompileOption option) { - switch( option ) + switch (option) { case ExpressCompileOption.Default: - return Compile_Translate( option ); + return Compile_Translate(option); case ExpressCompileOption.Translate: - return Compile_Translate( option ); + return Compile_Translate(option); case ExpressCompileOption.Compile: throw new NotSupportedException(); default: @@ -63,7 +60,7 @@ namespace StgSharp.Script.Express } } - internal GeneratedExpSchema Compile_Translate( ExpressCompileOption option ) + internal GeneratedExpSchema Compile_Translate(ExpressCompileOption option) { throw new NotImplementedException(); } diff --git a/StgSharp.Script/Express/ExpSchemaSource.cs b/StgSharp.Script/Express/ExpSchemaSource.cs index 8199c35f..3a9e5b66 100644 --- a/StgSharp.Script/Express/ExpSchemaSource.cs +++ b/StgSharp.Script/Express/ExpSchemaSource.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSchemaSource.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSchemaSource" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using StgSharp.Collections; using StgSharp.Graphics.OpenGL; @@ -79,69 +76,66 @@ namespace StgSharp.Script.Express public ExpSchema Organize() { - _compileResult.LoadFromSource( this ); + _compileResult.LoadFromSource(this); return _compileResult; } - public void ReadSchema( ExpFileSource reader ) + public void ReadSchema(ExpFileSource reader) { string line = reader.ReadLine(); - while( !_schemaBegin.IsMatch( line ) ) { + while (!_schemaBegin.IsMatch(line)) { line = reader.ReadLine(); } - name = _schemaBegin.Match( line ).Groups[ "namespace" ].Value; + name = _schemaBegin.Match(line).Groups["namespace"].Value; - while( !_schemaEnd.IsMatch( line ) ) + while (!_schemaEnd.IsMatch(line)) { - if( TryReadConst( line, reader, out IExpElementSource source ) ) + if (TryReadConst(line, reader, out IExpElementSource source)) { - _sourceCache.Add( source ); - } else if( TryReadType( line, reader, out source ) ) + _sourceCache.Add(source); + } else if (TryReadType(line, reader, out source)) { - _sourceCache.Add( source ); - } else if( TryReadEntity( line, reader, out source ) ) + _sourceCache.Add(source); + } else if (TryReadEntity(line, reader, out source)) { - _sourceCache.Add( source ); - } else if( TryReadRule( line, reader, out source ) ) + _sourceCache.Add(source); + } else if (TryReadRule(line, reader, out source)) { - _sourceCache.Add( source ); - } else if( TryReadFunction( line, reader, out source ) ) { - _sourceCache.Add( source ); + _sourceCache.Add(source); + } else if (TryReadFunction(line, reader, out source)) { + _sourceCache.Add(source); } line = reader.ReadLine(); } } - public static bool TryReadSchema( - string firstLine, - ExpFileSource reader, - out ExpSchemaSource source ) + public static bool TryReadSchema(string firstLine, ExpFileSource reader, out ExpSchemaSource source) { - if( !_schemaBegin.IsMatch( firstLine ) ) + if (!_schemaBegin.IsMatch(firstLine)) { source = null!; return false; } ExpSchemaSource _source = new ExpSchemaSource(); - _source.name = _schemaBegin.Match( firstLine ).Groups[ "namespace" ].Value; + _source.name = _schemaBegin.Match(firstLine).Groups["namespace"].Value; - while( !_schemaEnd.IsMatch( firstLine ) ) + while (!_schemaEnd.IsMatch(firstLine)) { - if( _source.TryReadConst( firstLine, reader, - out IExpElementSource _elementSource ) ) + if (_source.TryReadConst(firstLine, reader, + out IExpElementSource _elementSource)) { - _source._sourceCache.Add( _elementSource ); - } else if( _source.TryReadType( firstLine, reader, out _elementSource ) ) + _source._sourceCache.Add(_elementSource); + } else if (_source.TryReadType(firstLine, reader, out _elementSource)) { - _source._sourceCache.Add( _elementSource ); - } else if( _source.TryReadEntity( firstLine, reader, out _elementSource ) ) + _source._sourceCache.Add(_elementSource); + } else if (_source.TryReadEntity(firstLine, reader, out _elementSource)) { - _source._sourceCache.Add( _elementSource ); - } else if( _source.TryReadRule( firstLine, reader, out _elementSource ) ) + _source._sourceCache.Add(_elementSource); + } else if (_source.TryReadRule(firstLine, reader, out _elementSource)) { - _source._sourceCache.Add( _elementSource ); - } else if( _source.TryReadFunction( firstLine, reader, out _elementSource ) ) { - _source._sourceCache.Add( _elementSource ); + _source._sourceCache.Add(_elementSource); + } else if (_source.TryReadFunction(firstLine, reader, out _elementSource)) { + _source._sourceCache.Add(_elementSource); } firstLine = reader.ReadLine(); } @@ -149,74 +143,59 @@ namespace StgSharp.Script.Express return true; } - [GeneratedRegex( @"\s*CONSTANT" )] + [GeneratedRegex(@"\s*CONSTANT")] private static partial Regex GetConstDefineBegin(); - [GeneratedRegex( @"\s*END_CONSTANT;" )] + [GeneratedRegex(@"\s*END_CONSTANT;")] private static partial Regex GetConstDefineEnd(); - [GeneratedRegex( @"\s*ENTITY\s*(?[A-Za-z0-9_]+)\s*", RegexOptions.Compiled )] + [GeneratedRegex(@"\s*ENTITY\s*(?[A-Za-z0-9_]+)\s*", RegexOptions.Compiled)] private static partial Regex GetEntityDefineBegin(); - [GeneratedRegex( - @"\s*END_ENTITY;\s*--\s*(?[A-Za-z0-9_]+)\s*", - RegexOptions.Compiled )] + [GeneratedRegex(@"\s*END_ENTITY;\s*--\s*(?[A-Za-z0-9_]+)\s*", RegexOptions.Compiled)] private static partial Regex GetEntityDefineEnd(); - [GeneratedRegex( - @"\s*FUNCTION\s*\s*(?[a-zA-Z0-9_]+)\s*(?.*)", - RegexOptions.Compiled )] + [GeneratedRegex(@"\s*FUNCTION\s*\s*(?[a-zA-Z0-9_]+)\s*(?.*)", RegexOptions.Compiled)] private static partial Regex GetFunctionDefineBegin(); - [GeneratedRegex( - @"\s*END_FUNCTION\s*;\s*--\s*(?[a-zA-Z0-9_]+)", - RegexOptions.Compiled )] + [GeneratedRegex(@"\s*END_FUNCTION\s*;\s*--\s*(?[a-zA-Z0-9_]+)", RegexOptions.Compiled)] private static partial Regex GetFunctionDefineEnd(); [GeneratedRegex( @"\s*RULE\s*(?[a-zA-Z0-9_]+)\s*FOR\s*\((?[a-zA-Z0-9_]*(?:\s*\)\s*;)?)", - RegexOptions.Compiled )] + RegexOptions.Compiled)] private static partial Regex GetRuleDefineBegin(); - [GeneratedRegex( - @"\s*END_RULE\s*;\s*--\s*(?[A-Za-z0-9_]+)", - RegexOptions.Compiled )] + [GeneratedRegex(@"\s*END_RULE\s*;\s*--\s*(?[A-Za-z0-9_]+)", RegexOptions.Compiled)] private static partial Regex GetRuleDefineEnd(); - [GeneratedRegex( @"\s*SCHEMA\s*(?[A-Za-z0-9_]+)\s?;" )] + [GeneratedRegex(@"\s*SCHEMA\s*(?[A-Za-z0-9_]+)\s?;")] private static partial Regex GetSchemaBegin(); - [GeneratedRegex( @"END_SCHEMA;\s*--\s*(?[A-Za-z0-9_]+)", RegexOptions.Compiled )] + [GeneratedRegex(@"END_SCHEMA;\s*--\s*(?[A-Za-z0-9_]+)", RegexOptions.Compiled)] private static partial Regex GetSchemaEnd(); - [GeneratedRegex( - @"\s*TYPE\s+(?[A-Za-z0-9_]+)\s*=\s*(?[A-Z]+)", - RegexOptions.Compiled )] + [GeneratedRegex(@"\s*TYPE\s+(?[A-Za-z0-9_]+)\s*=\s*(?[A-Z]+)", RegexOptions.Compiled)] private static partial Regex GetTypeDefineBegin(); - [GeneratedRegex( - @"\s*END_TYPE\s*;\s*--\s*(?[a-zA-Z0-9_]+)", - RegexOptions.Compiled )] + [GeneratedRegex(@"\s*END_TYPE\s*;\s*--\s*(?[a-zA-Z0-9_]+)", RegexOptions.Compiled)] private static partial Regex GetTypeDefineEnd(); - private bool TryReadConst( - string firstLine, - ExpFileSource reader, - out IExpElementSource source ) + private bool TryReadConst(string firstLine, ExpFileSource reader, out IExpElementSource source) { - Match match = _constDefineBegin.Match( firstLine ); - if( match.Success ) + Match match = _constDefineBegin.Match(firstLine); + if (match.Success) { ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter( - "END_CONSTANT", reader.Location ); - ExpConstantCollectionSource _source = new ExpConstantCollectionSource( transmitter ); + "END_CONSTANT", reader.Location); + ExpConstantCollectionSource _source = new ExpConstantCollectionSource(transmitter); string line = reader.ReadLine(); - while( !_constDefineEnd.IsMatch( line ) ) + while (!_constDefineEnd.IsMatch(line)) { - transmitter.WriteLine( line ); + transmitter.WriteLine(line); line = reader.ReadLine(); } - transmitter.WriteLine( "END_CONSTANT" ); + transmitter.WriteLine("END_CONSTANT"); source = _source; return true; } @@ -224,31 +203,28 @@ namespace StgSharp.Script.Express return false; } - private bool TryReadEntity( - string firstLine, - ExpFileSource reader, - out IExpElementSource source ) + private bool TryReadEntity(string firstLine, ExpFileSource reader, out IExpElementSource source) { - Match match = _entityDefineBegin.Match( firstLine ); - if( match.Success ) + Match match = _entityDefineBegin.Match(firstLine); + if (match.Success) { ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter( - "END_ENTITY", reader.Location ); + "END_ENTITY", reader.Location); ExpEntitySource _source = new ExpEntitySource( - match.Groups[ "TypeName" ].ToString(), transmitter ); + match.Groups["TypeName"].ToString(), transmitter); string line = reader.ReadLine(); - match = _entityDefineEnd.Match( line ); - while( !match.Success ) + match = _entityDefineEnd.Match(line); + while (!match.Success) { - transmitter.WriteLine( line ); + transmitter.WriteLine(line); line = reader.ReadLine(); - match = _entityDefineEnd.Match( line ); + match = _entityDefineEnd.Match(line); } - string endedName = match.Groups[ "TypeName" ].ToString(); - if( !string.Equals( endedName, _source.Name ) ) { - throw new ExpInvalidElementDeclareEndingExceptions( _source.Name, endedName ); + string endedName = match.Groups["TypeName"].ToString(); + if (!string.Equals(endedName, _source.Name)) { + throw new ExpInvalidElementDeclareEndingExceptions(_source.Name, endedName); } - transmitter.WriteLine( "END_ENTITY" ); + transmitter.WriteLine("END_ENTITY"); source = _source; return true; } @@ -256,32 +232,29 @@ namespace StgSharp.Script.Express return false; } - private bool TryReadFunction( - string firstLine, - ExpFileSource reader, - out IExpElementSource source ) + private bool TryReadFunction(string firstLine, ExpFileSource reader, out IExpElementSource source) { - Match match = _functionDefineBegin.Match( firstLine ); - if( match.Success ) + Match match = _functionDefineBegin.Match(firstLine); + if (match.Success) { ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter( - "END_FUNCTION", reader.Location ); + "END_FUNCTION", reader.Location); ExpFunctionSource _source = new ExpFunctionSource( - match.Groups[ "FunctionName" ].ToString(), transmitter ); - transmitter.WriteLine( match.Groups[ "Remaining" ].ToString() ); + match.Groups["FunctionName"].ToString(), transmitter); + transmitter.WriteLine(match.Groups["Remaining"].ToString()); string line = reader.ReadLine(); - match = _functionDefineEnd.Match( line ); - while( !match.Success ) + match = _functionDefineEnd.Match(line); + while (!match.Success) { - transmitter.WriteLine( line ); + transmitter.WriteLine(line); line = reader.ReadLine(); - match = _functionDefineEnd.Match( line ); + match = _functionDefineEnd.Match(line); } - string endedName = match.Groups[ "FunctionName" ].ToString(); - if( !string.Equals( endedName, _source.Name ) ) { - throw new ExpInvalidElementDeclareEndingExceptions( _source.Name, endedName ); + string endedName = match.Groups["FunctionName"].ToString(); + if (!string.Equals(endedName, _source.Name)) { + throw new ExpInvalidElementDeclareEndingExceptions(_source.Name, endedName); } - transmitter.WriteLine( "END_FUNCTION" ); + transmitter.WriteLine("END_FUNCTION"); source = _source; return true; } @@ -289,35 +262,32 @@ namespace StgSharp.Script.Express return false; } - private bool TryReadRule( - string firstLine, - ExpFileSource reader, - out IExpElementSource source ) + private bool TryReadRule(string firstLine, ExpFileSource reader, out IExpElementSource source) { - Match match = _ruleDefineBegin.Match( firstLine ); - if( match.Success ) + Match match = _ruleDefineBegin.Match(firstLine); + if (match.Success) { ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter( - "END_RULE", reader.Location ); + "END_RULE", reader.Location); ExpRuleSource _source = new ExpRuleSource( - match.Groups[ "RuleName" ].ToString(), transmitter ); - string target = match.Groups[ "Target" ].ToString(); - if( !string.IsNullOrEmpty( target ) ) { - transmitter.WriteLine( target ); + match.Groups["RuleName"].ToString(), transmitter); + string target = match.Groups["Target"].ToString(); + if (!string.IsNullOrEmpty(target)) { + transmitter.WriteLine(target); } string line = reader.ReadLine(); - match = _ruleDefineEnd.Match( line ); - while( !match.Success ) + match = _ruleDefineEnd.Match(line); + while (!match.Success) { - transmitter.WriteLine( line ); + transmitter.WriteLine(line); line = reader.ReadLine(); - match = _ruleDefineEnd.Match( line ); + match = _ruleDefineEnd.Match(line); } - string endedName = match.Groups[ "RuleName" ].ToString(); - if( !string.Equals( endedName, _source.Name ) ) { - throw new ExpInvalidElementDeclareEndingExceptions( _source.Name, endedName ); + string endedName = match.Groups["RuleName"].ToString(); + if (!string.Equals(endedName, _source.Name)) { + throw new ExpInvalidElementDeclareEndingExceptions(_source.Name, endedName); } - transmitter.WriteLine( "END_RULE" ); + transmitter.WriteLine("END_RULE"); source = _source; return true; } @@ -325,32 +295,29 @@ namespace StgSharp.Script.Express return false; } - private bool TryReadType( - string firstLine, - ExpFileSource reader, - out IExpElementSource source ) + private bool TryReadType(string firstLine, ExpFileSource reader, out IExpElementSource source) { - Match match = _typeDefineBegin.Match( firstLine ); - if( match.Success ) + Match match = _typeDefineBegin.Match(firstLine); + if (match.Success) { ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter( - "END_ENTITY", reader.Location ); + "END_ENTITY", reader.Location); ExpTypeSource _source = new ExpTypeSource( - match.Groups[ "TypeName" ].ToString(), transmitter ); - transmitter.WriteLine( match.Groups[ "Remaining" ].ToString() ); + match.Groups["TypeName"].ToString(), transmitter); + transmitter.WriteLine(match.Groups["Remaining"].ToString()); string line = reader.ReadLine(); - match = _typeDefineEnd.Match( line ); - while( !match.Success ) + match = _typeDefineEnd.Match(line); + while (!match.Success) { - transmitter.WriteLine( line ); + transmitter.WriteLine(line); line = reader.ReadLine(); - match = _typeDefineEnd.Match( line ); + match = _typeDefineEnd.Match(line); } - string endedName = match.Groups[ "TypeName" ].ToString(); - if( !string.Equals( endedName, _source.Name ) ) { - throw new ExpInvalidElementDeclareEndingExceptions( _source.Name, endedName ); + string endedName = match.Groups["TypeName"].ToString(); + if (!string.Equals(endedName, _source.Name)) { + throw new ExpInvalidElementDeclareEndingExceptions(_source.Name, endedName); } - transmitter.WriteLine( "END_ENTITY" ); + transmitter.WriteLine("END_ENTITY"); source = _source; return true; } diff --git a/StgSharp.Script/Express/ExpSource.cs b/StgSharp.Script/Express/ExpSource.cs index 31815eb8..313a8296 100644 --- a/StgSharp.Script/Express/ExpSource.cs +++ b/StgSharp.Script/Express/ExpSource.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSource.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSource" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.IO; @@ -46,21 +43,20 @@ namespace StgSharp.Script.Express private MemoryMappedFile _expMemoryMappedFile; private MemoryMappedViewStream _expMemoryMappedStream; - private SemaphoreSlim readLineSemaphore = new SemaphoreSlim( 1, 1 ); + private SemaphoreSlim readLineSemaphore = new SemaphoreSlim(1, 1); private StreamReader _memoryReader; - public ExpFileSource( string path ) + public ExpFileSource(string path) { - if( !File.Exists( path ) ) { + if (!File.Exists(path)) { throw new FileNotFoundException(); } - _expFileStream = new FileStream( path, FileMode.Open, FileAccess.Read ); + _expFileStream = new FileStream(path, FileMode.Open, FileAccess.Read); _expMemoryMappedFile = MemoryMappedFile.CreateFromFile( - _expFileStream, null, 0, MemoryMappedFileAccess.Read, HandleInheritability.None, - true ); + _expFileStream, null, 0, MemoryMappedFileAccess.Read, HandleInheritability.None, true); _expMemoryMappedStream = _expMemoryMappedFile.CreateViewStream( - offset: 0, size: 0, access: MemoryMappedFileAccess.Read ); - _memoryReader = new StreamReader( _expMemoryMappedStream ); + offset:0, size:0, access:MemoryMappedFileAccess.Read); + _memoryReader = new StreamReader(_expMemoryMappedStream); } public bool IsEmpty => _memoryReader.EndOfStream; @@ -69,13 +65,13 @@ namespace StgSharp.Script.Express // ~ExpFileSource() // { - // Dispose(disposing: false); + // Dispose(disposing: false); // } public void Dispose() { - Dispose( disposing: true ); - GC.SuppressFinalize( this ); + Dispose(disposing:true); + GC.SuppressFinalize(this); } public void EndWriting() { } @@ -89,7 +85,7 @@ namespace StgSharp.Script.Express return line; } - public string ReadLine( out int position ) + public string ReadLine(out int position) { throw new NotImplementedException(); } @@ -97,16 +93,16 @@ namespace StgSharp.Script.Express public void ResetToBegin() { readLineSemaphore.Wait(); - _expMemoryMappedStream.Seek( 0, SeekOrigin.Begin ); + _expMemoryMappedStream.Seek(0, SeekOrigin.Begin); _location = 0; readLineSemaphore.Release(); } - protected virtual void Dispose( bool disposing ) + protected virtual void Dispose(bool disposing) { - if( !disposedValue ) + if (!disposedValue) { - if( disposing ) + if (disposing) { _expFileStream.Dispose(); _expMemoryMappedFile.Dispose(); @@ -117,7 +113,7 @@ namespace StgSharp.Script.Express } } - IScriptSourceProvider IScriptSourceProvider.Slice( int location, int count ) + IScriptSourceProvider IScriptSourceProvider.Slice(int location, int count) { throw new NotSupportedException(); } diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.CaseOf.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.CaseOf.cs index b0d3c9d6..e26d9c78 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.CaseOf.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.CaseOf.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.CaseOf.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.CaseOf" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Diagnostics; @@ -42,38 +39,37 @@ namespace StgSharp.Script.Express public partial class ExpSyntaxAnalyzer { - private bool AppendToken_CaseOf( Token t ) + private bool AppendToken_CaseOf(Token t) { Token op; ExpSyntaxNode root; - switch( t.Value ) + switch (t.Value) { case ExpKeyword.Case: - CaseOfStateCache state = new CaseOfStateCache( t ); + CaseOfStateCache state = new CaseOfStateCache(t); _cache.CurrentDepthMark.StateCache = state; state.CurrentState = t.Value; return true; case ExpKeyword.Of: state = _cache.StateOfCurrentDepth(); - while( _cache.TryPopOperator( out op ) ) { - ConvertAndPushOneOperator( op ); + while (_cache.TryPopOperator(out op)) { + ConvertAndPushOneOperator(op); } - _cache.PopOperand( out _, out root ); + _cache.PopOperand(out _, out root); state.CaseExpression = root; state.CurrentState = t.Value; return true; case ":": state = _cache.StateOfCurrentDepth(); - if( state.CurrentState != ExpKeyword.Of && - state.CurrentState != ExpKeyword.Otherwise ) + if (state.CurrentState != ExpKeyword.Of && state.CurrentState != ExpKeyword.Otherwise) { root = _cache.PackAllStatements(); - state.CloseCurrentCase( root ); + state.CloseCurrentCase(root); } - while( _cache.TryPopOperator( out op ) ) { - ConvertAndPushOneOperator( op ); + while (_cache.TryPopOperator(out op)) { + ConvertAndPushOneOperator(op); } - if( !_cache.PopOperand( out _, out root ) ) + if (!_cache.PopOperand(out _, out root)) { // sth wrong, case expression cannot generate; } @@ -82,20 +78,20 @@ namespace StgSharp.Script.Express case ExpKeyword.Otherwise: state = _cache.StateOfCurrentDepth(); root = _cache.PackAllStatements(); - state.CloseCurrentCase( root ); + state.CloseCurrentCase(root); state.CurrentState = t.Value; return true; case ExpKeyword.EndCase: state = _cache.StateOfCurrentDepth(); root = _cache.PackAllStatements(); - state.CloseCurrentCase( root ); + state.CloseCurrentCase(root); root = new ExpSwitchNode( - state.Begin, state.CaseExpression, state.DefaultCase, state.Cases ); + state.Begin, state.CaseExpression, state.DefaultCase, state.Cases); _cache.DecreaseDepth(); - _cache.StatementsInDepth.Push( root ); + _cache.StatementsInDepth.Push(root); return true; default: - AppendToken_Common( t ); + AppendToken_Common(t); return true; } } @@ -103,7 +99,7 @@ namespace StgSharp.Script.Express private class CaseOfStateCache : ICompileDepthState { - public CaseOfStateCache( Token t ) + public CaseOfStateCache(Token t) { Begin = t; } @@ -121,9 +117,9 @@ namespace StgSharp.Script.Express public Token Begin { get; init; } - public void CloseCurrentCase( ExpSyntaxNode root ) + public void CloseCurrentCase(ExpSyntaxNode root) { - Cases.Add( CurrentCase, root ); + Cases.Add(CurrentCase, root); } } diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.Common.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.Common.cs index a02a1313..34590a56 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.Common.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.Common.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.Common.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.Common" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp.Syntax; using System; @@ -45,7 +42,7 @@ namespace StgSharp.Script.Express public partial class ExpSyntaxAnalyzer { - private bool IsSeparatorMatch( Token leftSperator, Token rightSeparator ) + private bool IsSeparatorMatch(Token leftSperator, Token rightSeparator) { return leftSperator.Value switch { @@ -57,215 +54,215 @@ namespace StgSharp.Script.Express }; } - private bool TryAppendIndexLeft( Token t ) + private bool TryAppendIndexLeft(Token t) { - if( t.Flag != TokenFlag.Index_Left ) { + if (t.Flag != TokenFlag.Index_Left) { return false; } - if( _cache.TryPeekOperand( out bool isNode, out _, out ExpSyntaxNode? node ) ) + if (_cache.TryPeekOperand(out bool isNode, out _, out ExpSyntaxNode? node)) { - if( node.EqualityTypeConvert is not ExpCollectionBase ) { - ExpInvalidSyntaxException.ThrowNonCollectionIndex( t ); + if (node.EqualityTypeConvert is not ExpCollectionBase) { + ExpInvalidSyntaxException.ThrowNonCollectionIndex(t); } } - _cache.PushOperator( t ); - _cache.IncreaseDepth( ( int )ExpCompileStateCode.CollectionIndex ); + _cache.PushOperator(t); + _cache.IncreaseDepth((int)ExpCompileStateCode.CollectionIndex); return true; } - private bool TryAppendIndexRight( Token t ) + private bool TryAppendIndexRight(Token t) { - if( t.Flag != TokenFlag.Index_Right ) { + if (t.Flag != TokenFlag.Index_Right) { return false; } - //reverse building - ClosePrefixReverse( t ); + // reverse building + ClosePrefixReverse(t); - //make index node - _cache.PopOperand( out _, out ExpSyntaxNode? expNode ); - if( !_cache.PopOperand( out Token colleToken, out ExpSyntaxNode? colleNode ) ) { } + // make index node + _cache.PopOperand(out _, out ExpSyntaxNode? expNode); + if (!_cache.PopOperand(out Token colleToken, out ExpSyntaxNode? colleNode)) { } _cache.PushOperand( ExpCollectionIndexNode.Create( - t, ( colleNode as ExpCollectionInstanceBase )!, expNode ) ); + t, (colleNode as ExpCollectionInstanceBase)!, expNode)); return true; } - private bool TryAppendMember( Token t ) + private bool TryAppendMember(Token t) { - if( t.Flag != TokenFlag.Member ) { + if (t.Flag != TokenFlag.Member) { return false; } - if( TryParseConstant( t ) ) { + if (TryParseConstant(t)) { return true; } - if( TryParseFunction( t ) ) { + if (TryParseFunction(t)) { return true; } - if( TryParseInstance( t ) ) { + if (TryParseInstance(t)) { return true; } - if( TryParseKeyword( t ) ) { + if (TryParseKeyword(t)) { return true; } - if( TryParseElementName( t ) ) { + if (TryParseElementName(t)) { return true; } - //Many thing miss here - _cache.PushOperand( ExpElementMemberNameNode.Create( t ) ); + // Many thing miss here + _cache.PushOperand(ExpElementMemberNameNode.Create(t)); return true; } - private bool TryAppendMiddleSeparator( Token t ) + private bool TryAppendMiddleSeparator(Token t) { - if( t.Flag != TokenFlag.Separator_Middle ) { + if (t.Flag != TokenFlag.Separator_Middle) { return false; } - while( _cache.OperatorAheadOfDepth > 0 ) + while (_cache.OperatorAheadOfDepth > 0) { - _cache.TryPopOperator( out Token op ); - ExpSyntaxNode node = ConvertAndPushOneOperator( op ); + _cache.TryPopOperator(out Token op); + ExpSyntaxNode node = ConvertAndPushOneOperator(op); } - switch( _cache.OperandAheadOfDepth ) + switch (_cache.OperandAheadOfDepth) { case 0: - if( t.Value == ";" ) { + if (t.Value == ";") { return true; } - _cache.StatementsInDepth.Push( ExpSyntaxNode.Empty ); + _cache.StatementsInDepth.Push(ExpSyntaxNode.Empty); goto case 1; case 1: - _cache.PopOperand( out _, out ExpSyntaxNode? statement ); - _cache.StatementsInDepth.Push( statement ); + _cache.PopOperand(out _, out ExpSyntaxNode? statement); + _cache.StatementsInDepth.Push(statement); return true; default: - ExpInvalidSyntaxException.ThrowNoOperator( t ); + ExpInvalidSyntaxException.ThrowNoOperator(t); break; } return true; } - private bool TryAppendNumAndStrLiteral( Token t ) + private bool TryAppendNumAndStrLiteral(Token t) { - if( ( t.Flag & ( TokenFlag.String | TokenFlag.Number ) ) == 0 ) { + if ((t.Flag & (TokenFlag.String | TokenFlag.Number)) == 0) { return false; } - _cache.PushOperand( ExpElementInstance.CreateLiteral( t ) ); + _cache.PushOperand(ExpElementInstance.CreateLiteral(t)); return true; } - private bool TryAppendPrefixSeparator( Token t ) + private bool TryAppendPrefixSeparator(Token t) { - if( t.Flag != TokenFlag.Separator_Left ) { + if (t.Flag != TokenFlag.Separator_Left) { return false; } - _cache.PushOperator( t ); - _cache.IncreaseDepth( ( int )ExpCompileStateCode.Common ); + _cache.PushOperator(t); + _cache.IncreaseDepth((int)ExpCompileStateCode.Common); return true; } - private bool TryAppendPrefixSeparatorEnd( Token t ) + private bool TryAppendPrefixSeparatorEnd(Token t) { - if( t.Flag != TokenFlag.Separator_Right ) { + if (t.Flag != TokenFlag.Separator_Right) { return false; } - ClosePrefixReverse( t ); + ClosePrefixReverse(t); return true; } - private bool TryAppendSymbol( Token t ) + private bool TryAppendSymbol(Token t) { - if( ( t.Flag & ( TokenFlag.Symbol_Unary | TokenFlag.Symbol_Binary ) ) == 0 ) { + if ((t.Flag & (TokenFlag.Symbol_Unary | TokenFlag.Symbol_Binary)) == 0) { return false; } int cmp = -1; processPrecedence: - if( _cache.TryPeekOperator( out Token tmp ) ) + if (_cache.TryPeekOperator(out Token tmp)) { - cmp = CompareOperatorPrecedence( t, tmp ); - if( cmp >= 0 ) + cmp = CompareOperatorPrecedence(t, tmp); + if (cmp >= 0) { _cache.PopOperator(); - ExpSyntaxNode node = ConvertAndPushOneOperator( tmp ); + ExpSyntaxNode node = ConvertAndPushOneOperator(tmp); goto processPrecedence; } } - _cache.PushOperator( t ); + _cache.PushOperator(t); return true; } - private bool TryParseConstant( Token t ) + private bool TryParseConstant(Token t) { - switch( t.Value ) + switch (t.Value) { case ExpKeyword.E: - _cache.PushOperand( new ExpRealNumberNode( t, MathF.E, true ) ); + _cache.PushOperand(new ExpRealNumberNode(t, MathF.E, true)); return true; case ExpKeyword.Pi: - _cache.PushOperand( new ExpRealNumberNode( t, MathF.PI, true ) ); + _cache.PushOperand(new ExpRealNumberNode(t, MathF.PI, true)); return true; default: - if( ExpElementInstance.TryCreateLiteral( t, out ExpElementInstance? node ) ) + if (ExpElementInstance.TryCreateLiteral(t, out ExpElementInstance? node)) { - _cache.PushOperand( node ); + _cache.PushOperand(node); return true; } return false; } } - private bool TryParseElementName( Token t ) + private bool TryParseElementName(Token t) { - if( _context.TryGetType( t.Value, out ExpTypeSource? type ) ) + if (_context.TryGetType(t.Value, out ExpTypeSource? type)) { - _cache.PushOperand( ExpMetaRefNode.RefType( t, type ) ); + _cache.PushOperand(ExpMetaRefNode.RefType(t, type)); return true; } - if( _context.TryGetEntity( t.Value, out ExpEntitySource? entity ) ) + if (_context.TryGetEntity(t.Value, out ExpEntitySource? entity)) { - _cache.PushOperand( ExpMetaRefNode.RefEntity( t, entity ) ); + _cache.PushOperand(ExpMetaRefNode.RefEntity(t, entity)); return true; } return false; } - private bool TryParseFunction( Token t ) + private bool TryParseFunction(Token t) { - if( ExpKeyword.BuiltinFunctions.Contains( t.Value ) ) + if (ExpKeyword.BuiltinFunctions.Contains(t.Value)) { - _cache.PushOperator( t ); + _cache.PushOperator(t); return true; - } else if( _context.TryGetFunction( t.Value, out ExpFunctionSource? f ) ) + } else if (_context.TryGetFunction(t.Value, out ExpFunctionSource? f)) { - _cache.PushOperand( t ); + _cache.PushOperand(t); return true; } return false; } - private bool TryParseInstance( Token t ) + private bool TryParseInstance(Token t) { - if( _local.TryGetMember( t.Value, - out ExpSyntaxNode? node ) && - node is ExpElementInstance instance ) + if (_local.TryGetMember(t.Value, + out ExpSyntaxNode? node) && + node is ExpElementInstance instance) { - _cache.PushOperand( ExpInstanceReferenceNode.MakeReferenceFrom( t, instance ) ); + _cache.PushOperand(ExpInstanceReferenceNode.MakeReferenceFrom(t, instance)); return true; - } else if( _tempVariableInLoops.TryGetValue( t.Value, out instance! ) ) + } else if (_tempVariableInLoops.TryGetValue(t.Value, out instance!)) { - _cache.PushOperand( ExpInstanceReferenceNode.MakeReferenceFrom( t, instance ) ); + _cache.PushOperand(ExpInstanceReferenceNode.MakeReferenceFrom(t, instance)); return true; - } else if( _cache.IsLastAddedOperator ) + } else if (_cache.IsLastAddedOperator) { - if( _cache.PeekOperand( out _, - out ExpSyntaxNode? typenode ) && - typenode is ExpMetaRefNode typeRef ) + if (_cache.PeekOperand(out _, + out ExpSyntaxNode? typenode) && + typenode is ExpMetaRefNode typeRef) { - _cache.PopOperand( out _, out _ ); - _local.AddMember( t.Value, typeRef.SourceRef.CreateInstanceNode( t ) ); + _cache.PopOperand(out _, out _); + _local.AddMember(t.Value, typeRef.SourceRef.CreateInstanceNode(t)); } else { return false; @@ -274,15 +271,15 @@ namespace StgSharp.Script.Express return false; } - private bool TryParseKeyword( Token t ) + private bool TryParseKeyword(Token t) { - switch( t.Value ) + switch (t.Value) { case ExpKeyword.Return: - _cache.PushOperator( t ); + _cache.PushOperator(t); return true; case ExpKeyword.Skip: - _cache.PushOperand( ExpProcedureControlNode.Skip( t ) ); + _cache.PushOperand(ExpProcedureControlNode.Skip(t)); return true; default: return false; diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.DepthEnter.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.DepthEnter.cs index 71cd861f..88e06bae 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.DepthEnter.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.DepthEnter.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.DepthEnter.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.DepthEnter" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.Diagnostics; using System; @@ -43,21 +40,21 @@ namespace StgSharp.Script.Express public partial class ExpSyntaxAnalyzer { - internal void AttemptEnterNewDepth( Token t ) + internal void AttemptEnterNewDepth(Token t) { - switch( t.Value ) + switch (t.Value) { case ExpKeyword.If: - _cache.IncreaseDepth( ( int )ExpCompileStateCode.IfBranch ); + _cache.IncreaseDepth((int)ExpCompileStateCode.IfBranch); return; case ExpKeyword.Case: - _cache.IncreaseDepth( ( int )ExpCompileStateCode.CaseBranch ); + _cache.IncreaseDepth((int)ExpCompileStateCode.CaseBranch); return; case ExpKeyword.Repeat: - _cache.IncreaseDepth( ( int )ExpCompileStateCode.RepeatLoop ); + _cache.IncreaseDepth((int)ExpCompileStateCode.RepeatLoop); return; case ExpKeyword.While: - _cache.IncreaseDepth( ( int )ExpCompileStateCode.UntilLoop ); + _cache.IncreaseDepth((int)ExpCompileStateCode.UntilLoop); return; default: diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.ErrorProcess.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.ErrorProcess.cs index 84c3778e..46872bf3 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.ErrorProcess.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.ErrorProcess.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.ErrorProcess.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.ErrorProcess" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -39,9 +36,9 @@ namespace StgSharp.Script.Express public partial class ExpSyntaxAnalyzer { - public void ThrowCompileException( int errorCode ) + public void ThrowCompileException(int errorCode) { - switch( errorCode ) + switch (errorCode) { case 0 or 1: return; diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.If.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.If.cs index be436fd9..3e94db85 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.If.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.If.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.If.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.If" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -42,9 +39,9 @@ namespace StgSharp.Script.Express public partial class ExpSyntaxAnalyzer { - private bool AppendToken_IfBranch( Token t ) + private bool AppendToken_IfBranch(Token t) { - switch( t.Value ) + switch (t.Value) { case ExpKeyword.If: IfBranchStateCache state = new IfBranchStateCache(); @@ -53,23 +50,23 @@ namespace StgSharp.Script.Express return true; case ExpKeyword.Then: state = _cache.StateOfCurrentDepth(); - if( state.CurrentState == ExpKeyword.If ) + if (state.CurrentState == ExpKeyword.If) { - while( _cache.TryPopOperator( out Token op ) ) { - ConvertAndPushOneOperator( op ); + while (_cache.TryPopOperator(out Token op)) { + ConvertAndPushOneOperator(op); } - _cache.PopOperand( out _, out ExpSyntaxNode? node ); + _cache.PopOperand(out _, out ExpSyntaxNode? node); state.CurrentState = t.Value; state.BoolExpression = node; } else { throw new ExpCompileException( - t, $"Keyword {t.Value} should be after keyword {ExpKeyword.Then}" ); + t, $"Keyword {t.Value} should be after keyword {ExpKeyword.Then}"); } return true; case ExpKeyword.Else: state = _cache.StateOfCurrentDepth(); - if( state.CurrentState == ExpKeyword.Then ) + if (state.CurrentState == ExpKeyword.Then) { ExpSyntaxNode node = _cache.PackAllStatements(); state.CurrentState = t.Value; @@ -77,19 +74,19 @@ namespace StgSharp.Script.Express } else { throw new ExpCompileException( - t, $"Keyword {t.Value} should be after keyword {ExpKeyword.Then}" ); + t, $"Keyword {t.Value} should be after keyword {ExpKeyword.Then}"); } return true; case ExpKeyword.EndIf: state = _cache.StateOfCurrentDepth(); - if( state.CurrentState == ExpKeyword.Then ) + if (state.CurrentState == ExpKeyword.Then) { ExpSyntaxNode trueNode = _cache.PackAllStatements(); state.CurrentState = t.Value; state.ExpressionIfTrue = trueNode; state.ExpressionIfFalse = ExpSyntaxNode.Empty; - } else if( state.CurrentState == ExpKeyword.Else ) + } else if (state.CurrentState == ExpKeyword.Else) { ExpSyntaxNode falseNode = _cache.PackAllStatements(); state.CurrentState = t.Value; @@ -98,16 +95,16 @@ namespace StgSharp.Script.Express { throw new ExpCompileException( t, - $"Keyword {t.Value} should be after keyword {ExpKeyword.Then} or {ExpKeyword.Else}" ); + $"Keyword {t.Value} should be after keyword {ExpKeyword.Then} or {ExpKeyword.Else}"); } ExpIfNode ifNode = new ExpIfNode( state.Begin, state.BoolExpression, state.ExpressionIfTrue, - state.ExpressionIfFalse ); + state.ExpressionIfFalse); _cache.DecreaseDepth(); - _cache.StatementsInDepth.Push( ifNode ); + _cache.StatementsInDepth.Push(ifNode); return true; default: - AppendToken_Common( t ); + AppendToken_Common(t); return true; } } diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.OperatorParser.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.OperatorParser.cs index 4d5bd903..8e31530f 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.OperatorParser.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.OperatorParser.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.OperatorParser.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.OperatorParser" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -41,26 +38,26 @@ namespace StgSharp.Script.Express public partial class ExpSyntaxAnalyzer { - public int CompareOperatorPrecedence( Token left, Token right ) + public int CompareOperatorPrecedence(Token left, Token right) { - ExpressCompile.TryGetOperatorPrecedence( left.Value, out int leftPrecedence ); - ExpressCompile.TryGetOperatorPrecedence( right.Value, out int rightPrecedence ); + ExpressCompile.TryGetOperatorPrecedence(left.Value, out int leftPrecedence); + ExpressCompile.TryGetOperatorPrecedence(right.Value, out int rightPrecedence); return leftPrecedence - rightPrecedence; } - public bool TryGenerateUnaryNode( Token t, out ExpSyntaxNode node ) + public bool TryGenerateUnaryNode(Token t, out ExpSyntaxNode node) { ExpSyntaxNode operand = GetNextOperandCache(); - switch( t.Value ) + switch (t.Value) { case ExpKeyword.UnaryPlus: - node = ExpUnaryOperatorNode.UnaryPlus( t, operand ); + node = ExpUnaryOperatorNode.UnaryPlus(t, operand); return true; case ExpKeyword.UnaryMinus: - node = ExpUnaryOperatorNode.UnaryMinus( t, operand ); + node = ExpUnaryOperatorNode.UnaryMinus(t, operand); return true; case ExpKeyword.Not: - node = ExpUnaryOperatorNode.UnaryNot( t, operand ); + node = ExpUnaryOperatorNode.UnaryNot(t, operand); return true; default: node = ExpSyntaxNode.Empty; @@ -72,104 +69,104 @@ namespace StgSharp.Script.Express /// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING /// SYMBOLS. /// - private ExpSyntaxNode ConvertAndPushOneOperator( Token op ) + private ExpSyntaxNode ConvertAndPushOneOperator(Token op) { - switch( op.Flag ) + switch (op.Flag) { case TokenFlag.Symbol_Unary: - TryGenerateUnaryNode( op, out ExpSyntaxNode? node ); - _cache.PushOperand( node ); + TryGenerateUnaryNode(op, out ExpSyntaxNode? node); + _cache.PushOperand(node); return node; case TokenFlag.Symbol_Binary: - TryGenerateBinaryNode( op, out node ); - _cache.PushOperand( node ); + TryGenerateBinaryNode(op, out node); + _cache.PushOperand(node); return node; case TokenFlag.Member: - if( _context.TryGetFunction( op.Value, out ExpFunctionSource? f ) ) + if (_context.TryGetFunction(op.Value, out ExpFunctionSource? f)) { - if( !_cache.PopOperand( out Token t, out ExpSyntaxNode? p ) ) + if (!_cache.PopOperand(out Token t, out ExpSyntaxNode? p)) { - node = ExpFunctionCallingNode.CallFunction( op, f, p ); + node = ExpFunctionCallingNode.CallFunction(op, f, p); return node; } else { throw new ExpCompileException( t, - "An ExpNode for function calling is needed, but a token was popped" ); + "An ExpNode for function calling is needed, but a token was popped"); } - } else if( _context.TryGetProcedure( op.Value, out ExpProcedureSource? p ) ) + } else if (_context.TryGetProcedure(op.Value, out ExpProcedureSource? p)) { - if( !_cache.PopOperand( out Token t, out ExpSyntaxNode? param ) ) + if (!_cache.PopOperand(out Token t, out ExpSyntaxNode? param)) { - node = ExpProcedureCallingNode.CallProcedure( op, p, param ); + node = ExpProcedureCallingNode.CallProcedure(op, p, param); return node; } else { throw new ExpCompileException( t, - "An ExpNode for function calling is needed, but a token was popped" ); + "An ExpNode for function calling is needed, but a token was popped"); } - } else if( ExpSchema.BuiltinSchema.TryGetFunction( op.Value, out f ) ) + } else if (ExpSchema.BuiltinSchema.TryGetFunction(op.Value, out f)) { - if( !_cache.PopOperand( out Token t, out ExpSyntaxNode? param ) ) + if (!_cache.PopOperand(out Token t, out ExpSyntaxNode? param)) { - node = ExpFunctionCallingNode.CallFunction( op, f, param ); + node = ExpFunctionCallingNode.CallFunction(op, f, param); return node; } else { throw new ExpCompileException( t, - "An ExpNode for function calling is needed, but a token was popped" ); + "An ExpNode for function calling is needed, but a token was popped"); } } else { throw new NotImplementedException(); - //uncertain case here + // uncertain case here } default: throw new NotImplementedException(); } } - private bool TryGenerateBinaryNode( Token t, out ExpSyntaxNode node ) + private bool TryGenerateBinaryNode(Token t, out ExpSyntaxNode node) { ExpSyntaxNode right = GetNextOperandCache(); ExpSyntaxNode left = GetNextOperandCache(); - switch( t.Value ) + switch (t.Value) { case ExpKeyword.Add: - node = ExpBinaryOperatorNode.Add( t, left, right ); + node = ExpBinaryOperatorNode.Add(t, left, right); return true; case ExpKeyword.Sub: - node = ExpBinaryOperatorNode.Sub( t, left, right ); + node = ExpBinaryOperatorNode.Sub(t, left, right); return true; case ExpKeyword.Mul: - node = ExpBinaryOperatorNode.Mul( t, left, right ); + node = ExpBinaryOperatorNode.Mul(t, left, right); return true; case ExpKeyword.Div: - node = ExpBinaryOperatorNode.Div( t, left, right ); + node = ExpBinaryOperatorNode.Div(t, left, right); return true; case ExpKeyword.Equal: - node = ExpBinaryOperatorNode.EqualTo( t, left, right ); + node = ExpBinaryOperatorNode.EqualTo(t, left, right); return true; case ExpKeyword.NotEqual: - node = ExpBinaryOperatorNode.NotEqualTo( t, left, right ); + node = ExpBinaryOperatorNode.NotEqualTo(t, left, right); return true; case ExpKeyword.GreaterThan: - node = ExpBinaryOperatorNode.GreaterThan( t, left, right ); + node = ExpBinaryOperatorNode.GreaterThan(t, left, right); return true; case ExpKeyword.LessThan: - node = ExpBinaryOperatorNode.LessThan( t, left, right ); + node = ExpBinaryOperatorNode.LessThan(t, left, right); return true; case ExpKeyword.Assignment: - node = ExpBinaryOperatorNode.Assign( t, left, right ); + node = ExpBinaryOperatorNode.Assign(t, left, right); return true; case ExpKeyword.InstanceEqual: - node = ExpBinaryOperatorNode.CompareInstanceEqual( t, left, right ); + node = ExpBinaryOperatorNode.CompareInstanceEqual(t, left, right); return true; case ExpKeyword.InstanceNotEqual: - node = ExpBinaryOperatorNode.CompareInstanceNotEqual( t, left, right ); + node = ExpBinaryOperatorNode.CompareInstanceNotEqual(t, left, right); return true; default: node = ExpSyntaxNode.Empty; diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.RangeAndIndex.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.RangeAndIndex.cs index c8a0daf6..4342594d 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.RangeAndIndex.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.RangeAndIndex.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.RangeAndIndex.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.RangeAndIndex" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.Operations; using System; @@ -43,10 +40,10 @@ namespace StgSharp.Script.Express public partial class ExpSyntaxAnalyzer { - private void AppendToken_RangeAndIndex( Token t ) + private void AppendToken_RangeAndIndex(Token t) { ExpSyntaxNode root; - switch( t.Value ) + switch (t.Value) { case "[": RangeAndIndexState state = new RangeAndIndexState(); @@ -56,56 +53,56 @@ namespace StgSharp.Script.Express case "]": state = _cache.StateOfCurrentDepth(); - //Generate range or index object - if( _cache.StatementsInDepth.Count != 0 ) + // Generate range or index object + if (_cache.StatementsInDepth.Count != 0) { throw new ExpInvalidSyntaxException( - "Range and index syntax error: expected one statement to define range beginning." ); + "Range and index syntax error: expected one statement to define range beginning."); } ReverseAnalyzeStatement(); root = _cache.StatementsInDepth.Pop(); - if( ExpNodeFlag.BuiltinType_Int.IsNotInFlag( root.NodeFlag ) ) { + if (ExpNodeFlag.BuiltinType_Int.IsNotInFlag(root.NodeFlag)) { throw new ExpInvalidTypeException( - root, "integer", root.EqualityTypeConvert?.Name ?? string.Empty ); + root, "integer", root.EqualityTypeConvert?.Name ?? string.Empty); } - if( state.CurrentState == "[" ) { } else { } + if (state.CurrentState == "[") { } else { } break; case ":": state = _cache.StateOfCurrentDepth(); - if( state.CurrentState != "[" ) { + if (state.CurrentState != "[") { throw new ExpInvalidSyntaxException( - "Range and index syntax error: wrong position of :" ); + "Range and index syntax error: wrong position of :"); } - if( _cache.StatementsInDepth.Count != 0 ) { + if (_cache.StatementsInDepth.Count != 0) { throw new ExpInvalidSyntaxException( - "Range and index syntax error: expected one statement to define range beginning." ); + "Range and index syntax error: expected one statement to define range beginning."); } ReverseAnalyzeStatement(); root = _cache.StatementsInDepth.Pop(); - if( ExpNodeFlag.BuiltinType_Int.IsNotInFlag( root.NodeFlag ) ) { + if (ExpNodeFlag.BuiltinType_Int.IsNotInFlag(root.NodeFlag)) { throw new ExpInvalidTypeException( - root, "integer", root.EqualityTypeConvert?.Name ?? string.Empty ); + root, "integer", root.EqualityTypeConvert?.Name ?? string.Empty); } state.RangeStart = root; break; default: state = _cache.StateOfCurrentDepth(); - if( t.Value == "?" ) + if (t.Value == "?") { - switch( state.CurrentState ) + switch (state.CurrentState) { case ":": - _cache.PushOperand( new ExpIntNode( t, int.MaxValue, true ) ); + _cache.PushOperand(new ExpIntNode(t, int.MaxValue, true)); break; case "[": - _cache.PushOperand( new ExpIntNode( t, int.MaxValue, true ) ); + _cache.PushOperand(new ExpIntNode(t, int.MaxValue, true)); break; default: throw new ExpInvalidSyntaxException( - "Range and index syntax error: \"?\" can only be used in range or index" ); + "Range and index syntax error: \"?\" can only be used in range or index"); } } - AppendToken_Common( t ); + AppendToken_Common(t); break; } } diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.RepeatLoop.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.RepeatLoop.cs index 9cc7f93e..e3b314ab 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.RepeatLoop.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.RepeatLoop.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.RepeatLoop.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.RepeatLoop" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp.Syntax; using System; @@ -49,83 +46,81 @@ namespace StgSharp.Script.Express private Dictionary _tempVariableInLoops { get; } = new Dictionary(); - private bool AppendToken_RepeatLoop( Token t ) + private bool AppendToken_RepeatLoop(Token t) { RepeatLoopState state = _cache.StateOfCurrentDepth(); - if( state == null ) + if (state == null) { - state = new RepeatLoopState( t ); + state = new RepeatLoopState(t); _cache.CurrentDepthMark.StateCache = state; state.CurrentState = t.Value; return true; } - switch( state.CurrentState ) + switch (state.CurrentState) { case ExpKeyword.Repeat: - return TryParseRepeatVariable( state, t ); + return TryParseRepeatVariable(state, t); case ExpKeyword.To: - return TryParseRepeatEnding( state, t ); + return TryParseRepeatEnding(state, t); case ExpKeyword.By: - return TryParseRepeatVariable( state, t ); + return TryParseRepeatVariable(state, t); case ExpKeyword.Until: - return TryParseRepeatUntilRegulation( state, t ); + return TryParseRepeatUntilRegulation(state, t); case ExpKeyword.Assignment: - return TryParseRepeatBeginning( state, t ); + return TryParseRepeatBeginning(state, t); case ExpKeyword.While: - return TryParseRepeatWhileRegulation( state, t ); + return TryParseRepeatWhileRegulation(state, t); case ExpKeyword.Semicolon: - if( t.Value != ExpKeyword.EndRepeat ) + if (t.Value != ExpKeyword.EndRepeat) { - AppendToken_Common( t ); + AppendToken_Common(t); return true; } break; default: - AppendToken_Common( t ); + AppendToken_Common(t); return false; } ExpSyntaxNode root = _cache.PackAllStatements(); state.Body = root; _cache.DecreaseDepth(); - if( ExpTypeSource.IsNullOrVoid( state.IncrementVariableType ) ) + if (ExpTypeSource.IsNullOrVoid(state.IncrementVariableType)) { root = ExpRepeatNode.Create( - state.Position, state.IncrementVariable, state.Begin, state.End, - state.IncrementVariable, state.Body, state.UntilExpression, - state.WhileExpression ); + state.Position, state.IncrementVariable, state.Begin, state.End, state.IncrementVariable, + state.Body, state.UntilExpression, state.WhileExpression); } else { root = ExpRepeatNode.Create( state.Position, state.IncrementVariable.OriginObject, state.Begin, state.End, - state.IncrementVariable, state.Body, state.UntilExpression, - state.WhileExpression ); + state.IncrementVariable, state.Body, state.UntilExpression, state.WhileExpression); } - _cache.StatementsInDepth.Push( root ); - _tempVariableInLoops.Remove( state.IncrementVariable.CodeConvertTemplate ); + _cache.StatementsInDepth.Push(root); + _tempVariableInLoops.Remove(state.IncrementVariable.CodeConvertTemplate); return true; } - private bool TryParseRepeatBeginning( RepeatLoopState state, Token t ) + private bool TryParseRepeatBeginning(RepeatLoopState state, Token t) { - switch( t.Value ) + switch (t.Value) { case ExpKeyword.To: state.CurrentState = ExpKeyword.To; - while( _cache.TryPopOperator( out Token op ) ) { - ConvertAndPushOneOperator( op ); + while (_cache.TryPopOperator(out Token op)) { + ConvertAndPushOneOperator(op); } - _cache.PopOperand( out _, out ExpSyntaxNode? root ); + _cache.PopOperand(out _, out ExpSyntaxNode? root); state.Begin = root; return true; default: - AppendToken_Common( t ); + AppendToken_Common(t); return true; } } - private bool TryParseRepeatEnding( RepeatLoopState state, Token t ) + private bool TryParseRepeatEnding(RepeatLoopState state, Token t) { - switch( t.Value ) + switch (t.Value) { case ExpKeyword.By: state.CurrentState = ExpKeyword.By; @@ -137,20 +132,20 @@ namespace StgSharp.Script.Express state.CurrentState = ExpKeyword.While; break; default: - AppendToken_Common( t ); + AppendToken_Common(t); return true; } - while( _cache.TryPopOperator( out Token op ) ) { - ConvertAndPushOneOperator( op ); + while (_cache.TryPopOperator(out Token op)) { + ConvertAndPushOneOperator(op); } - _cache.PopOperand( out _, out ExpSyntaxNode? root ); + _cache.PopOperand(out _, out ExpSyntaxNode? root); state.End = root; return true; } - private bool TryParseRepeatIncrement( RepeatLoopState state, Token t ) + private bool TryParseRepeatIncrement(RepeatLoopState state, Token t) { - switch( t.Value ) + switch (t.Value) { case ExpKeyword.Semicolon: state.CurrentState = ExpKeyword.Semicolon; @@ -162,39 +157,39 @@ namespace StgSharp.Script.Express state.CurrentState = ExpKeyword.While; break; default: - AppendToken_Common( t ); + AppendToken_Common(t); return true; } - while( _cache.TryPopOperator( out Token op ) ) { - ConvertAndPushOneOperator( op ); + while (_cache.TryPopOperator(out Token op)) { + ConvertAndPushOneOperator(op); } - _cache.PopOperand( out _, out ExpSyntaxNode? root ); + _cache.PopOperand(out _, out ExpSyntaxNode? root); state.StepIncrement = root; return true; } - private bool TryParseRepeatUntilRegulation( RepeatLoopState state, Token t ) + private bool TryParseRepeatUntilRegulation(RepeatLoopState state, Token t) { - switch( t.Value ) + switch (t.Value) { case ExpKeyword.Semicolon: state.CurrentState = ExpKeyword.Semicolon; break; default: - AppendToken_Common( t ); + AppendToken_Common(t); return true; } - while( _cache.TryPopOperator( out Token op ) ) { - ConvertAndPushOneOperator( op ); + while (_cache.TryPopOperator(out Token op)) { + ConvertAndPushOneOperator(op); } - _cache.PopOperand( out _, out ExpSyntaxNode? root ); + _cache.PopOperand(out _, out ExpSyntaxNode? root); state.UntilExpression = root; return true; } - private bool TryParseRepeatVariable( RepeatLoopState state, Token t ) + private bool TryParseRepeatVariable(RepeatLoopState state, Token t) { - switch( t.Value ) + switch (t.Value) { case ExpKeyword.Integer: state.IncrementVariableType = ExpressCompile.ExpInt; @@ -207,48 +202,47 @@ namespace StgSharp.Script.Express state.CurrentState = ExpKeyword.Assignment; return true; default: - if( ExpTypeSource.IsNullOrVoid( state.IncrementVariableType ) ) + if (ExpTypeSource.IsNullOrVoid(state.IncrementVariableType)) { - if( ( _local.TryGetMember( t.Value, - out ExpSyntaxNode? node ) && - node is ExpElementInstance instance ) || - _tempVariableInLoops.TryGetValue( t.Value, out instance ) ) + if ((_local.TryGetMember(t.Value, + out ExpSyntaxNode? node) && + node is ExpElementInstance instance) || + _tempVariableInLoops.TryGetValue(t.Value, out instance)) { state.IncrementVariable = ExpInstanceReferenceNode.MakeReferenceFrom( - t, instance ); + t, instance); return true; } else { throw new ExpInvalidSyntaxException( - $"Variable {t.Value} is not declared or initialized." ); + $"Variable {t.Value} is not declared or initialized."); } } else { - ExpElementInstance variable = state.IncrementVariableType - .CreateInstanceNode( t ); - _tempVariableInLoops.Add( t.Value, variable ); + ExpElementInstance variable = state.IncrementVariableType.CreateInstanceNode(t); + _tempVariableInLoops.Add(t.Value, variable); state.IncrementVariable = ExpInstanceReferenceNode.MakeReferenceFrom( - t, variable ); + t, variable); return true; } } } - private bool TryParseRepeatWhileRegulation( RepeatLoopState state, Token t ) + private bool TryParseRepeatWhileRegulation(RepeatLoopState state, Token t) { - switch( t.Value ) + switch (t.Value) { case ExpKeyword.Until: state.CurrentState = ExpKeyword.Until; break; default: - AppendToken_Common( t ); + AppendToken_Common(t); return true; } - while( _cache.TryPopOperator( out Token op ) ) { - ConvertAndPushOneOperator( op ); + while (_cache.TryPopOperator(out Token op)) { + ConvertAndPushOneOperator(op); } - _cache.PopOperand( out _, out ExpSyntaxNode? root ); + _cache.PopOperand(out _, out ExpSyntaxNode? root); state.WhileExpression = root; return true; } @@ -256,7 +250,7 @@ namespace StgSharp.Script.Express private class RepeatLoopState : ICompileDepthState { - public RepeatLoopState( Token t ) + public RepeatLoopState(Token t) { Position = t; UntilExpression = ExpSyntaxNode.Empty; diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.ReverseAnalysing.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.ReverseAnalysing.cs index b7706bfa..5482ab21 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.ReverseAnalysing.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.ReverseAnalysing.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.ReverseAnalysing.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer.ReverseAnalysing" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -42,51 +39,51 @@ namespace StgSharp.Script.Express public partial class ExpSyntaxAnalyzer { - private void ClosePrefixReverse( Token rightSeparator ) + private void ClosePrefixReverse(Token rightSeparator) { ExpSyntaxNode root; ReverseAnalyzeStatement(); root = _cache.PackAllStatements(); - if( rightSeparator.Value == ")" ) { - root = ExpTupleNode.Pack( root ); + if (rightSeparator.Value == ")") { + root = ExpTupleNode.Pack(root); } _cache.DecreaseDepth(); - if( IsSeparatorMatch( _cache.PeekOperator(), rightSeparator ) ) + if (IsSeparatorMatch(_cache.PeekOperator(), rightSeparator)) { _cache.PopOperator(); - _cache.PushOperand( root ); + _cache.PushOperand(root); } else { throw new ExpCompileException( - rightSeparator, "Ending of block does not match its begging" ); + rightSeparator, "Ending of block does not match its begging"); } } private void ReverseAnalyzeStatement() { ExpSyntaxNode root; - if( _cache.OperatorAheadOfDepth == 0 ) + if (_cache.OperatorAheadOfDepth == 0) { - switch( _cache.OperandAheadOfDepth ) + switch (_cache.OperandAheadOfDepth) { case 1: - _cache.PopOperand( out _, out ExpSyntaxNode? statement ); - _cache.StatementsInDepth.Push( statement ); + _cache.PopOperand(out _, out ExpSyntaxNode? statement); + _cache.StatementsInDepth.Push(statement); break; case 0: - _cache.StatementsInDepth.Push( ExpSyntaxNode.Empty ); + _cache.StatementsInDepth.Push(ExpSyntaxNode.Empty); break; default: throw new ExpInvalidSyntaxException( - "More than one operand but no operator provided." ); + "More than one operand but no operator provided."); } } else { - while( _cache.TryPopOperator( out Token op ) ) { - ConvertAndPushOneOperator( op ); + while (_cache.TryPopOperator(out Token op)) { + ConvertAndPushOneOperator(op); } - _cache.PopOperand( out _, out root ); - _cache.StatementsInDepth.Push( root ); + _cache.PopOperand(out _, out root); + _cache.StatementsInDepth.Push(root); } } diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.cs index b7bd5025..3cee7cfa 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpSyntaxAnalyzer.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpSyntaxAnalyzer" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using Microsoft.CodeAnalysis.CSharp.Syntax; using StgSharp.Threading; @@ -61,43 +58,43 @@ namespace StgSharp.Script.Express _cache = new CompileStack(); } - public ExpSyntaxAnalyzer( ExpSchema context, IExpElementSource local ) + public ExpSyntaxAnalyzer(ExpSchema context, IExpElementSource local) { _cache = new CompileStack(); - ArgumentNullException.ThrowIfNull( context ); - if( context is not ExpSchema_Builtin ) + ArgumentNullException.ThrowIfNull(context); + if (context is not ExpSchema_Builtin) { _context = context; } else { - throw new InvalidCastException( "Not a valid Schema type" ); + throw new InvalidCastException("Not a valid Schema type"); } _local = local; } /**/ - public void AppendToken( Token expToken ) + public void AppendToken(Token expToken) { - switch( ( ExpCompileStateCode )TryEnterBranch( expToken ).Usage ) + switch ((ExpCompileStateCode)TryEnterBranch(expToken).Usage) { case ExpCompileStateCode.IfBranch: - AppendToken_IfBranch( expToken ); + AppendToken_IfBranch(expToken); break; case ExpCompileStateCode.CaseBranch: - AppendToken_CaseOf( expToken ); + AppendToken_CaseOf(expToken); break; case ExpCompileStateCode.RepeatLoop: - AppendToken_RepeatLoop( expToken ); + AppendToken_RepeatLoop(expToken); break; default: - AppendToken_Common( expToken ); + AppendToken_Common(expToken); break; } } public ExpSyntaxNode GetNextOperandCache() { - if( _cache.PopOperand( out Token t, out ExpSyntaxNode? n ) ) + if (_cache.PopOperand(out Token t, out ExpSyntaxNode? n)) { return n; } else @@ -112,53 +109,53 @@ namespace StgSharp.Script.Express /// Append a token to top of cache. This method will automatically convert token to node /// if meets separators or operators. /// - private void AppendToken_Common( Token expToken ) + private void AppendToken_Common(Token expToken) { - switch( expToken.Flag ) + switch (expToken.Flag) { case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary: - TryAppendSymbol( expToken ); + TryAppendSymbol(expToken); break; case TokenFlag.Number or TokenFlag.String: - ExpElementInstance node = ExpElementInstance.CreateLiteral( expToken ); - _cache.PushOperand( node ); + ExpElementInstance node = ExpElementInstance.CreateLiteral(expToken); + _cache.PushOperand(node); break; case TokenFlag.Separator_Left: - TryAppendPrefixSeparator( expToken ); + TryAppendPrefixSeparator(expToken); break; case TokenFlag.Separator_Right: - TryAppendPrefixSeparatorEnd( expToken ); + TryAppendPrefixSeparatorEnd(expToken); break; case TokenFlag.Separator_Middle: - TryAppendMiddleSeparator( expToken ); + TryAppendMiddleSeparator(expToken); break; case TokenFlag.Index_Left: - TryAppendIndexLeft( expToken ); + TryAppendIndexLeft(expToken); break; case TokenFlag.Index_Right: - TryAppendIndexRight( expToken ); + TryAppendIndexRight(expToken); break; case TokenFlag.Member: - TryAppendMember( expToken ); + TryAppendMember(expToken); break; default: break; } } - private CompileDepthMark TryEnterBranch( Token t ) + private CompileDepthMark TryEnterBranch(Token t) { - if( t.Flag == TokenFlag.String ) { + if (t.Flag == TokenFlag.String) { return _cache.CurrentDepthMark; } - switch( t.Value ) + switch (t.Value) { case ExpKeyword.Case: - return _cache.IncreaseDepth( ( int )ExpCompileStateCode.CaseBranch ); + return _cache.IncreaseDepth((int)ExpCompileStateCode.CaseBranch); case ExpKeyword.If: - return _cache.IncreaseDepth( ( int )ExpCompileStateCode.IfBranch ); + return _cache.IncreaseDepth((int)ExpCompileStateCode.IfBranch); case ExpKeyword.Repeat: - return _cache.IncreaseDepth( ( int )ExpCompileStateCode.RepeatLoop ); + return _cache.IncreaseDepth((int)ExpCompileStateCode.RepeatLoop); default: return _cache.CurrentDepthMark; } diff --git a/StgSharp.Script/Express/ExpTokenReader.cs b/StgSharp.Script/Express/ExpTokenReader.cs index e1d9b4cb..5d7afd29 100644 --- a/StgSharp.Script/Express/ExpTokenReader.cs +++ b/StgSharp.Script/Express/ExpTokenReader.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="ExpTokenReader.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="ExpTokenReader" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using CommunityToolkit.HighPerformance; using StgSharp.HighPerformance; @@ -43,12 +40,12 @@ namespace StgSharp.Script.Express public static ExpTokenReaderPreProcessor Default { get; } = new DefaultProcessor(); - public abstract bool Process( string codeLine, int line, ref int current, out Token t ); + public abstract bool Process(string codeLine, int line, ref int current, out Token t); private class DefaultProcessor : ExpTokenReaderPreProcessor { - public override bool Process( string codeLine, int line, ref int current, out Token t ) + public override bool Process(string codeLine, int line, ref int current, out Token t) { t = Token.Empty; return false; @@ -80,7 +77,7 @@ namespace StgSharp.Script.Express private string _lineCache; private Token _last; - public ExpTokenReader( IScriptSourceProvider provider ) + public ExpTokenReader(IScriptSourceProvider provider) { _provider = provider; _current = 0; @@ -90,8 +87,7 @@ namespace StgSharp.Script.Express public bool IsEmpty { - get => ( ( string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length ) ) && - _provider.IsEmpty; + get => ((string.IsNullOrEmpty(_lineCache) || _current >= _lineCache.Length)) && _provider.IsEmpty; } public ExpTokenReaderPreProcessor TokenReaderPreProcessor { get; set; } = ExpTokenReaderPreProcessor.Default; @@ -103,28 +99,28 @@ namespace StgSharp.Script.Express public unsafe ReadOnlySpan ReadLine() { - bool lineOver = string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length; - while( lineOver || _isReadingMultiLineComment ) + bool lineOver = string.IsNullOrEmpty(_lineCache) || _current >= _lineCache.Length; + while (lineOver || _isReadingMultiLineComment) { - if( IsEmpty ) { + if (IsEmpty) { return ReadOnlySpan.Empty; } - if( lineOver ) + if (lineOver) { do { - _lineCache = _provider.ReadLine( out _lineNum ); - } while (string.IsNullOrEmpty( _lineCache ) && !_provider.IsEmpty); + _lineCache = _provider.ReadLine(out _lineNum); + } while (string.IsNullOrEmpty(_lineCache) && !_provider.IsEmpty); _current = 0; } - if( _isReadingMultiLineComment ) + if (_isReadingMultiLineComment) { int index; - fixed( char* cPtr = _lineCache.AsSpan( _current ) ) { + fixed (char* cPtr = _lineCache.AsSpan(_current)) { index = UnsafeCompute.IndexOfCharPair( - cPtr, MultiLineEnd, _lineCache.Length ); + cPtr, MultiLineEnd, _lineCache.Length); } - if( index == -1 ) + if (index == -1) { _lineCache = string.Empty; } else @@ -133,9 +129,9 @@ namespace StgSharp.Script.Express _current += index + 2; } } - lineOver = string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length; + lineOver = string.IsNullOrEmpty(_lineCache) || _current >= _lineCache.Length; } - return _lineCache.AsSpan().Slice( _current ); + return _lineCache.AsSpan().Slice(_current); } public unsafe Token ReadToken() @@ -143,95 +139,95 @@ namespace StgSharp.Script.Express int begin, end, rest; readLine: ReadOnlySpan source; - if( !TryReadLine( out source ) ) { + if (!TryReadLine(out source)) { return Token.Empty; } - if( TokenReaderPreProcessor.Process( _lineCache, LineNumber, ref _current, - out Token t ) ) { + if (TokenReaderPreProcessor.Process(_lineCache, LineNumber, ref _current, + out Token t)) { return t; } - char c = source[ 0 ]; - if( char.IsLetter( c ) ) + char c = source[0]; + if (char.IsLetter(c)) { - Match match = _nextWordTokenPattern.Match( _lineCache, _current ); - if( match.Success ) + Match match = _nextWordTokenPattern.Match(_lineCache, _current); + if (match.Success) { - begin = match.Groups[ TokenMark ].Index; - end = match.Groups[ EndMark ].Index; - rest = match.Groups[ RestMark ].Index; + begin = match.Groups[TokenMark].Index; + end = match.Groups[EndMark].Index; + rest = match.Groups[RestMark].Index; _current = rest; _last = new( - ExpressCompile.PoolString( source[ ..( end - begin ) ] ), _lineNum, begin, - TokenFlag.Member ); + ExpressCompile.PoolString(source[..(end - begin)]), _lineNum, begin, + TokenFlag.Member); return _last; } else { - throw new ExpInvalidCharException( _current ); + throw new ExpInvalidCharException(_current); } - } else if( char.IsPunctuation( c ) || char.IsSymbol( c ) ) + } else if (char.IsPunctuation(c) || char.IsSymbol(c)) { Match match; - switch( c ) + switch (c) { case '\'': - char cNext = source[ 1 ]; - if( cNext == '\'' ) //empty string + char cNext = source[1]; + if (cNext == '\'') //empty string { begin = _current; _current += 2; - return new( string.Empty, _lineNum, begin, TokenFlag.String ); + return new(string.Empty, _lineNum, begin, TokenFlag.String); } - match = _nextStringLiteralPatternWithSingle.Match( _lineCache, _current ); - if( match.Success ) + match = _nextStringLiteralPatternWithSingle.Match(_lineCache, _current); + if (match.Success) { - begin = match.Groups[ "token" ].Index; - end = match.Groups[ "end" ].Index; - rest = match.Groups[ "rest" ].Index; + begin = match.Groups["token"].Index; + end = match.Groups["end"].Index; + rest = match.Groups["rest"].Index; _current = rest; _last = new( - ExpressCompile.PoolString( source[ 1..( end - begin ) ] ), _lineNum, - begin, TokenFlag.String ); + ExpressCompile.PoolString(source[1..(end - begin)]), _lineNum, + begin, TokenFlag.String); return _last; } else { - throw new ExpInvalidCharException( '\"' ); + throw new ExpInvalidCharException('\"'); } case '"': - cNext = source[ 1 ]; - if( cNext == '\"' ) //empty string + cNext = source[1]; + if (cNext == '\"') //empty string { begin = _current; _current += 2; - return new( string.Empty, _lineNum, begin, TokenFlag.String ); + return new(string.Empty, _lineNum, begin, TokenFlag.String); } - match = _nextStringLiteralPattern.Match( _lineCache, _current ); - if( match.Success ) + match = _nextStringLiteralPattern.Match(_lineCache, _current); + if (match.Success) { - begin = match.Groups[ "token" ].Index; - end = match.Groups[ "end" ].Index; - rest = match.Groups[ "rest" ].Index; + begin = match.Groups["token"].Index; + end = match.Groups["end"].Index; + rest = match.Groups["rest"].Index; _current = rest; _last = new( - ExpressCompile.PoolString( source[ 1..( end - begin ) ] ), _lineNum, - begin, TokenFlag.String ); + ExpressCompile.PoolString(source[1..(end - begin)]), _lineNum, + begin, TokenFlag.String); return _last; } else { - throw new ExpInvalidCharException( '\"' ); + throw new ExpInvalidCharException('\"'); } case '(': begin = _current; _current++; _last = new( - ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin, - TokenFlag.Separator_Left ); + ExpressCompile.PoolString(source[..1]), _lineNum, begin, + TokenFlag.Separator_Left); return _last; case ')' or '}': begin = _current; _current++; _last = new Token( - ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin, - TokenFlag.Separator_Right ); + ExpressCompile.PoolString(source[..1]), _lineNum, begin, + TokenFlag.Separator_Right); return _last; case '-': @@ -239,24 +235,24 @@ namespace StgSharp.Script.Express // 2. -- comment // 3. - number type param(UNARY) // 4. param - param(BINARY) - cNext = source[ 1 ]; - if( char.IsNumber( cNext ) ) + cNext = source[1]; + if (char.IsNumber(cNext)) { - match = _nextNumberLiteralPattern.Match( _lineCache, _current ); - if( match.Success ) + match = _nextNumberLiteralPattern.Match(_lineCache, _current); + if (match.Success) { - begin = match.Groups[ TokenMark ].Index; - end = match.Groups[ EndMark ].Index; - rest = match.Groups[ RestMark ].Index; + begin = match.Groups[TokenMark].Index; + end = match.Groups[EndMark].Index; + rest = match.Groups[RestMark].Index; _current = rest; return new( - ExpressCompile.PoolString( source[ ..( end - begin ) ] ), - _lineNum, begin, TokenFlag.Number ); + ExpressCompile.PoolString(source[..(end - begin)]), + _lineNum, begin, TokenFlag.Number); } else { - throw new ExpInvalidCharException( _current ); + throw new ExpInvalidCharException(_current); } - } else if( cNext == '-' ) + } else if (cNext == '-') { _lineCache = string.Empty; _current = 0; @@ -265,18 +261,18 @@ namespace StgSharp.Script.Express { begin = _current; _current++; - if( _last.Flag == TokenFlag.Member || + if (_last.Flag == TokenFlag.Member || _last.Flag == TokenFlag.Index_Right || - _last.Flag == TokenFlag.Separator_Right ) + _last.Flag == TokenFlag.Separator_Right) { _last = new( - ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin, - TokenFlag.Symbol_Binary ); + ExpressCompile.PoolString(source[..1]), _lineNum, begin, + TokenFlag.Symbol_Binary); } else { _last = new( - ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin, - TokenFlag.Symbol_Unary ); + ExpressCompile.PoolString(source[..1]), _lineNum, begin, + TokenFlag.Symbol_Unary); } return _last; } @@ -284,139 +280,131 @@ namespace StgSharp.Script.Express begin = _current; _current++; _last = new Token( - ExpressCompile.PoolString( "{" ), _lineNum, begin, - TokenFlag.Separator_Left ); + ExpressCompile.PoolString("{"), _lineNum, begin, + TokenFlag.Separator_Left); return _last; case '[': begin = _current; _current++; _last = new Token( - ExpressCompile.PoolString( "[" ), _lineNum, begin, - TokenFlag.Index_Left ); + ExpressCompile.PoolString("["), _lineNum, begin, + TokenFlag.Index_Left); return _last; case ']': begin = _current; _current++; _last = new Token( - ExpressCompile.PoolString( "]" ), _lineNum, begin, - TokenFlag.Index_Right ); + ExpressCompile.PoolString("]"), _lineNum, begin, + TokenFlag.Index_Right); return _last; case ';' or ',': begin = _current; _current++; _last = new Token( - ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin, - TokenFlag.Separator_Middle ); + ExpressCompile.PoolString(source[..1]), _lineNum, begin, + TokenFlag.Separator_Middle); return _last; case ':': - match = _nextSymbolPattern.Match( _lineCache, _current ); - begin = match.Groups[ TokenMark ].Index; - end = match.Groups[ EndMark ].Index; - rest = match.Groups[ RestMark ].Index; + match = _nextSymbolPattern.Match(_lineCache, _current); + begin = match.Groups[TokenMark].Index; + end = match.Groups[EndMark].Index; + rest = match.Groups[RestMark].Index; _current = rest; - if( end - begin == 1 ) + if (end - begin == 1) { _last = new Token( ExpressCompile.Keyword.Colon, _lineNum, begin, - TokenFlag.Separator_Middle ); + TokenFlag.Separator_Middle); } else { _last = new Token( - ExpressCompile.PoolString( source[ ..( end - begin ) ] ), _lineNum, - begin, TokenFlag.Symbol_Binary ); + ExpressCompile.PoolString(source[..(end - begin)]), _lineNum, + begin, TokenFlag.Symbol_Binary); } return _last; case '+' or '/' or '\\' or '*' or '.': - match = _nextSymbolPattern.Match( _lineCache, _current ); - begin = match.Groups[ TokenMark ].Index; - end = match.Groups[ EndMark ].Index; - rest = match.Groups[ RestMark ].Index; + match = _nextSymbolPattern.Match(_lineCache, _current); + begin = match.Groups[TokenMark].Index; + end = match.Groups[EndMark].Index; + rest = match.Groups[RestMark].Index; _current = rest; _last = new Token( - ExpressCompile.PoolString( source[ ..( end - begin ) ] ), _lineNum, - begin, TokenFlag.Symbol_Binary ); + ExpressCompile.PoolString(source[..(end - begin)]), _lineNum, + begin, TokenFlag.Symbol_Binary); return _last; case '=': begin = _current; _current++; _last = new Token( ExpressCompile.Keyword.Equal, _lineNum, begin, - TokenFlag.Symbol_Binary ); + TokenFlag.Symbol_Binary); return _last; default: - throw new ExpInvalidCharException( c ); + throw new ExpInvalidCharException(c); } - } else if( char.IsNumber( c ) ) + } else if (char.IsNumber(c)) { - Match match = _nextNumberLiteralPattern.Match( _lineCache, _current ); - if( match.Success ) + Match match = _nextNumberLiteralPattern.Match(_lineCache, _current); + if (match.Success) { - begin = match.Groups[ TokenMark ].Index; - end = match.Groups[ EndMark ].Index; - rest = match.Groups[ RestMark ].Index; + begin = match.Groups[TokenMark].Index; + end = match.Groups[EndMark].Index; + rest = match.Groups[RestMark].Index; _current = rest; - string str = ExpressCompile.PoolString( source[ ..( end - begin ) ] ); - return new( str, _lineNum, begin, TokenFlag.Number ); + string str = ExpressCompile.PoolString(source[..(end - begin)]); + return new(str, _lineNum, begin, TokenFlag.Number); } else { - throw new ExpInvalidCharException( _current ); + throw new ExpInvalidCharException(_current); } - } else if( char.IsWhiteSpace( c ) ) + } else if (char.IsWhiteSpace(c)) { - Match match = _skipBlankPattern.Match( _lineCache, _current ); - if( match.Success ) + Match match = _skipBlankPattern.Match(_lineCache, _current); + if (match.Success) { - rest = match.Groups[ RestMark ].Index; + rest = match.Groups[RestMark].Index; _current = rest; goto readLine; } else { - throw new ExpInvalidCharException( _current ); + throw new ExpInvalidCharException(_current); } } else { - throw new ExpInvalidCharException( c ); + throw new ExpInvalidCharException(c); } } - public bool TryReadLine( out ReadOnlySpan line ) + public bool TryReadLine(out ReadOnlySpan line) { line = ReadLine(); return line != ReadOnlySpan.Empty; } - public bool TryReadToken( out Token t ) + public bool TryReadToken(out Token t) { t = ReadToken(); return !IsEmpty; } - [GeneratedRegex( - @"(?[a-zA-Z][a-zA-Z0-9_]*)(?\s*?)(?\S|$)", - RegexOptions.Singleline )] + [GeneratedRegex(@"(?[a-zA-Z][a-zA-Z0-9_]*)(?\s*?)(?\S|$)", RegexOptions.Singleline)] private static partial Regex GetNextWordTokenPattern(); [GeneratedRegex( @"(?-?\s*?[0-9]+(?:\.[0-9]*)?E?(?:[+-]?[0-9]+)?)(?\s*?)(?\S|$)", - RegexOptions.Singleline )] + RegexOptions.Singleline)] private static partial Regex GetNumberLiteralPattern(); - [GeneratedRegex( @"(?:\s+?)(?\S|$)", RegexOptions.Singleline )] + [GeneratedRegex(@"(?:\s+?)(?\S|$)", RegexOptions.Singleline)] private static partial Regex GetSkipBlankPattern(); - [GeneratedRegex( - @"(?"")(?>\\\\|\\""|(?!')[^""])*(?""|$)\s*?(?\S|$)", - RegexOptions.Singleline )] + [GeneratedRegex(@"(?"")(?>\\\\|\\""|(?!')[^""])*(?""|$)\s*?(?\S|$)", RegexOptions.Singleline)] private static partial Regex GetStringLiteralPattern(); - [GeneratedRegex( - @"(?')(?>\\\\|\\'|''|(?!')[^'])*(?')\s*?(?\S|$)", - RegexOptions.Singleline )] + [GeneratedRegex(@"(?')(?>\\\\|\\'|''|(?!')[^'])*(?')\s*?(?\S|$)", RegexOptions.Singleline)] private static partial Regex GetStringLiteralPatternWithSingle(); - [GeneratedRegex( - @"(?[:<>=+\-*\/\.]+)(?\s?)\s*?(?\S|$)", - RegexOptions.Singleline )] + [GeneratedRegex(@"(?[:<>=+\-*\/\.]+)(?\s?)\s*?(?\S|$)", RegexOptions.Singleline)] private static partial Regex GetSymbolPattern(); } diff --git a/StgSharp.Script/Express/GeneratedExpSchema.cs b/StgSharp.Script/Express/GeneratedExpSchema.cs index 333fd4a3..e700616d 100644 --- a/StgSharp.Script/Express/GeneratedExpSchema.cs +++ b/StgSharp.Script/Express/GeneratedExpSchema.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="GeneratedExpSchema.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="GeneratedExpSchema" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using CommunityToolkit.HighPerformance.Helpers; using StgSharp.Collections; @@ -49,64 +46,64 @@ namespace StgSharp.Script.Express get => ExpSchema_Builtin.Only; } - public ExpTypeSource GetExpType( string typeName ) + public ExpTypeSource GetExpType(string typeName) { - if( BuiltinSchema.TryGetType( typeName, out ExpTypeSource? ret ) ) { + if (BuiltinSchema.TryGetType(typeName, out ExpTypeSource? ret)) { return ret; } - if( TypeDict.TryGetValue( typeName, out ret ) ) { + if (TypeDict.TryGetValue(typeName, out ret)) { return ret; } - foreach( GeneratedExpSchema item in SchemaInclude.Values ) + foreach (GeneratedExpSchema item in SchemaInclude.Values) { - if( item.TypeDict.TryGetValue( typeName, out ret ) ) { + if (item.TypeDict.TryGetValue(typeName, out ret)) { return ret; } } - throw new ExpElementLoadException( typeName, this ); + throw new ExpElementLoadException(typeName, this); } - public bool HasSchemaInclude( GeneratedExpSchema schema ) + public bool HasSchemaInclude(GeneratedExpSchema schema) { - return SchemaInclude.ContainsKey( schema.Name ); + return SchemaInclude.ContainsKey(schema.Name); } - public override void LoadFromSource( ExpSchemaSource source ) + public override void LoadFromSource(ExpSchemaSource source) { throw new NotImplementedException(); } - public override bool TryGetConst( string name, out ExpElementInstance c ) + public override bool TryGetConst(string name, out ExpElementInstance c) { - return ConstDict.TryGetValue( name, out c! ); + return ConstDict.TryGetValue(name, out c!); } - public override bool TryGetEntity( string name, out ExpEntitySource e ) + public override bool TryGetEntity(string name, out ExpEntitySource e) { - return EntityDict.TryGetValue( name, out e! ); + return EntityDict.TryGetValue(name, out e!); } - public override bool TryGetFunction( string name, out ExpFunctionSource f ) + public override bool TryGetFunction(string name, out ExpFunctionSource f) { - return FunctionDict.TryGetValue( name, out f! ); + return FunctionDict.TryGetValue(name, out f!); } - public override bool TryGetProcedure( string name, out ExpProcedureSource p ) + public override bool TryGetProcedure(string name, out ExpProcedureSource p) { throw new NotImplementedException(); } - public override bool TryGetRule( string name, out ExpRuleSource r ) + public override bool TryGetRule(string name, out ExpRuleSource r) { throw new NotImplementedException(); } - public override bool TryGetSchemaInclude( string name, out ExpSchema include ) + public override bool TryGetSchemaInclude(string name, out ExpSchema include) { throw new NotImplementedException(); } - public override bool TryGetType( string name, out ExpTypeSource element ) + public override bool TryGetType(string name, out ExpTypeSource element) { throw new NotImplementedException(); } diff --git a/StgSharp.Script/Express/IExpConvertableFrom.cs b/StgSharp.Script/Express/IExpConvertableFrom.cs index 61ecf92a..decb755b 100644 --- a/StgSharp.Script/Express/IExpConvertableFrom.cs +++ b/StgSharp.Script/Express/IExpConvertableFrom.cs @@ -1,33 +1,30 @@ //----------------------------------------------------------------------- -//----------------------------------------------------------------------- -// file="IExpConvertableFrom.cs" -// Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// ----------------------------------------------------------------------- +// file="IExpConvertableFrom" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // -// 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: +// 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. // -// 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. -// -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; @@ -40,30 +37,28 @@ namespace StgSharp.Script.Express public interface IExpConvertableFrom where T0: IExpConvertableFrom { - void FromInstance( T0 entity ); + void FromInstance(T0 entity); - bool IsConvertableTo( string entityTypeName ); + bool IsConvertableTo(string entityTypeName); } // 2 generic parameters - public interface IExpConvertableFrom : IExpConvertableFrom - where T0: IExpConvertableFrom + public interface IExpConvertableFrom : IExpConvertableFrom where T0: IExpConvertableFrom where T1: IExpConvertableFrom { - void FromInstance( T1 entity ); + void FromInstance(T1 entity); } // 3 generic parameters - public interface IExpConvertableFrom : IExpConvertableFrom - where T0: IExpConvertableFrom + public interface IExpConvertableFrom : IExpConvertableFrom where T0: IExpConvertableFrom where T1: IExpConvertableFrom where T2: IExpConvertableFrom { - void FromInstance( T2 entity ); + void FromInstance(T2 entity); } @@ -75,7 +70,7 @@ namespace StgSharp.Script.Express where T3: IExpConvertableFrom { - void FromInstance( T3 entity ); + void FromInstance(T3 entity); } @@ -88,7 +83,7 @@ namespace StgSharp.Script.Express where T4: IExpConvertableFrom { - void FromInstance( T4 entity ); + void FromInstance(T4 entity); } @@ -102,7 +97,7 @@ namespace StgSharp.Script.Express where T5: IExpConvertableFrom { - void FromInstance( T5 entity ); + void FromInstance(T5 entity); } @@ -117,7 +112,7 @@ namespace StgSharp.Script.Express where T6: IExpConvertableFrom { - void FromInstance( T6 entity ); + void FromInstance(T6 entity); } @@ -133,7 +128,7 @@ namespace StgSharp.Script.Express where T7: IExpConvertableFrom { - void FromInstance( T7 entity ); + void FromInstance(T7 entity); } @@ -150,7 +145,7 @@ namespace StgSharp.Script.Express where T8: IExpConvertableFrom { - void FromInstance( T8 entity ); + void FromInstance(T8 entity); } @@ -168,7 +163,7 @@ namespace StgSharp.Script.Express where T9: IExpConvertableFrom { - void FromInstance( T9 entity ); + void FromInstance(T9 entity); } @@ -187,7 +182,7 @@ namespace StgSharp.Script.Express where T10: IExpConvertableFrom { - void FromInstance( T10 entity ); + void FromInstance(T10 entity); } @@ -207,7 +202,7 @@ namespace StgSharp.Script.Express where T11: IExpConvertableFrom { - void FromInstance( T11 entity ); + void FromInstance(T11 entity); } @@ -228,7 +223,7 @@ namespace StgSharp.Script.Express where T12: IExpConvertableFrom { - void FromInstance( T12 entity ); + void FromInstance(T12 entity); } @@ -250,7 +245,7 @@ namespace StgSharp.Script.Express where T13: IExpConvertableFrom { - void FromInstance( T13 entity ); + void FromInstance(T13 entity); } @@ -273,7 +268,7 @@ namespace StgSharp.Script.Express where T14: IExpConvertableFrom { - void FromInstance( T14 entity ); + void FromInstance(T14 entity); } @@ -297,7 +292,7 @@ namespace StgSharp.Script.Express where T15: IExpConvertableFrom { - void FromInstance( T15 entity ); + void FromInstance(T15 entity); } }