Daily update on 20250618-051714 by Nitload Youmu. Additional Message : Brief support to collection operation in EXPRESS. A collection type added in core lib and compilestack.

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-06-18 05:17:14 +08:00
parent 74c01effe4
commit c624a8ca38
300 changed files with 12227 additions and 4303 deletions
@@ -73,8 +73,8 @@ namespace StgSharp.Script.Express
left.EqualityTypeConvert.Name );
}
bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) ==
0;
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
return new ExpBinaryOperatorNode( source, left, right )
{
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
@@ -158,8 +158,8 @@ namespace StgSharp.Script.Express
left.EqualityTypeConvert.Name );
}
bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) ==
0;
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
return new ExpBinaryOperatorNode( source, left, right )
{
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
@@ -229,8 +229,8 @@ namespace StgSharp.Script.Express
left.EqualityTypeConvert.Name );
}
bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) ==
0;
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
return new ExpBinaryOperatorNode( source, left, right )
{
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
@@ -283,8 +283,8 @@ namespace StgSharp.Script.Express
left.EqualityTypeConvert.Name );
}
bool isFloat =
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) ==
0;
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 ||
( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
return new ExpBinaryOperatorNode( source, left, right )
{
_returnType = isFloat ? ExpressCompile.ExpReal : ExpressCompile.ExpInt,
@@ -0,0 +1,68 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpEnumLiteralNode.cs"
// 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.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using System;
namespace StgSharp.Script.Express
{
public class ExpEnumLiteralNode : ExpSyntaxNode
{
private ExpEnumLiteralNode( Token t ) : base( t ) { }
public override ExpSyntaxNode Left => Empty;
public override ExpSyntaxNode Right => Empty;
public override IExpElementSource EqualityTypeConvert => ExpInstantiableElement.Void;
public string Literal { get; private set; }
public static ExpEnumLiteralNode Create( Token t, Func<string, string> parser )
{
string l;
if( parser is null )
{
l = t.Value;
} else
{
l = parser( t.Value );
}
return new ExpEnumLiteralNode( t )
{
Literal = l,
CodeConvertTemplate = l
};
}
}
}
@@ -88,7 +88,14 @@ namespace StgSharp.Script.Express
}
public class ExpBoolNode : ExpElementInstance
public interface IExpBooleanSyntax
{
bool Value { get; }
}
public class ExpBoolNode : ExpElementInstance, IExpBooleanSyntax
{
private readonly bool _value;
@@ -152,7 +159,7 @@ namespace StgSharp.Script.Express
}
public class ExpLogicValueNode : ExpElementInstance
public class ExpLogicValueNode : ExpElementInstance, IExpBooleanSyntax
{
private readonly ExpLogic _value;
@@ -166,7 +173,7 @@ namespace StgSharp.Script.Express
CodeConvertTemplate = isLiteral ? value.ToString() : source.Value;
}
public ExpLogic Value => _value;
public ExpLogic LogicValue => _value;
public override IExpElementSource EqualityTypeConvert
{
@@ -177,5 +184,7 @@ namespace StgSharp.Script.Express
public override string TypeName => EqualityTypeConvert.Name;
bool IExpBooleanSyntax.Value => _value.ToBoolean();
}
}
@@ -0,0 +1,61 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpRangeAndIndexNode.cs"
// 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.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Script.Express
{
public class ExpIndexNode : ExpInstanceReferenceNode
{
internal ExpIndexNode( Token t, ExpSyntaxNode node ) : base( t ) { }
public override ExpSyntaxNode Left => throw new NotImplementedException();
public override ExpSyntaxNode Right => throw new NotImplementedException();
public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException();
public static ExpIndexNode IndexAt( Token position, ExpSyntaxNode expression )
{
ArgumentNullException.ThrowIfNull( expression );
if( ExpNodeFlag.BuiltinType_Int.IsNotInFlag( expression.NodeFlag ) ) {
throw new ExpInvalidTypeException(
position, "Integer", expression.EqualityTypeConvert.Name );
}
return new ExpIndexNode( position, expression );
}
}
}
@@ -54,9 +54,9 @@ namespace StgSharp.Script.Express
ExpSyntaxNode whileRule )
: base( source )
{
if( variable.NodeFlag != begin.NodeFlag || begin.NodeFlag != end.NodeFlag || ( increment !=
null && end.NodeFlag !=
increment.NodeFlag ) ) {
if( variable.NodeFlag != begin.NodeFlag ||
begin.NodeFlag != end.NodeFlag ||
( increment != null && end.NodeFlag != increment.NodeFlag ) ) {
throw new InvalidCastException();
}
if( IsNullOrEmpty( increment ) )
@@ -60,9 +60,9 @@ namespace StgSharp.Script.Express
return new ExpTupleNode( node );
}
public ExpNodeNextEnumerator TupleAsEnumerator()
public ExpNodePresidentEnumerator TupleAsEnumerator()
{
return node.ToEnumerator();
return node.ToPresidentEnumerator();
}
}
@@ -122,11 +122,12 @@ namespace StgSharp.Script.Express
{
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 );