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,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpBinaryOperatorNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpBinaryOperatorNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using Microsoft.CodeAnalysis.CSharp;
using System;
@@ -48,8 +45,8 @@ namespace StgSharp.Script.Express
private ExpSyntaxNode _left;
private ExpSyntaxNode _right;
private ExpBinaryOperatorNode( Token source, ExpSyntaxNode left, ExpSyntaxNode right )
: base( source )
private ExpBinaryOperatorNode(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
: base(source)
{
_left = left;
_right = right;
@@ -63,19 +60,16 @@ namespace StgSharp.Script.Express
public string Operator { get; private set; }
public static ExpBinaryOperatorNode Add(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode Add(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( source, "Number",
left.EqualityTypeConvert.Name );
if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name);
}
bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
return new ExpBinaryOperatorNode( source, left, right )
(left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 ||
(right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0;
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
@@ -83,16 +77,13 @@ namespace StgSharp.Script.Express
};
}
public static ExpBinaryOperatorNode Assign(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode Assign(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) {
if (left.EqualityTypeConvert != right.EqualityTypeConvert) {
throw new ExpInvalidTypeException(
source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name );
source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name);
}
return new ExpBinaryOperatorNode( source, left, right )
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = ExpInstantiableElement.Void,
_nodeFlag = ExpNodeFlag.Operator_Binary | left._nodeFlag,
@@ -101,12 +92,9 @@ namespace StgSharp.Script.Express
};
}
public static ExpBinaryOperatorNode CompareInstanceEqual(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode CompareInstanceEqual(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
return new ExpBinaryOperatorNode( source, left, right )
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -117,9 +105,9 @@ namespace StgSharp.Script.Express
public static ExpBinaryOperatorNode CompareInstanceNotEqual(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
ExpSyntaxNode right)
{
return new ExpBinaryOperatorNode( source, left, right )
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -127,16 +115,13 @@ namespace StgSharp.Script.Express
};
}
public static ExpBinaryOperatorNode ConvertElement(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode ConvertElement(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
if( right is not ExpMetaRefNode metaRef ) {
if (right is not ExpMetaRefNode metaRef) {
throw new ExpInvalidTypeException(
source, "<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,
_nodeFlag = ExpNodeFlag.Operator_Binary,
@@ -148,19 +133,16 @@ namespace StgSharp.Script.Express
};
}
public static ExpBinaryOperatorNode Div(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode Div(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( source, "Number",
left.EqualityTypeConvert.Name );
if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name);
}
bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
return new ExpBinaryOperatorNode( source, left, right )
(left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 ||
(right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0;
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
@@ -168,16 +150,13 @@ namespace StgSharp.Script.Express
};
}
public static ExpBinaryOperatorNode EqualTo(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode EqualTo(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) {
if (left.EqualityTypeConvert != right.EqualityTypeConvert) {
throw new ExpInvalidTypeException(
source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name );
source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name);
}
return new ExpBinaryOperatorNode( source, left, right )
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -185,16 +164,13 @@ namespace StgSharp.Script.Express
};
}
public static ExpBinaryOperatorNode GreaterThan(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode GreaterThan(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( source, "Number",
left.EqualityTypeConvert.Name );
if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name);
}
return new ExpBinaryOperatorNode( source, left, right )
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -202,16 +178,13 @@ namespace StgSharp.Script.Express
};
}
public static ExpBinaryOperatorNode LessThan(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode LessThan(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( source, "Number",
left.EqualityTypeConvert.Name );
if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name);
}
return new ExpBinaryOperatorNode( source, left, right )
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -219,19 +192,16 @@ namespace StgSharp.Script.Express
};
}
public static ExpBinaryOperatorNode Mul(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode Mul(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( source, "Number",
left.EqualityTypeConvert.Name );
if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name);
}
bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
return new ExpBinaryOperatorNode( source, left, right )
(left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 ||
(right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0;
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
@@ -239,16 +209,13 @@ namespace StgSharp.Script.Express
};
}
public static ExpBinaryOperatorNode NotEqualTo(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode NotEqualTo(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) {
if (left.EqualityTypeConvert != right.EqualityTypeConvert) {
throw new ExpInvalidTypeException(
source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name );
source, left.EqualityTypeConvert.Name, right.EqualityTypeConvert.Name);
}
return new ExpBinaryOperatorNode( source, left, right )
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -256,16 +223,13 @@ namespace StgSharp.Script.Express
};
}
public static ExpBinaryOperatorNode SmallerThan(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode SmallerThan(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( source, "Number",
left.EqualityTypeConvert.Name );
if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name);
}
return new ExpBinaryOperatorNode( source, left, right )
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = ExpressCompile.ExpBool,
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
@@ -273,19 +237,16 @@ namespace StgSharp.Script.Express
};
}
public static ExpBinaryOperatorNode Sub(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
public static ExpBinaryOperatorNode Sub(Token source, ExpSyntaxNode left, ExpSyntaxNode right)
{
if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( source, "Number",
left.EqualityTypeConvert.Name );
if (!left.IsNumber && !right.IsNumber) {
throw new ExpInvalidTypeException(source, "Number",
left.EqualityTypeConvert.Name);
}
bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
return new ExpBinaryOperatorNode( source, left, right )
(left._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0 ||
(right._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0;
return new ExpBinaryOperatorNode(source, left, right)
{
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpCollectionIndexNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpCollectionIndexNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
@@ -43,11 +40,8 @@ namespace StgSharp.Script.Express
private ExpSyntaxNode _indexExpression;
private ExpCollectionIndexNode(
Token source,
ExpCollectionInstanceBase instance,
ExpSyntaxNode indexExpression )
: base( source )
private ExpCollectionIndexNode(Token source, ExpCollectionInstanceBase instance, ExpSyntaxNode indexExpression)
: base(source)
{
_collection = instance;
_indexExpression = indexExpression;
@@ -63,13 +57,13 @@ namespace StgSharp.Script.Express
public static ExpCollectionIndexNode Create(
Token source,
ExpCollectionInstanceBase instance,
ExpSyntaxNode indexExpression )
ExpSyntaxNode indexExpression)
{
if( !indexExpression.IsNumber ) {
if (!indexExpression.IsNumber) {
throw new ExpInvalidTypeException(
source, "Number", indexExpression.EqualityTypeConvert.Name );
source, "Number", indexExpression.EqualityTypeConvert.Name);
}
return new ExpCollectionIndexNode( source, instance, indexExpression );
return new ExpCollectionIndexNode(source, instance, indexExpression);
}
}
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpElementInitializingNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpElementInitializingNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
@@ -43,11 +40,8 @@ namespace StgSharp.Script.Express
private ExpMetaRefNode _type;
private ExpSyntaxNode _init;
private ExpElementInitializingNode(
Token source,
ExpMetaRefNode type,
ExpSyntaxNode initParameter )
: base( source )
private ExpElementInitializingNode(Token source, ExpMetaRefNode type, ExpSyntaxNode initParameter)
: base(source)
{
_type = type;
_init = initParameter;
@@ -59,16 +53,13 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert => _type.SourceRef;
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public ExpElementInitializingNode InitializeElement(
Token source,
ExpMetaRefNode type,
ExpSyntaxNode init )
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ExpElementInitializingNode InitializeElement(Token source, ExpMetaRefNode type, ExpSyntaxNode init)
{
if( init is ExpTupleNode tupleNode ) {
if (init is ExpTupleNode tupleNode) {
init = tupleNode.Right;
}
ExpElementInitializingNode node = new ExpElementInitializingNode( source, type, init );
ExpElementInitializingNode node = new ExpElementInitializingNode(source, type, init);
return node;
}
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpElementMemberNameNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpElementMemberNameNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
@@ -39,8 +36,8 @@ namespace StgSharp.Script.Express
public class ExpElementMemberNameNode : ExpSyntaxNode
{
internal ExpElementMemberNameNode( Token source )
: base( source )
internal ExpElementMemberNameNode(Token source)
: base(source)
{
_nodeFlag = ExpNodeFlag.Name_Operator;
CodeConvertTemplate = source.Value;
@@ -54,15 +51,14 @@ namespace StgSharp.Script.Express
{
get
{
ExpSchema.BuiltinSchema
.TryGetType( ExpressCompile.Keyword.String, out ExpTypeSource? strType );
ExpSchema.BuiltinSchema.TryGetType(ExpressCompile.Keyword.String, out ExpTypeSource? strType);
return strType;
}
}
public static ExpElementMemberNameNode Create( Token t )
public static ExpElementMemberNameNode Create(Token t)
{
return new ExpElementMemberNameNode( t );
return new ExpElementMemberNameNode(t);
}
}
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpEnumLiteralNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpEnumLiteralNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Script;
using System;
@@ -37,7 +34,7 @@ namespace StgSharp.Script.Express
public class ExpEnumLiteralNode : ExpSyntaxNode
{
private ExpEnumLiteralNode( Token t ) : base( t ) { }
private ExpEnumLiteralNode(Token t) : base(t) { }
public override ExpSyntaxNode Left => Empty;
@@ -47,17 +44,17 @@ namespace StgSharp.Script.Express
public string Literal { get; private set; }
public static ExpEnumLiteralNode Create( Token t, Func<string, string> parser )
public static ExpEnumLiteralNode Create(Token t, Func<string, string> parser)
{
string l;
if( parser is null )
if (parser is null)
{
l = t.Value;
} else
{
l = parser( t.Value );
l = parser(t.Value);
}
return new ExpEnumLiteralNode( t )
return new ExpEnumLiteralNode(t)
{
Literal = l,
CodeConvertTemplate = l
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpFunctionCallingNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpFunctionCallingNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
@@ -43,13 +40,10 @@ namespace StgSharp.Script.Express
private ExpSyntaxNode _parameter;
private ExpFunctionCallingNode(
Token source,
ExpFunctionSource function,
ExpSyntaxNode parameterEnumeration )
: base( source )
private ExpFunctionCallingNode(Token source, ExpFunctionSource function, ExpSyntaxNode parameterEnumeration)
: base(source)
{
if( parameterEnumeration is ExpTupleNode tuple ) {
if (parameterEnumeration is ExpTupleNode tuple) {
parameterEnumeration = tuple.Right;
}
_function = function;
@@ -64,20 +58,17 @@ namespace StgSharp.Script.Express
public override ExpSyntaxNode Right => _parameter;
public void AppendParameter( ExpSyntaxNode parameter )
public void AppendParameter(ExpSyntaxNode parameter)
{
_parameter.AppendNode( parameter );
_parameter.AppendNode(parameter);
}
public static ExpFunctionCallingNode CallFunction(
Token source,
ExpFunctionSource function,
ExpSyntaxNode param )
public static ExpFunctionCallingNode CallFunction(Token source, ExpFunctionSource function, ExpSyntaxNode param)
{
if( param is ExpTupleNode ) {
if (param is ExpTupleNode) {
param = param.Right;
}
return new ExpFunctionCallingNode( source, function, param );
return new ExpFunctionCallingNode(source, function, param);
}
}
+34 -37
View File
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpIfNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpIfNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Script.Express;
using System;
@@ -43,8 +40,8 @@ namespace StgSharp.Script.Express
private ExpSyntaxNode _rule;
private ExpSyntaxNode _trueOpBegin ;
public ExpIfNode( Token source, ExpSyntaxNode rule, ExpSyntaxNode trueOpBegin )
: base( source )
public ExpIfNode(Token source, ExpSyntaxNode rule, ExpSyntaxNode trueOpBegin)
: base(source)
{
_rule = rule;
_trueOpBegin = trueOpBegin;
@@ -54,15 +51,15 @@ namespace StgSharp.Script.Express
{
{1}
}
""" );
""");
}
public ExpIfNode(
Token source,
ExpSyntaxNode rule,
ExpSyntaxNode rootOperationIfTrue,
ExpSyntaxNode rootOperationIfFalse )
: base( source )
ExpSyntaxNode rootOperationIfFalse)
: base(source)
{
_rule = rule;
_trueOpBegin = rootOperationIfFalse;
@@ -75,7 +72,7 @@ namespace StgSharp.Script.Express
} else {
{2}
}
""" );
""");
}
public override ExpSyntaxNode Left => _trueOpBegin;
@@ -84,14 +81,14 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert => null!;
public void AppendFalseOperation( ExpSyntaxNode expressionRoot )
public void AppendFalseOperation(ExpSyntaxNode expressionRoot)
{
_falseOpBegin.AppendNode( expressionRoot );
_falseOpBegin.AppendNode(expressionRoot);
}
public void AppendTrueOperation( ExpSyntaxNode expressionRoot )
public void AppendTrueOperation(ExpSyntaxNode expressionRoot)
{
_trueOpBegin.AppendNode( expressionRoot );
_trueOpBegin.AppendNode(expressionRoot);
}
}
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpInstanceMemberNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpInstanceMemberNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using CommunityToolkit.HighPerformance.Helpers;
using System;
@@ -45,15 +42,12 @@ namespace StgSharp.Script.Express
private ExpElementMemberNameNode _memberName;
private ExpSyntaxNode _member;
public ExpInstanceMemberNode(
Token source,
ExpElementInstance instance,
ExpElementMemberNameNode memberName )
: base( source )
public ExpInstanceMemberNode(Token source, ExpElementInstance instance, ExpElementMemberNameNode memberName)
: base(source)
{
_instance = instance;
_memberName = memberName;
_instance.TryGetMember( memberName.CodeConvertTemplate, out _member );
_instance.TryGetMember(memberName.CodeConvertTemplate, out _member);
}
public override ExpSyntaxNode Left => _instance;
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpInstanceReferenceNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpInstanceReferenceNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
@@ -40,19 +37,19 @@ namespace StgSharp.Script.Express
public class ExpInstanceReferenceNode : ExpSyntaxNode
{
internal ExpInstanceReferenceNode( Token source, ExpElementInstance instance )
: base( source )
internal ExpInstanceReferenceNode(Token source, ExpElementInstance instance)
: base(source)
{
OriginObject = instance;
_nodeFlag = ( OriginObject._nodeFlag | ( ExpNodeFlag.Name_Any | ExpNodeFlag.Collection_Any ) );
_nodeFlag = (OriginObject._nodeFlag | (ExpNodeFlag.Name_Any | ExpNodeFlag.Collection_Any));
CodeConvertTemplate = source.Value;
}
internal ExpInstanceReferenceNode( Token source, ExpInstanceReferenceNode reference )
: base( source )
internal ExpInstanceReferenceNode(Token source, ExpInstanceReferenceNode reference)
: base(source)
{
OriginObject = reference.OriginObject;
_nodeFlag = ( OriginObject._nodeFlag | ( ExpNodeFlag.Name_Any | ExpNodeFlag.Collection_Any ) );
_nodeFlag = (OriginObject._nodeFlag | (ExpNodeFlag.Name_Any | ExpNodeFlag.Collection_Any));
CodeConvertTemplate = source.Value;
}
@@ -64,21 +61,19 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert => OriginObject.EqualityTypeConvert;
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static ExpInstanceReferenceNode MakeReferenceFrom(
Token source,
ExpElementInstance instance )
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ExpInstanceReferenceNode MakeReferenceFrom(Token source, ExpElementInstance instance)
{
/**/
if( instance.IsLiteral )
if (instance.IsLiteral)
{
throw new ExpCompileException( source, "Cannot make reference to a literal." );
throw new ExpCompileException(source, "Cannot make reference to a literal.");
}
if( instance.CodeConvertTemplate != source.Value ) {
throw new ExpCompileException( source, "Token point at a wrong instance" );
if (instance.CodeConvertTemplate != source.Value) {
throw new ExpCompileException(source, "Token point at a wrong instance");
}
/**/
return new ExpInstanceReferenceNode( source, instance );
return new ExpInstanceReferenceNode(source, instance);
}
}
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpLiteralNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpLiteralNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Data;
using System;
@@ -43,8 +40,8 @@ namespace StgSharp.Script.Express
private int _value;
public ExpIntNode( Token source, int value, bool isLiteral )
: base( source )
public ExpIntNode(Token source, int value, bool isLiteral)
: base(source)
{
this.IsLiteral = isLiteral;
_value = value;
@@ -68,8 +65,8 @@ namespace StgSharp.Script.Express
private readonly string _value;
public ExpStringNode( Token source, string value, bool isLiteral )
: base( source )
public ExpStringNode(Token source, string value, bool isLiteral)
: base(source)
{
this.IsLiteral = IsLiteral;
_value = value;
@@ -100,8 +97,8 @@ namespace StgSharp.Script.Express
private readonly bool _value;
public ExpBoolNode( Token source, bool value, bool isLiteral )
: base( source )
public ExpBoolNode(Token source, bool value, bool isLiteral)
: base(source)
{
this.IsLiteral = isLiteral;
_value = value;
@@ -113,22 +110,22 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert
{
get => ExpSchema.BuiltinSchema
.TryGetType( ExpressCompile.Keyword.Boolean, out ExpTypeSource? type ) ?
type : throw new ExpCompileNotInitializedException();
get => ExpSchema.BuiltinSchema.TryGetType(ExpressCompile.Keyword.Boolean, out ExpTypeSource? type) ?
type :
throw new ExpCompileNotInitializedException();
}
public override string TypeName => EqualityTypeConvert.Name;
public static ExpBoolNode False( Token? t )
public static ExpBoolNode False(Token? t)
{
return new( t ?? new Token( "FALSE", 0, -1, TokenFlag.Member ), false,
isLiteral: true );
return new(t ?? new Token("FALSE", 0, -1, TokenFlag.Member), false,
isLiteral:true);
}
public static ExpBoolNode True( Token? t )
public static ExpBoolNode True(Token? t)
{
return new( t ?? new Token( "TRUE", 0, -1, TokenFlag.Member ), true, isLiteral: true );
return new(t ?? new Token("TRUE", 0, -1, TokenFlag.Member), true, isLiteral:true);
}
}
@@ -138,8 +135,8 @@ namespace StgSharp.Script.Express
private readonly float _value;
public ExpRealNumberNode( Token source, float value, bool isLiteral )
: base( source )
public ExpRealNumberNode(Token source, float value, bool isLiteral)
: base(source)
{
_value = value;
_nodeFlag = ExpNodeFlag.BuiltinType_Real | ExpNodeFlag.Element_Type;
@@ -150,9 +147,9 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert
{
get => ExpSchema.BuiltinSchema
.TryGetType( ExpressCompile.Keyword.String, out ExpTypeSource? type ) ?
type : throw new ExpCompileNotInitializedException();
get => ExpSchema.BuiltinSchema.TryGetType(ExpressCompile.Keyword.String, out ExpTypeSource? type) ?
type :
throw new ExpCompileNotInitializedException();
}
public override string TypeName => EqualityTypeConvert.Name;
@@ -164,8 +161,8 @@ namespace StgSharp.Script.Express
private readonly ExpLogic _value;
public ExpLogicValueNode( Token source, ExpLogic value, bool isLiteral )
: base( source )
public ExpLogicValueNode(Token source, ExpLogic value, bool isLiteral)
: base(source)
{
this.IsLiteral = isLiteral;
_value = value;
@@ -177,9 +174,9 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert
{
get => ExpSchema.BuiltinSchema
.TryGetType( ExpressCompile.Keyword.Logical, out ExpTypeSource? type ) ?
type : throw new ExpCompileNotInitializedException();
get => ExpSchema.BuiltinSchema.TryGetType(ExpressCompile.Keyword.Logical, out ExpTypeSource? type) ?
type :
throw new ExpCompileNotInitializedException();
}
public override string TypeName => EqualityTypeConvert.Name;
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpMetaRefNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpMetaRefNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using Microsoft.CodeAnalysis;
using System;
@@ -41,8 +38,8 @@ namespace StgSharp.Script.Express
public class ExpMetaRefNode : ExpSyntaxNode
{
internal ExpMetaRefNode( Token source, ExpInstantiableElement element )
: base( source )
internal ExpMetaRefNode(Token source, ExpInstantiableElement element)
: base(source)
{
SourceRef = element;
}
@@ -55,28 +52,28 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert => ExpInstantiableElement.Void;
public static ExpMetaRefNode RefEntity( Token position, ExpEntitySource entity )
public static ExpMetaRefNode RefEntity(Token position, ExpEntitySource entity)
{
if( position.Value != entity.Name ) {
if (position.Value != entity.Name) {
throw new ExpCompileException(
position,
$"Meta data does not match, name of source to match is {entity.Name}, but token is {position.Value}" );
$"Meta data does not match, name of source to match is {entity.Name}, but token is {position.Value}");
}
ExpMetaRefNode node = new ExpMetaRefNode( position, entity )
ExpMetaRefNode node = new ExpMetaRefNode(position, entity)
{
CodeConvertTemplate = entity.Name,
};
return node;
}
public static ExpMetaRefNode RefType( Token position, ExpTypeSource type )
public static ExpMetaRefNode RefType(Token position, ExpTypeSource type)
{
if( position.Value != type.Name ) {
if (position.Value != type.Name) {
throw new ExpCompileException(
position,
$"Meta data does not match, name of source to match is {type.Name}, but token is {position.Value}" );
$"Meta data does not match, name of source to match is {type.Name}, but token is {position.Value}");
}
ExpMetaRefNode node = new ExpMetaRefNode( position, type )
ExpMetaRefNode node = new ExpMetaRefNode(position, type)
{
CodeConvertTemplate = type.Name,
};
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpProcedureCallingNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpProcedureCallingNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
@@ -42,11 +39,8 @@ namespace StgSharp.Script.Express
private ExpSyntaxNode _params;
public ExpProcedureCallingNode(
Token source,
ExpProcedureSource caller,
ExpSyntaxNode param )
: base( source )
public ExpProcedureCallingNode(Token source, ExpProcedureSource caller, ExpSyntaxNode param)
: base(source)
{
_params = param;
CalledProcedure = caller;
@@ -63,14 +57,15 @@ namespace StgSharp.Script.Express
public static ExpProcedureCallingNode CallProcedure(
Token postion,
ExpProcedureSource caller,
ExpSyntaxNode input )
ExpSyntaxNode input)
{
ExpProcedureCallingNode node = new ExpProcedureCallingNode( postion, caller, input )
ExpProcedureCallingNode node = new ExpProcedureCallingNode(postion, caller, input)
{
/*
* 0. parameters
*/
CodeConvertTemplate = $$"""
CodeConvertTemplate =
$$"""
{{caller.Name}}( {0} )
"""
};
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpProcedureControlNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpProcedureControlNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
@@ -45,7 +42,7 @@ namespace StgSharp.Script.Express
private ExpSyntaxNode _additional;
internal ExpProcedureControlNode( Token source ) : base( source ) { }
internal ExpProcedureControlNode(Token source) : base(source) { }
public override ExpSyntaxNode Left => Empty;
@@ -53,23 +50,22 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert => ExpTypeSource.Void;
public static ExpProcedureControlNode Return( Token t, ExpSyntaxNode valueToReturn )
public static ExpProcedureControlNode Return(Token t, ExpSyntaxNode valueToReturn)
{
if( t.Value != ExpKeyword.Return ) {
if (t.Value != ExpKeyword.Return) {
throw new InvalidCastException();
}
ExpProcedureControlNode ret = new ExpProcedureControlNode( t )
ExpProcedureControlNode ret = new ExpProcedureControlNode(t)
{
_additional = valueToReturn ?? Empty,
CodeConvertTemplate = IsNullOrEmpty( valueToReturn! ) ?
ExpKeyword.Return : "return {0}",
CodeConvertTemplate = IsNullOrEmpty(valueToReturn!) ? ExpKeyword.Return : "return {0}",
};
return ret;
}
public static ExpProcedureControlNode Skip( Token t )
public static ExpProcedureControlNode Skip(Token t)
{
ExpProcedureControlNode ret = new ExpProcedureControlNode( t )
ExpProcedureControlNode ret = new ExpProcedureControlNode(t)
{
_additional = Empty,
CodeConvertTemplate = "break"
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpRangeAndIndexNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpRangeAndIndexNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
@@ -44,8 +41,8 @@ namespace StgSharp.Script.Express
private ExpSyntaxNode _index;
internal ExpIndexNode( Token t, ExpSyntaxNode node )
: base( t )
internal ExpIndexNode(Token t, ExpSyntaxNode node)
: base(t)
{
_index = node;
CodeConvertTemplate = _codeTemplate;
@@ -57,14 +54,14 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException();
public static ExpIndexNode IndexAt( Token position, ExpSyntaxNode expression )
public static ExpIndexNode IndexAt(Token position, ExpSyntaxNode expression)
{
ArgumentNullException.ThrowIfNull( expression );
if( ExpNodeFlag.BuiltinType_Int.IsNotInFlag( expression.NodeFlag ) ) {
ArgumentNullException.ThrowIfNull(expression);
if (ExpNodeFlag.BuiltinType_Int.IsNotInFlag(expression.NodeFlag)) {
throw new ExpInvalidTypeException(
position, "Integer", expression.EqualityTypeConvert.Name );
position, "Integer", expression.EqualityTypeConvert.Name);
}
return new ExpIndexNode( position, expression );
return new ExpIndexNode(position, expression);
}
}
@@ -76,8 +73,8 @@ namespace StgSharp.Script.Express
private ExpSyntaxNode _begin, _end;
internal ExpRangeNode( Token t, ExpSyntaxNode begin, ExpSyntaxNode end )
: base( t )
internal ExpRangeNode(Token t, ExpSyntaxNode begin, ExpSyntaxNode end)
: base(t)
{
_begin = begin;
_end = end;
@@ -90,22 +87,19 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert => ExpInstantiableElement.Void;
public static ExpRangeNode RangeNode(
Token position,
ExpSyntaxNode beginNode,
ExpSyntaxNode endNode )
public static ExpRangeNode RangeNode(Token position, ExpSyntaxNode beginNode, ExpSyntaxNode endNode)
{
ArgumentNullException.ThrowIfNull( beginNode );
ArgumentNullException.ThrowIfNull( endNode );
if( ExpNodeFlag.BuiltinType_Int.IsNotInFlag( beginNode.NodeFlag ) ) {
ArgumentNullException.ThrowIfNull(beginNode);
ArgumentNullException.ThrowIfNull(endNode);
if (ExpNodeFlag.BuiltinType_Int.IsNotInFlag(beginNode.NodeFlag)) {
throw new ExpInvalidTypeException(
position, "Integer", beginNode.EqualityTypeConvert.Name );
position, "Integer", beginNode.EqualityTypeConvert.Name);
}
if( ExpNodeFlag.BuiltinType_Int.IsNotInFlag( endNode.NodeFlag ) ) {
if (ExpNodeFlag.BuiltinType_Int.IsNotInFlag(endNode.NodeFlag)) {
throw new ExpInvalidTypeException(
position, "Integer", endNode.EqualityTypeConvert.Name );
position, "Integer", endNode.EqualityTypeConvert.Name);
}
return new ExpRangeNode( position, beginNode, endNode );
return new ExpRangeNode(position, beginNode, endNode);
}
}
@@ -113,7 +107,7 @@ namespace StgSharp.Script.Express
public class ExpCollectionExpressionNode : ExpSyntaxNode
{
internal ExpCollectionExpressionNode( Token t, ExpTupleNode tupleNode ) : base( t ) { }
internal ExpCollectionExpressionNode(Token t, ExpTupleNode tupleNode) : base(t) { }
public override ExpSyntaxNode Left => throw new NotImplementedException();
@@ -1,30 +1,27 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpRepeatNode.cs"
// file="ExpRepeatNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
@@ -147,7 +144,8 @@ namespace StgSharp.Script.Express
* 6: until
*/
CodeConvertTemplate = $$"""
CodeConvertTemplate =
$$"""
for( {0} = {1}; {0} <= {2}; {0} += {3})
{
if(!( {5} )) break;
@@ -171,8 +169,7 @@ namespace StgSharp.Script.Express
{
whileRule = IsNullOrEmpty(whileRule) ? ExpBoolNode.True(t) : whileRule;
untilRule = IsNullOrEmpty(untilRule) ? ExpBoolNode.False(t) : untilRule;
ExpRepeatNode ret = new ExpRepeatNode(
t, repeatVariable, begin, end, increment, body, whileRule, untilRule)
ExpRepeatNode ret = new ExpRepeatNode(t, repeatVariable, begin, end, increment, body, whileRule, untilRule)
{
/*
* 0: variable name
@@ -184,7 +181,8 @@ namespace StgSharp.Script.Express
* 6: until
*/
CodeConvertTemplate = $$"""
CodeConvertTemplate =
$$"""
for({{repeatVariable.TypeName}} {0} = {1}; {0} <= {2}; {0} += {3})
{
if(!( {5} )) break;
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSwitchNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpSwitchNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
@@ -47,21 +44,21 @@ namespace StgSharp.Script.Express
Token source,
ExpSyntaxNode target,
ExpSyntaxNode defaultCase,
params (ExpSyntaxNode label, ExpSyntaxNode op)[] cases )
: base( source )
params (ExpSyntaxNode label, ExpSyntaxNode op)[] cases)
: base(source)
{
_target = target;
_default = defaultCase;
Dictionary<ExpSyntaxNode, ExpSyntaxNode> casesDic = new Dictionary<ExpSyntaxNode, ExpSyntaxNode>(
);
foreach( (ExpSyntaxNode label, ExpSyntaxNode op ) item in cases )
foreach ((ExpSyntaxNode label, ExpSyntaxNode op ) item in cases)
{
if( item.op == null )
if (item.op == null)
{
casesDic.Add( item.label, null! );
casesDic.Add(item.label, null!);
} else
{
casesDic.Add( item.label, item.op );
casesDic.Add(item.label, item.op);
}
}
_cases = casesDic.ToFrozenDictionary();
@@ -69,8 +66,8 @@ namespace StgSharp.Script.Express
string str = @"switch( {0} ){";
StringBuilder codeFormatBuilder = new StringBuilder();
codeFormatBuilder.AppendLine( str );
for( int i = 0; i < casesDic.Count; i++ )
codeFormatBuilder.AppendLine(str);
for (int i = 0; i < casesDic.Count; i++)
{
int index = i * 2 + 1;
codeFormatBuilder.AppendLine(
@@ -78,7 +75,7 @@ namespace StgSharp.Script.Express
case {{{index}}}:
{{{index + 1}}}
break;
""" );
""");
}
CodeConvertTemplate = codeFormatBuilder.ToString();
}
@@ -87,8 +84,8 @@ namespace StgSharp.Script.Express
Token source,
ExpSyntaxNode target,
ExpSyntaxNode defaultCase,
IDictionary<ExpSyntaxNode, ExpSyntaxNode> cases )
: base( source )
IDictionary<ExpSyntaxNode, ExpSyntaxNode> cases)
: base(source)
{
_target = target;
_default = defaultCase;
@@ -96,8 +93,8 @@ namespace StgSharp.Script.Express
string str = @"switch( {0} ){";
StringBuilder codeFormatBuilder = new StringBuilder();
codeFormatBuilder.AppendLine( str );
for( int i = 0; i < cases.Count; i++ )
codeFormatBuilder.AppendLine(str);
for (int i = 0; i < cases.Count; i++)
{
int index = i * 2 + 1;
codeFormatBuilder.AppendLine(
@@ -105,16 +102,16 @@ namespace StgSharp.Script.Express
case {{{index}}}:
{{{index + 1}}}
break;
""" );
""");
}
CodeConvertTemplate = codeFormatBuilder.ToString();
}
public ExpSyntaxNode this[ ExpSyntaxNode index ]
public ExpSyntaxNode this[ExpSyntaxNode index]
{
get
{
if( _cases.TryGetValue( index, out ExpSyntaxNode? ret ) ) {
if (_cases.TryGetValue(index, out ExpSyntaxNode? ret)) {
return ret;
}
return _default;
@@ -127,9 +124,9 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert => null!;
public bool ContainsCase( ExpSyntaxNode token )
public bool ContainsCase(ExpSyntaxNode token)
{
return _cases.ContainsKey( token );
return _cases.ContainsKey(token);
}
}
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpTupleNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpTupleNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
@@ -42,8 +39,8 @@ namespace StgSharp.Script.Express
private ExpSyntaxNode node;
private ExpTupleNode( ExpSyntaxNode node )
: base( node._source )
private ExpTupleNode(ExpSyntaxNode node)
: base(node._source)
{
this.node = node;
}
@@ -54,10 +51,10 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException();
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static ExpTupleNode Pack( ExpSyntaxNode node )
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ExpTupleNode Pack(ExpSyntaxNode node)
{
return new ExpTupleNode( node );
return new ExpTupleNode(node);
}
public ExpNodePresidentEnumerator TupleAsEnumerator()
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpUnaryOperatorNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpUnaryOperatorNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
@@ -41,10 +38,10 @@ namespace StgSharp.Script.Express
private ExpSyntaxNode _operand;
private ExpUnaryOperatorNode( Token source ) : base( source ) { }
private ExpUnaryOperatorNode(Token source) : base(source) { }
public ExpUnaryOperatorNode( Token source, ExpSyntaxNode operand, ExpSchema context )
: base( source )
public ExpUnaryOperatorNode(Token source, ExpSyntaxNode operand, ExpSchema context)
: base(source)
{
_operand = operand;
}
@@ -55,44 +52,43 @@ namespace StgSharp.Script.Express
public override IExpElementSource EqualityTypeConvert => _operand.EqualityTypeConvert;
public static ExpUnaryOperatorNode UnaryMinus( Token source, ExpSyntaxNode operand )
public static ExpUnaryOperatorNode UnaryMinus(Token source, ExpSyntaxNode operand)
{
if( !operand.IsNumber ) {
if (!operand.IsNumber) {
throw new ExpInvalidTypeException(
source, "Number", operand.EqualityTypeConvert.Name );
source, "Number", operand.EqualityTypeConvert.Name);
}
bool isFloat =
( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
return new ExpUnaryOperatorNode( source )
(operand._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0;
return new ExpUnaryOperatorNode(source)
{
_nodeFlag = ExpNodeFlag.Operator_Unary | ExpNodeFlag.BuiltinType_Number,
CodeConvertTemplate = "- {0}",
};
}
public static ExpUnaryOperatorNode UnaryNot( Token source, ExpSyntaxNode operand )
public static ExpUnaryOperatorNode UnaryNot(Token source, ExpSyntaxNode operand)
{
if( ( operand._nodeFlag | ( ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.BuiltinType_Logic ) ) ==
0 ) {
if ((operand._nodeFlag | (ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.BuiltinType_Logic)) == 0) {
throw new ExpInvalidTypeException(
source, "Bool or Logic", operand.EqualityTypeConvert.Name );
source, "Bool or Logic", operand.EqualityTypeConvert.Name);
}
return new ExpUnaryOperatorNode( source )
return new ExpUnaryOperatorNode(source)
{
_nodeFlag = ExpNodeFlag.Operator_Unary | ExpNodeFlag.BuiltinType_Logic,
CodeConvertTemplate = "! {0}",
};
}
public static ExpUnaryOperatorNode UnaryPlus( Token source, ExpSyntaxNode operand )
public static ExpUnaryOperatorNode UnaryPlus(Token source, ExpSyntaxNode operand)
{
if( !operand.IsNumber ) {
if (!operand.IsNumber) {
throw new ExpInvalidTypeException(
source, "Number", operand.EqualityTypeConvert.Name );
source, "Number", operand.EqualityTypeConvert.Name);
}
bool isFloat =
( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
return new ExpUnaryOperatorNode( source )
(operand._nodeFlag | ExpNodeFlag.BuiltinType_Real) == 0;
return new ExpUnaryOperatorNode(source)
{
_nodeFlag = ExpNodeFlag.Operator_Unary | ExpNodeFlag.BuiltinType_Number,
CodeConvertTemplate = "+ {0}",
+42 -48
View File
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="_ExpNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="_ExpNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using CommunityToolkit.HighPerformance.Buffers;
using System;
@@ -45,7 +42,7 @@ namespace StgSharp.Script.Express
protected internal ExpNodeFlag _nodeFlag;
protected internal Token _source;
protected ExpSyntaxNode( Token source )
protected ExpSyntaxNode(Token source)
{
_source = source;
Next = this;
@@ -54,7 +51,7 @@ namespace StgSharp.Script.Express
public bool IsNumber
{
get { return ( _nodeFlag | ExpNodeFlag.BuiltinType_Number ) != 0; }
get { return (_nodeFlag | ExpNodeFlag.BuiltinType_Number) != 0; }
}
public abstract ExpSyntaxNode Left { get; }
@@ -76,7 +73,7 @@ namespace StgSharp.Script.Express
public int Column => _source.Column;
public long NodeFlag => ( long )_nodeFlag;
public long NodeFlag => (long)_nodeFlag;
public string CodeConvertTemplate { get; init; }
@@ -85,7 +82,7 @@ namespace StgSharp.Script.Express
get => _source;
}
public void AppendNode( ExpSyntaxNode nextNode )
public void AppendNode(ExpSyntaxNode nextNode)
{
Next.Previous = nextNode;
nextNode.Next = Next;
@@ -93,24 +90,24 @@ namespace StgSharp.Script.Express
Next.Previous = this;
}
public static bool IsNullOrEmpty( [AllowNull]ExpSyntaxNode node )
public static bool IsNullOrEmpty([AllowNull]ExpSyntaxNode node)
{
return node == ExpEmptyNode._only || node == null;
}
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static ExpSyntaxNode NonOperation( Token source )
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ExpSyntaxNode NonOperation(Token source)
{
return new ExpEmptyNode( source.Line, source.Column );
return new ExpEmptyNode(source.Line, source.Column);
}
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static ExpSyntaxNode NonOperation( int line, int column )
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ExpSyntaxNode NonOperation(int line, int column)
{
return new ExpEmptyNode( line, column );
return new ExpEmptyNode(line, column);
}
public void PrependNode( ExpSyntaxNode previousNode )
public void PrependNode(ExpSyntaxNode previousNode)
{
Previous.Next = previousNode;
previousNode.Previous = Previous;
@@ -118,19 +115,17 @@ namespace StgSharp.Script.Express
previousNode.Next = this;
}
public static bool VerifyTypeConvertable( ExpSyntaxNode left, ExpSyntaxNode right )
public static bool VerifyTypeConvertable(ExpSyntaxNode left, ExpSyntaxNode right)
{
IExpElementSource tLeft = left.EqualityTypeConvert,
tRight = right.EqualityTypeConvert;
if( tLeft is not ExpInstantiableElement tLeftIns ||
tRight is not ExpInstantiableElement tRightIns ) {
if (tLeft is not ExpInstantiableElement tLeftIns || tRight is not ExpInstantiableElement tRightIns) {
return false;
}
if( ExpInstantiableElement.IsNullOrVoid( tLeftIns ) ||
ExpInstantiableElement.IsNullOrVoid( tLeftIns ) ) {
if (ExpInstantiableElement.IsNullOrVoid(tLeftIns) || ExpInstantiableElement.IsNullOrVoid(tLeftIns)) {
return false;
}
return tLeft.IsConvertable( tRight );
return tLeft.IsConvertable(tRight);
}
private class ExpEmptyNode : ExpSyntaxNode
@@ -138,10 +133,9 @@ namespace StgSharp.Script.Express
internal static readonly ExpEmptyNode _only = new();
public ExpEmptyNode() : base( Token.Empty ) { }
public ExpEmptyNode() : base(Token.Empty) { }
public ExpEmptyNode( int line, int column )
: base( new Token( string.Empty, line, column, TokenFlag.None ) ) { }
public ExpEmptyNode(int line, int column) : base(new Token(string.Empty, line, column, TokenFlag.None)) { }
public override ExpInstantiableElement EqualityTypeConvert => ExpInstantiableElement.Void;