Daily update on 20251020-041041 by Nitload Youmu. Additional Message : Code cleanup and new design of parallel (maybe THE THENTH VERSION? Tough work!).

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-10-20 04:10:41 +08:00
parent 1927f4fdf3
commit 547ba80a01
141 changed files with 5475 additions and 6175 deletions
@@ -1,39 +1,40 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="DecorationBox" // file="DecorationBox.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload // AuthorGroup: Nitload Space
// Copyright (c) Nitload. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person
// of this software and associated documentation files (the "Software"), to deal // obtaining a copy of this software and associated documentation
// in the Software without restriction, including without limitation the rights // files (the “Software”), to deal in the Software without restriction,
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // including without limitation the rights to use, copy, modify, merge,
// copies of the Software, and to permit persons to whom the Software is // publish, distribute, sublicense, and/or sell copies of the Software,
// furnished to do so, subject to the following conditions: // 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 above copyright notice and
// // this permission notice shall be included in all copies
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // or substantial portions of the Software.
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // THE SOFTWARE IS PROVIDED “AS IS”,
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// SOFTWARE. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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.Geometries;
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic; using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Runtime.CompilerServices;
namespace StgSharp.Controls namespace StgSharp.Controls
{ {
@@ -52,6 +53,7 @@ namespace StgSharp.Controls
public ReadOnlySpan<Vec4> TextureBox public ReadOnlySpan<Vec4> TextureBox
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => renderMesh.TextureCoord; get => renderMesh.TextureCoord;
} }
@@ -2,8 +2,8 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="MatrixParallel.Publish" // file="MatrixParallel.Publish"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload // AuthorGroup: Nitload Space
// Copyright (c) Nitload. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
@@ -830,12 +830,15 @@ namespace StgSharp.Mathematics.Numeric
int total = tileCount; int total = tileCount;
List<MatrixParallelWrap> w = new List<MatrixParallelWrap>(Wraps.Count); List<MatrixParallelWrap> w = new List<MatrixParallelWrap>(Wraps.Count);
int baseTile = 0;
// TODO 干脆用四个掩码分别表示各种部分算了。
for (int i = 0; i < Wraps.Count; i++) for (int i = 0; i < Wraps.Count; i++)
{ {
MatrixParallelWrap wrap = Wraps.Pop(); MatrixParallelWrap wrap = Wraps.Pop();
wrap.WrapTask = (MatrixParallelTaskPackageNonGeneric*)package; wrap.WrapTask = (MatrixParallelTaskPackageNonGeneric*)package;
wrap.WrapTaskCapacity = ; wrap.WrapTaskCapacity = tilePerThreadLess + (i < extraTiles ? 1 : 0);
wrap.WrapTaskSliceCount = ; wrap.WrapTaskSliceCount = (i * tilePerThreadLess) + Math.Min(i, extraTiles);
w.Add(wrap); w.Add(wrap);
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.Common.cs" // file="ExpSyntaxAnalyzer.Common"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.CSharp.Syntax;
using StgSharp.Script; using StgSharp.Script;
@@ -53,10 +50,10 @@ namespace StgSharp.Model.Step
private StepDependencyDetector _dependencyDetector = new StepDependencyDetector(); private StepDependencyDetector _dependencyDetector = new StepDependencyDetector();
[GeneratedRegex( @"^[A-Z0-9_]+$", RegexOptions.Singleline )] [GeneratedRegex(@"^[A-Z0-9_]+$", RegexOptions.Singleline)]
private static partial Regex GetEntityTypeCheckPattern(); private static partial Regex GetEntityTypeCheckPattern();
private bool IsSeparatorMatch( Token leftSeparator, Token rightSeparator ) private bool IsSeparatorMatch(Token leftSeparator, Token rightSeparator)
{ {
return leftSeparator.Value switch 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; 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 ) { if (node.EqualityTypeConvert is not ExpCollectionBase) {
ExpInvalidSyntaxException.ThrowNonCollectionIndex( t ); ExpInvalidSyntaxException.ThrowNonCollectionIndex(t);
} }
} }
_cache.PushOperator( t ); _cache.PushOperator(t);
_cache.IncreaseDepth( ( int )ExpCompileStateCode.CollectionIndex ); _cache.IncreaseDepth((int)ExpCompileStateCode.CollectionIndex);
return true; 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; return false;
} }
//reverse building // reverse building
ClosePrefixReverse( t ); ClosePrefixReverse(t);
//make index node // make index node
_cache.PopOperand( out _, out ExpSyntaxNode? expNode ); _cache.PopOperand(out _, out ExpSyntaxNode? expNode);
if( !_cache.PopOperand( out Token colleToken, out ExpSyntaxNode? colleNode ) ) { } if (!_cache.PopOperand(out Token colleToken, out ExpSyntaxNode? colleNode)) { }
_cache.PushOperand( _cache.PushOperand(
ExpCollectionIndexNode.Create( ExpCollectionIndexNode.Create(
t, ( colleNode as ExpCollectionInstanceBase )!, expNode ) ); t, (colleNode as ExpCollectionInstanceBase)!, expNode));
return true; return true;
} }
private bool TryAppendMember( Token t ) private bool TryAppendMember(Token t)
{ {
if( t.Flag != TokenFlag.Member ) { if (t.Flag != TokenFlag.Member) {
return false; return false;
} }
if( TryParseConstant( t ) ) { if (TryParseConstant(t)) {
return true; return true;
} }
if( TryParseFunction( t ) ) { if (TryParseFunction(t)) {
return true; return true;
} }
if( TryParseInstance( t ) ) { if (TryParseInstance(t)) {
return true; return true;
} }
if( TryParseKeyword( t ) ) { if (TryParseKeyword(t)) {
return true; return true;
} }
if( TryParseElementName( t ) ) { if (TryParseElementName(t)) {
return true; return true;
} }
//Many thing miss here // Many thing miss here
_cache.PushOperand( ExpElementMemberNameNode.Create( t ) ); _cache.PushOperand(ExpElementMemberNameNode.Create(t));
return true; 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; return false;
} }
while( _cache.OperatorAheadOfDepth > 0 ) while (_cache.OperatorAheadOfDepth > 0)
{ {
_cache.TryPopOperator( out Token op ); _cache.TryPopOperator(out Token op);
ExpSyntaxNode node = ConvertAndPushOneOperator( op ); ExpSyntaxNode node = ConvertAndPushOneOperator(op);
} }
switch( _cache.OperandAheadOfDepth ) switch (_cache.OperandAheadOfDepth)
{ {
case 0: case 0:
if( t.Value == ";" ) { if (t.Value == ";") {
return true; return true;
} }
_cache.StatementsInDepth.Push( ExpSyntaxNode.Empty ); _cache.StatementsInDepth.Push(ExpSyntaxNode.Empty);
goto case 1; goto case 1;
case 1: case 1:
_cache.PopOperand( out _, out ExpSyntaxNode? statement ); _cache.PopOperand(out _, out ExpSyntaxNode? statement);
if( t.Value == ";" ) if (t.Value == ";")
{ {
StepEntityDefineSequence sequence = new StepEntityDefineSequence( StepEntityDefineSequence sequence = new StepEntityDefineSequence(
statement, _dependencyDetector.ExportAllDependencies() ); statement, _dependencyDetector.ExportAllDependencies());
StepEntityInitStatements.Enqueue( sequence ); StepEntityInitStatements.Enqueue(sequence);
} else } else
{ {
_cache.StatementsInDepth.Push( statement ); _cache.StatementsInDepth.Push(statement);
} }
return true; return true;
default: default:
ExpInvalidSyntaxException.ThrowNoOperator( t ); ExpInvalidSyntaxException.ThrowNoOperator(t);
break; break;
} }
return true; 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; return false;
} }
_cache.PushOperand( ExpElementInstance.CreateLiteral( t ) ); _cache.PushOperand(ExpElementInstance.CreateLiteral(t));
return true; 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; return false;
} }
_cache.PushOperator( t ); _cache.PushOperator(t);
_cache.IncreaseDepth( ( int )ExpCompileStateCode.Common ); _cache.IncreaseDepth((int)ExpCompileStateCode.Common);
return true; 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; return false;
} }
ClosePrefixReverse( t ); ClosePrefixReverse(t);
return true; 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; return false;
} }
int cmp = -1; int cmp = -1;
processPrecedence: processPrecedence:
if( _cache.TryPeekOperator( out Token tmp ) ) if (_cache.TryPeekOperator(out Token tmp))
{ {
cmp = CompareOperatorPrecedence( t, tmp ); cmp = CompareOperatorPrecedence(t, tmp);
if( cmp >= 0 ) if (cmp >= 0)
{ {
_cache.PopOperator(); _cache.PopOperator();
ExpSyntaxNode node = ConvertAndPushOneOperator( tmp ); ExpSyntaxNode node = ConvertAndPushOneOperator(tmp);
goto processPrecedence; goto processPrecedence;
} }
} }
_cache.PushOperator( t ); _cache.PushOperator(t);
return true; return true;
} }
private bool TryParseConstant( Token t ) private bool TryParseConstant(Token t)
{ {
switch( t.Value ) switch (t.Value)
{ {
case "$": case "$":
_cache.PushOperand( StepEntityInstanceNode.RegisterNull( t ) ); _cache.PushOperand(StepEntityInstanceNode.RegisterNull(t));
return true; return true;
case "*": case "*":
_cache.PushOperand( StepEntityInstanceNode.RegisterRuntimeInference( t ) ); _cache.PushOperand(StepEntityInstanceNode.RegisterRuntimeInference(t));
return true; return true;
case ExpKeyword.E: case ExpKeyword.E:
_cache.PushOperand( new ExpRealNumberNode( t, MathF.E, true ) ); _cache.PushOperand(new ExpRealNumberNode(t, MathF.E, true));
return true; return true;
case ExpKeyword.Pi: case ExpKeyword.Pi:
_cache.PushOperand( new ExpRealNumberNode( t, MathF.PI, true ) ); _cache.PushOperand(new ExpRealNumberNode(t, MathF.PI, true));
return true; return true;
default: default:
if( ExpElementInstance.TryCreateLiteral( t, out ExpElementInstance? node ) ) if (ExpElementInstance.TryCreateLiteral(t, out ExpElementInstance? node))
{ {
_cache.PushOperand( node ); _cache.PushOperand(node);
return true; return true;
} }
return false; 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; 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 true;
} }
return false; 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(); Token op = _cache.PopOperator();
ConvertAndPushOneOperator( op ); ConvertAndPushOneOperator(op);
} }
_cache.PushOperator( t ); _cache.PushOperator(t);
return true; return true;
} }
return false; 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 ); StepEntityInstanceNode node = StepEntityInstanceNode.Register(t);
if( t.Column != 0 ) { if (t.Column != 0) {
_dependencyDetector.AddDependency( node ); _dependencyDetector.AddDependency(node);
} }
_cache.PushOperand( node ); _cache.PushOperand(node);
return true; return true;
} }
return false; return false;
} }
private bool TryParseKeyword( Token t ) private bool TryParseKeyword(Token t)
{ {
switch( t.Value ) switch (t.Value)
{ {
case ExpKeyword.Return: case ExpKeyword.Return:
_cache.PushOperator( t ); _cache.PushOperator(t);
return true; return true;
case ExpKeyword.Skip: case ExpKeyword.Skip:
_cache.PushOperand( ExpProcedureControlNode.Skip( t ) ); _cache.PushOperand(ExpProcedureControlNode.Skip(t));
return true; return true;
default: default:
return false; return false;
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.Enum.cs" // file="ExpSyntaxAnalyzer.Enum"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -42,26 +39,26 @@ namespace StgSharp.Model.Step
internal partial class StepExpSyntaxAnalyzer internal partial class StepExpSyntaxAnalyzer
{ {
private static string ParseStepEnumLiteral( string source ) private static string ParseStepEnumLiteral(string source)
{ {
int length = source.Length; int length = source.Length;
ReadOnlySpan<char> span = source.AsSpan(); ReadOnlySpan<char> span = source.AsSpan();
if( length > 2 && span[ 0 ] == '.' && span[ length - 1 ] == '.' ) { if (length > 2 && span[0] == '.' && span[length - 1] == '.') {
return span.Slice( 1, length - 2 ).ToString(); 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 ExpSyntaxNode node = e.Value switch
{ {
".T." => new ExpBoolNode( e, true, true ), ".T." => new ExpBoolNode(e, true, true),
".F." => new ExpBoolNode( e, false, true ), ".F." => new ExpBoolNode(e, false, true),
".U." => new ExpLogicValueNode( e, ExpLogic.Unknown, true ), ".U." => new ExpLogicValueNode(e, ExpLogic.Unknown, true),
_ => ExpEnumLiteralNode.Create( e, ParseStepEnumLiteral ), _ => ExpEnumLiteralNode.Create(e, ParseStepEnumLiteral),
}; };
_cache.PushOperand( node ); _cache.PushOperand(node);
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.ErrorProcess.cs" // file="ExpSyntaxAnalyzer.ErrorProcess"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -39,9 +36,9 @@ namespace StgSharp.Model.Step
internal partial class StepExpSyntaxAnalyzer internal partial class StepExpSyntaxAnalyzer
{ {
public void ThrowCompileException( int errorCode ) public void ThrowCompileException(int errorCode)
{ {
switch( errorCode ) switch (errorCode)
{ {
case 0 or 1: case 0 or 1:
return; return;
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.OperatorParser.cs" // file="ExpSyntaxAnalyzer.OperatorParser"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -44,26 +41,26 @@ namespace StgSharp.Model.Step
internal partial class StepExpSyntaxAnalyzer 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(left.Value, out int leftPrecedence);
ExpressCompile.TryGetOperatorPrecedence( right.Value, out int rightPrecedence ); ExpressCompile.TryGetOperatorPrecedence(right.Value, out int rightPrecedence);
return leftPrecedence - rightPrecedence; return leftPrecedence - rightPrecedence;
} }
public bool TryGenerateUnaryNode( Token t, out ExpSyntaxNode node ) public bool TryGenerateUnaryNode(Token t, out ExpSyntaxNode node)
{ {
ExpSyntaxNode operand = GetNextOperandCache(); ExpSyntaxNode operand = GetNextOperandCache();
switch( t.Value ) switch (t.Value)
{ {
case ExpKeyword.UnaryPlus: case ExpKeyword.UnaryPlus:
node = ExpUnaryOperatorNode.UnaryPlus( t, operand ); node = ExpUnaryOperatorNode.UnaryPlus(t, operand);
return true; return true;
case ExpKeyword.UnaryMinus: case ExpKeyword.UnaryMinus:
node = ExpUnaryOperatorNode.UnaryMinus( t, operand ); node = ExpUnaryOperatorNode.UnaryMinus(t, operand);
return true; return true;
case ExpKeyword.Not: case ExpKeyword.Not:
node = ExpUnaryOperatorNode.UnaryNot( t, operand ); node = ExpUnaryOperatorNode.UnaryNot(t, operand);
return true; return true;
default: default:
node = ExpSyntaxNode.Empty; node = ExpSyntaxNode.Empty;
@@ -75,43 +72,43 @@ namespace StgSharp.Model.Step
/// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING /// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING
/// SYMBOLS. /// SYMBOLS.
/// </summary> /// </summary>
private ExpSyntaxNode ConvertAndPushOneOperator( Token op ) private ExpSyntaxNode ConvertAndPushOneOperator(Token op)
{ {
switch( op.Flag ) switch (op.Flag)
{ {
case TokenFlag.Symbol_Unary: case TokenFlag.Symbol_Unary:
TryGenerateUnaryNode( op, out ExpSyntaxNode? node ); TryGenerateUnaryNode(op, out ExpSyntaxNode? node);
_cache.PushOperand( node ); _cache.PushOperand(node);
return node; return node;
case TokenFlag.Symbol_Binary: case TokenFlag.Symbol_Binary:
TryGenerateBinaryNode( op, out node ); TryGenerateBinaryNode(op, out node);
_cache.PushOperand( node ); _cache.PushOperand(node);
return node; return node;
case TokenFlag.Member: case TokenFlag.Member:
_cache.PopOperand( out _, out ExpSyntaxNode? p ); _cache.PopOperand(out _, out ExpSyntaxNode? p);
StepEntityInitCaller caller = StepEntityInitCaller.CreateCaller( op.Value ); StepEntityInitCaller caller = StepEntityInitCaller.CreateCaller(op.Value);
node = ExpFunctionCallingNode.CallFunction( op, caller, p ); node = ExpFunctionCallingNode.CallFunction(op, caller, p);
_cache.StatementsInDepth.Push( node ); _cache.StatementsInDepth.Push(node);
return node; return node;
default: default:
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
private bool TryGenerateBinaryNode( Token t, out ExpSyntaxNode node ) private bool TryGenerateBinaryNode(Token t, out ExpSyntaxNode node)
{ {
/* /*
ExpSyntaxNode right = GetNextOperandCache(); ExpSyntaxNode right = GetNextOperandCache();
ExpSyntaxNode left = GetNextOperandCache(); ExpSyntaxNode left = GetNextOperandCache();
/**/ /**/
switch( t.Value ) switch (t.Value)
{ {
case "=": case "=":
ExpSyntaxNode right = GetNextOperandCache(); ExpSyntaxNode right = GetNextOperandCache();
ExpSyntaxNode left; ExpSyntaxNode left;
if( right is ExpTupleNode tuple ) if (right is ExpTupleNode tuple)
{ {
right = StepComplexEntityNode.FromTuple( tuple ); right = StepComplexEntityNode.FromTuple(tuple);
left = GetNextOperandCache(); left = GetNextOperandCache();
} else } else
{ {
@@ -119,7 +116,7 @@ namespace StgSharp.Model.Step
right = _cache.StatementsInDepth.Pop(); right = _cache.StatementsInDepth.Pop();
} }
node = ExpBinaryOperatorNode.Assign( t, left, right ); node = ExpBinaryOperatorNode.Assign(t, left, right);
return true; return true;
default: default:
node = ExpSyntaxNode.Empty; node = ExpSyntaxNode.Empty;
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs" // file="ExpSyntaxAnalyzer.PrefixReverseAnalysing"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -45,44 +42,44 @@ namespace StgSharp.Model.Step
internal partial class StepExpSyntaxAnalyzer internal partial class StepExpSyntaxAnalyzer
{ {
private void ClosePrefixReverse( Token rightSeparator ) private void ClosePrefixReverse(Token rightSeparator)
{ {
Token op; Token op;
ExpSyntaxNode root; 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.PopOperand(out _, out ExpSyntaxNode? statement);
_cache.StatementsInDepth.Push( statement ); _cache.StatementsInDepth.Push(statement);
} else } else
{ {
_cache.StatementsInDepth.Push( ExpSyntaxNode.Empty ); _cache.StatementsInDepth.Push(ExpSyntaxNode.Empty);
} }
} else } 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.PopOperand(out _, out root);
_cache.StatementsInDepth.Push( root ); _cache.StatementsInDepth.Push(root);
} }
} }
root = _cache.PackAllStatements(); root = _cache.PackAllStatements();
_cache.DecreaseDepth(); _cache.DecreaseDepth();
if( IsSeparatorMatch( _cache.PeekOperator(), rightSeparator ) ) if (IsSeparatorMatch(_cache.PeekOperator(), rightSeparator))
{ {
_cache.PopOperator(); _cache.PopOperator();
root = ExpTupleNode.Pack( root ); root = ExpTupleNode.Pack(root);
_cache.PushOperand( root ); _cache.PushOperand(root);
} else } else
{ {
throw new ExpCompileException( throw new ExpCompileException(
rightSeparator, "Ending of block does not match its begging" ); rightSeparator, "Ending of block does not match its begging");
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.cs" // file="ExpSyntaxAnalyzer"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.CSharp.Syntax;
using StgSharp.Script; 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 /// Append a token to top of cache. This method will automatically convert token to node
/// if meets separators or operators. /// if meets separators or operators.
/// </summary> /// </summary>
public void AppendToken( Token expToken ) public void AppendToken(Token expToken)
{ {
switch( expToken.Flag ) switch (expToken.Flag)
{ {
case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary: case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary:
TryAppendSymbol( expToken ); TryAppendSymbol(expToken);
break; break;
case TokenFlag.Number or TokenFlag.String: case TokenFlag.Number or TokenFlag.String:
ExpElementInstance node = ExpElementInstance.CreateLiteral( expToken ); ExpElementInstance node = ExpElementInstance.CreateLiteral(expToken);
_cache.PushOperand( node ); _cache.PushOperand(node);
break; break;
case TokenFlag.Separator_Left: case TokenFlag.Separator_Left:
TryAppendPrefixSeparator( expToken ); TryAppendPrefixSeparator(expToken);
break; break;
case TokenFlag.Separator_Right: case TokenFlag.Separator_Right:
TryAppendPrefixSeparatorEnd( expToken ); TryAppendPrefixSeparatorEnd(expToken);
break; break;
case TokenFlag.Separator_Middle: case TokenFlag.Separator_Middle:
TryAppendMiddleSeparator( expToken ); TryAppendMiddleSeparator(expToken);
break; break;
case TokenFlag.Index_Left: case TokenFlag.Index_Left:
TryAppendIndexLeft( expToken ); TryAppendIndexLeft(expToken);
break; break;
case TokenFlag.Index_Right: case TokenFlag.Index_Right:
TryAppendIndexRight( expToken ); TryAppendIndexRight(expToken);
break; break;
case TokenFlag.Member: case TokenFlag.Member:
TryAppendMember( expToken ); TryAppendMember(expToken);
break; break;
case TokenFlag.Enum: case TokenFlag.Enum:
TryAppendEnum( expToken ); TryAppendEnum(expToken);
break; break;
default: default:
break; break;
@@ -110,7 +107,7 @@ namespace StgSharp.Model.Step
public ExpSyntaxNode GetNextOperandCache() public ExpSyntaxNode GetNextOperandCache()
{ {
if( _cache.PopOperand( out Token t, out ExpSyntaxNode? n ) ) if (_cache.PopOperand(out Token t, out ExpSyntaxNode? n))
{ {
return n; return n;
} else } else
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepDataSectionsTranmitter.cs" // file="StepDataSectionsTranmitter"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System; using System;
@@ -45,13 +42,13 @@ namespace StgSharp.Model.Step
private const string EndDataText = "ENDSEC;"; private const string EndDataText = "ENDSEC;";
//private bool _isEmpty; // private bool _isEmpty;
private ConcurrentQueue<string> _cache = new ConcurrentQueue<string>(); private ConcurrentQueue<string> _cache = new ConcurrentQueue<string>();
private int _line = 0; private int _line = 0;
public StepDataSectionTransmitter() { } public StepDataSectionTransmitter() { }
public StepDataSectionTransmitter( int begins ) public StepDataSectionTransmitter(int begins)
{ {
Begin = begins; Begin = begins;
_line = Begin; _line = Begin;
@@ -72,7 +69,7 @@ namespace StgSharp.Model.Step
public string ReadLine() public string ReadLine()
{ {
if( _cache.TryDequeue( out string? line ) ) if (_cache.TryDequeue(out string? line))
{ {
_line++; _line++;
return line; return line;
@@ -80,29 +77,29 @@ namespace StgSharp.Model.Step
return string.Empty; return string.Empty;
} }
public string ReadLine( out int position ) public string ReadLine(out int position)
{ {
string ret = ReadLine(); string ret = ReadLine();
position = _line; position = _line;
return ret; return ret;
} }
public void WriteLine( string line ) public void WriteLine(string line)
{ {
if( line == "DATA;" ) { if (line == "DATA;") {
return; return;
} }
if( line == EndDataText ) if (line == EndDataText)
{ {
EndWriting(); EndWriting();
return; return;
} }
if( IsWriting ) { if (IsWriting) {
_cache.Enqueue( line ); _cache.Enqueue(line);
} }
} }
IScriptSourceProvider IScriptSourceProvider.Slice( int location, int count ) IScriptSourceProvider IScriptSourceProvider.Slice(int location, int count)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepDataTokenReader.cs" // file="StepDataTokenReader"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -48,15 +45,13 @@ namespace StgSharp.Model.Step
private ExpTokenReader _reader; private ExpTokenReader _reader;
private HashSet<string> tokenHash = [ private HashSet<string> tokenHash = [ "T", "F", "UNSPECIFIED" ];
"T","F","UNSPECIFIED"
];
private Queue<Token> _cache = new Queue<Token>(); private Queue<Token> _cache = new Queue<Token>();
private StepDataSectionTransmitter _transmitter; private StepDataSectionTransmitter _transmitter;
public StepDataTokenReader( StepDataSectionTransmitter transmitter ) public StepDataTokenReader(StepDataSectionTransmitter transmitter)
{ {
_reader = new ExpTokenReader( transmitter ); _reader = new ExpTokenReader(transmitter);
_reader.TokenReaderPreProcessor = new TokenPreReader(); _reader.TokenReaderPreProcessor = new TokenPreReader();
_transmitter = transmitter; _transmitter = transmitter;
} }
@@ -65,7 +60,7 @@ namespace StgSharp.Model.Step
{ {
get get
{ {
if( _reader.IsEmpty ) { if (_reader.IsEmpty) {
return !_transmitter.IsWriting; return !_transmitter.IsWriting;
} }
return false; return false;
@@ -77,9 +72,9 @@ namespace StgSharp.Model.Step
return _reader.ReadToken(); 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 private partial class TokenPreReader : ExpTokenReaderPreProcessor
@@ -90,61 +85,61 @@ namespace StgSharp.Model.Step
_nextEnumPattern = GetNextEnumPattern(), _nextEnumPattern = GetNextEnumPattern(),
_stringPattern = GetStringPattern(); _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<char> chars = codeLine.AsSpan( current ); ReadOnlySpan<char> chars = codeLine.AsSpan(current);
char c = chars[ 0 ]; char c = chars[0];
Match match; Match match;
switch( c ) switch (c)
{ {
case '#': case '#':
match = _nextHashtagSymbolPattern.Match( codeLine, current ); match = _nextHashtagSymbolPattern.Match(codeLine, current);
if( match.Success ) if (match.Success)
{ {
int begin = match.Groups[ "token" ].Index; int begin = match.Groups["token"].Index;
int end = match.Groups[ "end" ].Index; int end = match.Groups["end"].Index;
int rest = match.Groups[ "rest" ].Index; int rest = match.Groups["rest"].Index;
current = rest; current = rest;
t = new( t = new(
ExpressCompile.PoolString( chars[ 0..( end - begin ) ] ), line, ExpressCompile.PoolString(chars[0..(end - begin)]), line,
begin, TokenFlag.Member ); begin, TokenFlag.Member);
return true; return true;
} }
break; break;
case '.': case '.':
match = _nextEnumPattern.Match( codeLine, current ); match = _nextEnumPattern.Match(codeLine, current);
if( match.Success ) if (match.Success)
{ {
int begin = match.Groups[ "token" ].Index; int begin = match.Groups["token"].Index;
int end = match.Groups[ "end" ].Index; int end = match.Groups["end"].Index;
int rest = match.Groups[ "rest" ].Index; int rest = match.Groups["rest"].Index;
current = rest; current = rest;
t = new Token( t = new Token(
match.Groups[ "token" ].Value, line, begin, TokenFlag.Enum ); match.Groups["token"].Value, line, begin, TokenFlag.Enum);
return true; return true;
} }
break; break;
case '$': case '$':
t = new Token( "$", line, current, TokenFlag.Member ); t = new Token("$", line, current, TokenFlag.Member);
current++; current++;
return true; return true;
case '*': case '*':
t = new Token( "*", line, current, TokenFlag.Member ); t = new Token("*", line, current, TokenFlag.Member);
current++; current++;
return true; return true;
case '\'': case '\'':
match = _stringPattern.Match( codeLine, current ); match = _stringPattern.Match(codeLine, current);
if( match.Success ) if (match.Success)
{ {
int begin = match.Groups[ "token" ].Index; int begin = match.Groups["token"].Index;
int end = match.Groups[ "end" ].Index; int end = match.Groups["end"].Index;
int rest = match.Groups[ "rest" ].Index; int rest = match.Groups["rest"].Index;
current = rest; current = rest;
string value = chars.Slice( 1, ( end - begin - 1 ) ).ToString(); string value = chars.Slice(1, (end - begin - 1)).ToString();
if( string.IsNullOrWhiteSpace( value ) ) { if (string.IsNullOrWhiteSpace(value)) {
value = string.Empty; value = string.Empty;
} }
t = new Token( value, line, begin, TokenFlag.String ); t = new Token(value, line, begin, TokenFlag.String);
return true; return true;
} }
break; break;
@@ -155,19 +150,13 @@ namespace StgSharp.Model.Step
return false; return false;
} }
[GeneratedRegex( [GeneratedRegex(@"(?<token>#[0-9A-Za-z]+)(?<end>\s*?)(?<rest>\S|$)", RegexOptions.Singleline)]
@"(?<token>#[0-9A-Za-z]+)(?<end>\s*?)(?<rest>\S|$)",
RegexOptions.Singleline )]
private static partial Regex GetEntityTagSymbolPattern(); private static partial Regex GetEntityTagSymbolPattern();
[GeneratedRegex( [GeneratedRegex(@"(?<token>\.[A-Za-z_]+\.)(?<end>\s*)(?<rest>\S*)", RegexOptions.Singleline)]
@"(?<token>\.[A-Za-z_]+\.)(?<end>\s*)(?<rest>\S*)",
RegexOptions.Singleline )]
private static partial Regex GetNextEnumPattern(); private static partial Regex GetNextEnumPattern();
[GeneratedRegex( [GeneratedRegex(@"(?<token>')(?>\\\\|''|(?!')[^'])*(?<end>')\s*?(?<rest>\S|$)", RegexOptions.Singleline)]
@"(?<token>')(?>\\\\|''|(?!')[^'])*(?<end>')\s*?(?<rest>\S|$)",
RegexOptions.Singleline )]
private static partial Regex GetStringPattern(); private static partial Regex GetStringPattern();
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepDependencyDetector.cs" // file="StepDependencyDetector"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 System; using System;
@@ -45,9 +42,9 @@ namespace StgSharp.Model.Step
public List<int> Dependencies { get; private set; } = new(); public List<int> 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<int> ExportAllDependencies() public IEnumerable<int> ExportAllDependencies()
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepEntityDefineSequence.cs" // file="StepEntityDefineSequence"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 StgSharp.Script.Express;
using System; using System;
@@ -41,7 +38,8 @@ namespace StgSharp.Model.Step
{ {
public record class StepEntityDefineSequence public record class StepEntityDefineSequence
{ {
public StepEntityDefineSequence( ExpSyntaxNode node, IEnumerable<int> dep )
public StepEntityDefineSequence(ExpSyntaxNode node, IEnumerable<int> dep)
{ {
Expression = node; Expression = node;
Dependencies = dep; Dependencies = dep;
@@ -50,5 +48,6 @@ namespace StgSharp.Model.Step
public ExpSyntaxNode Expression { get; init; } public ExpSyntaxNode Expression { get; init; }
public IEnumerable<int> Dependencies { get; init; } public IEnumerable<int> Dependencies { get; init; }
} }
} }
+37 -60
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpressStepUtil.cs" // file="ExpressStepUtil"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 CommunityToolkit.HighPerformance.Buffers;
using StgSharp.Model.Step; using StgSharp.Model.Step;
@@ -65,27 +62,7 @@ namespace StgSharp.Model.Step
public const string VertexPointText = "VERTEX_POINT"; public const string VertexPointText = "VERTEX_POINT";
private static private static
HashSet<string> names = [ HashSet<string> names = [ AdvancedFaceText, Axis2Placement2DText, Axis2Placement3DText, BSplineCurveWithKnotsText, CartesianPointText, CircleText, CylindricalSurfaceText, DirectionText, EdgeCurveText, EdgeLoopText, EllipseText, FaceBoundText, FaceOuterBoundText, LineText, OrientedEdgeText, PlaneText, RepresentationItemText, VectorText, VertexPointText, ];
AdvancedFaceText,
Axis2Placement2DText,
Axis2Placement3DText,
BSplineCurveWithKnotsText,
CartesianPointText,
CircleText,
CylindricalSurfaceText,
DirectionText,
EdgeCurveText,
EdgeLoopText,
EllipseText,
FaceBoundText,
FaceOuterBoundText,
LineText,
OrientedEdgeText,
PlaneText,
RepresentationItemText,
VectorText,
VertexPointText,
];
private FrozenDictionary<string, ExpEntitySource> entitiesDefine; private FrozenDictionary<string, ExpEntitySource> entitiesDefine;
private StringPool _entityNamePool = new StringPool(); private StringPool _entityNamePool = new StringPool();
@@ -93,56 +70,56 @@ namespace StgSharp.Model.Step
public ExpressStepUtil() public ExpressStepUtil()
{ {
IEnumerable<KeyValuePair<string, ExpEntitySource>> defineSource = []; IEnumerable<KeyValuePair<string, ExpEntitySource>> defineSource = [];
entitiesDefine = new Dictionary<string, ExpEntitySource>( defineSource ) entitiesDefine = new Dictionary<string, ExpEntitySource>(defineSource)
.ToFrozenDictionary(); .ToFrozenDictionary();
foreach( string item in names ) { foreach (string item in names) {
_entityNamePool.Add( item ); _entityNamePool.Add(item);
} }
} }
internal StepModel Current { get; set; } internal StepModel Current { get; set; }
public override void LoadFromSource( ExpSchemaSource source ) public override void LoadFromSource(ExpSchemaSource source)
{ {
return; return;
} }
public override bool TryGetConst( string name, out ExpElementInstance c ) public override bool TryGetConst(string name, out ExpElementInstance c)
{ {
c = null!; c = null!;
return false; 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!; f = null!;
return false; return false;
} }
public override bool TryGetProcedure( string name, out ExpProcedureSource p ) public override bool TryGetProcedure(string name, out ExpProcedureSource p)
{ {
p = null!; p = null!;
return false; return false;
} }
public override bool TryGetRule( string name, out ExpRuleSource r ) public override bool TryGetRule(string name, out ExpRuleSource r)
{ {
r = null!; r = null!;
return false; return false;
} }
public override bool TryGetSchemaInclude( string name, out ExpSchema include ) public override bool TryGetSchemaInclude(string name, out ExpSchema include)
{ {
include = null!; include = null!;
return false; return false;
} }
public override bool TryGetType( string name, out ExpTypeSource t ) public override bool TryGetType(string name, out ExpTypeSource t)
{ {
t = null!; t = null!;
return false; return false;
+38 -41
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepAdvancedFace.cs" // file="StepAdvancedFace"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
@@ -40,34 +37,34 @@ namespace StgSharp.Model.Step
public class StepAdvancedFace : StepFaceSurface, IExpConvertableFrom<StepAdvancedFace> public class StepAdvancedFace : StepFaceSurface, IExpConvertableFrom<StepAdvancedFace>
{ {
public StepAdvancedFace( StepModel model ) : base( model ) { } public StepAdvancedFace(StepModel model) : base(model) { }
public override StepItemType ItemType => StepItemType.AdvancedFace; 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 ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepAdvancedFace face = new StepAdvancedFace( binder ); StepAdvancedFace face = new StepAdvancedFace(binder);
enumerator.AssertEnumeratorCount( 4 ); enumerator.AssertEnumeratorCount(4);
face.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; face.Name = (enumerator[0]as ExpStringNode)!.Value;
ExpNodePresidentEnumerator boundsList = enumerator[ 1 ].TupleToPresidentEnumerator(); ExpNodePresidentEnumerator boundsList = enumerator[1].TupleToPresidentEnumerator();
face.Bounds.Clear(); face.Bounds.Clear();
face.Bounds face.Bounds
.AddRange( .AddRange(
Enumerable.Range( 0, enumerator.Count ).Select( _ => ( StepFaceBound )null ) ); Enumerable.Range(0, enumerator.Count).Select(_ => (StepFaceBound)null));
for( int i = 0; i < boundsList.Count; i++ ) for (int i = 0; i < boundsList.Count; i++)
{ {
int j = i; // capture to avoid rebinding 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.FaceGeometry = binder[enumerator[2]] as StepSurface;
face.SameSense = ( enumerator[ 3 ] as ExpBoolNode )!.Value; face.SameSense = (enumerator[3] as ExpBoolNode)!.Value;
return face; return face;
} }
+28 -31
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepAxis2Placement.cs" // file="StepAxis2Placement"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
@@ -40,21 +37,21 @@ namespace StgSharp.Model.Step
private StepDirection _refDirection; private StepDirection _refDirection;
protected StepAxis2Placement( StepModel model ) : base( model ) { } protected StepAxis2Placement(StepModel model) : base(model) { }
public StepDirection RefDirection public StepDirection RefDirection
{ {
get { return _refDirection; } get { return _refDirection; }
set set
{ {
ArgumentNullException.ThrowIfNull( value ); ArgumentNullException.ThrowIfNull(value);
_refDirection = 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";
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepAxis2Placement2D.cs" // file="StepAxis2Placement2D"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
@@ -40,13 +37,10 @@ namespace StgSharp.Model.Step
public class StepAxis2Placement2D : StepAxis2Placement, IExpConvertableFrom<StepAxis2Placement2D> public class StepAxis2Placement2D : StepAxis2Placement, IExpConvertableFrom<StepAxis2Placement2D>
{ {
private StepAxis2Placement2D( StepModel model ) : base( model ) { } private StepAxis2Placement2D(StepModel model) : base(model) { }
public StepAxis2Placement2D( public StepAxis2Placement2D(StepModel model, StepCartesianPoint location, StepDirection direction)
StepModel model, : base(model)
StepCartesianPoint location,
StepDirection direction )
: base( model )
{ {
Location = location; Location = location;
RefDirection = direction; RefDirection = direction;
@@ -54,23 +48,21 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.AxisPlacement2D; 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; Location = entity.Location;
RefDirection = entity.RefDirection; RefDirection = entity.RefDirection;
} }
internal static StepAxis2Placement2D FromSyntax( internal static StepAxis2Placement2D FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
StepModel binder,
ExpSyntaxNode syntaxList )
{ {
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepAxis2Placement2D axis = new StepAxis2Placement2D( binder ); StepAxis2Placement2D axis = new StepAxis2Placement2D(binder);
enumerator.AssertEnumeratorCount( 3 ); enumerator.AssertEnumeratorCount(3);
axis.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; axis.Name = (enumerator[0]as ExpStringNode)!.Value;
axis.Location = binder[ enumerator[ 1 ] ] as StepCartesianPoint; axis.Location = binder[enumerator[1]] as StepCartesianPoint;
axis.RefDirection = binder[ enumerator[ 2 ] ] as StepDirection; axis.RefDirection = binder[enumerator[2]] as StepDirection;
return axis; return axis;
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepAxis2Placement3D.cs" // file="StepAxis2Placement3D"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -42,14 +39,14 @@ namespace StgSharp.Model.Step
private StepDirection _axis; private StepDirection _axis;
private StepAxis2Placement3D( StepModel model ) : base( model ) { } private StepAxis2Placement3D(StepModel model) : base(model) { }
public StepAxis2Placement3D( public StepAxis2Placement3D(
StepModel model, StepModel model,
StepCartesianPoint location, StepCartesianPoint location,
StepDirection axis, StepDirection axis,
StepDirection refDirection ) StepDirection refDirection)
: base( model ) : base(model)
{ {
Location = location; Location = location;
Axis = axis; Axis = axis;
@@ -61,33 +58,31 @@ namespace StgSharp.Model.Step
get { return _axis; } get { return _axis; }
set set
{ {
ArgumentNullException.ThrowIfNull( value ); ArgumentNullException.ThrowIfNull(value);
_axis = value; _axis = value;
} }
} }
public override StepItemType ItemType => StepItemType.AxisPlacement3D; public override StepItemType ItemType => StepItemType.AxisPlacement3D;
public override bool IsConvertableTo( string entityTypeName ) public override bool IsConvertableTo(string entityTypeName)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
internal static StepAxis2Placement3D FromSyntax( internal static StepAxis2Placement3D FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
StepModel binder,
ExpSyntaxNode syntaxList )
{ {
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepAxis2Placement3D axis = new StepAxis2Placement3D( binder ); StepAxis2Placement3D axis = new StepAxis2Placement3D(binder);
enumerator.AssertEnumeratorCount( 4 ); enumerator.AssertEnumeratorCount(4);
axis.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; axis.Name = (enumerator[0]as ExpStringNode)!.Value;
axis.Location = binder[ enumerator[ 1 ] ] as StepCartesianPoint; axis.Location = binder[enumerator[1]] as StepCartesianPoint;
axis.Axis = binder[ enumerator[ 2 ] ] as StepDirection; axis.Axis = binder[enumerator[2]] as StepDirection;
axis.RefDirection = binder[ enumerator[ 3 ] ] as StepDirection; axis.RefDirection = binder[enumerator[3]] as StepDirection;
return axis; return axis;
} }
void IExpConvertableFrom<StepAxis2Placement3D>.FromInstance( StepAxis2Placement3D entity ) void IExpConvertableFrom<StepAxis2Placement3D>.FromInstance(StepAxis2Placement3D entity)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
+36 -46
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepBSplineCurve.cs" // file="StepBSplineCurve"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -61,27 +58,20 @@ namespace StgSharp.Model.Step
internal const string POLYLINE_FORM = "POLYLINE_FORM"; internal const string POLYLINE_FORM = "POLYLINE_FORM";
internal const string UNSPECIFIED = "UNSPECIFIED"; internal const string UNSPECIFIED = "UNSPECIFIED";
internal static HashSet<string> AllPossibleValue { get; } = [ internal static HashSet<string> AllPossibleValue { get; } = [ CIRCULAR_ARC, ELLIPTIC_ARC, HYPERBOLIC_ARC, PARABOLIC_ARC, POLYLINE_FORM, UNSPECIFIED, ];
CIRCULAR_ARC,
ELLIPTIC_ARC,
HYPERBOLIC_ARC,
PARABOLIC_ARC,
POLYLINE_FORM,
UNSPECIFIED,
];
} }
public class StepBSplineCurve : StepBoundedCurve, IExpConvertableFrom<StepBSplineCurve> public class StepBSplineCurve : StepBoundedCurve, IExpConvertableFrom<StepBSplineCurve>
{ {
public StepBSplineCurve( StepModel model, params StepCartesianPoint[] controlPoints ) public StepBSplineCurve(StepModel model, params StepCartesianPoint[] controlPoints)
: this( model, ( IEnumerable<StepCartesianPoint> )controlPoints ) { } : this(model, (IEnumerable<StepCartesianPoint>)controlPoints) { }
public StepBSplineCurve( StepModel model, IEnumerable<StepCartesianPoint> controlPoints ) public StepBSplineCurve(StepModel model, IEnumerable<StepCartesianPoint> controlPoints)
: base( model ) : base(model)
{ {
ControlPointsList.AddRange( controlPoints ); ControlPointsList.AddRange(controlPoints);
} }
public bool ClosedCurve { get; set; } public bool ClosedCurve { get; set; }
@@ -95,21 +85,21 @@ namespace StgSharp.Model.Step
public StepBSplineCurveForm CurveForm { get; set; } = StepBSplineCurveForm.Unspecified; 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.Degree = entity.Degree;
this.ClosedCurve = entity.ClosedCurve; this.ClosedCurve = entity.ClosedCurve;
this.ControlPointsList = entity.ControlPointsList; this.ControlPointsList = entity.ControlPointsList;
this.SelfIntersect = entity.SelfIntersect; 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 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 return enumerationValue.ToUpperInvariant() switch
{ {
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepBSplineCurveWithKnots.cs" // file="StepBSplineCurveWithKnots"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -60,15 +57,11 @@ namespace StgSharp.Model.Step
private const string UNIFORM_KNOTS = "UNIFORM_KNOTS"; private const string UNIFORM_KNOTS = "UNIFORM_KNOTS";
private const string UNSPECIFIED = "UNSPECIFIED"; private const string UNSPECIFIED = "UNSPECIFIED";
public StepBSplineCurveWithKnots( public StepBSplineCurveWithKnots(StepModel model, IEnumerable<StepCartesianPoint> controlPoints)
StepModel model, : base(model, controlPoints) { }
IEnumerable<StepCartesianPoint> controlPoints )
: base( model, controlPoints ) { }
public StepBSplineCurveWithKnots( public StepBSplineCurveWithKnots(StepModel model, params StepCartesianPoint[] controlPoints)
StepModel model, : base(model, controlPoints) { }
params StepCartesianPoint[] controlPoints )
: base( model, controlPoints ) { }
public List<int> KnotMultiplicities { get; } = new List<int>(); public List<int> KnotMultiplicities { get; } = new List<int>();
@@ -78,59 +71,57 @@ namespace StgSharp.Model.Step
public StepKnotType KnotSpec { get; set; } = StepKnotType.Unspecified; 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; KnotSpec = entity.KnotSpec;
KnotMultiplicities.Clear(); KnotMultiplicities.Clear();
KnotMultiplicities.AddRange( entity.KnotMultiplicities ); KnotMultiplicities.AddRange(entity.KnotMultiplicities);
Knots.Clear(); Knots.Clear();
Knots.AddRange( entity.Knots ); Knots.AddRange(entity.Knots);
} }
internal static StepBSplineCurveWithKnots FromSyntax( internal static StepBSplineCurveWithKnots FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
StepModel binder,
ExpSyntaxNode syntaxList )
{ {
ExpNodePresidentEnumerator enumerator = syntaxList .ToPresidentEnumerator(); ExpNodePresidentEnumerator enumerator = syntaxList .ToPresidentEnumerator();
enumerator.AssertEnumeratorCount( 9 ); enumerator.AssertEnumeratorCount(9);
ExpNodePresidentEnumerator controlPointsList = enumerator[ 2 ].TupleToPresidentEnumerator( ExpNodePresidentEnumerator controlPointsList = enumerator[2].TupleToPresidentEnumerator(
); );
StepBSplineCurveWithKnots spline = new StepBSplineCurveWithKnots( StepBSplineCurveWithKnots spline = new StepBSplineCurveWithKnots(
binder, new StepCartesianPoint[controlPointsList.Count] ); binder, new StepCartesianPoint[controlPointsList.Count]);
spline.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; spline.Name = (enumerator[0]as ExpStringNode)!.Value;
spline.Degree = ( enumerator[ 1 ] as ExpIntNode )!.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 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.CurveForm = ParseCurveForm(enumerator[3].CodeConvertTemplate);
spline.ClosedCurve = ( enumerator[ 4 ] as ExpBoolNode )!.Value; spline.ClosedCurve = (enumerator[4] as ExpBoolNode)!.Value;
spline.SelfIntersect = ( enumerator[ 5 ]as ExpBoolNode )!.Value; spline.SelfIntersect = (enumerator[5]as ExpBoolNode)!.Value;
ExpNodePresidentEnumerator knotMultiplicitiesList = enumerator[ 6 ].TupleToPresidentEnumerator( ExpNodePresidentEnumerator knotMultiplicitiesList = enumerator[6].TupleToPresidentEnumerator(
); );
spline.KnotMultiplicities.Clear(); spline.KnotMultiplicities.Clear();
for( int i = 0; i < knotMultiplicitiesList.Count; i++ ) { for (int i = 0; i < knotMultiplicitiesList.Count; i++) {
spline.KnotMultiplicities.Add( ( knotMultiplicitiesList[ i ]as ExpIntNode )!.Value ); spline.KnotMultiplicities.Add((knotMultiplicitiesList[i]as ExpIntNode)!.Value);
} }
ExpNodePresidentEnumerator knotsList = enumerator[ 7 ].TupleToPresidentEnumerator(); ExpNodePresidentEnumerator knotsList = enumerator[7].TupleToPresidentEnumerator();
spline.Knots.Clear(); spline.Knots.Clear();
for( int i = 0; i < knotsList.Count; i++ ) { for (int i = 0; i < knotsList.Count; i++) {
spline.Knots.Add( ( knotsList[ i ]as ExpRealNumberNode )!.Value ); spline.Knots.Add((knotsList[i]as ExpRealNumberNode)!.Value);
} }
spline.KnotSpec = ParseKnotSpec( enumerator[ 8 ].CodeConvertTemplate ); spline.KnotSpec = ParseKnotSpec(enumerator[8].CodeConvertTemplate);
return spline; return spline;
} }
private static string GetKnotSpec( StepKnotType spec ) private static string GetKnotSpec(StepKnotType spec)
{ {
return spec switch 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 return enumerationValue.ToUpperInvariant() switch
{ {
+53 -56
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepBSplineSurface.cs" // file="StepBSplineSurface"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 CommunityToolkit.HighPerformance;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -74,7 +71,7 @@ namespace StgSharp.Model.Step
public const string TOROIDAL_SURF_TEXT = "TOROIDAL_SURF"; public const string TOROIDAL_SURF_TEXT = "TOROIDAL_SURF";
public const string UNSPECIFIED_TEXT = "UNSPECIFIED"; public const string UNSPECIFIED_TEXT = "UNSPECIFIED";
public StepBSplineSurface( StepModel model ) : base( model ) { } public StepBSplineSurface(StepModel model) : base(model) { }
public bool UClosed { get; set; } public bool UClosed { get; set; }
@@ -88,62 +85,62 @@ namespace StgSharp.Model.Step
public int UUpper => ControlPointsList.Count - 1; public int UUpper => ControlPointsList.Count - 1;
public int VUpper => ControlPointsList[ 0 ].Count - 1; public int VUpper => ControlPointsList[0].Count - 1;
public List<List<StepCartesianPoint>> ControlPointsList { get; set; } public List<List<StepCartesianPoint>> ControlPointsList { get; set; }
= new List<List<StepCartesianPoint>>(); = new List<List<StepCartesianPoint>>();
public StepBSplineSurfaceForm SurfaceForm { get; set; } 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(); ExpNodePresidentEnumerator enumerator = syntax.ToPresidentEnumerator();
enumerator.AssertEnumeratorCount( 7 ); enumerator.AssertEnumeratorCount(7);
StepBSplineSurface ret = new StepBSplineSurface( binder ); StepBSplineSurface ret = new StepBSplineSurface(binder);
ret.UDegree = ( enumerator[ 0 ] as ExpIntNode ).Value; ret.UDegree = (enumerator[0] as ExpIntNode).Value;
ret.VDegree = ( enumerator[ 1 ] as ExpIntNode ).Value; ret.VDegree = (enumerator[1] as ExpIntNode).Value;
ExpNodePresidentEnumerator pointList = enumerator[ 2 ].TupleToPresidentEnumerator(); ExpNodePresidentEnumerator pointList = enumerator[2].TupleToPresidentEnumerator();
pointList.AssertEnumeratorCount( 2, int.MaxValue ); pointList.AssertEnumeratorCount(2, int.MaxValue);
for( int i = 0; i < pointList.Count; i++ ) for (int i = 0; i < pointList.Count; i++)
{ {
ExpNodePresidentEnumerator points = pointList[ i ].TupleToPresidentEnumerator(); ExpNodePresidentEnumerator points = pointList[i].TupleToPresidentEnumerator();
points.AssertEnumeratorCount( 2, int.MaxValue ); points.AssertEnumeratorCount(2, int.MaxValue);
List<StepCartesianPoint> pList = new List<StepCartesianPoint>( points.Count ); List<StepCartesianPoint> pList = new List<StepCartesianPoint>(points.Count);
CollectionsMarshal.SetCount( pList, points.Count ); CollectionsMarshal.SetCount(pList, points.Count);
Span<StepCartesianPoint> ls = CollectionsMarshal.AsSpan( pList ); Span<StepCartesianPoint> ls = CollectionsMarshal.AsSpan(pList);
Span<ExpSyntaxNode> aspan = points.AsSpan(); Span<ExpSyntaxNode> 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; StepCartesianPoint p = binder[aspan[i] as StepEntityInstanceNode] as StepCartesianPoint;
ls[ j ] = p; ls[j] = p;
} }
ret.ControlPointsList.Add( pList ); ret.ControlPointsList.Add(pList);
} }
ret.SurfaceForm = GetSurfaceForm( enumerator[ 3 ].CodeConvertTemplate ); ret.SurfaceForm = GetSurfaceForm(enumerator[3].CodeConvertTemplate);
ret.UClosed = ( enumerator[ 4 ] as ExpBoolNode ).Value; ret.UClosed = (enumerator[4] as ExpBoolNode).Value;
ret.VClosed = ( enumerator[ 5 ] as ExpBoolNode ).Value; ret.VClosed = (enumerator[5] as ExpBoolNode).Value;
ret.SelfIntersections = ( enumerator[ 6 ] as ExpBoolNode ).Value; ret.SelfIntersections = (enumerator[6] as ExpBoolNode).Value;
return ret; return ret;
} }
public void FromInstance( StepBSplineSurface entity ) public void FromInstance(StepBSplineSurface entity)
{ {
base.FromInstance( entity ); base.FromInstance(entity);
UClosed = entity.UClosed; UClosed = entity.UClosed;
VClosed = entity.VClosed; VClosed = entity.VClosed;
UDegree = entity.UDegree; UDegree = entity.UDegree;
VDegree = entity.VDegree; VDegree = entity.VDegree;
ControlPointsList.Clear(); ControlPointsList.Clear();
foreach( List<StepCartesianPoint> list in entity.ControlPointsList ) { foreach (List<StepCartesianPoint> list in entity.ControlPointsList) {
ControlPointsList.Add( new List<StepCartesianPoint>( list ) ); ControlPointsList.Add(new List<StepCartesianPoint>(list));
} }
SurfaceForm = entity.SurfaceForm; SurfaceForm = entity.SurfaceForm;
} }
protected static StepBSplineSurfaceForm GetSurfaceForm( string literal ) protected static StepBSplineSurfaceForm GetSurfaceForm(string literal)
{ {
return literal switch 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 return form switch
{ {
+31 -34
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepBoundedCurve.cs" // file="StepBoundedCurve"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -37,21 +34,21 @@ namespace StgSharp.Model.Step
public class StepBoundedCurve : StepCurve, IExpConvertableFrom<StepBoundedCurve> public class StepBoundedCurve : StepCurve, IExpConvertableFrom<StepBoundedCurve>
{ {
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);
} }
} }
+27 -30
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepBoundedSurface.cs" // file="StepBoundedSurface"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 StgSharp.Script.Express;
using System; using System;
@@ -41,13 +38,13 @@ namespace StgSharp.Model.Step
public class StepBoundedSurface : StepSurface, IExpConvertableFrom<StepBoundedSurface> public class StepBoundedSurface : StepSurface, IExpConvertableFrom<StepBoundedSurface>
{ {
public StepBoundedSurface( StepModel model ) : base( model ) { } public StepBoundedSurface(StepModel model) : base(model) { }
public override StepItemType ItemType => StepItemType.BoundedSurface; public override StepItemType ItemType => StepItemType.BoundedSurface;
public void FromInstance( StepBoundedSurface entity ) public void FromInstance(StepBoundedSurface entity)
{ {
base.FromInstance( entity ); base.FromInstance(entity);
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepBoundedSurfaceCurve.cs" // file="StepBoundedSurfaceCurve"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 StgSharp.Script.Express;
using System; using System;
@@ -41,18 +38,18 @@ namespace StgSharp.Model.Step
internal class StepBoundedSurfaceCurve : StepBoundedCurve, IExpConvertableFrom<StepBoundedSurfaceCurve, StepSurfaceCurve> internal class StepBoundedSurfaceCurve : StepBoundedCurve, IExpConvertableFrom<StepBoundedSurfaceCurve, StepSurfaceCurve>
{ {
public StepBoundedSurfaceCurve( StepModel model ) : base( model ) { } public StepBoundedSurfaceCurve(StepModel model) : base(model) { }
public StepCurve Parent { get; set; } = null!; 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);
} }
} }
+30 -34
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepCartesianPoint.cs" // file="StepCartesianPoint"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -37,23 +34,22 @@ namespace StgSharp.Model.Step
public class StepCartesianPoint : StepTriple, IExpConvertableFrom<StepCartesianPoint> public class StepCartesianPoint : StepTriple, IExpConvertableFrom<StepCartesianPoint>
{ {
private StepCartesianPoint( StepModel model ) : base( model ) { } private StepCartesianPoint(StepModel model) : base(model) { }
public StepCartesianPoint( StepModel model, float x, float y, float z ) public StepCartesianPoint(StepModel model, float x, float y, float z) : base(model, x, y, z) { }
: base( model, x, y, z ) { }
public override StepItemType ItemType => StepItemType.CartesianPoint; public override StepItemType ItemType => StepItemType.CartesianPoint;
protected override int MinimumValueCount => 1; 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);
} }
} }
+37 -40
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepCircle.cs" // file="StepCircle"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -42,10 +39,10 @@ namespace StgSharp.Model.Step
private StepAxis2Placement _position; private StepAxis2Placement _position;
public StepCircle( StepModel model ) : base( model ) { } public StepCircle(StepModel model) : base(model) { }
public StepCircle( StepModel model, StepAxis2Placement position, float radius ) public StepCircle(StepModel model, StepAxis2Placement position, float radius)
: base( model ) : base(model)
{ {
Position = position; Position = position;
Radius = radius; Radius = radius;
@@ -58,7 +55,7 @@ namespace StgSharp.Model.Step
get { return _position; } get { return _position; }
set set
{ {
if( value == null ) { if (value == null) {
throw new ArgumentNullException(); throw new ArgumentNullException();
} }
@@ -68,20 +65,20 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.Circle; 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; 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 ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepCircle circle = new StepCircle( binder ); StepCircle circle = new StepCircle(binder);
enumerator.AssertEnumeratorCount( 3 ); enumerator.AssertEnumeratorCount(3);
circle.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; circle.Name = (enumerator[0]as ExpStringNode)!.Value;
circle.Position = binder[ enumerator[ 1 ] ] as StepAxis2Placement; circle.Position = binder[enumerator[1]] as StepAxis2Placement;
circle.Radius = ( enumerator[ 2 ]as ExpRealNumberNode )!.Value; circle.Radius = (enumerator[2]as ExpRealNumberNode)!.Value;
return circle; return circle;
} }
+29 -32
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepConic.cs" // file="StepConic"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -37,18 +34,18 @@ namespace StgSharp.Model.Step
public class StepConic : StepCurve, IExpConvertableFrom<StepConic> public class StepConic : StepCurve, IExpConvertableFrom<StepConic>
{ {
public StepConic( StepModel model ) : base( model ) { } public StepConic(StepModel model) : base(model) { }
public override StepItemType ItemType => StepItemType.Conic; 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<StepConic>.FromInstance( StepConic entity ) void IExpConvertableFrom<StepConic>.FromInstance(StepConic entity)
{ {
base.FromInstance( entity ); base.FromInstance(entity);
} }
} }
+29 -32
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepCurve.cs" // file="StepCurve"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -37,18 +34,18 @@ namespace StgSharp.Model.Step
public class StepCurve : StepGeometricRepresentationItem, IExpConvertableFrom<StepCurve> public class StepCurve : StepGeometricRepresentationItem, IExpConvertableFrom<StepCurve>
{ {
public StepCurve( StepModel model ) : base( model ) { } public StepCurve(StepModel model) : base(model) { }
public override StepItemType ItemType => StepItemType.Curve; 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";
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepCylindricalSurface.cs" // file="StepCylindricalSurface"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
@@ -40,13 +37,10 @@ namespace StgSharp.Model.Step
public class StepCylindricalSurface : StepElementarySurface, IExpConvertableFrom<StepCylindricalSurface> public class StepCylindricalSurface : StepElementarySurface, IExpConvertableFrom<StepCylindricalSurface>
{ {
public StepCylindricalSurface( StepModel model ) : base( model ) { } public StepCylindricalSurface(StepModel model) : base(model) { }
public StepCylindricalSurface( public StepCylindricalSurface(StepModel model, StepAxis2Placement3D position, float radius)
StepModel model, : base(model, position)
StepAxis2Placement3D position,
float radius )
: base( model, position )
{ {
Radius = radius; Radius = radius;
} }
@@ -55,22 +49,20 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.CylindricalSurface; 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; Radius = entity.Radius;
} }
internal static StepRepresentationItem FromSyntax( internal static StepRepresentationItem FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
StepModel binder,
ExpSyntaxNode syntaxList )
{ {
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
enumerator.AssertEnumeratorCount( 3 ); enumerator.AssertEnumeratorCount(3);
StepCylindricalSurface surface = new StepCylindricalSurface( binder ); StepCylindricalSurface surface = new StepCylindricalSurface(binder);
surface.Name = ( enumerator[ 0 ] as ExpStringNode )!.Value; surface.Name = (enumerator[0] as ExpStringNode)!.Value;
surface.Position = binder[ enumerator[ 1 ] ]as StepAxis2Placement3D; surface.Position = binder[enumerator[1]]as StepAxis2Placement3D;
surface.Radius = ( enumerator[ 2 ]as ExpRealNumberNode )!.Value; surface.Radius = (enumerator[2]as ExpRealNumberNode)!.Value;
return surface; return surface;
} }
+30 -34
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepDirection.cs" // file="StepDirection"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -37,23 +34,22 @@ namespace StgSharp.Model.Step
public class StepDirection : StepTriple, IExpConvertableFrom<StepDirection> public class StepDirection : StepTriple, IExpConvertableFrom<StepDirection>
{ {
private StepDirection( StepModel model ) : base( model ) { } private StepDirection(StepModel model) : base(model) { }
public StepDirection( StepModel model, float x, float y, float z ) public StepDirection(StepModel model, float x, float y, float z) : base(model, x, y, z) { }
: base( model, x, y, z ) { }
public override StepItemType ItemType => StepItemType.Direction; public override StepItemType ItemType => StepItemType.Direction;
protected override int MinimumValueCount => 2; 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);
} }
} }
+31 -34
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepEdge.cs" // file="StepEdge"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
@@ -40,10 +37,10 @@ namespace StgSharp.Model.Step
public class StepEdge : StepTopologicalRepresentationItem, IExpConvertableFrom<StepEdge> public class StepEdge : StepTopologicalRepresentationItem, IExpConvertableFrom<StepEdge>
{ {
protected StepEdge( StepModel model ) : base( model ) { } protected StepEdge(StepModel model) : base(model) { }
protected StepEdge( StepModel model, StepVertex edgeStart, StepVertex edgeEnd ) protected StepEdge(StepModel model, StepVertex edgeStart, StepVertex edgeEnd)
: base( model ) : base(model)
{ {
EdgeStart = edgeStart; EdgeStart = edgeStart;
EdgeEnd = edgeEnd; EdgeEnd = edgeEnd;
@@ -53,16 +50,16 @@ namespace StgSharp.Model.Step
public StepVertex EdgeEnd { get; set; } public StepVertex EdgeEnd { get; set; }
public void FromInstance( StepEdge entity ) public void FromInstance(StepEdge entity)
{ {
base.FromInstance( entity ); base.FromInstance(entity);
EdgeStart = entity.EdgeStart; EdgeStart = entity.EdgeStart;
EdgeEnd = entity.EdgeEnd; 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";
} }
} }
+39 -42
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepEdgeCurve.cs" // file="StepEdgeCurve"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -42,15 +39,15 @@ namespace StgSharp.Model.Step
private StepCurve _edgeGeometry; private StepCurve _edgeGeometry;
private StepEdgeCurve( StepModel model ) : base( model ) { } private StepEdgeCurve(StepModel model) : base(model) { }
public StepEdgeCurve( public StepEdgeCurve(
StepModel model, StepModel model,
StepVertex edgeStart, StepVertex edgeStart,
StepVertex edgeEnd, StepVertex edgeEnd,
StepCurve edgeGeometry, StepCurve edgeGeometry,
bool isSameSense ) bool isSameSense)
: base( model, edgeStart, edgeEnd ) : base(model, edgeStart, edgeEnd)
{ {
EdgeGeometry = edgeGeometry; EdgeGeometry = edgeGeometry;
IsSameSense = isSameSense; IsSameSense = isSameSense;
@@ -63,29 +60,29 @@ namespace StgSharp.Model.Step
get { return _edgeGeometry; } get { return _edgeGeometry; }
set set
{ {
ArgumentNullException.ThrowIfNull( value ); ArgumentNullException.ThrowIfNull(value);
_edgeGeometry = value; _edgeGeometry = value;
} }
} }
public override StepItemType ItemType => StepItemType.EdgeCurve; 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; EdgeGeometry = entity.EdgeGeometry;
} }
internal static StepEdgeCurve FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) internal static StepEdgeCurve FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{ {
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepEdgeCurve edgeCurve = new StepEdgeCurve( binder ); StepEdgeCurve edgeCurve = new StepEdgeCurve(binder);
enumerator.AssertEnumeratorCount( 5 ); enumerator.AssertEnumeratorCount(5);
edgeCurve.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; edgeCurve.Name = (enumerator[0]as ExpStringNode)!.Value;
edgeCurve.EdgeStart = binder[ enumerator[ 1 ] ] as StepVertex; edgeCurve.EdgeStart = binder[enumerator[1]] as StepVertex;
edgeCurve.EdgeEnd = binder[ enumerator[ 2 ] ] as StepVertex; edgeCurve.EdgeEnd = binder[enumerator[2]] as StepVertex;
edgeCurve.EdgeGeometry = binder[ enumerator[ 3 ] ] as StepCurve; edgeCurve.EdgeGeometry = binder[enumerator[3]] as StepCurve;
edgeCurve.IsSameSense = ( enumerator[ 4 ]as ExpBoolNode )!.Value; edgeCurve.IsSameSense = (enumerator[4]as ExpBoolNode)!.Value;
return edgeCurve; return edgeCurve;
} }
+39 -42
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepEdgeLoop.cs" // file="StepEdgeLoop"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -40,36 +37,36 @@ namespace StgSharp.Model.Step
public class StepEdgeLoop : StepLoop, IExpConvertableFrom<StepEdgeCurve> public class StepEdgeLoop : StepLoop, IExpConvertableFrom<StepEdgeCurve>
{ {
public StepEdgeLoop( StepModel model, params StepOrientedEdge[] edgeList ) public StepEdgeLoop(StepModel model, params StepOrientedEdge[] edgeList)
: this( model, ( IEnumerable<StepOrientedEdge> )edgeList ) { } : this(model, (IEnumerable<StepOrientedEdge>)edgeList) { }
public StepEdgeLoop( StepModel model, IEnumerable<StepOrientedEdge> edgeList ) public StepEdgeLoop(StepModel model, IEnumerable<StepOrientedEdge> edgeList)
: base( model ) : base(model)
{ {
EdgeList = new List<StepOrientedEdge>( edgeList ); EdgeList = new List<StepOrientedEdge>(edgeList);
} }
public List<StepOrientedEdge> EdgeList { get; private set; } public List<StepOrientedEdge> EdgeList { get; private set; }
public override StepItemType ItemType => StepItemType.EdgeLoop; 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 ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
enumerator.AssertEnumeratorCount( 2 ); enumerator.AssertEnumeratorCount(2);
ExpNodePresidentEnumerator edgeSyntaxList = enumerator[ 1 ].TupleToPresidentEnumerator(); ExpNodePresidentEnumerator edgeSyntaxList = enumerator[1].TupleToPresidentEnumerator();
StepEdgeLoop edgeLoop = new StepEdgeLoop( StepEdgeLoop edgeLoop = new StepEdgeLoop(
binder, new StepOrientedEdge[edgeSyntaxList.Count] ); binder, new StepOrientedEdge[edgeSyntaxList.Count]);
edgeLoop.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; edgeLoop.Name = (enumerator[0]as ExpStringNode)!.Value;
for( int i = 0; i < edgeSyntaxList.Count; i++ ) for (int i = 0; i < edgeSyntaxList.Count; i++)
{ {
int j = i; // capture to avoid rebinding 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; return edgeLoop;
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepElementarySurface.cs" // file="StepElementarySurface"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -42,10 +39,10 @@ namespace StgSharp.Model.Step
private StepAxis2Placement3D _position; private StepAxis2Placement3D _position;
public StepElementarySurface( StepModel model ) : base( model ) { } public StepElementarySurface(StepModel model) : base(model) { }
public StepElementarySurface( StepModel model, StepAxis2Placement3D position ) public StepElementarySurface(StepModel model, StepAxis2Placement3D position)
: base( model ) : base(model)
{ {
Position = position; Position = position;
} }
@@ -55,14 +52,14 @@ namespace StgSharp.Model.Step
get { return _position; } get { return _position; }
set set
{ {
ArgumentNullException.ThrowIfNull( value ); ArgumentNullException.ThrowIfNull(value);
_position = value; _position = value;
} }
} }
public void FromInstance( StepElementarySurface entity ) public void FromInstance(StepElementarySurface entity)
{ {
base.FromInstance( entity ); base.FromInstance(entity);
_position = entity.Position; _position = entity.Position;
} }
+38 -46
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepEllipse.cs" // file="StepEllipse"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -42,15 +39,10 @@ namespace StgSharp.Model.Step
private StepAxis2Placement _position; private StepAxis2Placement _position;
private StepEllipse( StepModel model ) : base( model ) { } private StepEllipse(StepModel model) : base(model) { }
public StepEllipse( public StepEllipse(StepModel model, string name, StepAxis2Placement position, float semiAxis1, float semiAxis2)
StepModel model, : base(model)
string name,
StepAxis2Placement position,
float semiAxis1,
float semiAxis2 )
: base( model )
{ {
Position = position; Position = position;
SemiAxis1 = semiAxis1; SemiAxis1 = semiAxis1;
@@ -66,7 +58,7 @@ namespace StgSharp.Model.Step
get { return _position; } get { return _position; }
set set
{ {
ArgumentNullException.ThrowIfNull( value ); ArgumentNullException.ThrowIfNull(value);
_position = value; _position = value;
} }
@@ -74,22 +66,22 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.Ellipse; 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; SemiAxis1 = entity.SemiAxis1;
SemiAxis2 = entity.SemiAxis2; SemiAxis2 = entity.SemiAxis2;
} }
internal static StepEllipse FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) internal static StepEllipse FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{ {
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepEllipse ellipse = new StepEllipse( binder ); StepEllipse ellipse = new StepEllipse(binder);
enumerator.AssertEnumeratorCount( 4 ); enumerator.AssertEnumeratorCount(4);
ellipse.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; ellipse.Name = (enumerator[0]as ExpStringNode)!.Value;
ellipse.Position = binder[ ( enumerator[ 1 ] as StepEntityInstanceNode )!.Id ]as StepAxis2Placement2D; ellipse.Position = binder[(enumerator[1] as StepEntityInstanceNode)!.Id]as StepAxis2Placement2D;
ellipse.SemiAxis1 = ( enumerator[ 2 ] as ExpRealNumberNode )!.Value; ellipse.SemiAxis1 = (enumerator[2] as ExpRealNumberNode)!.Value;
ellipse.SemiAxis2 = ( enumerator[ 3 ] as ExpRealNumberNode )!.Value; ellipse.SemiAxis2 = (enumerator[3] as ExpRealNumberNode)!.Value;
return ellipse; return ellipse;
} }
+29 -32
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepFace.cs" // file="StepFace"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -40,21 +37,21 @@ namespace StgSharp.Model.Step
public class StepFace : StepTopologicalRepresentationItem, IExpConvertableFrom<StepFace> public class StepFace : StepTopologicalRepresentationItem, IExpConvertableFrom<StepFace>
{ {
public StepFace( StepModel model ) : base( model ) { } public StepFace(StepModel model) : base(model) { }
public List<StepFaceBound> Bounds { get; private set; } = new List<StepFaceBound>(); public List<StepFaceBound> Bounds { get; private set; } = new List<StepFaceBound>();
public override StepItemType ItemType => StepItemType.Face; 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; 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";
} }
} }
+36 -39
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepFaceBound.cs" // file="StepFaceBound"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
@@ -40,10 +37,10 @@ namespace StgSharp.Model.Step
public class StepFaceBound : StepTopologicalRepresentationItem, IExpConvertableFrom<StepFaceBound> public class StepFaceBound : StepTopologicalRepresentationItem, IExpConvertableFrom<StepFaceBound>
{ {
public StepFaceBound( StepModel model ) : base( model ) { } public StepFaceBound(StepModel model) : base(model) { }
public StepFaceBound( StepModel model, StepLoop bound, bool orientation ) public StepFaceBound(StepModel model, StepLoop bound, bool orientation)
: base( model ) : base(model)
{ {
Bound = bound; Bound = bound;
Orientation = orientation; Orientation = orientation;
@@ -55,21 +52,21 @@ namespace StgSharp.Model.Step
public StepLoop Bound { get; set; } public StepLoop Bound { get; set; }
public void FromInstance( StepFaceBound entity ) public void FromInstance(StepFaceBound entity)
{ {
base.FromInstance( entity ); base.FromInstance(entity);
Bound = entity.Bound; Bound = entity.Bound;
Orientation = entity.Orientation; Orientation = entity.Orientation;
} }
internal static StepFaceBound FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) internal static StepFaceBound FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{ {
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
enumerator.AssertEnumeratorCount( 3 ); enumerator.AssertEnumeratorCount(3);
StepFaceBound faceBound = new StepFaceBound( binder ); StepFaceBound faceBound = new StepFaceBound(binder);
faceBound.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; faceBound.Name = (enumerator[0]as ExpStringNode)!.Value;
faceBound.Bound = binder[ enumerator[ 1 ] ] as StepLoop; faceBound.Bound = binder[enumerator[1]] as StepLoop;
faceBound.Orientation = ( enumerator[ 2 ]as ExpBoolNode )!.Value; faceBound.Orientation = (enumerator[2]as ExpBoolNode)!.Value;
return faceBound; return faceBound;
} }
+36 -41
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepFaceOuterBound.cs" // file="StepFaceOuterBound"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -37,28 +34,26 @@ namespace StgSharp.Model.Step
public class StepFaceOuterBound : StepFaceBound, IExpConvertableFrom<StepFaceOuterBound> public class StepFaceOuterBound : StepFaceBound, IExpConvertableFrom<StepFaceOuterBound>
{ {
private StepFaceOuterBound( StepModel model ) : base( model ) { } private StepFaceOuterBound(StepModel model) : base(model) { }
public StepFaceOuterBound( StepModel model, StepLoop bound, bool orientation ) public StepFaceOuterBound(StepModel model, StepLoop bound, bool orientation)
: base( model, bound, orientation ) { } : base(model, bound, orientation) { }
public override StepItemType ItemType => StepItemType.FaceOuterBound; 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( internal static new StepFaceOuterBound FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
StepModel binder,
ExpSyntaxNode syntaxList )
{ {
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
enumerator.AssertEnumeratorCount( 3 ); enumerator.AssertEnumeratorCount(3);
StepFaceOuterBound faceOuterBound = new StepFaceOuterBound( binder ); StepFaceOuterBound faceOuterBound = new StepFaceOuterBound(binder);
faceOuterBound.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; faceOuterBound.Name = (enumerator[0]as ExpStringNode)!.Value;
faceOuterBound.Bound = binder[ enumerator[ 1 ] ] as StepLoop; faceOuterBound.Bound = binder[enumerator[1]] as StepLoop;
faceOuterBound.Orientation = ( enumerator[ 2 ]as ExpBoolNode )!.Value; faceOuterBound.Orientation = (enumerator[2]as ExpBoolNode)!.Value;
return faceOuterBound; return faceOuterBound;
} }
+27 -30
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepFaceSurface.cs" // file="StepFaceSurface"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
@@ -40,15 +37,15 @@ namespace StgSharp.Model.Step
public class StepFaceSurface : StepFace, IExpConvertableFrom<StepFaceSurface> public class StepFaceSurface : StepFace, IExpConvertableFrom<StepFaceSurface>
{ {
public StepFaceSurface( StepModel model ) : base( model ) { } public StepFaceSurface(StepModel model) : base(model) { }
public bool SameSense { get; set; } public bool SameSense { get; set; }
public StepSurface FaceGeometry { 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; SameSense = entity.SameSense;
FaceGeometry = entity.FaceGeometry; FaceGeometry = entity.FaceGeometry;
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepGeometricRepresentationItem.cs" // file="StepGeometricRepresentationItem"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -37,17 +34,16 @@ namespace StgSharp.Model.Step
public class StepGeometricRepresentationItem : StepRepresentationItem, IExpConvertableFrom<StepGeometricRepresentationItem> public class StepGeometricRepresentationItem : StepRepresentationItem, IExpConvertableFrom<StepGeometricRepresentationItem>
{ {
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 ) || return base.IsConvertableTo(entityName) || entityName is "StepGeometricRepresentationItem";
entityName is "StepGeometricRepresentationItem";
} }
} }
+19 -29
View File
@@ -1,30 +1,27 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepLine.cs" // file="StepLine"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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; Vector = entity.Vector;
} }
public static StepLine FromPoints( public static StepLine FromPoints(StepModel model, float x1, float y1, float z1, float x2, float y2, float z2)
StepModel model,
float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
{ {
StepCartesianPoint start = new StepCartesianPoint(model, x1, y1, z1); StepCartesianPoint start = new StepCartesianPoint(model, x1, y1, z1);
float dx = x2 - x1; float dx = x2 - x1;
+27 -30
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepLoop.cs" // file="StepLoop"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -37,11 +34,11 @@ namespace StgSharp.Model.Step
public abstract class StepLoop : StepTopologicalRepresentationItem, IExpConvertableFrom<StepLoop> public abstract class StepLoop : StepTopologicalRepresentationItem, IExpConvertableFrom<StepLoop>
{ {
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);
} }
} }
+39 -42
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepOrientedEdge.cs" // file="StepOrientedEdge"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 Microsoft.Win32.SafeHandles;
using StgSharp.Model.Step; using StgSharp.Model.Step;
@@ -44,15 +41,15 @@ namespace StgSharp.Model.Step
private StepEdge _edgeElement; private StepEdge _edgeElement;
private StepOrientedEdge( StepModel model ) : base( model ) { } private StepOrientedEdge(StepModel model) : base(model) { }
public StepOrientedEdge( public StepOrientedEdge(
StepModel model, StepModel model,
StepVertex edgeStart, StepVertex edgeStart,
StepVertex edgeEnd, StepVertex edgeEnd,
StepEdge edgeElement, StepEdge edgeElement,
bool orientation ) bool orientation)
: base( model, edgeStart, edgeEnd ) : base(model, edgeStart, edgeEnd)
{ {
EdgeElement = edgeElement; EdgeElement = edgeElement;
Orientation = orientation; Orientation = orientation;
@@ -65,7 +62,7 @@ namespace StgSharp.Model.Step
get { return _edgeElement; } get { return _edgeElement; }
set set
{ {
if( value == null ) { if (value == null) {
throw new ArgumentNullException(); throw new ArgumentNullException();
} }
@@ -75,23 +72,23 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.OrientedEdge; 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; EdgeElement = entity.EdgeElement;
Orientation = entity.Orientation; Orientation = entity.Orientation;
} }
internal static StepOrientedEdge FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) internal static StepOrientedEdge FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{ {
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepOrientedEdge orientedEdge = new StepOrientedEdge( binder ); StepOrientedEdge orientedEdge = new StepOrientedEdge(binder);
enumerator.AssertEnumeratorCount( 5 ); enumerator.AssertEnumeratorCount(5);
orientedEdge.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; orientedEdge.Name = (enumerator[0]as ExpStringNode)!.Value;
orientedEdge.EdgeStart = binder[ enumerator[ 1 ] ]as StepVertex; orientedEdge.EdgeStart = binder[enumerator[1]]as StepVertex;
orientedEdge.EdgeEnd = binder[ enumerator[ 2 ] ] as StepVertex; orientedEdge.EdgeEnd = binder[enumerator[2]] as StepVertex;
orientedEdge.EdgeElement = binder[ enumerator[ 3 ] ] as StepEdge; orientedEdge.EdgeElement = binder[enumerator[3]] as StepEdge;
orientedEdge.Orientation = ( enumerator[ 4 ]as ExpBoolNode )!.Value; orientedEdge.Orientation = (enumerator[4]as ExpBoolNode)!.Value;
return orientedEdge; return orientedEdge;
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepPcurveOrSurface.cs" // file="StepPcurveOrSurface"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 StgSharp.Script.Express;
using System; using System;
@@ -41,11 +38,11 @@ namespace StgSharp.Model.Step.Items
public class StepPCurveOrSurface : StepGeometricRepresentationItem, IExpConvertableFrom<StepPCurveOrSurface> public class StepPCurveOrSurface : StepGeometricRepresentationItem, IExpConvertableFrom<StepPCurveOrSurface>
{ {
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);
} }
} }
+32 -35
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepPlacement.cs" // file="StepPlacement"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -41,10 +38,10 @@ namespace StgSharp.Model.Step
private StepCartesianPoint _location; private StepCartesianPoint _location;
public StepPlacement( StepModel model ) : base( model ) { } public StepPlacement(StepModel model) : base(model) { }
public StepPlacement( StepModel model, StepCartesianPoint location ) public StepPlacement(StepModel model, StepCartesianPoint location)
: base( model ) : base(model)
{ {
_location = location; _location = location;
} }
@@ -54,20 +51,20 @@ namespace StgSharp.Model.Step
get { return _location; } get { return _location; }
set set
{ {
ArgumentNullException.ThrowIfNull( value ); ArgumentNullException.ThrowIfNull(value);
_location = value; _location = value;
} }
} }
public void FromInstance( StepPlacement entity ) public void FromInstance(StepPlacement entity)
{ {
base.FromInstance( entity ); base.FromInstance(entity);
this.Location = entity.Location; 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";
} }
} }
+34 -38
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepPlane.cs" // file="StepPlane"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.Geometries;
using StgSharp.Model.Step; using StgSharp.Model.Step;
using StgSharp.Script; using StgSharp.Script;
@@ -38,25 +35,24 @@ namespace StgSharp.Model.Step
public class StepPlane : StepElementarySurface, IExpConvertableFrom<StepPlane> public class StepPlane : StepElementarySurface, IExpConvertableFrom<StepPlane>
{ {
public StepPlane( StepModel model ) : base( model ) { } public StepPlane(StepModel model) : base(model) { }
public StepPlane( StepModel model, StepAxis2Placement3D position ) public StepPlane(StepModel model, StepAxis2Placement3D position) : base(model, position) { }
: base( model, position ) { }
public override StepItemType ItemType => StepItemType.Plane; 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 ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepPlane plane = new StepPlane( binder ); StepPlane plane = new StepPlane(binder);
enumerator.AssertEnumeratorCount( 2 ); enumerator.AssertEnumeratorCount(2);
plane.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; plane.Name = (enumerator[0]as ExpStringNode)!.Value;
plane.Position = binder[ enumerator[ 1 ] ] as StepAxis2Placement3D; plane.Position = binder[enumerator[1]] as StepAxis2Placement3D;
return plane; return plane;
} }
+29 -32
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepPoint.cs" // file="StepPoint"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -39,18 +36,18 @@ namespace StgSharp.Model.Step
public class StepPoint : StepGeometricRepresentationItem, IExpConvertableFrom<StepPoint> public class StepPoint : StepGeometricRepresentationItem, IExpConvertableFrom<StepPoint>
{ {
public StepPoint( StepModel model ) : base( model ) { } public StepPoint(StepModel model) : base(model) { }
public override StepItemType ItemType => StepItemType.Point; 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";
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepRepresentationItem.cs" // file="StepRepresentationItem"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.CSharp.Syntax;
using StgSharp.Model.Step; using StgSharp.Model.Step;
@@ -42,19 +39,19 @@ namespace StgSharp.Model.Step
public class StepRepresentationItem : StepEntityBase, IExpConvertableFrom<StepRepresentationItem> public class StepRepresentationItem : StepEntityBase, IExpConvertableFrom<StepRepresentationItem>
{ {
protected StepRepresentationItem( StepModel model ) protected StepRepresentationItem(StepModel model)
{ {
Context = model; Context = model;
} }
public override StepItemType ItemType => StepItemType.PresentationItem; 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"; return entityName == "StepRepresentationItem";
} }
+29 -32
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepSurface.cs" // file="StepSurface"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -37,16 +34,16 @@ namespace StgSharp.Model.Step
public class StepSurface : StepGeometricRepresentationItem, IExpConvertableFrom<StepSurface> public class StepSurface : StepGeometricRepresentationItem, IExpConvertableFrom<StepSurface>
{ {
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";
} }
} }
+26 -29
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepSurfaceCurve.cs" // file="StepSurfaceCurve"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 StgSharp.Script.Express;
using System; using System;
@@ -41,11 +38,11 @@ namespace StgSharp.Model.Step
public class StepSurfaceCurve : StepCurve, IExpConvertableFrom<StepSurfaceCurve> public class StepSurfaceCurve : StepCurve, IExpConvertableFrom<StepSurfaceCurve>
{ {
public StepSurfaceCurve( StepModel model ) : base( model ) { } public StepSurfaceCurve(StepModel model) : base(model) { }
public StepCurve Curve3D { get; set; } public StepCurve Curve3D { get; set; }
public void FromInstance( StepSurfaceCurve entity ) public void FromInstance(StepSurfaceCurve entity)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepTopologicalRepresentationItem.cs" // file="StepTopologicalRepresentationItem"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -39,17 +36,16 @@ namespace StgSharp.Model.Step
public class StepTopologicalRepresentationItem : StepRepresentationItem, IExpConvertableFrom<StepTopologicalRepresentationItem> public class StepTopologicalRepresentationItem : StepRepresentationItem, IExpConvertableFrom<StepTopologicalRepresentationItem>
{ {
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 ) || return base.IsConvertableTo(entityName) || entityName == "StepTopologicalRepresentationItem";
entityName == "StepTopologicalRepresentationItem";
} }
} }
+18 -21
View File
@@ -1,30 +1,27 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepTriple.cs" // file="StepTriple"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
+37 -40
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepVector.cs" // file="StepVector"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -42,10 +39,10 @@ namespace StgSharp.Model.Step
private StepDirection _direction; private StepDirection _direction;
private StepVector( StepModel model ) : base( model ) { } private StepVector(StepModel model) : base(model) { }
public StepVector( StepModel model, StepDirection direction, double length ) public StepVector(StepModel model, StepDirection direction, double length)
: base( model ) : base(model)
{ {
Direction = direction; Direction = direction;
Length = length; Length = length;
@@ -58,7 +55,7 @@ namespace StgSharp.Model.Step
get { return _direction; } get { return _direction; }
set set
{ {
ArgumentNullException.ThrowIfNull( value ); ArgumentNullException.ThrowIfNull(value);
_direction = value; _direction = value;
} }
@@ -66,20 +63,20 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.Vector; 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; _direction = entity.Direction;
} }
internal static StepVector FromSyntax( StepModel binder, ExpSyntaxNode syntaxList ) internal static StepVector FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{ {
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepVector vector = new StepVector( binder ); StepVector vector = new StepVector(binder);
enumerator.AssertEnumeratorCount( 3 ); enumerator.AssertEnumeratorCount(3);
vector.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; vector.Name = (enumerator[0]as ExpStringNode)!.Value;
vector.Direction = binder[ enumerator[ 1 ] ] as StepDirection; vector.Direction = binder[enumerator[1]] as StepDirection;
vector.Length = ( enumerator[ 2 ]as ExpRealNumberNode )!.Value; vector.Length = (enumerator[2]as ExpRealNumberNode)!.Value;
return vector; return vector;
} }
+18 -21
View File
@@ -1,30 +1,27 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepVertex.cs" // file="StepVertex"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
+36 -39
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepVertexPoint.cs" // file="StepVertexPoint"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -42,10 +39,10 @@ namespace StgSharp.Model.Step
private StepCartesianPoint _location; private StepCartesianPoint _location;
public StepVertexPoint( StepModel model ) : base( model ) { } public StepVertexPoint(StepModel model) : base(model) { }
public StepVertexPoint( StepModel model, StepCartesianPoint location ) public StepVertexPoint(StepModel model, StepCartesianPoint location)
: base( model ) : base(model)
{ {
Location = location; Location = location;
} }
@@ -55,26 +52,26 @@ namespace StgSharp.Model.Step
get { return _location; } get { return _location; }
set set
{ {
ArgumentNullException.ThrowIfNull( value ); ArgumentNullException.ThrowIfNull(value);
_location = value; _location = value;
} }
} }
public override StepItemType ItemType => StepItemType.VertexPoint; 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; 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 ); ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepVertexPoint vertex = new StepVertexPoint( binder ); StepVertexPoint vertex = new StepVertexPoint(binder);
enumerator.AssertEnumeratorCount( 2 ); enumerator.AssertEnumeratorCount(2);
vertex.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value; vertex.Name = (enumerator[0]as ExpStringNode)!.Value;
vertex.Location = binder[ enumerator[ 1 ] ] as StepCartesianPoint; vertex.Location = binder[enumerator[1]] as StepCartesianPoint;
return vertex; return vertex;
} }
+18 -21
View File
@@ -1,30 +1,27 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepDataParser.cs" // file="StepDataParser"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
+52 -55
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepEntityBase.cs" // file="StepEntityBase"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.CSharp.Syntax;
using StgSharp.Mathematics; using StgSharp.Mathematics;
@@ -52,7 +49,7 @@ namespace StgSharp.Model.Step
public int Id public int Id
{ {
get => Label.Id; get => Label.Id;
protected set { Label = new StepEntityLabel( value ); } protected set { Label = new StepEntityLabel(value); }
} }
public StepEntityLabel Label { get; protected set; } public StepEntityLabel Label { get; protected set; }
@@ -65,7 +62,7 @@ namespace StgSharp.Model.Step
protected string ExpEntityTypeName { get; set; } protected string ExpEntityTypeName { get; set; }
public void FromInstance( StepEntityBase entity ) public void FromInstance(StepEntityBase entity)
{ {
this.Id = entity.Id; this.Id = entity.Id;
this.Label = entity.Label; this.Label = entity.Label;
@@ -73,58 +70,58 @@ namespace StgSharp.Model.Step
this.Name = entity.Name; this.Name = entity.Name;
} }
public unsafe string[] GetEntityDescription( int depth ) public unsafe string[] GetEntityDescription(int depth)
{ {
List<string> ret = new(); List<string> ret = new();
string thisDescription = $"Entity Id: {Id}, type: {ExpEntityTypeName}"; string thisDescription = $"Entity Id: {Id}, type: {ExpEntityTypeName}";
if( depth <= 0 ) { if (depth <= 0) {
return [thisDescription]; return[ thisDescription ];
} }
switch( Dependencies.Count() ) switch (Dependencies.Count())
{ {
case 0: case 0:
return [thisDescription]; return[ thisDescription ];
case 1: case 1:
ret.Add( thisDescription ); ret.Add(thisDescription);
int only = Dependencies.First(); int only = Dependencies.First();
string[] dep = Context[ only ]!.GetEntityDescription( depth - 1 ); string[] dep = Context[only]!.GetEntityDescription(depth - 1);
ret.Add( $" ©¸-{dep[0]}" ); ret.Add($" ©¸-{dep[0]}");
for( int i = 1; i < dep.Length; i++ ) { for (int i = 1; i < dep.Length; i++) {
ret.Add( $" {dep[i]}" ); ret.Add($" {dep[i]}");
} }
return ret.ToArray(); return ret.ToArray();
default: default:
ret.Add( thisDescription ); ret.Add(thisDescription);
int first = Dependencies.First(); int first = Dependencies.First();
dep = Context[ first ]!.GetEntityDescription( depth - 1 ); dep = Context[first]!.GetEntityDescription(depth - 1);
ret.Add( $" ©À-{dep[0]}" ); ret.Add($" ©À-{dep[0]}");
int index = 0; int index = 0;
for( int i = 1; i < dep.Length; i++ ) { for (int i = 1; i < dep.Length; i++) {
ret.Add( $" | {dep[i]}" ); ret.Add($" | {dep[i]}");
} }
foreach( int item in Dependencies ) foreach (int item in Dependencies)
{ {
index++; index++;
if( index == 1 || index >= Dependencies.Count() ) if (index == 1 || index >= Dependencies.Count())
{ {
continue; continue;
} }
dep = Context[ item ]!.GetEntityDescription( depth - 1 ); dep = Context[item]!.GetEntityDescription(depth - 1);
ret.Add( $" ©À-{dep[0]}" ); ret.Add($" ©À-{dep[0]}");
for( int i = 1; i < dep.Length; i++ ) { for (int i = 1; i < dep.Length; i++) {
ret.Add( $" | {dep[i]}" ); ret.Add($" | {dep[i]}");
} }
} }
dep = Context[ Dependencies.Last() ].GetEntityDescription( depth - 1 ); dep = Context[Dependencies.Last()].GetEntityDescription(depth - 1);
ret.Add( $" ©¸-{dep[0]}" ); ret.Add($" ©¸-{dep[0]}");
for( int i = 1; i < dep.Length; i++ ) { for (int i = 1; i < dep.Length; i++) {
ret.Add( $" {dep[i]}" ); ret.Add($" {dep[i]}");
} }
return ret.ToArray(); return ret.ToArray();
} }
} }
public bool IsConvertableTo( string entityName ) public bool IsConvertableTo(string entityName)
{ {
return false; return false;
} }
+27 -28
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepEntityLabel.cs" // file="StepEntityLabel"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.PipeLine;
using System; using System;
@@ -40,7 +37,8 @@ namespace StgSharp.Model.Step
{ {
public record class StepEntityLabel : PipelineNodeLabel public record class StepEntityLabel : PipelineNodeLabel
{ {
public StepEntityLabel( int id )
public StepEntityLabel(int id)
{ {
Id = id; Id = id;
} }
@@ -56,5 +54,6 @@ namespace StgSharp.Model.Step
{ {
return $"StepEntityLabel: {Id}"; return $"StepEntityLabel: {Id}";
} }
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepEntityUnsupportedException.cs" // file="StepEntityUnsupportedException"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
+32 -27
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepHeader.cs" // file="StepHeader"
// Project: World // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -39,6 +36,7 @@ namespace StgSharp.Model.Step
/// </summary> /// </summary>
public record class StepInfo public record class StepInfo
{ {
private STEPFileDescriptor _header = new(); private STEPFileDescriptor _header = new();
private STEPFileName _name = new(); private STEPFileName _name = new();
private STEPSchema _schema = new(); private STEPSchema _schema = new();
@@ -126,6 +124,7 @@ namespace StgSharp.Model.Step
get => _schema.Data; get => _schema.Data;
internal set => _schema.Data = value; internal set => _schema.Data = value;
} }
} }
/// <summary> /// <summary>
@@ -133,6 +132,7 @@ namespace StgSharp.Model.Step
/// </summary> /// </summary>
public record class STEPFileName public record class STEPFileName
{ {
public DateTime TimeStamp { get; internal set; } public DateTime TimeStamp { get; internal set; }
public string Name { 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 OriginatingSystem { get; internal set; }
public string Authorization { get; internal set; } public string Authorization { get; internal set; }
} }
public record class STEPSchema public record class STEPSchema
{ {
private List<string> _schema = new(); private List<string> _schema = new();
public string Data { get; internal set; } public string Data { get; internal set; }
} }
/// <summary> /// <summary>
@@ -164,8 +167,10 @@ namespace StgSharp.Model.Step
/// </summary> /// </summary>
public record class STEPFileDescriptor public record class STEPFileDescriptor
{ {
public (int mainLevel,int? subLevel) Level { get; internal set; } public (int mainLevel,int? subLevel) Level { get; internal set; }
public string Description { get; internal set; } public string Description { get; internal set; }
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepHeaderLineConstructor.cs" // file="StepHeaderLineConstructor"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@@ -43,22 +40,22 @@ namespace StgSharp.Model.Step
private static Regex regex = new Regex( private static Regex regex = new Regex(
@"(?<param1>.+?(\)|'\s?\)|'))\s?(?<sepcomma>,)\s?(?<other>(.|\(|\(\s?').+)", @"(?<param1>.+?(\)|'\s?\)|'))\s?(?<sepcomma>,)\s?(?<other>(.|\(|\(\s?').+)",
RegexOptions.Compiled ); RegexOptions.Compiled);
private readonly int _id; private readonly int _id;
private readonly List<string> _paramList; private readonly List<string> _paramList;
private string _caller; private string _caller;
public StepHeaderLineConstructor( int id, string caller, string parameters ) public StepHeaderLineConstructor(int id, string caller, string parameters)
{ {
_caller = caller; _caller = caller;
_paramList = new List<string>(); _paramList = new List<string>();
SplitParameter( parameters ); SplitParameter(parameters);
} }
public string this[ int paramIndex ] public string this[int paramIndex]
{ {
get => _paramList[ paramIndex ]; get => _paramList[paramIndex];
} }
public ReadOnlyCollection<string> ParamList public ReadOnlyCollection<string> ParamList
@@ -77,24 +74,24 @@ namespace StgSharp.Model.Step
internal set => _caller = value; 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; return;
} }
Match match = regex.Match( parameters ); Match match = regex.Match(parameters);
while( match.Success ) while (match.Success)
{ {
_paramList.Add( match.Groups[ "param1" ].Value ); _paramList.Add(match.Groups["param1"].Value);
parameters = match.Groups[ "other" ].Value; parameters = match.Groups["other"].Value;
match = regex.Match( parameters ); match = regex.Match(parameters);
} }
_paramList.Add( parameters ); _paramList.Add(parameters);
} }
} }
+24 -27
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepItemType.cs" // file="StepItemType"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
+78 -85
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepModel.cs" // file="StepModel"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.PipeLine;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -52,89 +49,89 @@ namespace StgSharp.Model.Step
private PipelineScheduler _initScheduler = new PipelineScheduler(); private PipelineScheduler _initScheduler = new PipelineScheduler();
private StepInfo _header; private StepInfo _header;
internal StepModel( StepInfo header ) internal StepModel(StepInfo header)
{ {
_header = header; _header = header;
_builder = new PipelineScheduler(); _builder = new PipelineScheduler();
} }
public StepEntityBase? this[ int id ] public StepEntityBase? this[int id]
{ {
get get
{ {
if( id == 0 ) { if (id == 0) {
return null; 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(); throw new StepEntityUnsupportedException();
} }
return node; return node;
} }
node = new StepUninitializedEntity( this, id ); node = new StepUninitializedEntity(this, id);
_nodes.Add( id, node ); _nodes.Add(id, node);
return node; return node;
} }
private set { _nodes[ id ] = value!; } private set { _nodes[id] = value!; }
} }
internal StepEntityBase? this[ ExpSyntaxNode node ] internal StepEntityBase? this[ExpSyntaxNode node]
{ {
get get
{ {
if( node is not StepEntityInstanceNode instance ) { if (node is not StepEntityInstanceNode instance) {
throw new InvalidCastException(); throw new InvalidCastException();
} }
return this[ instance.Id ]; return this[instance.Id];
} }
set set
{ {
if( node is not StepEntityInstanceNode instance ) { if (node is not StepEntityInstanceNode instance) {
throw new InvalidCastException(); throw new InvalidCastException();
} }
this[ instance.Id ] = value; this[instance.Id] = value;
} }
} }
public void BindValue( ExpSyntaxNode node, Action<StepEntityBase> action ) { } public void BindValue(ExpSyntaxNode node, Action<StepEntityBase> 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; 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 ); u.FromSequence(sequence);
node = _initScheduler.GetNode( u.Label ); node = _initScheduler.GetNode(u.Label);
} else } else
{ {
u = new StepUninitializedEntity( this, id ); u = new StepUninitializedEntity(this, id);
u.FromSequenceUnsafe( sequence ); u.FromSequenceUnsafe(sequence);
_nodes.Add( id, u ); _nodes.Add(id, u);
node = _initScheduler.Create( u.Label, u ); node = _initScheduler.Create(u.Label, u);
} }
PipelineNodeInPort port = node.GetInputPort( StepUninitializedEntity.InName ); PipelineNodeInPort port = node.GetInputPort(StepUninitializedEntity.InName);
if( sequence.Dependencies.Count() == 0 ) if (sequence.Dependencies.Count() == 0)
{ {
_initScheduler.LinkToInput( port ); _initScheduler.LinkToInput(port);
} else } else
{ {
foreach( int i in sequence.Dependencies ) foreach (int i in sequence.Dependencies)
{ {
PipelineNode dNode; PipelineNode dNode;
StepEntityLabel label = new StepEntityLabel( i ); StepEntityLabel label = new StepEntityLabel(i);
if( _nodes.TryGetValue( i, out e ) ) if (_nodes.TryGetValue(i, out e))
{ {
dNode = _initScheduler.GetNode( label ); dNode = _initScheduler.GetNode(label);
} else } else
{ {
u = new StepUninitializedEntity( this, i ); u = new StepUninitializedEntity(this, i);
_nodes.Add( i, u ); _nodes.Add(i, u);
dNode = _initScheduler.Create( u.Label, u ); dNode = _initScheduler.Create(u.Label, u);
} }
port.Connect( dNode.GetOutputPort( StepUninitializedEntity.OutName ) ); port.Connect(dNode.GetOutputPort(StepUninitializedEntity.OutName));
} }
} }
return u; return u;
@@ -142,53 +139,49 @@ namespace StgSharp.Model.Step
public void InitEntity() public void InitEntity()
{ {
if( _initScheduler is null ) { if (_initScheduler is null) {
return; return;
} }
_initScheduler.ArrangeNodes(); _initScheduler.ArrangeNodes();
PipeLineRunner.Run( _initScheduler ); PipeLineRunner.Run(_initScheduler);
_initScheduler = null!; _initScheduler = null!;
} }
public void ReplaceEntity( public void ReplaceEntity(StepUninitializedEntity uninitialized, StepEntityBase accurateEntity)
StepUninitializedEntity uninitialized,
StepEntityBase accurateEntity )
{ {
ArgumentNullException.ThrowIfNull( uninitialized ); ArgumentNullException.ThrowIfNull(uninitialized);
if( uninitialized.Context != this || accurateEntity.Context != this ) { if (uninitialized.Context != this || accurateEntity.Context != this) {
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
if( uninitialized.Id != accurateEntity.Id ) { if (uninitialized.Id != accurateEntity.Id) {
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
_nodes[ uninitialized.Id ] = accurateEntity; _nodes[uninitialized.Id] = accurateEntity;
} }
public string[] ShowStructure( int depth ) public string[] ShowStructure(int depth)
{ {
_initScheduler.ArrangeNodes(); _initScheduler.ArrangeNodes();
IEnumerable<PipelineNode> nodes = PipelineMarshal.GetNodeSortedEnumeration( IEnumerable<PipelineNode> nodes = PipelineMarshal.GetNodeSortedEnumeration(
_initScheduler ); _initScheduler);
int count = 0; int count = 0;
List<string> info = [ List<string> info = [ @$"Step model root", ];
@$"Step model root", foreach (PipelineNode node in nodes)
];
foreach( PipelineNode node in nodes )
{ {
count++; count++;
StepUninitializedEntity uncertain = ( node.NodeOperation as StepUninitializedEntity )!; StepUninitializedEntity uncertain = (node.NodeOperation as StepUninitializedEntity)!;
string[] strings = uncertain.GetEntityDescription( depth - 1 ); string[] strings = uncertain.GetEntityDescription(depth - 1);
if( count < nodes.Count() ) if (count < nodes.Count())
{ {
info.Add( $" ├-{strings[0]}" ); info.Add($" ├-{strings[0]}");
for( int i = 1; i < strings.Length; i++ ) { for (int i = 1; i < strings.Length; i++) {
info.Add( $" | {strings[i]}" ); info.Add($" | {strings[i]}");
} }
} else } else
{ {
info.Add( $" └-{strings[0]}" ); info.Add($" └-{strings[0]}");
for( int i = 1; i < strings.Length; i++ ) { for (int i = 1; i < strings.Length; i++) {
info.Add( $" {strings[i]}" ); info.Add($" {strings[i]}");
} }
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepReader.DataSectionReader.cs" // file="StepReader.DataSectionReader"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.Model.Step; using StgSharp.Model.Step;
using StgSharp.Script; using StgSharp.Script;
@@ -53,15 +50,15 @@ namespace StgSharp.Model.Step
internal async void ReadDataSection() internal async void ReadDataSection()
{ {
using( MemoryMappedViewStream ms = _memoryFile.CreateViewStream( using (MemoryMappedViewStream ms = _memoryFile.CreateViewStream(
0, _size, MemoryMappedFileAccess.Read ) ) 0, _size, MemoryMappedFileAccess.Read))
{ {
StreamReader sr = new StreamReader( ms ); StreamReader sr = new StreamReader(ms);
ms.Position = _dataStart; ms.Position = _dataStart;
DataTransmitter.Begin = _dataBeginLine; DataTransmitter.Begin = _dataBeginLine;
string line; string line;
while( !string.IsNullOrEmpty( line = sr.ReadLine()! ) ) { while (!string.IsNullOrEmpty(line = sr.ReadLine()!)) {
DataTransmitter.WriteLine( line ); DataTransmitter.WriteLine(line);
} }
sr.Dispose(); sr.Dispose();
} }
@@ -69,7 +66,7 @@ namespace StgSharp.Model.Step
[GeneratedRegex( [GeneratedRegex(
@"^#(?<id>[0-9]+)\s*?=\s*?(?<expression>\S.*?)\s*;$", @"^#(?<id>[0-9]+)\s*?=\s*?(?<expression>\S.*?)\s*;$",
RegexOptions.Compiled | RegexOptions.Singleline )] RegexOptions.Compiled | RegexOptions.Singleline)]
private static partial Regex GetExpressionSplitter(); private static partial Regex GetExpressionSplitter();
} }
+47 -50
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepReader.HeadReader.cs" // file="StepReader.HeadReader"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -48,53 +45,53 @@ namespace StgSharp.Model.Step
public StepInfo GetInfo() public StepInfo GetInfo()
{ {
if( _info is not null ) { if (_info is not null) {
return _info; return _info;
} }
StepInfo info = new StepInfo(); StepInfo info = new StepInfo();
List<StepHeaderLineConstructor> constructorList = new List<StepHeaderLineConstructor>(); List<StepHeaderLineConstructor> constructorList = new List<StepHeaderLineConstructor>();
using( MemoryMappedViewStream ms = _memoryFile.CreateViewStream( using (MemoryMappedViewStream ms = _memoryFile.CreateViewStream(
0, _size, MemoryMappedFileAccess.Read ) ) 0, _size, MemoryMappedFileAccess.Read))
{ {
using( StreamReader sr = new StreamReader( ms ) ) using (StreamReader sr = new StreamReader(ms))
{ {
long pos = _headStart; long pos = _headStart;
ms.Seek( _headStart, SeekOrigin.Begin ); ms.Seek(_headStart, SeekOrigin.Begin);
while( pos <= _headEnd ) while (pos <= _headEnd)
{ {
string token = ReadToken( sr, ref pos ); string token = ReadToken(sr, ref pos);
if( token == "HEADER;" ) if (token == "HEADER;")
{ {
continue; continue;
} }
if( token == "ENDSEC;" ) if (token == "ENDSEC;")
{ {
break; break;
} }
GroupCollection match = expressionSplitter.Match( token ).Groups; GroupCollection match = expressionSplitter.Match(token).Groups;
constructorList.Add( constructorList.Add(
new StepHeaderLineConstructor( 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": case "FILE_DESCRIPTION":
info.Description = StepDataParser.ToString( constructor[ 0 ] ); info.Description = StepDataParser.ToString(constructor[0]);
info.Level = StepDataParser.ToVersion( constructor[ 1 ] ); info.Level = StepDataParser.ToVersion(constructor[1]);
break; break;
case "FILE_NAME": case "FILE_NAME":
info.Name = StepDataParser.ToString( constructor[ 0 ] ); info.Name = StepDataParser.ToString(constructor[0]);
info.TimeStamp = StepDataParser.ToDateTime( constructor[ 1 ] ); info.TimeStamp = StepDataParser.ToDateTime(constructor[1]);
info.Author = StepDataParser.ToString( constructor[ 2 ] ); info.Author = StepDataParser.ToString(constructor[2]);
info.Organization = StepDataParser.ToString( constructor[ 3 ] ); info.Organization = StepDataParser.ToString(constructor[3]);
info.PreprocessorVersion = StepDataParser.ToString( info.PreprocessorVersion = StepDataParser.ToString(
constructor[ 4 ] ); constructor[4]);
info.OriginatingSystem = StepDataParser.ToString( constructor[ 5 ] ); info.OriginatingSystem = StepDataParser.ToString(constructor[5]);
info.Authorization = StepDataParser.ToString( constructor[ 6 ] ); info.Authorization = StepDataParser.ToString(constructor[6]);
break; break;
default: default:
break; break;
@@ -105,7 +102,7 @@ namespace StgSharp.Model.Step
return info; return info;
} }
[GeneratedRegex( @"^(?<CALLER>[A-Z_]+)\s?\((?<PARAM>.+)\)\;", RegexOptions.Compiled )] [GeneratedRegex(@"^(?<CALLER>[A-Z_]+)\s?\((?<PARAM>.+)\)\;", RegexOptions.Compiled)]
private static partial Regex GetStepHeadExpressionParser(); private static partial Regex GetStepHeadExpressionParser();
/**/ /**/
+51 -55
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepReader.ToModel.cs" // file="StepReader.ToModel"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -55,78 +52,77 @@ namespace StgSharp.Model.Step
public StepModel ReadToModel() public StepModel ReadToModel()
{ {
if( Model is not null ) { if (Model is not null) {
return Model; return Model;
} }
if( _version != 0 ) { if (_version != 0) {
throw new InvalidOperationException( 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(); GetInfo();
tokenReader = new StepDataTokenReader( DataTransmitter ); tokenReader = new StepDataTokenReader(DataTransmitter);
analyzer = new StepExpSyntaxAnalyzer(); analyzer = new StepExpSyntaxAnalyzer();
ConcurrentQueue<StepEntityDefineSequence> initStatements = analyzer.StepEntityInitStatements; ConcurrentQueue<StepEntityDefineSequence> initStatements = analyzer.StepEntityInitStatements;
Task secTask = Task.Run( ReadDataSection ); Task secTask = Task.Run(ReadDataSection);
Task anTask = Task.Run( ReadStepToken ); Task anTask = Task.Run(ReadStepToken);
Model = new StepModel( _info ); Model = new StepModel(_info);
while( initStatements.TryDequeue( out StepEntityDefineSequence? statement ) || while (initStatements.TryDequeue(out StepEntityDefineSequence? statement) || !anTask.IsCompleted)
!anTask.IsCompleted )
{ {
if( statement is null ) if (statement is null)
{ {
Thread.Sleep( 0 ); Thread.Sleep(0);
continue; continue;
} }
StepUninitializedEntity entity = Model.FromInitSequence( statement ); StepUninitializedEntity entity = Model.FromInitSequence(statement);
} }
Task.WaitAll( secTask, anTask ); Task.WaitAll(secTask, anTask);
return Model; return Model;
} }
public async Task<StepModel> ReadToModelAsync() public async Task<StepModel> ReadToModelAsync()
{ {
if( ReadToModelTask is null ) { if (ReadToModelTask is null) {
ReadToModelTask = Task.Run( ReadToModel ); ReadToModelTask = Task.Run(ReadToModel);
} }
return await ReadToModelTask; return await ReadToModelTask;
} }
public StepModel ReadToModelSingleThread() public StepModel ReadToModelSingleThread()
{ {
if( Model is not null ) { if (Model is not null) {
return Model; return Model;
} }
if( _version != 0 ) { if (_version != 0) {
throw new InvalidOperationException( 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(); GetInfo();
tokenReader = new StepDataTokenReader( DataTransmitter ); tokenReader = new StepDataTokenReader(DataTransmitter);
analyzer = new StepExpSyntaxAnalyzer(); analyzer = new StepExpSyntaxAnalyzer();
ConcurrentQueue<StepEntityDefineSequence> initStatements = analyzer.StepEntityInitStatements; ConcurrentQueue<StepEntityDefineSequence> initStatements = analyzer.StepEntityInitStatements;
ReadDataSection(); ReadDataSection();
ReadStepToken(); ReadStepToken();
Model = new StepModel( _info ); Model = new StepModel(_info);
while( initStatements.TryDequeue( out StepEntityDefineSequence? statement ) ) while (initStatements.TryDequeue(out StepEntityDefineSequence? statement))
{ {
if( statement is null ) if (statement is null)
{ {
Thread.Sleep( 0 ); Thread.Sleep(0);
continue; continue;
} }
StepUninitializedEntity entity = Model.FromInitSequence( statement ); StepUninitializedEntity entity = Model.FromInitSequence(statement);
} }
return Model; return Model;
} }
private void ReadStepToken() private void ReadStepToken()
{ {
while( !tokenReader.IsEmpty ) while (!tokenReader.IsEmpty)
{ {
Token t = tokenReader.ReadToken(); Token t = tokenReader.ReadToken();
analyzer.AppendToken( t ); analyzer.AppendToken(t);
} }
} }
+60 -65
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepReader.cs" // file="StepReader"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using StgSharp.Script; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -58,43 +55,41 @@ namespace StgSharp.Model.Step
private StepReader() { } private StepReader() { }
private StepReader( FileStream stream, long size ) private StepReader(FileStream stream, long size)
{ {
_fileStream = stream; _fileStream = stream;
_size = size; _size = size;
_memoryFile = MemoryMappedFile.CreateFromFile( _memoryFile = MemoryMappedFile.CreateFromFile(
stream, mapName: null, size, MemoryMappedFileAccess.Read, HandleInheritability.None, stream, mapName:null, size, MemoryMappedFileAccess.Read, HandleInheritability.None, leaveOpen:true);
leaveOpen: true );
} }
// ~StepReader() // ~StepReader()
// { // {
// Dispose(disposing: false); // Dispose(disposing: false);
// } // }
public void Dispose() public void Dispose()
{ {
Dispose( disposing: true ); Dispose(disposing:true);
GC.SuppressFinalize( this ); 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 ); FileInfo info = new FileInfo(path);
if( !info.Exists ) if (!info.Exists)
{ {
reader = null!; reader = null!;
return false; return false;
} }
FileStream stream = new FileStream( FileStream stream = new FileStream(
path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 4096, path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize:4096, useAsync:true);
useAsync: true );
byte[] fileHead = new byte[40]; byte[] fileHead = new byte[40];
stream.Read( fileHead, 0, fileLabel.Length ); stream.Read(fileHead, 0, fileLabel.Length);
if( !Encoding.UTF8.GetString( fileHead ).Contains( fileLabel ) ) { if (!Encoding.UTF8.GetString(fileHead).Contains(fileLabel)) {
throw new InvalidDataException( "The given file is not a STEP file" ); 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(); reader.LocateSection();
return reader != null; return reader != null;
} }
@@ -104,62 +99,62 @@ namespace StgSharp.Model.Step
long startPos = 0; long startPos = 0;
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
Span<byte> bufferSpan = buffer, Span<byte> bufferSpan = buffer,
headerSec = Encoding.UTF8.GetBytes( "HEADER;" ), headerSec = Encoding.UTF8.GetBytes("HEADER;"),
endsecSec = Encoding.UTF8.GetBytes( "ENDSEC;" ), endsecSec = Encoding.UTF8.GetBytes("ENDSEC;"),
dataSec = Encoding.UTF8.GetBytes( "DATA;" ); dataSec = Encoding.UTF8.GetBytes("DATA;");
_fileStream.Position = 0; _fileStream.Position = 0;
for( ; startPos < _size; startPos += 1000 ) for (; startPos < _size; startPos += 1000)
{ {
_fileStream.Read( buffer ); _fileStream.Read(buffer);
if( _headStart == -1 ) if (_headStart == -1)
{ {
long pos = bufferSpan.IndexOf( headerSec ); long pos = bufferSpan.IndexOf(headerSec);
if( pos >= 0 ) { if (pos >= 0) {
_headStart = startPos + pos; _headStart = startPos + pos;
} }
} }
if( _headEnd == -1 ) if (_headEnd == -1)
{ {
long pos = bufferSpan.IndexOf( endsecSec ); long pos = bufferSpan.IndexOf(endsecSec);
if( pos >= 0 ) { if (pos >= 0) {
_headEnd = startPos + pos; _headEnd = startPos + pos;
} }
} }
if( _dataStart == -1 ) if (_dataStart == -1)
{ {
long pos = bufferSpan.IndexOf( dataSec ); long pos = bufferSpan.IndexOf(dataSec);
if( pos >= 0 ) { if (pos >= 0) {
_dataStart = startPos + pos; _dataStart = startPos + pos;
} }
} else } else
{ {
break; 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 ); StringBuilder token = new StringBuilder(100);
while( token.Length == 0 || token[ token.Length - 1 ] != ';' ) while (token.Length == 0 || token[token.Length - 1] != ';')
{ {
string subString = reader.ReadLine()!; string subString = reader.ReadLine()!;
if( subString == null ) if (subString == null)
{ {
break; break;
} }
token.Append( subString.TrimStart() ); token.Append(subString.TrimStart());
} }
posCache += token.Length; posCache += token.Length;
return token.ToString(); 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(); _fileStream.Dispose();
_memoryFile.Dispose(); _memoryFile.Dispose();
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepUncertainElement.Parse.cs" // file="StepUncertainEntity.Parse"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 StgSharp.Script.Express;
using System; using System;
@@ -41,40 +38,38 @@ namespace StgSharp.Model.Step
public partial class StepUninitializedEntity public partial class StepUninitializedEntity
{ {
private static StepRepresentationItem ConvertSimpleEntity( private static StepRepresentationItem ConvertSimpleEntity(StepModel context, ExpFunctionCallingNode calling)
StepModel context,
ExpFunctionCallingNode calling )
{ {
string name = calling.FunctionCaller.Name; string name = calling.FunctionCaller.Name;
return name switch return name switch
{ {
ExpressStepUtil.AdvancedFaceText => StepAdvancedFace.FromSyntax( ExpressStepUtil.AdvancedFaceText => StepAdvancedFace.FromSyntax(
context, calling.Right ), context, calling.Right),
ExpressStepUtil.Axis2Placement2DText => StepAxis2Placement2D.FromSyntax( ExpressStepUtil.Axis2Placement2DText => StepAxis2Placement2D.FromSyntax(
context, calling.Right ), context, calling.Right),
ExpressStepUtil.Axis2Placement3DText => StepAxis2Placement3D.FromSyntax( ExpressStepUtil.Axis2Placement3DText => StepAxis2Placement3D.FromSyntax(
context, calling.Right ), context, calling.Right),
ExpressStepUtil.BSplineCurveWithKnotsText => StepBSplineCurveWithKnots.FromSyntax( ExpressStepUtil.BSplineCurveWithKnotsText => StepBSplineCurveWithKnots.FromSyntax(
context, calling.Right ), context, calling.Right),
ExpressStepUtil.CartesianPointText => StepCartesianPoint.FromSyntax( ExpressStepUtil.CartesianPointText => StepCartesianPoint.FromSyntax(
context, calling.Right ), context, calling.Right),
ExpressStepUtil.CircleText => StepCircle.FromSyntax( context, calling.Right ), ExpressStepUtil.CircleText => StepCircle.FromSyntax(context, calling.Right),
ExpressStepUtil.CylindricalSurfaceText => StepCylindricalSurface.FromSyntax( ExpressStepUtil.CylindricalSurfaceText => StepCylindricalSurface.FromSyntax(
context, calling.Right ), context, calling.Right),
ExpressStepUtil.DirectionText => StepDirection.FromSyntax( context, calling.Right ), ExpressStepUtil.DirectionText => StepDirection.FromSyntax(context, calling.Right),
ExpressStepUtil.EdgeCurveText => StepEdgeCurve.FromSyntax( context, calling.Right ), ExpressStepUtil.EdgeCurveText => StepEdgeCurve.FromSyntax(context, calling.Right),
ExpressStepUtil.EdgeLoopText => StepEdgeLoop.FromSyntax( context, calling.Right ), ExpressStepUtil.EdgeLoopText => StepEdgeLoop.FromSyntax(context, calling.Right),
ExpressStepUtil.EllipseText => StepEllipse.FromSyntax( context, calling.Right ), ExpressStepUtil.EllipseText => StepEllipse.FromSyntax(context, calling.Right),
ExpressStepUtil.FaceBoundText => StepFaceBound.FromSyntax( context, calling.Right ), ExpressStepUtil.FaceBoundText => StepFaceBound.FromSyntax(context, calling.Right),
ExpressStepUtil.FaceOuterBoundText => StepFaceOuterBound.FromSyntax( ExpressStepUtil.FaceOuterBoundText => StepFaceOuterBound.FromSyntax(
context, calling.Right ), context, calling.Right),
ExpressStepUtil.LineText => StepLine.FromSyntax( context, calling.Right ), ExpressStepUtil.LineText => StepLine.FromSyntax(context, calling.Right),
ExpressStepUtil.OrientedEdgeText => StepOrientedEdge.FromSyntax( ExpressStepUtil.OrientedEdgeText => StepOrientedEdge.FromSyntax(
context, calling.Right ), context, calling.Right),
ExpressStepUtil.PlaneText => StepPlane.FromSyntax( context, calling.Right ), ExpressStepUtil.PlaneText => StepPlane.FromSyntax(context, calling.Right),
ExpressStepUtil.VectorText => StepVector.FromSyntax( context, calling.Right ), ExpressStepUtil.VectorText => StepVector.FromSyntax(context, calling.Right),
ExpressStepUtil.VertexPointText => StepVertexPoint.FromSyntax( ExpressStepUtil.VertexPointText => StepVertexPoint.FromSyntax(
context, calling.Right ), context, calling.Right),
_ => throw new StepEntityUnsupportedException() _ => throw new StepEntityUnsupportedException()
}; };
} }
+72 -75
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepUncertainEntity.cs" // file="StepUncertainEntity"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.CSharp.Syntax;
using Microsoft.CodeAnalysis.Operations; using Microsoft.CodeAnalysis.Operations;
@@ -60,13 +57,13 @@ namespace StgSharp.Model.Step
private ExpSyntaxNode _data; private ExpSyntaxNode _data;
internal StepUninitializedEntity( StepModel model, int id ) internal StepUninitializedEntity(StepModel model, int id)
{ {
Context = model; Context = model;
Id = id; Id = id;
} }
internal StepUninitializedEntity( StepModel model, StepEntityLabel label ) internal StepUninitializedEntity(StepModel model, StepEntityLabel label)
{ {
Context = model; Context = model;
Label = label; Label = label;
@@ -76,12 +73,12 @@ namespace StgSharp.Model.Step
StepModel model, StepModel model,
int id, int id,
ExpSyntaxNode initialization, ExpSyntaxNode initialization,
IEnumerable<int> dependency ) IEnumerable<int> dependency)
{ {
Context = model; Context = model;
Id = id; Id = id;
_data = initialization; _data = initialization;
if( dependency == null ) if (dependency == null)
{ {
Dependencies = []; Dependencies = [];
} else } else
@@ -112,38 +109,38 @@ namespace StgSharp.Model.Step
} }
return null; return null;
/**/ /**/
if( _data is ExpFunctionCallingNode initNode ) if (_data is ExpFunctionCallingNode initNode)
{ {
string name = initNode.FunctionCaller.Name; string name = initNode.FunctionCaller.Name;
StepEntityBase? entity = ConvertSimpleEntity( Context, initNode ); StepEntityBase? entity = ConvertSimpleEntity(Context, initNode);
if( entity is null ) if (entity is null)
{ {
UnsupportedItemTypes.Add( name ); UnsupportedItemTypes.Add(name);
return null; return null;
} }
return entity; 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!; 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(); throw new InvalidCastException();
} }
StepRepresentationItem? e = ConvertSimpleEntity( Context, init ); StepRepresentationItem? e = ConvertSimpleEntity(Context, init);
if( e is null ) if (e is null)
{ {
//throw new NotImplementedException( $"Unknown entity type in sequence {Id}" ); // throw new NotImplementedException( $"Unknown entity type in sequence {Id}" );
return null; return null;
} }
if( entity is null ) if (entity is null)
{ {
entity = e; entity = e;
} else } else
{ {
entity = StepDataParser.Implement( entity, e ); entity = StepDataParser.Implement(entity, e);
} }
} }
return entity; return entity;
@@ -151,54 +148,54 @@ namespace StgSharp.Model.Step
return null; return null;
} else } 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; ExpSyntaxNode node = sequence.Expression;
if( node is not ExpBinaryOperatorNode assign ) { if (node is not ExpBinaryOperatorNode assign) {
throw new ExpInvalidSyntaxException( "Not an assign expression " ); throw new ExpInvalidSyntaxException("Not an assign expression ");
} }
StepEntityInstanceNode? idNode = assign.Left as StepEntityInstanceNode; StepEntityInstanceNode? idNode = assign.Left as StepEntityInstanceNode;
if( idNode!.Id != this.Id ) { if (idNode!.Id != this.Id) {
throw new InvalidOperationException(); 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; ExpSyntaxNode initNode;
if( ( assign.Right is ExpFunctionCallingNode f ) ) if ((assign.Right is ExpFunctionCallingNode f))
{ {
initNode = assign.Right; initNode = assign.Right;
ExpEntityTypeName = f.FunctionCaller.Name; ExpEntityTypeName = f.FunctionCaller.Name;
} else if( ( assign.Right is StepComplexEntityNode c ) ) } else if ((assign.Right is StepComplexEntityNode c))
{ {
initNode = assign.Right; initNode = assign.Right;
ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator( c.Right, false ); ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator(c.Right, false);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append( "Complex entity initialization: " ); sb.Append("Complex entity initialization: ");
int count = 0; int count = 0;
while( enumerator.MoveNext() ) while (enumerator.MoveNext())
{ {
if( count > 0 ) { if (count > 0) {
sb.Append( " <-> " ); sb.Append(" <-> ");
} }
f = ( enumerator.Current as ExpFunctionCallingNode )!; f = (enumerator.Current as ExpFunctionCallingNode)!;
sb.Append( $"{f.FunctionCaller.Name}" ); sb.Append($"{f.FunctionCaller.Name}");
count++; count++;
} }
ExpEntityTypeName = sb.ToString(); ExpEntityTypeName = sb.ToString();
} else } else
{ {
throw new ExpInvalidSyntaxException( 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; return;
} }
_data = initNode!; _data = initNode!;
@@ -207,32 +204,32 @@ namespace StgSharp.Model.Step
void IConvertableToPipelineNode.NodeMain( void IConvertableToPipelineNode.NodeMain(
in Dictionary<string, PipelineNodeInPort> input, in Dictionary<string, PipelineNodeInPort> input,
in Dictionary<string, PipelineNodeOutPort> output ) in Dictionary<string, PipelineNodeOutPort> output)
{ {
try try
{ {
StepEntityBase? entity = ConvertToAccurate(); StepEntityBase? entity = ConvertToAccurate();
if( entity is not null ) if (entity is not null)
{ {
entity.FromInstance( this ); entity.FromInstance(this);
Context.ReplaceEntity( this, entity ); Context.ReplaceEntity(this, entity);
} }
} }
catch( StepEntityUnsupportedException ) { } catch (StepEntityUnsupportedException) { }
catch( Exception ex ) 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 ); // Context.ReplaceEntity( this, entity );
PipelineNodeOutPort.SkipAll( output ); PipelineNodeOutPort.SkipAll(output);
} }
IEnumerable<string> IConvertableToPipelineNode.InputPortName => [InName]; IEnumerable<string> IConvertableToPipelineNode.InputPortName => [ InName ];
PipelineNodeOperation IConvertableToPipelineNode.Operation => ( this as IConvertableToPipelineNode ).NodeMain; PipelineNodeOperation IConvertableToPipelineNode.Operation => (this as IConvertableToPipelineNode).NodeMain;
IEnumerable<string> IConvertableToPipelineNode.OutputPortName => [OutName]; IEnumerable<string> IConvertableToPipelineNode.OutputPortName => [ OutName ];
} }
} }
+25 -28
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepUnsupportedEntity.cs" // file="StepUnsupportedEntity"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 StgSharp.Script.Express;
using System; using System;
@@ -43,7 +40,7 @@ namespace StgSharp.Model.Step
private ExpSyntaxNode _initSequence; 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; Id = id;
Name = name; Name = name;
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepComplexEntityNode.cs" // file="StepComplexEntityNode"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 StgSharp.Script.Express;
using System; using System;
@@ -43,8 +40,8 @@ namespace StgSharp.Model.Step
private ExpSyntaxNode _begin; private ExpSyntaxNode _begin;
private StepComplexEntityNode( ExpSyntaxNode node ) private StepComplexEntityNode(ExpSyntaxNode node)
: base( node.Source ) : base(node.Source)
{ {
_begin = node; _begin = node;
} }
@@ -55,12 +52,12 @@ namespace StgSharp.Model.Step
public override IExpElementSource EqualityTypeConvert => StepEntityType.Source; public override IExpElementSource EqualityTypeConvert => StepEntityType.Source;
public static StepComplexEntityNode FromTuple( ExpSyntaxNode node ) public static StepComplexEntityNode FromTuple(ExpSyntaxNode node)
{ {
if( node is not ExpTupleNode tuple ) { if (node is not ExpTupleNode tuple) {
throw new ExpInvalidSyntaxException( "Node to convert is not a complex" ); throw new ExpInvalidSyntaxException("Node to convert is not a complex");
} }
return new StepComplexEntityNode( tuple.Right ); return new StepComplexEntityNode(tuple.Right);
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepEntityInitCaller.cs" // file="StepEntityInitCaller"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.CSharp.Syntax;
using StgSharp.Script; using StgSharp.Script;
@@ -47,19 +44,19 @@ namespace StgSharp.Model.Step
private static Dictionary<string, StepEntityInitCaller> _callers = new(); private static Dictionary<string, StepEntityInitCaller> _callers = new();
private StepEntityInitCaller( string name ) private StepEntityInitCaller(string name)
: base( name, null ) : base(name, null)
{ {
ReturningType = StepEntityType.Source; 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; return caller;
} }
caller = new StepEntityInitCaller( name ); caller = new StepEntityInitCaller(name);
_callers.Add( name, caller ); _callers.Add(name, caller);
return caller; return caller;
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepEntityInstanceNode.cs" // file="StepEntityInstanceNode"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -44,7 +41,7 @@ namespace StgSharp.Model.Step
public class StepEntityInstanceNode : ExpSyntaxNode public class StepEntityInstanceNode : ExpSyntaxNode
{ {
private StepEntityInstanceNode( Token source ) : base( source ) { } private StepEntityInstanceNode(Token source) : base(source) { }
public override ExpSyntaxNode Left => Empty; public override ExpSyntaxNode Left => Empty;
@@ -54,38 +51,38 @@ namespace StgSharp.Model.Step
public int Id { get; init; } public int Id { get; init; }
public static StepEntityInstanceNode Register( Token t ) public static StepEntityInstanceNode Register(Token t)
{ {
if( t.Value[ 0 ] != '#' ) { if (t.Value[0] != '#') {
throw new ExpInvalidSyntaxException( "Entity label in STEP should be # + number" ); 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; return node;
} }
public static StepEntityInstanceNode RegisterNull( Token t ) public static StepEntityInstanceNode RegisterNull(Token t)
{ {
if( t.Value != "$" ) { if (t.Value != "$") {
throw new ExpInvalidSyntaxException( 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, Id = 0,
}; };
return node; return node;
} }
public static StepEntityInstanceNode RegisterRuntimeInference( Token t ) public static StepEntityInstanceNode RegisterRuntimeInference(Token t)
{ {
if( t.Value != "*" ) { if (t.Value != "*") {
throw new ExpInvalidSyntaxException( 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, Id = -1,
}; };
@@ -97,9 +94,9 @@ namespace StgSharp.Model.Step
internal class StepEntityType : ExpTypeSource 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");
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="StepExpEnumValueNode.cs" // file="StepExpEnumValueNode"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -42,8 +39,8 @@ namespace StgSharp.Model.Step
internal class StepExpEnumValueNode : ExpSyntaxNode internal class StepExpEnumValueNode : ExpSyntaxNode
{ {
public StepExpEnumValueNode( Token source ) public StepExpEnumValueNode(Token source)
: base( source ) : base(source)
{ {
EnumValue = source.Value; EnumValue = source.Value;
} }
+26 -29
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="AbstractSyntaxTree.cs" // file="AbstractSyntaxTree"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.Collections;
using System; using System;
@@ -51,9 +48,9 @@ namespace StgSharp.Script
public TNode Root => _root; public TNode Root => _root;
public bool Contains( TNode node ) public bool Contains(TNode node)
{ {
return _allToken.Contains( node ); return _allToken.Contains(node);
} }
} }
+46 -49
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="CodeLineHelper.cs" // file="CodeLineHelper"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -37,66 +34,66 @@ namespace StgSharp.Script
public static class CodeLineHelper 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 ) { if (line == null) {
throw new ArgumentNullException( nameof( line ) ); throw new ArgumentNullException(nameof(line));
} }
if( startIndex < 0 || startIndex >= line.Length ) { if (startIndex < 0 || startIndex >= line.Length) {
throw new ArgumentOutOfRangeException( nameof( startIndex ) ); throw new ArgumentOutOfRangeException(nameof(startIndex));
} }
ReadOnlySpan<char> sourceSpan = line.AsSpan(); ReadOnlySpan<char> sourceSpan = line.AsSpan();
ReadOnlySpan<char> subSpan = sourceSpan.Slice( startIndex ); ReadOnlySpan<char> subSpan = sourceSpan.Slice(startIndex);
int start = 0; int start = 0;
while( start < subSpan.Length && char.IsWhiteSpace( subSpan[ start ] ) ) { while (start < subSpan.Length && char.IsWhiteSpace(subSpan[start])) {
start++; start++;
} }
int end = subSpan.Length - 1; int end = subSpan.Length - 1;
while( end >= start && char.IsWhiteSpace( subSpan[ end ] ) ) { while (end >= start && char.IsWhiteSpace(subSpan[end])) {
end--; end--;
} }
if( start > end ) { if (start > end) {
return string.Empty; return string.Empty;
} }
int finalLength = end - start + 1; 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 ) { if (line == null) {
throw new ArgumentNullException( nameof( line ) ); throw new ArgumentNullException(nameof(line));
} }
if( startIndex < 0 || startIndex >= line.Length ) { if (startIndex < 0 || startIndex >= line.Length) {
throw new ArgumentOutOfRangeException( nameof( startIndex ) ); throw new ArgumentOutOfRangeException(nameof(startIndex));
} }
if( length < 0 || startIndex + length > line.Length ) { if (length < 0 || startIndex + length > line.Length) {
throw new ArgumentOutOfRangeException( nameof( length ) ); throw new ArgumentOutOfRangeException(nameof(length));
} }
ReadOnlySpan<char> sourceSpan = line.AsSpan(); ReadOnlySpan<char> sourceSpan = line.AsSpan();
ReadOnlySpan<char> subSpan = sourceSpan.Slice( startIndex, length ); ReadOnlySpan<char> subSpan = sourceSpan.Slice(startIndex, length);
int start = 0; int start = 0;
while( start < subSpan.Length && char.IsWhiteSpace( subSpan[ start ] ) ) { while (start < subSpan.Length && char.IsWhiteSpace(subSpan[start])) {
start++; start++;
} }
int end = subSpan.Length - 1; int end = subSpan.Length - 1;
while( end >= start && char.IsWhiteSpace( subSpan[ end ] ) ) { while (end >= start && char.IsWhiteSpace(subSpan[end])) {
end--; end--;
} }
if( start > end ) { if (start > end) {
return string.Empty; return string.Empty;
} }
int finalLength = end - start + 1; int finalLength = end - start + 1;
return new string( subSpan.Slice( start, finalLength ) ); return new string(subSpan.Slice(start, finalLength));
} }
} }
+26 -33
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="CompileDepthState.cs" // file="CompileDepthState"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
@@ -47,18 +44,14 @@ namespace StgSharp.Script
public class CompileDepthMark public class CompileDepthMark
{ {
internal CompileDepthMark( int operatorBegin, int operandBegin, int usage ) internal CompileDepthMark(int operatorBegin, int operandBegin, int usage)
{ {
OperatorBegin = operatorBegin; OperatorBegin = operatorBegin;
OperandBegin = operandBegin; OperandBegin = operandBegin;
Usage = usage; Usage = usage;
} }
internal CompileDepthMark( internal CompileDepthMark(int operatorBegin, int operandBegin, int usage, ICompileDepthState stateCache)
int operatorBegin,
int operandBegin,
int usage,
ICompileDepthState stateCache )
{ {
OperatorBegin = operatorBegin; OperatorBegin = operatorBegin;
OperandBegin = operandBegin; OperandBegin = operandBegin;
+91 -98
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="CompileStack.cs" // file="CompileStack"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.Collections;
using System; using System;
@@ -55,14 +52,14 @@ namespace StgSharp.Script
); );
private RandomAccessibleStack<OperandIndex> _isNode = new RandomAccessibleStack<OperandIndex>( private RandomAccessibleStack<OperandIndex> _isNode = new RandomAccessibleStack<OperandIndex>(
8 ); 8);
private Stack<Stack<TNode>> _statementCache = new Stack<Stack<TNode>>(); private Stack<Stack<TNode>> _statementCache = new Stack<Stack<TNode>>();
private TNode _lastNode; private TNode _lastNode;
public CompileStack() public CompileStack()
{ {
_depthStack.Push( new CompileDepthMark( 0, 0, 0, null! ) ); _depthStack.Push(new CompileDepthMark(0, 0, 0, null!));
_statementCache.Push( new Stack<TNode>() ); _statementCache.Push(new Stack<TNode>());
} }
public bool IsLastAddedOperator { get; private set; } public bool IsLastAddedOperator { get; private set; }
@@ -99,86 +96,82 @@ namespace StgSharp.Script
Stack<TNode> statementsInDepth = _statementCache.Pop(); Stack<TNode> 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 ]; OperandIndex index = _isNode[i];
if( index.IsNode ) if (index.IsNode)
{ {
operandNode = _nodeArray[ index.Index ]; operandNode = _nodeArray[index.Index];
operandToken = Token.Empty; operandToken = Token.Empty;
return true; return true;
} else } else
{ {
operandToken = _tokenArray[ index.Index ]; operandToken = _tokenArray[index.Index];
operandNode = default!; operandNode = default!;
return false; return false;
} }
} }
public bool GetOperandAt( public bool GetOperandAt(CompileDepthMark depth, Index i, out Token operandToken, out TNode operandNode)
CompileDepthMark depth,
Index i,
out Token operandToken,
out TNode operandNode )
{ {
OperandIndex index = _isNode[ i ]; OperandIndex index = _isNode[i];
_depthStack.Contains( depth ); _depthStack.Contains(depth);
if( index.IsNode ) if (index.IsNode)
{ {
operandNode = _nodeArray[ index.Index ]; operandNode = _nodeArray[index.Index];
operandToken = Token.Empty; operandToken = Token.Empty;
return true; return true;
} else } else
{ {
operandToken = _tokenArray[ index.Index ]; operandToken = _tokenArray[index.Index];
operandNode = default!; operandNode = default!;
return false; return false;
} }
} }
public CompileDepthMark IncreaseDepth( int usage ) public CompileDepthMark IncreaseDepth(int usage)
{ {
CompileDepthMark mark = CompileDepthMark mark =
new CompileDepthMark( OperatorCount, OperandCount, usage ); new CompileDepthMark(OperatorCount, OperandCount, usage);
_depthStack.Push( mark ); _depthStack.Push(mark);
_statementCache.Push( new Stack<TNode>() ); _statementCache.Push(new Stack<TNode>());
return mark; return mark;
} }
public TNode PackAllStatements() public TNode PackAllStatements()
{ {
if( StatementsInDepth.Count == 0 ) { if (StatementsInDepth.Count == 0) {
return TNode.Empty; return TNode.Empty;
} }
TNode end = StatementsInDepth.Peek(); TNode end = StatementsInDepth.Peek();
TNode first = end; TNode first = end;
while( StatementsInDepth.Count > 0 ) while (StatementsInDepth.Count > 0)
{ {
first = StatementsInDepth.Pop(); first = StatementsInDepth.Pop();
end.PrependNode( first ); end.PrependNode(first);
end = first; end = first;
} }
return 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; t = Token.Empty;
n = TNode.Empty; n = TNode.Empty;
return false; return false;
} }
if( _isNode.Pop().IsNode ) if (_isNode.Pop().IsNode)
{ {
t = Token.Empty; t = Token.Empty;
n = _nodeArray[ _nodeCount - 1 ]; n = _nodeArray[_nodeCount - 1];
return true; return true;
} else } else
{ {
t = _tokenArray[ _tokenCount - 1 ]; t = _tokenArray[_tokenCount - 1];
n = TNode.Empty; n = TNode.Empty;
return false; return false;
} }
@@ -186,28 +179,28 @@ namespace StgSharp.Script
public Token PeekOperator() public Token PeekOperator()
{ {
if( OperatorAheadOfDepth > 0 ) { if (OperatorAheadOfDepth > 0) {
return _operatorArray[ _operatorCount - 1 ]; return _operatorArray[_operatorCount - 1];
} }
return Token.Empty; 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; t = Token.Empty;
n = TNode.Empty; n = TNode.Empty;
return false; return false;
} }
if( _isNode.Pop().IsNode ) if (_isNode.Pop().IsNode)
{ {
t = Token.Empty; t = Token.Empty;
n = _nodeArray[ --_nodeCount ]; n = _nodeArray[--_nodeCount];
return true; return true;
} else } else
{ {
t = _tokenArray[ --_tokenCount ]; t = _tokenArray[--_tokenCount];
n = TNode.Empty; n = TNode.Empty;
return false; return false;
} }
@@ -215,122 +208,122 @@ namespace StgSharp.Script
public Token PopOperator() public Token PopOperator()
{ {
if( OperatorAheadOfDepth > 0 ) if (OperatorAheadOfDepth > 0)
{ {
_operatorCount--; _operatorCount--;
return _operatorArray[ _operatorCount ]; return _operatorArray[_operatorCount];
} }
return Token.Empty; return Token.Empty;
} }
public void PushOperand( TNode node ) public void PushOperand(TNode node)
{ {
if( _nodeArray.Length == _nodeCount ) { if (_nodeArray.Length == _nodeCount) {
Array.Resize( ref _nodeArray, _nodeArray.Length * 2 ); Array.Resize(ref _nodeArray, _nodeArray.Length * 2);
} }
_nodeArray[ _nodeCount ] = node; _nodeArray[_nodeCount] = node;
_isNode.Push( new( true, _nodeCount ) ); _isNode.Push(new(true, _nodeCount));
_nodeCount++; _nodeCount++;
IsLastAddedOperator = false; IsLastAddedOperator = false;
} }
public void PushOperand( Token token ) public void PushOperand(Token token)
{ {
if( _tokenArray.Length == _tokenCount ) { if (_tokenArray.Length == _tokenCount) {
Array.Resize( ref _tokenArray, _tokenArray.Length * 2 ); Array.Resize(ref _tokenArray, _tokenArray.Length * 2);
} }
_tokenArray[ _tokenCount ] = token; _tokenArray[_tokenCount] = token;
_isNode.Push( new( false, _tokenCount ) ); _isNode.Push(new(false, _tokenCount));
_tokenCount++; _tokenCount++;
IsLastAddedOperator = false; IsLastAddedOperator = false;
} }
public void PushOperator( Token token ) public void PushOperator(Token token)
{ {
if( _operatorArray.Length == _operatorCount ) { if (_operatorArray.Length == _operatorCount) {
Array.Resize( ref _operatorArray, _operatorArray.Length * 2 ); Array.Resize(ref _operatorArray, _operatorArray.Length * 2);
} }
_operatorArray[ _operatorCount ] = token; _operatorArray[_operatorCount] = token;
_operatorCount++; _operatorCount++;
IsLastAddedOperator = true; IsLastAddedOperator = true;
} }
public T StateOfCurrentDepth<T>() where T: class, ICompileDepthState public T StateOfCurrentDepth<T>() 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; t = Token.Empty;
n = TNode.Empty; n = TNode.Empty;
isNode = false; isNode = false;
return false; return false;
} }
if( _isNode.Pop().IsNode ) if (_isNode.Pop().IsNode)
{ {
t = Token.Empty; t = Token.Empty;
n = _nodeArray[ _nodeCount - 1 ]; n = _nodeArray[_nodeCount - 1];
isNode = true; isNode = true;
return true; return true;
} else } else
{ {
t = _tokenArray[ _tokenCount - 1 ]; t = _tokenArray[_tokenCount - 1];
n = TNode.Empty; n = TNode.Empty;
isNode = false; isNode = false;
return 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; return true;
} }
op = Token.Empty; op = Token.Empty;
return false; 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; t = Token.Empty;
n = TNode.Empty; n = TNode.Empty;
isNode = false; isNode = false;
return false; return false;
} }
if( _isNode.Pop().IsNode ) if (_isNode.Pop().IsNode)
{ {
t = Token.Empty; t = Token.Empty;
n = _nodeArray[ --_nodeCount ]; n = _nodeArray[--_nodeCount];
isNode = true; isNode = true;
return true; return true;
} else } else
{ {
t = _tokenArray[ --_tokenCount ]; t = _tokenArray[--_tokenCount];
n = TNode.Empty; n = TNode.Empty;
isNode = false; isNode = false;
return true; 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; return true;
} }
op = Token.Empty; op = Token.Empty;
return false; return false;
} }
private record struct OperandIndex( bool IsNode, int Index ); private record struct OperandIndex(bool IsNode, int Index);
} }
} }
+26 -29
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="IScriptSourceProvider.cs" // file="IScriptSourceProvider"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -45,7 +42,7 @@ namespace StgSharp.Script
string ReadLine(); string ReadLine();
string ReadLine( out int position ); string ReadLine(out int position);
/// <summary> /// <summary>
/// Return part of current provider. /// Return part of current provider.
@@ -56,7 +53,7 @@ namespace StgSharp.Script
/// <returns> /// <returns>
/// ///
/// </returns> /// </returns>
public IScriptSourceProvider Slice( int location, int count ); public IScriptSourceProvider Slice(int location, int count);
} }
} }
+25 -28
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="IScriptTokenReader.cs" // file="IScriptTokenReader"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 namespace StgSharp.Script
{ {
public interface IScriptTokenReader public interface IScriptTokenReader
@@ -37,7 +34,7 @@ namespace StgSharp.Script
Token ReadToken(); Token ReadToken();
bool TryReadToken( out Token t ); bool TryReadToken(out Token t);
} }
} }
+25 -28
View File
@@ -1,39 +1,36 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ISyntaxAnalyzer.cs" // file="ISyntaxAnalyzer"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 namespace StgSharp.Script
{ {
public interface ISyntaxAnalyzer public interface ISyntaxAnalyzer
{ {
void AppendToken( Token t ); void AppendToken(Token t);
} }
} }
+27 -31
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ISyntaxNode.cs" // file="ISyntaxNode"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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.Collections;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -39,8 +36,7 @@ using System.Text;
namespace StgSharp.Script namespace StgSharp.Script
{ {
public interface ISyntaxNode<TNode, TType> where TNode: ISyntaxNode<TNode, TType> public interface ISyntaxNode<TNode, TType> where TNode: ISyntaxNode<TNode, TType> where TType: ITypeSource<TType>
where TType: ITypeSource<TType>
{ {
long NodeFlag { get; } long NodeFlag { get; }
@@ -61,9 +57,9 @@ namespace StgSharp.Script
TType EqualityTypeConvert { get; } TType EqualityTypeConvert { get; }
void AppendNode( TNode nextToken ); void AppendNode(TNode nextToken);
void PrependNode( TNode previusNode ); void PrependNode(TNode previusNode);
} }
} }
+25 -28
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ITypeSource.cs" // file="ITypeSource"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -39,7 +36,7 @@ namespace StgSharp.Script
public interface ITypeSource<in TConvert> where TConvert: ITypeSource<TConvert> public interface ITypeSource<in TConvert> where TConvert: ITypeSource<TConvert>
{ {
bool IsConvertable( TConvert targetType ); bool IsConvertable(TConvert targetType);
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ScriptSourceTransmitter.cs" // file="ScriptSourceTransmitter"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections; using System.Collections;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@@ -46,7 +43,7 @@ namespace StgSharp.Script
{ {
private static ScriptSourceTransmitter _empty = new ScriptSourceTransmitter( private static ScriptSourceTransmitter _empty = new ScriptSourceTransmitter(
string.Empty, 0, 0 ) string.Empty, 0, 0)
{ {
_cache = [], _cache = [],
_buffer = [] _buffer = []
@@ -58,14 +55,14 @@ namespace StgSharp.Script
private List<string> _cache; private List<string> _cache;
private readonly string _completeMark; private readonly string _completeMark;
internal ScriptSourceTransmitter( string[] buffer, int start ) internal ScriptSourceTransmitter(string[] buffer, int start)
{ {
_buffer = buffer; _buffer = buffer;
_begin = start; _begin = start;
_isWriting = false; _isWriting = false;
} }
public ScriptSourceTransmitter( string endMark, int start ) public ScriptSourceTransmitter(string endMark, int start)
{ {
_cache = new List<string>(); _cache = new List<string>();
_completeMark = endMark; _completeMark = endMark;
@@ -73,16 +70,15 @@ namespace StgSharp.Script
_index = 0; _index = 0;
} }
public ScriptSourceTransmitter( string endMark, int start, int capacity ) public ScriptSourceTransmitter(string endMark, int start, int capacity)
{ {
_cache = new List<string>( capacity ); _cache = new List<string>(capacity);
_completeMark = endMark; _completeMark = endMark;
_begin = start; _begin = start;
_index = 0; _index = 0;
} }
public bool IsEmpty => _isWriting ? public bool IsEmpty => _isWriting ? (_cache.Count == 0) : (_buffer.Length == 0) || (_index >= _buffer.Length);
( _cache.Count == 0 ) : ( _buffer.Length == 0 ) || ( _index >= _buffer.Length );
public bool IsFrozen => !_isWriting; public bool IsFrozen => !_isWriting;
@@ -92,7 +88,7 @@ namespace StgSharp.Script
public void EndWriting() public void EndWriting()
{ {
if( !_isWriting ) { if (!_isWriting) {
return; return;
} }
_isWriting = false; _isWriting = false;
@@ -102,53 +98,53 @@ namespace StgSharp.Script
public string ReadLine() public string ReadLine()
{ {
if( _isWriting ) { if (_isWriting) {
throw new InvalidOperationException( "Cannot read before all writing operation." ); throw new InvalidOperationException("Cannot read before all writing operation.");
} }
if( _index >= _buffer.Length ) { if (_index >= _buffer.Length) {
return string.Empty; return string.Empty;
} }
string str = _buffer[ _index ]; string str = _buffer[_index];
_index++; _index++;
return str; return str;
} }
public string ReadLine( out int position ) public string ReadLine(out int position)
{ {
if( _isWriting ) { if (_isWriting) {
throw new InvalidOperationException( "Cannot read before all writing operation." ); throw new InvalidOperationException("Cannot read before all writing operation.");
} }
if( _index >= _buffer.Length ) if (_index >= _buffer.Length)
{ {
position = -1; position = -1;
return string.Empty; return string.Empty;
} }
position = _begin + _index; position = _begin + _index;
string str = _buffer[ _index ]; string str = _buffer[_index];
_index++; _index++;
return str; 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( ArgumentOutOfRangeException.ThrowIfGreaterThan(
location + count, _begin + _buffer.Length ); location + count, _begin + _buffer.Length);
return new ScriptSourceTransmitter( 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; return;
} }
if( string.Equals( _completeMark, line ) ) if (string.Equals(_completeMark, line))
{ {
EndWriting(); EndWriting();
return; return;
} }
_cache.Add( line ); _cache.Add(line);
} }
} }
+28 -31
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Token.cs" // file="Token"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -47,7 +44,7 @@ namespace StgSharp.Script
public readonly string Value; public readonly string Value;
public readonly TokenFlag Flag; 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; Value = chars;
Line = lineNumber; Line = lineNumber;
@@ -57,10 +54,10 @@ namespace StgSharp.Script
public static Token Empty => EmptyToken; public static Token Empty => EmptyToken;
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Token ReLocate( int line, int column ) public Token ReLocate(int line, int column)
{ {
return new Token( Value, line, column, Flag ); return new Token(Value, line, column, Flag);
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpBuiltinType.cs" // file="ExpBuiltinType"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 StgSharp.Data;
using System; using System;
@@ -41,8 +38,8 @@ namespace StgSharp.Script.Express
private Type _marshalType; private Type _marshalType;
internal ExpBuiltinType( string name, Type origin ) internal ExpBuiltinType(string name, Type origin)
: base( name, ScriptSourceTransmitter.Empty ) : base(name, ScriptSourceTransmitter.Empty)
{ {
_marshalType = origin; _marshalType = origin;
} }
@@ -52,7 +49,7 @@ namespace StgSharp.Script.Express
return; return;
} }
//A method convert value to CLR type // A method convert value to CLR type
//Used for direct running rather than compiling to C# code. // Used for direct running rather than compiling to C# code.
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpCollection.cs" // file="ExpCollection"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections; using System.Collections;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@@ -42,7 +39,7 @@ namespace StgSharp.Script.Express
protected internal string _accurateType; protected internal string _accurateType;
protected ExpCollectionBase( string accurateType ) protected ExpCollectionBase(string accurateType)
{ {
_accurateType = accurateType; _accurateType = accurateType;
} }
@@ -51,7 +48,7 @@ namespace StgSharp.Script.Express
public abstract int Count { get; } public abstract int Count { get; }
public override sealed IScriptSourceProvider SourceProvider => ScriptSourceTransmitter.Empty; public sealed override IScriptSourceProvider SourceProvider => ScriptSourceTransmitter.Empty;
public string MemberType public string MemberType
{ {
@@ -65,7 +62,7 @@ namespace StgSharp.Script.Express
public abstract IEnumerator<ExpElementInstance> GetEnumerator(); public abstract IEnumerator<ExpElementInstance> GetEnumerator();
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) public override bool TryGetMember(string name, out ExpSyntaxNode memberNode)
{ {
memberNode = ExpSyntaxNode.Empty; memberNode = ExpSyntaxNode.Empty;
return false; return false;
@@ -83,32 +80,32 @@ namespace StgSharp.Script.Express
private ExpElementInstance[] _collection; 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 set
{ {
if( value.TypeName != MemberType ) { if (value.TypeName != MemberType) {
throw new ExpInvalidCollectionMemberTypeException( value, this ); throw new ExpInvalidCollectionMemberTypeException(value, this);
} }
_collection[ index ] = value; _collection[index] = value;
} }
} }
public override int Count => _collection.Length; 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(); throw new NotImplementedException();
} }
public override IEnumerator<ExpElementInstance> GetEnumerator() public override IEnumerator<ExpElementInstance> GetEnumerator()
{ {
return ( ( IEnumerable<ExpElementInstance> )_collection ) return ((IEnumerable<ExpElementInstance>)_collection)
.GetEnumerator(); .GetEnumerator();
} }
@@ -120,13 +117,13 @@ namespace StgSharp.Script.Express
private ConcurrentBag<ExpElementInstance> _collection = new ConcurrentBag<ExpElementInstance>( private ConcurrentBag<ExpElementInstance> _collection = new ConcurrentBag<ExpElementInstance>(
); );
public ExpBag( string accurateType ) : base( accurateType ) { } public ExpBag(string accurateType) : base(accurateType) { }
public override int Count => _collection.Count; 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(); throw new NotImplementedException();
} }
@@ -143,13 +140,13 @@ namespace StgSharp.Script.Express
private List<ExpElementInstance> _collection = new List<ExpElementInstance>(); private List<ExpElementInstance> _collection = new List<ExpElementInstance>();
public ExpList( string accurateType ) : base( accurateType ) { } public ExpList(string accurateType) : base(accurateType) { }
public override int Count => _collection.Count; 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(); throw new NotImplementedException();
} }
@@ -166,28 +163,28 @@ namespace StgSharp.Script.Express
private HashSet<ExpElementInstance> _collection = new(); private HashSet<ExpElementInstance> _collection = new();
public ExpSet( string accurateType ) : base( accurateType ) { } public ExpSet(string accurateType) : base(accurateType) { }
public override int Count => _collection.Count; 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 ) { if (token.TypeName != MemberType) {
throw new ExpInvalidCollectionMemberTypeException( token, this ); 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(); throw new NotImplementedException();
} }
public override sealed IEnumerator<ExpElementInstance> GetEnumerator() public sealed override IEnumerator<ExpElementInstance> GetEnumerator()
{ {
return ( ( IEnumerable<ExpElementInstance> )_collection ) return ((IEnumerable<ExpElementInstance>)_collection)
.GetEnumerator(); .GetEnumerator();
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpCollectionInstance.cs" // file="ExpCollectionInstance"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -40,7 +37,7 @@ namespace StgSharp.Script.Express
protected internal (int min, int max) _range; protected internal (int min, int max) _range;
protected internal ExpElementType _memberType; protected internal ExpElementType _memberType;
protected ExpCollectionInstanceBase( Token source ) : base( source ) { } protected ExpCollectionInstanceBase(Token source) : base(source) { }
public abstract ExpCollectionBase CollectionValue { get; } public abstract ExpCollectionBase CollectionValue { get; }
@@ -64,8 +61,8 @@ namespace StgSharp.Script.Express
private ExpSet _collection; private ExpSet _collection;
public ExpSetInstance( Token source, ExpSet set ) public ExpSetInstance(Token source, ExpSet set)
: base( source ) : base(source)
{ {
_collection = set; _collection = set;
} }
@@ -82,8 +79,8 @@ namespace StgSharp.Script.Express
private ExpBag _collection; private ExpBag _collection;
public ExpBagInstance( Token source, ExpBag bag ) public ExpBagInstance(Token source, ExpBag bag)
: base( source ) : base(source)
{ {
_collection = bag; _collection = bag;
} }
@@ -100,8 +97,8 @@ namespace StgSharp.Script.Express
private ExpList _collection; private ExpList _collection;
public ExpListInstance( Token source, ExpList list ) public ExpListInstance(Token source, ExpList list)
: base( source ) : base(source)
{ {
_collection = list; _collection = list;
} }
@@ -118,8 +115,8 @@ namespace StgSharp.Script.Express
private ExpArray _collection; private ExpArray _collection;
public ExpArrayInstance( Token source, ExpArray array ) public ExpArrayInstance(Token source, ExpArray array)
: base( source ) : base(source)
{ {
_collection = array; _collection = array;
} }
+42 -45
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpLogic.cs" // file="ExpLogic"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@@ -47,14 +44,14 @@ namespace StgSharp.Script.Express
public struct ExpLogic 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 True = new ExpLogic(ExpLogicValue.True);
public static readonly ExpLogic Unknown = new ExpLogic( ExpLogicValue.Unknown ); public static readonly ExpLogic Unknown = new ExpLogic(ExpLogicValue.Unknown);
private readonly ExpLogicValue _value; private readonly ExpLogicValue _value;
public ExpLogic( ExpLogicValue value ) public ExpLogic(ExpLogicValue value)
{ {
_value = value; _value = value;
} }
@@ -65,7 +62,7 @@ namespace StgSharp.Script.Express
public bool IsUnknown => _value == ExpLogicValue.Unknown; public bool IsUnknown => _value == ExpLogicValue.Unknown;
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool ToBoolean() public bool ToBoolean()
{ {
return _value == ExpLogicValue.True; return _value == ExpLogicValue.True;
@@ -73,11 +70,11 @@ namespace StgSharp.Script.Express
public override string ToString() => _value.ToString(); public override string ToString() => _value.ToString();
public static bool TryParse( ReadOnlySpan<char> value, out ExpLogic result ) public static bool TryParse(ReadOnlySpan<char> value, out ExpLogic result)
{ {
if( Enum.TryParse<ExpLogicValue>( value, out ExpLogicValue e ) ) if (Enum.TryParse<ExpLogicValue>(value, out ExpLogicValue e))
{ {
result = new ExpLogic( e ); result = new ExpLogic(e);
return true; return true;
} }
result = default; result = default;
@@ -85,19 +82,19 @@ namespace StgSharp.Script.Express
} }
// NOT ! // NOT !
public static ExpLogic operator !( ExpLogic a ) public static ExpLogic operator !(ExpLogic a)
{ {
return a.IsTrue ? False : a.IsFalse ? True : Unknown; return a.IsTrue ? False : a.IsFalse ? True : Unknown;
} }
// AND & // 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; return False;
} }
if( a.IsUnknown || b.IsUnknown ) { if (a.IsUnknown || b.IsUnknown) {
return Unknown; return Unknown;
} }
@@ -105,23 +102,23 @@ namespace StgSharp.Script.Express
} }
// XOR ^ // 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 Unknown;
} }
return ( a.IsTrue ^ b.IsTrue ) ? True : False; return (a.IsTrue ^ b.IsTrue) ? True : False;
} }
// OR | // 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; return True;
} }
if( a.IsUnknown || b.IsUnknown ) { if (a.IsUnknown || b.IsUnknown) {
return Unknown; return Unknown;
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="BuiltinType.cs" // file="BuiltinType"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="DefaultSchema.cs" // file="DefaultSchema"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections; using System.Collections;
using System.Collections.Frozen; using System.Collections.Frozen;
@@ -54,80 +51,72 @@ namespace StgSharp.Script.Express
get => _onlyInstance; get => _onlyInstance;
} }
public override void LoadFromSource( ExpSchemaSource source ) public override void LoadFromSource(ExpSchemaSource source)
{ {
return; 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; e = null;
return false; 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!; r = null!;
return false; return false;
} }
public override bool TryGetSchemaInclude( string name, out ExpSchema include ) public override bool TryGetSchemaInclude(string name, out ExpSchema include)
{ {
include = null!; include = null!;
return false; 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() internal void Init()
{ {
IEnumerable<KeyValuePair<string, ExpTypeSource>> builtinTypeSource = [ IEnumerable<KeyValuePair<string, ExpTypeSource>> builtinTypeSource = [ new KeyValuePair<string, ExpTypeSource>(
new KeyValuePair<string, ExpTypeSource>( PoolString(Keyword.Integer),
PoolString( Keyword.Integer ), new ExpBuiltinType(Keyword.Integer, typeof(int))), new KeyValuePair<string, ExpTypeSource>(
new ExpBuiltinType( Keyword.Integer, typeof( int ) ) ), PoolString(Keyword.Real), new ExpBuiltinType(Keyword.Real, typeof(float))), new KeyValuePair<string, ExpTypeSource>(
new KeyValuePair<string, ExpTypeSource>( PoolString(Keyword.Boolean),
PoolString( Keyword.Real ), new ExpBuiltinType( Keyword.Real, typeof( float ) ) ), new ExpBuiltinType(Keyword.Boolean, typeof(bool))), new KeyValuePair<string, ExpTypeSource>(
new KeyValuePair<string, ExpTypeSource>( PoolString(Keyword.Logical),
PoolString( Keyword.Boolean ), new ExpBuiltinType(Keyword.Logical, typeof(ExpLogic))), new KeyValuePair<string, ExpTypeSource>(
new ExpBuiltinType( Keyword.Boolean, typeof( bool ) ) ), PoolString(Keyword.String),
new KeyValuePair<string, ExpTypeSource>( new ExpBuiltinType(Keyword.String, typeof(string))), new KeyValuePair<string, ExpTypeSource>(
PoolString( Keyword.Logical ), PoolString(Keyword.Binary),
new ExpBuiltinType( Keyword.Logical, typeof( ExpLogic ) ) ), new ExpBuiltinType(Keyword.Binary, typeof(BitArray))), ];
new KeyValuePair<string, ExpTypeSource>( TypeDict = new Dictionary<string, ExpTypeSource>(builtinTypeSource,
PoolString( Keyword.String ), Multiplexer).ToFrozenDictionary();
new ExpBuiltinType( Keyword.String, typeof( string ) ) ),
new KeyValuePair<string, ExpTypeSource>(
PoolString( Keyword.Binary ),
new ExpBuiltinType( Keyword.Binary, typeof( BitArray ) ) ),
];
TypeDict = new Dictionary<string, ExpTypeSource>( builtinTypeSource,
Multiplexer ).ToFrozenDictionary();
ConstDict = new Dictionary<string, ExpElementInstance>( Multiplexer ) { ConstDict = new Dictionary<string, ExpElementInstance>(Multiplexer) {
{ PoolString( "PI" ), new ExpRealNumberNode( { PoolString("PI"), new ExpRealNumberNode(
new Token( PoolString( "PI" ), -1, -1, TokenFlag.Number ), MathF.PI, true ) }, new Token(PoolString("PI"), -1, -1, TokenFlag.Number), MathF.PI, true) },
{ PoolString( "E" ), new ExpRealNumberNode( { PoolString("E"), new ExpRealNumberNode(
new Token( PoolString( "E" ), -1, -1, TokenFlag.Number ), MathF.E, true ) }, new Token(PoolString("E"), -1, -1, TokenFlag.Number), MathF.E, true) },
}.ToFrozenDictionary(); }.ToFrozenDictionary();
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpCompile.cs" // file="ExpCompile"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 CommunityToolkit.HighPerformance.Buffers;
using StgSharp.Collections; using StgSharp.Collections;
@@ -56,7 +53,7 @@ namespace StgSharp.Script.Express
{ {
get get
{ {
if( _multiplexer == null ) { if (_multiplexer == null) {
throw new ExpCompileNotInitializedException(); throw new ExpCompileNotInitializedException();
} }
return _multiplexer; return _multiplexer;
@@ -87,34 +84,23 @@ namespace StgSharp.Script.Express
PoolKeywords(); PoolKeywords();
InitPrecedence(); InitPrecedence();
_operatorsWithLetter = [ _operatorsWithLetter = [ Keyword.Add, Keyword.Sub, Keyword.Mul, Keyword.Div, Keyword.And, Keyword.Or, Keyword.Xor, Keyword.AndOr, Keyword.Not, ];
Keyword.Add,
Keyword.Sub,
Keyword.Mul,
Keyword.Div,
Keyword.And,
Keyword.Or,
Keyword.Xor,
Keyword.AndOr,
Keyword.Not,
];
ExpSchema_Builtin.Only ExpSchema_Builtin.Only
.TryGetType( .TryGetType(
PoolString( Keyword.Integer ), out ExpTypeSource? _expInt ); PoolString(Keyword.Integer), out ExpTypeSource? _expInt);
ExpInt = _expInt; ExpInt = _expInt;
ExpSchema_Builtin.Only ExpSchema_Builtin.Only.TryGetType(PoolString(Keyword.Real), out ExpTypeSource? _expReal);
.TryGetType( PoolString( Keyword.Real ), out ExpTypeSource? _expReal );
ExpReal = _expReal; ExpReal = _expReal;
ExpSchema_Builtin.Only ExpSchema_Builtin.Only
.TryGetType( .TryGetType(
PoolString( Keyword.Boolean ), out ExpTypeSource? _expBool ); PoolString(Keyword.Boolean), out ExpTypeSource? _expBool);
ExpBool = _expBool; ExpBool = _expBool;
ExpSchema_Builtin.Only ExpSchema_Builtin.Only
.TryGetType( .TryGetType(
PoolString( Keyword.Boolean ), out ExpTypeSource? _expString ); PoolString(Keyword.Boolean), out ExpTypeSource? _expString);
ExpString = _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 ] ) ) { if (char.IsLetter(str[0])) {
return _keywordSet.Contains( str ); return _keywordSet.Contains(str);
} }
return true; return true;
} }
public static bool LetterIsOperator( string str ) public static bool LetterIsOperator(string str)
{ {
if( char.IsLetter( str[ 0 ] ) ) { if (char.IsLetter(str[0])) {
return Array.IndexOf( _operatorsWithLetter, str ) != -1; return Array.IndexOf(_operatorsWithLetter, str) != -1;
} }
return true; 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<char> str ) public static string PoolString(ReadOnlySpan<char> str)
{ {
return _compileStringCache.GetOrAdd( str ); return _compileStringCache.GetOrAdd(str);
} }
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpOperatorPrecedence.cs" // file="ExpOperatorPrecedence"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Frozen; using System.Collections.Frozen;
using System.Collections.Generic; using System.Collections.Generic;
@@ -40,59 +37,24 @@ namespace StgSharp.Script.Express
public static partial class ExpressCompile 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( public static bool TryGetSuperTypeOperatorPrecedence(string operatorName, out int precedence)
string operatorName,
out int precedence )
{ {
return _superTypeOperatorPrecedent.TryGetValue( operatorName, out precedence ); return _superTypeOperatorPrecedent.TryGetValue(operatorName, out precedence);
} }
private static void InitPrecedence() private static void InitPrecedence()
{ {
KeyValuePair<string, int>[] source = [ KeyValuePair<string, int>[] source = [ new KeyValuePair<string, int>(PoolString("["), 1), new KeyValuePair<string, int>(PoolString("."), 1), new KeyValuePair<string, int>(PoolString("\\"), 1), new KeyValuePair<string, int>(PoolString("unary+"), 2), new KeyValuePair<string, int>(PoolString("unary-"), 2), new KeyValuePair<string, int>(PoolString("NOT"), 2), new KeyValuePair<string, int>(PoolString("**"), 3), new KeyValuePair<string, int>(PoolString("*"), 4), new KeyValuePair<string, int>(PoolString("/"), 4), new KeyValuePair<string, int>(PoolString("AND"), 4), new KeyValuePair<string, int>(PoolString("MOD"), 4), new KeyValuePair<string, int>(PoolString("DIV"), 4), new KeyValuePair<string, int>(PoolString("||"), 4), new KeyValuePair<string, int>(PoolString("+"), 5), new KeyValuePair<string, int>(PoolString("-"), 5), new KeyValuePair<string, int>(PoolString("OR"), 5), new KeyValuePair<string, int>(PoolString("XOR"), 5), new KeyValuePair<string, int>(PoolString("="), 6), new KeyValuePair<string, int>(PoolString("<>"), 6), new KeyValuePair<string, int>(PoolString("<="), 6), new KeyValuePair<string, int>(PoolString(">="), 6), new KeyValuePair<string, int>(PoolString(">"), 6), new KeyValuePair<string, int>(PoolString("<"), 6), new KeyValuePair<string, int>(PoolString(":=:"), 6), new KeyValuePair<string, int>(PoolString(":<>:"), 6), new KeyValuePair<string, int>(PoolString("IN"), 6), new KeyValuePair<string, int>(PoolString("LIKE"), 6), new KeyValuePair<string, int>(PoolString(Keyword.Assignment), 7) ];
new KeyValuePair<string, int>( PoolString( "[" ), 1 ), _operatorPrecedence = new Dictionary<string, int>(source,
new KeyValuePair<string, int>( PoolString( "." ), 1 ), _multiplexer).ToFrozenDictionary();
new KeyValuePair<string, int>( PoolString( "\\" ), 1 ), source = [ new KeyValuePair<string, int>("ONEOF", 1), new KeyValuePair<string, int>("AND", 2), new KeyValuePair<string, int>("ANDOR", 3), ];
new KeyValuePair<string, int>( PoolString( "unary+" ), 2 ), _superTypeOperatorPrecedent = new Dictionary<string, int>(source,
new KeyValuePair<string, int>( PoolString( "unary-" ), 2 ), _multiplexer).ToFrozenDictionary(
new KeyValuePair<string, int>( PoolString( "NOT" ), 2 ),
new KeyValuePair<string, int>( PoolString( "**" ), 3 ),
new KeyValuePair<string, int>( PoolString( "*" ), 4 ),
new KeyValuePair<string, int>( PoolString( "/" ), 4 ),
new KeyValuePair<string, int>( PoolString( "AND" ), 4 ),
new KeyValuePair<string, int>( PoolString( "MOD" ), 4 ),
new KeyValuePair<string, int>( PoolString( "DIV" ), 4 ),
new KeyValuePair<string, int>( PoolString( "||" ), 4 ),
new KeyValuePair<string, int>( PoolString( "+" ), 5 ),
new KeyValuePair<string, int>( PoolString( "-" ), 5 ),
new KeyValuePair<string, int>( PoolString( "OR" ), 5 ),
new KeyValuePair<string, int>( PoolString( "XOR" ), 5 ),
new KeyValuePair<string, int>( PoolString( "=" ), 6 ),
new KeyValuePair<string, int>( PoolString( "<>" ), 6 ),
new KeyValuePair<string, int>( PoolString( "<=" ), 6 ),
new KeyValuePair<string, int>( PoolString( ">=" ), 6 ),
new KeyValuePair<string, int>( PoolString( ">" ), 6 ),
new KeyValuePair<string, int>( PoolString( "<" ), 6 ),
new KeyValuePair<string, int>( PoolString( ":=:" ), 6 ),
new KeyValuePair<string, int>( PoolString( ":<>:" ), 6 ),
new KeyValuePair<string, int>( PoolString( "IN" ), 6 ),
new KeyValuePair<string, int>( PoolString( "LIKE" ), 6 ),
new KeyValuePair<string, int>( PoolString( Keyword.Assignment ), 7 )
];
_operatorPrecedence = new Dictionary<string, int>( source,
_multiplexer ).ToFrozenDictionary();
source = [
new KeyValuePair<string, int>( "ONEOF", 1 ),
new KeyValuePair<string, int>( "AND", 2 ),
new KeyValuePair<string, int>( "ANDOR", 3 ),
];
_superTypeOperatorPrecedent = new Dictionary<string, int>( source,
_multiplexer ).ToFrozenDictionary(
); );
} }
+45 -83
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="KeyWord.cs" // file="KeyWord"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -46,16 +43,16 @@ namespace StgSharp.Script.Express
{ {
_keywordSet = new(); _keywordSet = new();
FieldInfo[] fields = typeof( Keyword ).GetFields( BindingFlags.Public ); FieldInfo[] fields = typeof(Keyword).GetFields(BindingFlags.Public);
ParallelLoopResult result = Parallel.ForEach( ParallelLoopResult result = Parallel.ForEach(
fields, static( field ) => { fields, static(field) => {
if( field.FieldType == typeof( string ) && field.GetValue( null ) is string str ) if (field.FieldType == typeof(string) && field.GetValue(null) is string str)
{ {
_compileStringCache.GetOrAdd( str ); _compileStringCache.GetOrAdd(str);
_keywordSet.Add( str ); _keywordSet.Add(str);
} }
} ); });
while( !result.IsCompleted ) { } while (!result.IsCompleted) { }
} }
public static class Keyword 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 EndAlias, EndCase, EndConstant, EndEntity, EndFunction, EndIf, EndLocal, EndProcedure, EndRepeat, EndRule, EndSchema, EndSubtypeConstraint, EndType
}; };
public static HashSet<string> Symbols = [ public static HashSet<string> Symbols = [ Dot, Comma, Semicolon, Colon, Percent, Apostrophe, Backslash, IndexOf, RightBracket, LeftBrace, RightBrace, Pipe, LeftParen, RightParen, LeftAsterisk, Assignment, DoublePipe, ExpSymbol, CommentSingleLine, CommentStart, CommentEnd, InstanceEqual, InstanceNotEqual ];
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<string> DataTypes { get; } = [ public static HashSet<string> DataTypes { get; } = [ Array, Bag, Binary, Boolean, Enumeration, Integer, List, Logical, Number, Of, Real, Set, String ];
Array, Bag, Binary, Boolean, Enumeration, Integer, List, Logical, Number, Of, Real, Set, String
];
public static HashSet<string> InternalProcess { get; } = [ public static HashSet<string> InternalProcess { get; } = [ Insert, Remove ];
Insert, Remove
];
public static HashSet<string> BuiltinFunctions { get; } = [ public static HashSet<string> 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 ];
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<string> Literals { get; } = [ public static HashSet<string> Literals { get; } = [ QuestionMark, Self, Const, E, Pi, False, True, Unknown ];
QuestionMark, Self, Const, E, Pi, False, True, Unknown
];
public static HashSet<string> Operators { get; } = [ public static HashSet<string> Operators { get; } = [ And, AndOr, Div, In, Like, Mod, Not, Or, Xor, Add, Sub, Mul, Slash, Equal, NotEqual, LessThan, GreaterThan, LessThanOrEqual, GreaterThanOrEqual ];
And, AndOr, Div, In, Like, Mod, Not, Or, Xor,
Add, Sub, Mul, Slash, Equal, NotEqual,
LessThan, GreaterThan, LessThanOrEqual, GreaterThanOrEqual
];
public static HashSet<string> Aliasing { get; } = [ public static HashSet<string> Aliasing { get; } = [ Alias, Renamed ];
Alias, Renamed
];
public static HashSet<string> ModifiersAttributes { get; } = [ public static HashSet<string> ModifiersAttributes { get; } = [ Abstract, Aggregate, As, BasedOn, By, Escape, Fixed, From, Use, With ];
Abstract, Aggregate, As, BasedOn, By, Escape, Fixed, From, Use, With
];
public static HashSet<string> QueryReference { get; } = [ public static HashSet<string> QueryReference { get; } = [ Query, Reference, Select ];
Query, Reference, Select
];
public static HashSet<string> ConstraintsInheritance { get; } = [ public static HashSet<string> ConstraintsInheritance { get; } = [ Oneof, Optional, Subtype, SubtypeConstraint, Supertype, TotalOver, Unique, Where ];
Oneof, Optional, Subtype, SubtypeConstraint, Supertype, TotalOver, Unique, Where
];
public static HashSet<string> Declarations { get; } = [ public static HashSet<string> Declarations { get; } = [ Constant, Derive, Entity, Extensible, Fixed, Function, Generic, GenericEntity, Inverse, Local, Procedure, Rule, Schema, Type, Var ];
Constant, Derive, Entity, Extensible, Fixed, Function, Generic,
GenericEntity, Inverse, Local, Procedure, Rule, Schema, Type, Var
];
public static HashSet<string> FlowControl { get; } = [ public static HashSet<string> FlowControl { get; } = [ Begin, Case, Else, End, For, If, Otherwise, Repeat, Return, Skip, Then, To, Until, While ];
Begin, Case, Else, End, For, If, Otherwise, Repeat, Return, Skip, Then, To, Until, While
];
#region Basic Data Type #region Basic Data Type
+36 -39
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpConst.cs" // file="ExpConst"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections; using System.Collections;
using System.Collections.Frozen; using System.Collections.Frozen;
@@ -45,10 +42,10 @@ namespace StgSharp.Script.Express
private Dictionary<string, ExpElementInstance> _constants; private Dictionary<string, ExpElementInstance> _constants;
private IScriptSourceProvider _sourceProvider; private IScriptSourceProvider _sourceProvider;
public ExpConstantCollectionSource( IScriptSourceProvider sourceProvider ) public ExpConstantCollectionSource(IScriptSourceProvider sourceProvider)
{ {
_sourceProvider = sourceProvider; _sourceProvider = sourceProvider;
_constants = new Dictionary<string, ExpElementInstance>( ExpressCompile.Multiplexer ); _constants = new Dictionary<string, ExpElementInstance>(ExpressCompile.Multiplexer);
} }
public override ExpElementType ElementType => ExpElementType.Const; public override ExpElementType ElementType => ExpElementType.Const;
@@ -65,28 +62,28 @@ namespace StgSharp.Script.Express
throw new NotImplementedException(); 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!; return null!;
} }
if( _constants.Count == 0 ) { if (_constants.Count == 0) {
return null!; return null!;
} }
if( _constants.TryGetValue( str, out ExpElementInstance? token ) ) { if (_constants.TryGetValue(str, out ExpElementInstance? token)) {
return token; return token;
} }
return null!; 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; memberNode = node;
return true; return true;
@@ -95,9 +92,9 @@ namespace StgSharp.Script.Express
return false; return false;
} }
internal void AddConstant( string name, ExpElementInstance value ) internal void AddConstant(string name, ExpElementInstance value)
{ {
_constants.Add( name, value ); _constants.Add(name, value);
} }
} }
+27 -30
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpEntity.cs" // file="ExpEntity"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -41,7 +38,7 @@ namespace StgSharp.Script.Express
private ScriptSourceTransmitter _source; private ScriptSourceTransmitter _source;
private string _name; private string _name;
public ExpEntitySource( string name, ScriptSourceTransmitter provider ) public ExpEntitySource(string name, ScriptSourceTransmitter provider)
{ {
_name = name; _name = name;
_source = provider; _source = provider;
@@ -58,12 +55,12 @@ namespace StgSharp.Script.Express
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override ExpSyntaxNode CreateInstanceNode( Token t ) public override ExpSyntaxNode CreateInstanceNode(Token t)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) public override bool TryGetMember(string name, out ExpSyntaxNode memberNode)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
+29 -32
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpFunction.cs" // file="ExpFunction"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -40,7 +37,7 @@ namespace StgSharp.Script.Express
private ScriptSourceTransmitter _transmitter; private ScriptSourceTransmitter _transmitter;
private string _name; private string _name;
public ExpFunctionSource( string name, ScriptSourceTransmitter transmitter ) public ExpFunctionSource(string name, ScriptSourceTransmitter transmitter)
{ {
_name = name; _name = name;
_transmitter = transmitter; _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(); 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; memberNode = param;
return true; return true;
} }
if( LocalVariables.TryGetValue( name, out ExpElementInstance? variable ) ) if (LocalVariables.TryGetValue(name, out ExpElementInstance? variable))
{ {
memberNode = variable; memberNode = variable;
return true; return true;
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpProcedureSource.cs" // file="ExpProcedureSource"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -50,12 +47,12 @@ namespace StgSharp.Script.Express
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override ExpSyntaxNode MakeReference( params object[] options ) public override ExpSyntaxNode MakeReference(params object[] options)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) public override bool TryGetMember(string name, out ExpSyntaxNode memberNode)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
+28 -31
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpRule.cs" // file="ExpRule"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
@@ -41,7 +38,7 @@ namespace StgSharp.Script.Express
private ExpRuleSource _source; private ExpRuleSource _source;
public ExpRule( Token source ) : base( source ) { } public ExpRule(Token source) : base(source) { }
public object? value => throw new NotImplementedException(); public object? value => throw new NotImplementedException();
@@ -62,7 +59,7 @@ namespace StgSharp.Script.Express
private ScriptSourceTransmitter _transmitter; private ScriptSourceTransmitter _transmitter;
private string _name; private string _name;
public ExpRuleSource( string name, ScriptSourceTransmitter transmitter ) public ExpRuleSource(string name, ScriptSourceTransmitter transmitter)
{ {
_name = name; _name = name;
_transmitter = transmitter; _transmitter = transmitter;
@@ -79,12 +76,12 @@ namespace StgSharp.Script.Express
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override ExpSyntaxNode MakeReference( params object[] options ) public override ExpSyntaxNode MakeReference(params object[] options)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode ) public override bool TryGetMember(string name, out ExpSyntaxNode memberNode)
{ {
memberNode = ExpSyntaxNode.Empty; memberNode = ExpSyntaxNode.Empty;
return false; return false;
+30 -33
View File
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpType.cs" // file="ExpType"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the ¡°Software¡±), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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;
using System; using System;
@@ -42,14 +39,14 @@ namespace StgSharp.Script.Express
private string _name; private string _name;
protected bool _isBuiltinType; protected bool _isBuiltinType;
protected ExpTypeSource( string name ) protected ExpTypeSource(string name)
{ {
_name = name; _name = name;
_transmitter = ScriptSourceTransmitter.Empty; _transmitter = ScriptSourceTransmitter.Empty;
_isBuiltinType = true; _isBuiltinType = true;
} }
public ExpTypeSource( string name, ScriptSourceTransmitter transmitter ) public ExpTypeSource(string name, ScriptSourceTransmitter transmitter)
{ {
_name = name; _name = name;
_transmitter = transmitter; _transmitter = transmitter;
@@ -77,17 +74,17 @@ namespace StgSharp.Script.Express
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override ExpElementInstance CreateInstanceNode( Token t ) public override ExpElementInstance CreateInstanceNode(Token t)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public static bool IsNullOrVoid( IExpElementSource type ) public static bool IsNullOrVoid(IExpElementSource type)
{ {
return type == null || type == ExpVoidType.Only; 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; memberNode = ExpSyntaxNode.Empty;
return false; return false;
@@ -98,7 +95,7 @@ namespace StgSharp.Script.Express
private static readonly ExpVoidType _onlyInstance = new ExpVoidType(); private static readonly ExpVoidType _onlyInstance = new ExpVoidType();
private ExpVoidType() : base( string.Empty ) { } private ExpVoidType() : base(string.Empty) { }
public static ExpVoidType Only public static ExpVoidType Only
{ {
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ExpBinaryOperatorNode.cs" // file="ExpBinaryOperatorNode"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// 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 Microsoft.CodeAnalysis.CSharp;
using System; using System;
@@ -48,8 +45,8 @@ namespace StgSharp.Script.Express
private ExpSyntaxNode _left; private ExpSyntaxNode _left;
private ExpSyntaxNode _right; private ExpSyntaxNode _right;
private ExpBinaryOperatorNode( Token source, ExpSyntaxNode left, ExpSyntaxNode right ) private ExpBinaryOperatorNode(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
: base( source ) : base(source)
{ {
_left = left; _left = left;
_right = right; _right = right;
@@ -63,19 +60,16 @@ namespace StgSharp.Script.Express
public string Operator { get; private set; } public string Operator { get; private set; }
public static ExpBinaryOperatorNode Add( public static ExpBinaryOperatorNode Add(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException( source, "Number", throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name ); left.EqualityTypeConvert.Name);
} }
bool isFloat = bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || (left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; (right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0;
return new ExpBinaryOperatorNode( source, left, right ) return new ExpBinaryOperatorNode(source, left, right)
{ {
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt, _returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number, _nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
@@ -83,16 +77,13 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode Assign( public static ExpBinaryOperatorNode Assign(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) { if (left.EqualityTypeConvert != right.EqualityTypeConvert) {
throw new ExpInvalidTypeException( 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, _returnType = ExpInstantiableElement.Void,
_nodeFlag = ExpNodeFlag.Operator_Binary | left._nodeFlag, _nodeFlag = ExpNodeFlag.Operator_Binary | left._nodeFlag,
@@ -101,12 +92,9 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode CompareInstanceEqual( public static ExpBinaryOperatorNode CompareInstanceEqual(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
return new ExpBinaryOperatorNode( source, left, right ) return new ExpBinaryOperatorNode(source, left, right)
{ {
_returnType = ExpressCompile.ExpBool, _returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -117,9 +105,9 @@ namespace StgSharp.Script.Express
public static ExpBinaryOperatorNode CompareInstanceNotEqual( public static ExpBinaryOperatorNode CompareInstanceNotEqual(
Token source, Token source,
ExpSyntaxNode left, ExpSyntaxNode left,
ExpSyntaxNode right ) ExpSyntaxNode right)
{ {
return new ExpBinaryOperatorNode( source, left, right ) return new ExpBinaryOperatorNode(source, left, right)
{ {
_returnType = ExpressCompile.ExpBool, _returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -127,16 +115,13 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode ConvertElement( public static ExpBinaryOperatorNode ConvertElement(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( right is not ExpMetaRefNode metaRef ) { if (right is not ExpMetaRefNode metaRef) {
throw new ExpInvalidTypeException( throw new ExpInvalidTypeException(
source, "<source of element>", right.EqualityTypeConvert.Name ); source, "<source of element>", right.EqualityTypeConvert.Name);
} }
return new ExpBinaryOperatorNode( source, left, right ) return new ExpBinaryOperatorNode(source, left, right)
{ {
_returnType = metaRef.SourceRef, _returnType = metaRef.SourceRef,
_nodeFlag = ExpNodeFlag.Operator_Binary, _nodeFlag = ExpNodeFlag.Operator_Binary,
@@ -148,19 +133,16 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode Div( public static ExpBinaryOperatorNode Div(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException( source, "Number", throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name ); left.EqualityTypeConvert.Name);
} }
bool isFloat = bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || (left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; (right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0;
return new ExpBinaryOperatorNode( source, left, right ) return new ExpBinaryOperatorNode(source, left, right)
{ {
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt, _returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number, _nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
@@ -168,16 +150,13 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode EqualTo( public static ExpBinaryOperatorNode EqualTo(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) { if (left.EqualityTypeConvert != right.EqualityTypeConvert) {
throw new ExpInvalidTypeException( 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, _returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -185,16 +164,13 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode GreaterThan( public static ExpBinaryOperatorNode GreaterThan(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException( source, "Number", throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name ); left.EqualityTypeConvert.Name);
} }
return new ExpBinaryOperatorNode( source, left, right ) return new ExpBinaryOperatorNode(source, left, right)
{ {
_returnType = ExpressCompile.ExpBool, _returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -202,16 +178,13 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode LessThan( public static ExpBinaryOperatorNode LessThan(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException( source, "Number", throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name ); left.EqualityTypeConvert.Name);
} }
return new ExpBinaryOperatorNode( source, left, right ) return new ExpBinaryOperatorNode(source, left, right)
{ {
_returnType = ExpressCompile.ExpBool, _returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -219,19 +192,16 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode Mul( public static ExpBinaryOperatorNode Mul(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException( source, "Number", throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name ); left.EqualityTypeConvert.Name);
} }
bool isFloat = bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || (left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; (right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0;
return new ExpBinaryOperatorNode( source, left, right ) return new ExpBinaryOperatorNode(source, left, right)
{ {
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt, _returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number, _nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
@@ -239,16 +209,13 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode NotEqualTo( public static ExpBinaryOperatorNode NotEqualTo(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) { if (left.EqualityTypeConvert != right.EqualityTypeConvert) {
throw new ExpInvalidTypeException( 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, _returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -256,16 +223,13 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode SmallerThan( public static ExpBinaryOperatorNode SmallerThan(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException( source, "Number", throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name ); left.EqualityTypeConvert.Name);
} }
return new ExpBinaryOperatorNode( source, left, right ) return new ExpBinaryOperatorNode(source, left, right)
{ {
_returnType = ExpressCompile.ExpBool, _returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary, _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -273,19 +237,16 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode Sub( public static ExpBinaryOperatorNode Sub(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException( source, "Number", throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name ); left.EqualityTypeConvert.Name);
} }
bool isFloat = bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || (left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; (right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0;
return new ExpBinaryOperatorNode( source, left, right ) return new ExpBinaryOperatorNode(source, left, right)
{ {
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt, _returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number, _nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,

Some files were not shown because too many files have changed in this diff Show More