diff --git a/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.AssemblyInfo.cs b/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.AssemblyInfo.cs index 4c2d9f9b..28878ddc 100644 --- a/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.AssemblyInfo.cs +++ b/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Model")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+148b0fed4a1abaaeaa3a28e7c7b088590805ebef")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ffd5825a051f04f4105ac5ed02e754176ce6f608")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Model")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Model")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.sourcelink.json b/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.sourcelink.json index 248b54bf..146ac8e6 100644 --- a/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.sourcelink.json +++ b/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.sourcelink.json @@ -1 +1 @@ -{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/148b0fed4a1abaaeaa3a28e7c7b088590805ebef/*"}} \ No newline at end of file +{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/ffd5825a051f04f4105ac5ed02e754176ce6f608/*"}} \ No newline at end of file diff --git a/StgSharp.Script/Express/Builtin/ExpBuiltinType.cs b/StgSharp.Script/Express/Builtin/ExpBuiltinType.cs index c1f79391..a4c4cf7f 100644 --- a/StgSharp.Script/Express/Builtin/ExpBuiltinType.cs +++ b/StgSharp.Script/Express/Builtin/ExpBuiltinType.cs @@ -36,7 +36,7 @@ using System.Text; namespace StgSharp.Script.Express { - public sealed class ExpBuiltinType : ExpTypeSource + internal sealed class ExpBuiltinType : ExpTypeSource { private Type _marshalType; diff --git a/StgSharp.Script/Express/Builtin/ExpCollection.cs b/StgSharp.Script/Express/Builtin/ExpCollection.cs index c6e2dbe4..817c380e 100644 --- a/StgSharp.Script/Express/Builtin/ExpCollection.cs +++ b/StgSharp.Script/Express/Builtin/ExpCollection.cs @@ -37,7 +37,7 @@ using System.Text; namespace StgSharp.Script.Express { - public abstract class ExpCollectionBase : ExpInstantiableElement, IEnumerable + public abstract class ExpCollectionBase : ExpInstantiableElement, IEnumerable { protected internal string _accurateType; @@ -49,10 +49,7 @@ namespace StgSharp.Script.Express public override ExpElementType ElementType => ExpElementType.Collection; - public abstract int Count - { - get; - } + public abstract int Count { get; } public override sealed IScriptSourceProvider SourceProvider => ScriptSourceTransmitter.Empty; @@ -66,7 +63,7 @@ namespace StgSharp.Script.Express return; } - public abstract IEnumerator GetEnumerator(); + public abstract IEnumerator GetEnumerator(); public override bool TryGetMember( string name, out ExpNode memberNode ) { @@ -84,18 +81,17 @@ namespace StgSharp.Script.Express public class ExpArray : ExpCollectionBase { - private ExpElementInstanceBase[] _collection; + private ExpElementInstance[] _collection; public ExpArray( string accurateType ) : base( accurateType ) { } - public ExpElementInstanceBase this[ int index ] + public ExpElementInstance this[ int index ] { get { return _collection[ index ]; } set { if( value.TypeName != MemberType ) { - throw new ExpInvalidCollectionMemberTypeException( - value, this ); + throw new ExpInvalidCollectionMemberTypeException( value, this ); } _collection[ index ] = value; } @@ -110,9 +106,9 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override IEnumerator GetEnumerator() + public override IEnumerator GetEnumerator() { - return ( ( IEnumerable )_collection ) + return ( ( IEnumerable )_collection ) .GetEnumerator(); } @@ -121,7 +117,7 @@ namespace StgSharp.Script.Express public class ExpBag : ExpCollectionBase { - private ConcurrentBag _collection = new ConcurrentBag( + private ConcurrentBag _collection = new ConcurrentBag( ); public ExpBag( string accurateType ) : base( accurateType ) { } @@ -135,7 +131,7 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override IEnumerator GetEnumerator() + public override IEnumerator GetEnumerator() { return _collection.GetEnumerator(); } @@ -145,8 +141,7 @@ namespace StgSharp.Script.Express public sealed class ExpList : ExpCollectionBase { - private List _collection = new List( - ); + private List _collection = new List(); public ExpList( string accurateType ) : base( accurateType ) { } @@ -159,7 +154,7 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override IEnumerator GetEnumerator() + public override IEnumerator GetEnumerator() { return _collection.GetEnumerator(); } @@ -169,7 +164,7 @@ namespace StgSharp.Script.Express public class ExpSet : ExpCollectionBase { - private HashSet _collection = new(); + private HashSet _collection = new(); public ExpSet( string accurateType ) : base( accurateType ) { } @@ -177,11 +172,10 @@ namespace StgSharp.Script.Express public override string Name => ExpressCompile.PoolString( "SET" ); - public void Add( ExpElementInstanceBase token ) + public void Add( ExpElementInstance token ) { if( token.TypeName != MemberType ) { - throw new ExpInvalidCollectionMemberTypeException( token, - this ); + throw new ExpInvalidCollectionMemberTypeException( token, this ); } _collection.Add( token ); } @@ -191,10 +185,9 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override sealed IEnumerator GetEnumerator( - ) + public override sealed IEnumerator GetEnumerator() { - return ( ( IEnumerable )_collection ) + return ( ( IEnumerable )_collection ) .GetEnumerator(); } diff --git a/StgSharp.Script/Express/Builtin/IExpBuiltinType.cs b/StgSharp.Script/Express/Builtin/IExpBuiltinType.cs new file mode 100644 index 00000000..17b21a0f --- /dev/null +++ b/StgSharp.Script/Express/Builtin/IExpBuiltinType.cs @@ -0,0 +1,45 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="IExpBuiltinType.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 interface IExpBuiltinType where TSelf: ExpElementInstance, IExpBuiltinType + { + + static abstract ExpElementInstance CreateInstance(); + + } +} diff --git a/StgSharp.Script/Express/CompileEnv/BuiltinType.cs b/StgSharp.Script/Express/CompileEnv/BuiltinType.cs index 53e5b44f..7b036980 100644 --- a/StgSharp.Script/Express/CompileEnv/BuiltinType.cs +++ b/StgSharp.Script/Express/CompileEnv/BuiltinType.cs @@ -39,23 +39,13 @@ namespace StgSharp.Script.Express public static partial class ExpressCompile { - public static ExpTypeSource ExpInt - { - get; - private set; - } + public static ExpTypeSource ExpInt { get; private set; } - public static ExpTypeSource ExpReal - { - get; - private set; - } + public static ExpTypeSource ExpReal { get; private set; } - public static ExpTypeSource ExpBool - { - get; - private set; - } + public static ExpTypeSource ExpBool { get; private set; } + + public static ExpTypeSource ExpString { get; private set; } } } diff --git a/StgSharp.Script/Express/CompileEnv/DefaultSchema.cs b/StgSharp.Script/Express/CompileEnv/DefaultSchema.cs index d61fd9c7..9df8c128 100644 --- a/StgSharp.Script/Express/CompileEnv/DefaultSchema.cs +++ b/StgSharp.Script/Express/CompileEnv/DefaultSchema.cs @@ -59,7 +59,7 @@ namespace StgSharp.Script.Express return; } - public override bool TryGetConst( string name, out ExpElementInstanceBase c ) + public override bool TryGetConst( string name, out ExpElementInstance c ) { return ConstDict.TryGetValue( name, out c ); } @@ -118,11 +118,11 @@ namespace StgSharp.Script.Express Multiplexer ).ToFrozenDictionary(); - ConstDict = new Dictionary( Multiplexer ) { + ConstDict = new Dictionary( Multiplexer ) { { PoolString( "PI" ), new ExpRealNumberNode( - new Token( PoolString( "PI" ), -1, -1, TokenFlag.Number ), MathF.PI ) }, + new Token( PoolString( "PI" ), -1, -1, TokenFlag.Number ), MathF.PI, true ) }, { PoolString( "E" ), new ExpRealNumberNode( - new Token( PoolString( "E" ), -1, -1, TokenFlag.Number ), MathF.E ) }, + new Token( PoolString( "E" ), -1, -1, TokenFlag.Number ), MathF.E, true ) }, }.ToFrozenDictionary(); } diff --git a/StgSharp.Script/Express/CompileEnv/ExpCompile.cs b/StgSharp.Script/Express/CompileEnv/ExpCompile.cs index da1cbf10..e92a288f 100644 --- a/StgSharp.Script/Express/CompileEnv/ExpCompile.cs +++ b/StgSharp.Script/Express/CompileEnv/ExpCompile.cs @@ -47,7 +47,7 @@ namespace StgSharp.Script.Express private static string[] _operatorsWithLetter; private static ConcurrentStringHashMultiplexer _multiplexer; - private static FrozenDictionary _builtinConst; + private static FrozenDictionary _builtinConst; private static FrozenDictionary _builtinType; private static FrozenDictionary _operators; private static StringPool _compileStringCache,_emptyCache; @@ -112,6 +112,12 @@ namespace StgSharp.Script.Express PoolString( Keyword.Boolean ), out ExpTypeSource? _expBool ); ExpBool = _expBool; + ExpSchema_Builtin.Only + .TryGetType( + PoolString( Keyword.Boolean ), out ExpTypeSource? _expString ); + ExpString = _expString; + + _emptyCache = new StringPool(); /* foreach( string str in _compileStringCache ) { diff --git a/StgSharp.Script/Express/Element/ExpConst.cs b/StgSharp.Script/Express/Element/ExpConst.cs index 9c491786..7e646993 100644 --- a/StgSharp.Script/Express/Element/ExpConst.cs +++ b/StgSharp.Script/Express/Element/ExpConst.cs @@ -42,14 +42,13 @@ namespace StgSharp.Script.Express public sealed class ExpConstantCollectionSource : ExpImmutableElement { - private Dictionary _constants; + private Dictionary _constants; private IScriptSourceProvider _sourceProvider; public ExpConstantCollectionSource( IScriptSourceProvider sourceProvider ) { _sourceProvider = sourceProvider; - _constants = new Dictionary( - ExpressCompile.Multiplexer ); + _constants = new Dictionary( ExpressCompile.Multiplexer ); } public override ExpElementType ElementType => ExpElementType.Const; @@ -74,20 +73,20 @@ namespace StgSharp.Script.Express if( _constants.Count == 0 ) { return null!; } - if( _constants.TryGetValue( str, out ExpElementInstanceBase? token ) ) { + if( _constants.TryGetValue( str, out ExpElementInstance? token ) ) { return token; } return null!; } - public bool TryGetConstant( string name, out ExpElementInstanceBase instance ) + public bool TryGetConstant( string name, out ExpElementInstance instance ) { return _constants.TryGetValue( name, out instance ); } public override bool TryGetMember( string name, out ExpNode memberNode ) { - if( _constants.TryGetValue( name, out ExpElementInstanceBase? node ) ) + if( _constants.TryGetValue( name, out ExpElementInstance? node ) ) { memberNode = node; return true; @@ -96,7 +95,7 @@ namespace StgSharp.Script.Express return false; } - internal void AddConstant( string name, ExpElementInstanceBase value ) + internal void AddConstant( string name, ExpElementInstance value ) { _constants.Add( name, value ); } diff --git a/StgSharp.Script/Express/Element/ExpFunction.cs b/StgSharp.Script/Express/Element/ExpFunction.cs index 65858c77..050629ff 100644 --- a/StgSharp.Script/Express/Element/ExpFunction.cs +++ b/StgSharp.Script/Express/Element/ExpFunction.cs @@ -40,25 +40,17 @@ namespace StgSharp.Script.Express private ScriptSourceTransmitter _transmitter; private string _name; - public ExpFunctionSource( - string name, - ScriptSourceTransmitter transmitter ) + public ExpFunctionSource( string name, ScriptSourceTransmitter transmitter ) { _name = name; _transmitter = transmitter; } - public Dictionary FuncParams - { - get; - init; - } = new Dictionary(); + public Dictionary FuncParams { get; init; } = new Dictionary( + ); - public Dictionary LocalVariables - { - get; - init; - } = new Dictionary(); + public Dictionary LocalVariables { get; init; } = new Dictionary( + ); public override ExpElementType ElementType => ExpElementType.Function; @@ -66,11 +58,7 @@ namespace StgSharp.Script.Express public override string Name => _name; - public string CallingFormat - { - get; - private set; - } + public string CallingFormat { get; private set; } public override void Analyse() { @@ -89,13 +77,13 @@ namespace StgSharp.Script.Express public override bool TryGetMember( string name, out ExpNode memberNode ) { - if( FuncParams.TryGetValue( - name, out ExpElementInstanceBase? param ) ) { + if( FuncParams.TryGetValue( name, out ExpElementInstance? param ) ) + { memberNode = param; return true; } - if( LocalVariables.TryGetValue( - name, out ExpElementInstanceBase? variable ) ) { + if( LocalVariables.TryGetValue( name, out ExpElementInstance? variable ) ) + { memberNode = variable; return true; } diff --git a/StgSharp.Script/Express/Element/ExpRule.cs b/StgSharp.Script/Express/Element/ExpRule.cs index a704e734..e638f1e5 100644 --- a/StgSharp.Script/Express/Element/ExpRule.cs +++ b/StgSharp.Script/Express/Element/ExpRule.cs @@ -36,7 +36,7 @@ using System.Text; namespace StgSharp.Script.Express { - public class ExpRule : ExpElementInstanceBase + public class ExpRule : ExpElementInstance { private ExpRuleSource _source; diff --git a/StgSharp.Script/Express/Element/ExpType.cs b/StgSharp.Script/Express/Element/ExpType.cs index 6f567c22..69c81492 100644 --- a/StgSharp.Script/Express/Element/ExpType.cs +++ b/StgSharp.Script/Express/Element/ExpType.cs @@ -77,7 +77,7 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override ExpElementInstanceBase CreateInstanceNode() + public override ExpElementInstance CreateInstanceNode() { throw new NotImplementedException(); } @@ -96,8 +96,7 @@ namespace StgSharp.Script.Express private class ExpVoidType : ExpTypeSource { - private static readonly ExpVoidType _onlyInstance = new ExpVoidType( - ); + private static readonly ExpVoidType _onlyInstance = new ExpVoidType(); private ExpVoidType() : base( string.Empty ) { } diff --git a/StgSharp.Script/Express/ExpAstNode/ExpInstanceMemberNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpInstanceMemberNode.cs index d971767c..19d817ad 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpInstanceMemberNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpInstanceMemberNode.cs @@ -41,20 +41,19 @@ namespace StgSharp.Script.Express public class ExpInstanceMemberNode : ExpNode { - private ExpElementInstanceBase _instance; + private ExpElementInstance _instance; private ExpElementMemberNameNode _memberName; private ExpNode _member; public ExpInstanceMemberNode( - Token source, - ExpElementInstanceBase instance, - ExpElementMemberNameNode memberName ) + 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 ExpNode Left => _instance; diff --git a/StgSharp.Script/Express/ExpAstNode/ExpInstanceReferenceNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpInstanceReferenceNode.cs index dbdaeb13..e50cf585 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpInstanceReferenceNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpInstanceReferenceNode.cs @@ -40,13 +40,14 @@ namespace StgSharp.Script.Express public class ExpInstanceReferenceNode : ExpNode { - private ExpElementInstanceBase _instance; + private ExpElementInstance _instance; - internal ExpInstanceReferenceNode( Token source, ExpElementInstanceBase instance ) + internal ExpInstanceReferenceNode( Token source, ExpElementInstance instance ) : base( source ) { _instance = instance; _nodeFlag = ( _instance._nodeFlag | ( ExpNodeFlag.Name_Any | ExpNodeFlag.Collection_Any ) ); + CodeConvertTemplate = source.Value; } internal ExpInstanceReferenceNode( Token source, ExpInstanceReferenceNode reference ) @@ -64,11 +65,15 @@ namespace StgSharp.Script.Express public override IExpElementSource EqualityTypeConvert => _instance.EqualityTypeConvert; [MethodImpl( MethodImplOptions.AggressiveInlining )] - public static ExpInstanceReferenceNode Create( + public static ExpInstanceReferenceNode MakeReferenceFrom( Token source, - ExpElementInstanceBase instance ) + ExpElementInstance instance ) { - /* + /**/ + if( instance.IsLiteral ) + { + 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" ); } diff --git a/StgSharp.Script/Express/ExpAstNode/ExpLiteralNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpLiteralNode.cs index 6d0ded4b..5d627030 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpLiteralNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpLiteralNode.cs @@ -34,26 +34,28 @@ using System; using System.Collections; using System.Collections.Generic; using System.Text; +using System.Text.RegularExpressions; namespace StgSharp.Script.Express { - public class ExpIntNode : ExpElementInstanceBase + public class ExpIntNode : ExpElementInstance { private int _value; - public ExpIntNode( Token source, int value ) + public ExpIntNode( Token source, int value, bool isLiteral ) : base( source ) { + this.IsLiteral = isLiteral; _value = value; _nodeFlag = ExpNodeFlag.BuiltinType_Int | ExpNodeFlag.Element_Type; + CodeConvertTemplate = IsLiteral ? value.ToString() : source.Value; } - public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema - .TryGetType( - ExpressCompile.Keyword.Integer, - out ExpTypeSource? type ) ? - type : throw new ExpCompileNotInitializedException(); + public override IExpElementSource EqualityTypeConvert + { + get => ExpressCompile.ExpInt; + } public int Value => _value; @@ -61,23 +63,24 @@ namespace StgSharp.Script.Express } - public class ExpStringNode : ExpElementInstanceBase + public class ExpStringNode : ExpElementInstance { private readonly string _value; - public ExpStringNode( Token source, string value ) + public ExpStringNode( Token source, string value, bool isLiteral ) : base( source ) { + this.IsLiteral = IsLiteral; _value = value; _nodeFlag = ExpNodeFlag.BuiltinType_String | ExpNodeFlag.Element_Type; + CodeConvertTemplate = IsLiteral ? $"\"{value}\"" : source.Value; } - public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema - .TryGetType( - ExpressCompile.Keyword.String, - out ExpTypeSource? type ) ? - type : throw new ExpCompileNotInitializedException(); + public override IExpElementSource EqualityTypeConvert + { + get => ExpressCompile.ExpString; + } public override string TypeName => EqualityTypeConvert.Name; @@ -85,73 +88,81 @@ namespace StgSharp.Script.Express } - public class ExpBoolNode : ExpElementInstanceBase + public class ExpBoolNode : ExpElementInstance { private readonly bool _value; - public ExpBoolNode( Token source, bool value ) + public ExpBoolNode( Token source, bool value, bool isLiteral ) : base( source ) { + this.IsLiteral = isLiteral; _value = value; _nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Element_Type; + CodeConvertTemplate = IsLiteral ? value.ToString() : source.Value; } public bool Value => _value; - public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema - .TryGetType( - ExpressCompile.Keyword.Boolean, - out ExpTypeSource? type ) ? - type : throw new ExpCompileNotInitializedException(); + public override IExpElementSource EqualityTypeConvert + { + get => ExpSchema.BuiltinSchema + .TryGetType( ExpressCompile.Keyword.Boolean, out ExpTypeSource? type ) ? + type : throw new ExpCompileNotInitializedException(); + } public override string TypeName => EqualityTypeConvert.Name; } - public class ExpRealNumberNode : ExpElementInstanceBase + public class ExpRealNumberNode : ExpElementInstance { private readonly float _value; - public ExpRealNumberNode( Token source, float value ) + public ExpRealNumberNode( Token source, float value, bool isLiteral ) : base( source ) { _value = value; _nodeFlag = ExpNodeFlag.BuiltinType_Real | ExpNodeFlag.Element_Type; + CodeConvertTemplate = isLiteral ? $"{value:F8}f" : source.Value; } public float Value => _value; - public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema - .TryGetType( - ExpressCompile.Keyword.String, - out ExpTypeSource? type ) ? - type : throw new ExpCompileNotInitializedException(); + public override IExpElementSource EqualityTypeConvert + { + get => ExpSchema.BuiltinSchema + .TryGetType( ExpressCompile.Keyword.String, out ExpTypeSource? type ) ? + type : throw new ExpCompileNotInitializedException(); + } public override string TypeName => EqualityTypeConvert.Name; } - public class ExpLogicValueNode : ExpElementInstanceBase + public class ExpLogicValueNode : ExpElementInstance { private readonly ExpLogic _value; - public ExpLogicValueNode( Token source, ExpLogic value ) + public ExpLogicValueNode( Token source, ExpLogic value, bool isLiteral ) : base( source ) { + this.IsLiteral = isLiteral; _value = value; _nodeFlag = ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.Element_Type; + CodeConvertTemplate = isLiteral ? value.ToString() : source.Value; } public ExpLogic Value => _value; - public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema - .TryGetType( - ExpressCompile.Keyword.Logical, - out ExpTypeSource? type ) ? - type : throw new ExpCompileNotInitializedException(); + public override IExpElementSource EqualityTypeConvert + { + get => ExpSchema.BuiltinSchema + .TryGetType( ExpressCompile.Keyword.Logical, out ExpTypeSource? type ) ? + type : throw new ExpCompileNotInitializedException(); + } public override string TypeName => EqualityTypeConvert.Name; diff --git a/StgSharp.Script/Express/ExpAstNode/ExpRepeatNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpRepeatNode.cs index 15c27778..ed8c5e83 100644 --- a/StgSharp.Script/Express/ExpAstNode/ExpRepeatNode.cs +++ b/StgSharp.Script/Express/ExpAstNode/ExpRepeatNode.cs @@ -41,43 +41,44 @@ namespace StgSharp.Script.Express //TODO: Current code cannot represent full functionality defined in ISO10303, need rewrite. - private ExpElementInstanceBase _variable, _begin, _end, _increment; + private ExpElementInstance _variable, _begin, _end, _increment; private ExpNode _operationBegin; public ExpRepeatNode( - Token source, - ExpNode operationBegin, - ExpElementInstanceBase variable, - ExpElementInstanceBase begin, - ExpElementInstanceBase end, - ExpElementInstanceBase increment ) + Token source, + ExpNode operationBegin, + ExpElementInstance variable, + ExpElementInstance begin, + ExpElementInstance end, + ExpElementInstance increment ) : 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( increment == null ) { - switch( ( ExpNodeFlag )variable.NodeFlag | ExpNodeFlag.BuiltinType_Any ) { + if( increment == null ) + { + switch( ( ExpNodeFlag )variable.NodeFlag | ExpNodeFlag.BuiltinType_Any ) + { case ExpNodeFlag.BuiltinType_Real: increment = new ExpRealNumberNode( new Token( - ExpressCompile.PoolString( "1.0f" ), source.Line, - -1, TokenFlag.Number ), - 1.0f ); + ExpressCompile.PoolString( "1.0f" ), source.Line, -1, + TokenFlag.Number ), + 1.0f, isLiteral: true ); break; case ExpNodeFlag.BuiltinType_Int: increment = new ExpIntNode( new Token( ExpressCompile.PoolString( "1" ), source.Line, -1, TokenFlag.Number ), - 1 ); + 1, isLiteral: true ); break; default: - throw new ExpInvalidTypeException( - "Int or Real", "otherwise" ); + throw new ExpInvalidTypeException( "Int or Real", "otherwise" ); } } _begin = begin; diff --git a/StgSharp.Script/Express/ExpElementInstance.cs b/StgSharp.Script/Express/ExpElementInstance.cs new file mode 100644 index 00000000..4f546362 --- /dev/null +++ b/StgSharp.Script/Express/ExpElementInstance.cs @@ -0,0 +1,133 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="ExpElementInstance.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.IO; +using System.Runtime.CompilerServices; +using System.Text; + +namespace StgSharp.Script.Express +{ + [Flags] + public enum ExpElementType : int + { + + Void = 0, + Const = 1, + Entity = 2, + Type = 4, + Function = 8, + Section = 16, + Expression = 32, + Rule = 64, + Procedure = 128, + Collection = 256, + + } + + public abstract class ExpElementInstance : ExpNode + { + + protected ExpElementInstance( Token source ) + : base( source ) + { + CodeConvertTemplate = source.Value; + } + + public bool IsLiteral { get; init; } + + public ExpElementType ElementType { get; } + + public override ExpNode Left => Empty; + + public override ExpNode Right => Empty; + + public abstract string TypeName { get; } + + public static ExpElementInstance CreateLiteral( Token t ) + { + if( int.TryParse( t.Value, out int _int ) ) + { + return new ExpIntNode( t, _int, true ); + } else if( float.TryParse( t.Value, out float _float ) ) + { + return new ExpRealNumberNode( t, _float, true ); + } else if( bool.TryParse( t.Value, out bool _bool ) ) + { + return new ExpBoolNode( t, _bool, true ); + } else if( ExpLogic.TryParse( t.Value, out ExpLogic _logic ) ) + { + return new ExpLogicValueNode( t, _logic, true ); + } else + { + return new ExpStringNode( t, t.Value, true ); + } + } + + public ExpInstanceReferenceNode MakeReference( Token t ) + { + return new ExpInstanceReferenceNode( t, this ); + } + + public static bool TryCreateLiteral( Token t, out ExpElementInstance instance ) + { + if( int.TryParse( t.Value, out int _int ) ) + { + instance = new ExpIntNode( t, _int, true ); + return true; + } else if( float.TryParse( t.Value, out float _float ) ) + { + instance = new ExpRealNumberNode( t, _float, true ); + return true; + } else if( bool.TryParse( t.Value, out bool _bool ) ) + { + instance = new ExpBoolNode( t, _bool, true ); + return true; + } else if( ExpLogic.TryParse( t.Value, out ExpLogic _logic ) ) + { + instance = new ExpLogicValueNode( t, _logic, true ); + return true; + } else if( t.Flag == TokenFlag.String ) + { + instance = new ExpStringNode( t, t.Value, true ); + return true; + } + instance = null!; + return false; + } + + public bool TryGetMember( string name, out ExpNode node ) + { + return EqualityTypeConvert.TryGetMember( name, out node ); + } + + } +} diff --git a/StgSharp.Script/Express/ExpExceptions.cs b/StgSharp.Script/Express/ExpExceptions.cs index 2dcdc445..e342bcb5 100644 --- a/StgSharp.Script/Express/ExpExceptions.cs +++ b/StgSharp.Script/Express/ExpExceptions.cs @@ -42,19 +42,18 @@ namespace StgSharp.Script.Express public class ExpInvalidCharException : Exception { - public ExpInvalidCharException( char c ) - : base( $"An unknown char {c} occurred." ) { } + public ExpInvalidCharException( char c ) : base( $"An unknown char {c} occurred." ) { } + + public ExpInvalidCharException( int index ) + : base( $"Cannot read a token from line at {index}" ) { } } - /// - /// Exception when cannot reading a token from a line. - /// - public class ExpInvalidTokenException : Exception + public class ExpStringNotCloseException : Exception { - public ExpInvalidTokenException( int index ) - : base( $"Cannot read a token from line at {index}" ) { } + public ExpStringNotCloseException( int linenum ) + : base( $"A string does not closed at end of line {linenum}." ) { } } @@ -80,9 +79,7 @@ namespace StgSharp.Script.Express public class ExpInvalidElementDeclareEndingExceptions : Exception { - public ExpInvalidElementDeclareEndingExceptions( - string declaredName, - string endedName ) + public ExpInvalidElementDeclareEndingExceptions( string declaredName, string endedName ) : base( $"The datatype is declared with name {declaredName} but ended with {endedName}" ) { } @@ -91,11 +88,8 @@ namespace StgSharp.Script.Express public class ExpInvalidElementNameException : Exception { - public ExpInvalidElementNameException( - string elementName, - ExpSchema schema ) - : base( - $"Cannot find any element named {elementName} in {schema.Name}" ) { } + public ExpInvalidElementNameException( string elementName, ExpSchema schema ) + : base( $"Cannot find any element named {elementName} in {schema.Name}" ) { } } @@ -121,8 +115,8 @@ namespace StgSharp.Script.Express { public ExpInvalidCollectionMemberTypeException( - ExpElementInstanceBase elementInstance, - ExpCollectionBase collection ) + ExpElementInstance elementInstance, + ExpCollectionBase collection ) : base( $"Attempt to add or remove an element of type: {elementInstance.ElementType} from a collection collects {collection.MemberType}" ) { } @@ -131,9 +125,7 @@ namespace StgSharp.Script.Express public class ExpInvalidSchemaIncludeException : InvalidOperationException { - public ExpInvalidSchemaIncludeException( - ExpSchema context, - ExpSchema source ) + public ExpInvalidSchemaIncludeException( ExpSchema context, ExpSchema source ) : base( $"Attempted to refer to an EXPRESS language expression in the current schema context '{context.Name}', but this expression comes from another schema '{source.Name}' that has not been included." ) { } @@ -152,8 +144,7 @@ namespace StgSharp.Script.Express { public ExpCompileNotInitializedException() - : base( - "Attempt to compile an EXPRESS script before the init of compiler." ) { } + : base( "Attempt to compile an EXPRESS script before the init of compiler." ) { } } @@ -162,7 +153,7 @@ namespace StgSharp.Script.Express public ExpCompileException( Token pos, string message ) : base( - $"Compiler exception occour when processing token at line {pos.Line}, column {pos.Column}. Detailed message:{Environment.NewLine}{message} " ) { } + $"Compiler exception occur when processing token at line {pos.Line}, column {pos.Column}. Detailed message:{Environment.NewLine}{message} " ) { } } } diff --git a/StgSharp.Script/Express/ExpNodeGenerator.TokenSpliter.cs b/StgSharp.Script/Express/ExpNodeGenerator.TokenSpliter.cs index a62eb65b..4c74e688 100644 --- a/StgSharp.Script/Express/ExpNodeGenerator.TokenSpliter.cs +++ b/StgSharp.Script/Express/ExpNodeGenerator.TokenSpliter.cs @@ -33,6 +33,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Schema; using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword; @@ -114,12 +115,26 @@ namespace StgSharp.Script.Express if( t.Flag != TokenFlag.Separator_Middle ) { return false; } + processOperator: if( _cache.OperatorAheadOfDepth == 0 ) { if( _cache.OperandAheadOfDepth == 1 ) { + if( _cache.Depth != 1 ) + { + _cache.DecreaseDepth(); + if( _cache.PeekOperator().Value == t.Value ) + { + _cache.PopOperand( out _, out ExpNode? currentExpression ); + _cache.PopOperand( out Token valToken, out _ ); + _cache.PopOperand( out _, out ExpNode? previousExpression ); + currentExpression.PrependNode( previousExpression ); + _cache.PushOperand( previousExpression ); + } + } _cache.PushOperand( t ); _cache.PushOperator( t ); + _cache.IncreaseDepth( ( int )ExpCompileStateCode.Common ); return true; } else { @@ -127,7 +142,6 @@ namespace StgSharp.Script.Express } } Token op; - processOperator: if( _cache.TryPopOperator( out op ) ) { if( op.Value == t.Value ) @@ -151,7 +165,7 @@ namespace StgSharp.Script.Express if( ( t.Flag & ( TokenFlag.String | TokenFlag.Number ) ) == 0 ) { return false; } - _cache.PushOperand( ExpElementInstanceBase.CreateLiteral( t ) ); + _cache.PushOperand( ExpElementInstance.CreateLiteral( t ) ); return true; } @@ -189,7 +203,6 @@ namespace StgSharp.Script.Express { _cache.PopOperator(); ExpNode node = ConvertAndPushOneOperator( tmp ); - _cache.PushOperand( node ); goto processPrecedence; } } @@ -199,16 +212,22 @@ namespace StgSharp.Script.Express private bool TryParseConstant( Token t ) { - if( t.Value == ExpKeyword.True ) + switch( t.Value ) { - _cache.PushOperand( new ExpBoolNode( t, true ) ); - return true; - } else if( t.Value == ExpKeyword.False ) - { - _cache.PushOperand( new ExpBoolNode( t, false ) ); - return true; + case ExpKeyword.E: + _cache.PushOperand( new ExpRealNumberNode( t, MathF.E, true ) ); + return true; + case ExpKeyword.Pi: + _cache.PushOperand( new ExpRealNumberNode( t, MathF.PI, true ) ); + return true; + default: + if( ExpElementInstance.TryCreateLiteral( t, out ExpElementInstance? node ) ) + { + _cache.PushOperand( node ); + return true; + } + return false; } - return false; } private bool TryParseFunction( Token t ) @@ -228,9 +247,9 @@ namespace StgSharp.Script.Express private bool TryParseInstance( Token t ) { if( _local.TryGetMember( t.Value, - out ExpNode? node ) && node is ExpElementInstanceBase instance ) + out ExpNode? node ) && node is ExpElementInstance instance ) { - _cache.PushOperand( ExpInstanceReferenceNode.Create( t, instance ) ); + _cache.PushOperand( ExpInstanceReferenceNode.MakeReferenceFrom( t, instance ) ); return true; } return false; diff --git a/StgSharp.Script/Express/ExpNodeGenerator.cs b/StgSharp.Script/Express/ExpNodeGenerator.cs index 6ff6f54b..c955a09e 100644 --- a/StgSharp.Script/Express/ExpNodeGenerator.cs +++ b/StgSharp.Script/Express/ExpNodeGenerator.cs @@ -108,6 +108,10 @@ namespace StgSharp.Script.Express case TokenFlag.Index_Right: TryAppendIndexRight( expToken ); break; + case TokenFlag.Number or TokenFlag.String: + ExpElementInstance node = ExpElementInstance.CreateLiteral( expToken ); + _cache.PushOperand( node ); + break; default: break; } diff --git a/StgSharp.Script/Express/ExpSchemaBase.cs b/StgSharp.Script/Express/ExpSchemaBase.cs index 76813005..23838ee1 100644 --- a/StgSharp.Script/Express/ExpSchemaBase.cs +++ b/StgSharp.Script/Express/ExpSchemaBase.cs @@ -46,72 +46,38 @@ namespace StgSharp.Script.Express get => ExpSchema_Builtin.Only; } - public string Name - { - get; - internal set; - } + public string Name { get; internal set; } public abstract void LoadFromSource( ExpSchemaSource source ); - public abstract bool TryGetConst( - string name, - out ExpElementInstanceBase c ); + public abstract bool TryGetConst( string name, out ExpElementInstance c ); public abstract bool TryGetEntity( string name, out ExpEntitySource e ); - public abstract bool TryGetFunction( - string name, - out ExpFunctionSource f ); + public abstract bool TryGetFunction( string name, out ExpFunctionSource f ); public abstract bool TryGetRule( string name, out ExpRuleSource r ); - public abstract bool TryGetSchemaInclude( - string name, - out ExpSchema include ); + public abstract bool TryGetSchemaInclude( string name, out ExpSchema include ); public abstract bool TryGetType( string name, out ExpTypeSource t ); #pragma warning disable CS8618 - protected FrozenDictionary ConstDict - { - get; - set; - } + protected FrozenDictionary ConstDict { get; set; } public IEnumerable IncludedSchema => IncludedSchema; - protected FrozenDictionary EntityDict - { - get; - set; - } + protected FrozenDictionary EntityDict { get; set; } - protected FrozenDictionary FunctionDict - { - get; - set; - } + protected FrozenDictionary FunctionDict { get; set; } protected ConcurrentStringHashMultiplexer StringMultiplexer => ExpressCompile.Multiplexer; - protected FrozenDictionary RuleDict - { - get; - set; - } + protected FrozenDictionary RuleDict { get; set; } - protected FrozenDictionary SchemaInclude - { - get; - set; - } + protected FrozenDictionary SchemaInclude { get; set; } - protected FrozenDictionary TypeDict - { - get; - set; - } + protected FrozenDictionary TypeDict { get; set; } #pragma warning restore CS8618 } } diff --git a/StgSharp.Script/Express/ExpSourceReader.cs b/StgSharp.Script/Express/ExpSourceReader.cs index fa4b1d69..04b6ea0d 100644 --- a/StgSharp.Script/Express/ExpSourceReader.cs +++ b/StgSharp.Script/Express/ExpSourceReader.cs @@ -53,6 +53,7 @@ namespace StgSharp.Script.Express private Regex _nextWordTokenPattern = GetNextWordTokenPattern(), _nextStringLiteralPattern = GetStringLiteralPattern(), _nextNumberLiteralPattern = GetNumberLiteralPattern(), + _nextStringLiteralPatternWithSingle = GetStringLiteralPatternWithSingle(), _skipBlankPattern = GetSkipBlankPattern(); private string _lineCache; private Token _last; @@ -76,10 +77,10 @@ namespace StgSharp.Script.Express } /// - /// Read code until end of a line. Lines in multi-line comment will be ignored. - /// Line begins with part of multi-line comment will automatically remove the comment - /// part, but beginning with a full multi-line comment will not causing removing. - /// (*Just Like The Comment Here*) Will Not Be Removed + /// Read code until end of a line. Lines in multi-line comment will be ignored. Line + /// begins with part of multi-line comment will automatically remove the comment part, + /// but beginning with a full multi-line comment will not causing removing. + /// (*Just Like The Comment Here*) Will Not Be Removed /// /// /// @@ -130,6 +131,9 @@ namespace StgSharp.Script.Express Match match = _nextWordTokenPattern.Match( _lineCache, _current ); if( match.Success ) { + if( match.Groups[ EndMark ].Index >= _lineCache.Length ) { + throw new ExpStringNotCloseException( _lineNum ); + } begin = match.Groups[ TokenMark ].Index; end = match.Groups[ EndMark ].Index; rest = match.Groups[ RestMark ].Index; @@ -140,12 +144,14 @@ namespace StgSharp.Script.Express return _last; } else { - throw new ExpInvalidTokenException( _current ); + throw new ExpInvalidCharException( _current ); } } else if( char.IsPunctuation( c ) || char.IsSymbol( c ) ) { switch( c ) { + case '\'': + case '"': char cNext = source[ 1 ]; if( cNext == '\"' ) //empty string @@ -213,7 +219,7 @@ namespace StgSharp.Script.Express _lineNum, begin, TokenFlag.Number ); } else { - throw new ExpInvalidTokenException( _current ); + throw new ExpInvalidCharException( _current ); } } else if( cNext == '-' ) { @@ -297,7 +303,7 @@ namespace StgSharp.Script.Express return new( str, _lineNum, begin, TokenFlag.Number ); } else { - throw new ExpInvalidTokenException( _current ); + throw new ExpInvalidCharException( _current ); } } else if( char.IsWhiteSpace( c ) ) { @@ -309,7 +315,7 @@ namespace StgSharp.Script.Express goto readLine; } else { - throw new ExpInvalidTokenException( _current ); + throw new ExpInvalidCharException( _current ); } } else { @@ -342,9 +348,14 @@ namespace StgSharp.Script.Express private static partial Regex GetSkipBlankPattern(); [GeneratedRegex( - @"(?"")(?:.*?[^\\](?:\\\\)*?)(?"")\s*?(?\S|$)", + @"(?"")(?>\\\\|\\""|(?!')[^""])*(?""|$)\s*?(?\S|$)", RegexOptions.Singleline )] private static partial Regex GetStringLiteralPattern(); + [GeneratedRegex( + @"(?')(?>\\\\|\\'|''|(?!')[^'])*(?')\s*?(?\S|$)", + RegexOptions.Singleline )] + private static partial Regex GetStringLiteralPatternWithSingle(); + } } diff --git a/StgSharp.Script/Express/GeneratedExpSchema.cs b/StgSharp.Script/Express/GeneratedExpSchema.cs index 03477e82..a335f975 100644 --- a/StgSharp.Script/Express/GeneratedExpSchema.cs +++ b/StgSharp.Script/Express/GeneratedExpSchema.cs @@ -57,7 +57,8 @@ namespace StgSharp.Script.Express if( TypeDict.TryGetValue( typeName, out ret ) ) { return ret; } - foreach( GeneratedExpSchema item in SchemaInclude.Values ) { + foreach( GeneratedExpSchema item in SchemaInclude.Values ) + { if( item.TypeDict.TryGetValue( typeName, out ret ) ) { return ret; } @@ -75,9 +76,7 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override bool TryGetConst( - string name, - out ExpElementInstanceBase c ) + public override bool TryGetConst( string name, out ExpElementInstance c ) { return ConstDict.TryGetValue( name, out c ); } @@ -87,9 +86,7 @@ namespace StgSharp.Script.Express return EntityDict.TryGetValue( name, out e ); } - public override bool TryGetFunction( - string name, - out ExpFunctionSource f ) + public override bool TryGetFunction( string name, out ExpFunctionSource f ) { return FunctionDict.TryGetValue( name, out f ); } @@ -99,16 +96,12 @@ namespace StgSharp.Script.Express throw new NotImplementedException(); } - public override bool TryGetSchemaInclude( - string name, - out ExpSchema include ) + public override bool TryGetSchemaInclude( string name, out ExpSchema include ) { throw new NotImplementedException(); } - public override bool TryGetType( - string name, - out ExpTypeSource element ) + public override bool TryGetType( string name, out ExpTypeSource element ) { throw new NotImplementedException(); } diff --git a/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.AssemblyInfo.cs b/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.AssemblyInfo.cs index d983aaac..6a583a5c 100644 --- a/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.AssemblyInfo.cs +++ b/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Script")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+148b0fed4a1abaaeaa3a28e7c7b088590805ebef")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ffd5825a051f04f4105ac5ed02e754176ce6f608")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.sourcelink.json b/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.sourcelink.json index 248b54bf..146ac8e6 100644 --- a/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.sourcelink.json +++ b/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.sourcelink.json @@ -1 +1 @@ -{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/148b0fed4a1abaaeaa3a28e7c7b088590805ebef/*"}} \ No newline at end of file +{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/ffd5825a051f04f4105ac5ed02e754176ce6f608/*"}} \ No newline at end of file diff --git a/StgSharpDebug/ExpLinearExpressionTest.cs b/StgSharpDebug/ExpLinearExpressionTest.cs index a811c1ae..dc243b16 100644 --- a/StgSharpDebug/ExpLinearExpressionTest.cs +++ b/StgSharpDebug/ExpLinearExpressionTest.cs @@ -47,17 +47,13 @@ namespace StgSharp : base( name, source ) { LocalVariables.Add( - "a", - ExpElementInstanceBase.CreateLiteral( new Token( "1", 0, 0, TokenFlag.Number ) ) ); + "a", new ExpIntNode( new Token( "a", 0, 0, TokenFlag.Number ), 1, false ) ); LocalVariables.Add( - "b", - ExpElementInstanceBase.CreateLiteral( new Token( "1", 0, 0, TokenFlag.Number ) ) ); + "b", new ExpIntNode( new Token( "b", 0, 0, TokenFlag.Number ), 1, false ) ); LocalVariables.Add( - "c", - ExpElementInstanceBase.CreateLiteral( new Token( "1", 0, 0, TokenFlag.Number ) ) ); + "c", new ExpIntNode( new Token( "c", 0, 0, TokenFlag.Number ), 1, false ) ); LocalVariables.Add( - "d", - ExpElementInstanceBase.CreateLiteral( new Token( "1", 0, 0, TokenFlag.Number ) ) ); + "d", new ExpIntNode( new Token( "d", 0, 0, TokenFlag.Number ), 1, false ) ); } } @@ -77,7 +73,7 @@ namespace StgSharp return; } - public override bool TryGetConst( string name, out ExpElementInstanceBase c ) + public override bool TryGetConst( string name, out ExpElementInstance c ) { c = null; return false; @@ -127,9 +123,11 @@ namespace StgSharp { ExpressCompile.InitCompile(); ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter( "END", 0 ); - transmitter.WriteLine( @"a := ( b + c + d * 2 ) * d;" ); - //transmitter.WriteLine( @"a := b + (c + d) * a;" ); + //Console.WriteLine( @$"a := ( b * E + d * 2 ) * d;" ); + transmitter.WriteLine( @$"a := ( b * E + d * 2 ) * d;" ); + + transmitter.WriteLine( @"a := b + (c + d) * a;" ); transmitter.EndWriting(); ExpSourceReader reader = new ExpSourceReader( transmitter ); /**/ diff --git a/StgSharpDebug/TestRender.cs b/StgSharpDebug/TestRender.cs index 9096d24a..cc0f1d94 100644 --- a/StgSharpDebug/TestRender.cs +++ b/StgSharpDebug/TestRender.cs @@ -48,20 +48,10 @@ namespace StgSharp StgSharp.InitGL( 4, 6 ); StgSharp.GlobalSetting.VSyncActivated = false; - ViewPort vp = new ViewPort( - 800, 600, "Hello StgSharp!", IntPtr.Zero ); + ViewPort vp = new ViewPort( 800, 600, "Hello StgSharp!", IntPtr.Zero ); //throw new NotImplementedException(); - StringHashMultiplexer mul = new StringHashMultiplexer(); - IEqualityComparer com = mul; - string str = "1234567012345670"; - for( int i = 1; i < 100; i++ ) { - str += $"{(i % 8)}"; - int hash = mul.ForceComputeHash( str ); - Thread.Sleep( 20 ); - } - ViewModelBase mainModel = new ViewModelMain( vp ); mainModel.CreateAndBindView( "MainView", (1, 1, 1) ); diff --git a/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.AssemblyInfo.cs b/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.AssemblyInfo.cs index a59e88fc..67e0058a 100644 --- a/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.AssemblyInfo.cs +++ b/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+148b0fed4a1abaaeaa3a28e7c7b088590805ebef")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ffd5825a051f04f4105ac5ed02e754176ce6f608")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.sourcelink.json b/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.sourcelink.json index 248b54bf..146ac8e6 100644 --- a/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.sourcelink.json +++ b/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.sourcelink.json @@ -1 +1 @@ -{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/148b0fed4a1abaaeaa3a28e7c7b088590805ebef/*"}} \ No newline at end of file +{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/ffd5825a051f04f4105ac5ed02e754176ce6f608/*"}} \ No newline at end of file