add from giga-device, new branch added

This commit is contained in:
Nitload Youmu
2025-08-21 16:51:25 +08:00
commit 43bbc06bbb
1296 changed files with 264186 additions and 0 deletions
+104
View File
@@ -0,0 +1,104 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpConst.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;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using System.Text;
namespace StgSharp.Script.Express
{
public sealed class ExpConstantCollectionSource : ExpImmutableElement
{
private Dictionary<string, ExpElementInstance> _constants;
private IScriptSourceProvider _sourceProvider;
public ExpConstantCollectionSource( IScriptSourceProvider sourceProvider )
{
_sourceProvider = sourceProvider;
_constants = new Dictionary<string, ExpElementInstance>( ExpressCompile.Multiplexer );
}
public override ExpElementType ElementType => ExpElementType.Const;
public override IScriptSourceProvider SourceProvider => _sourceProvider;
public override string Name
{
get => ExpressCompile.Keyword.Constant;
}
public override void Analyse()
{
throw new NotImplementedException();
}
public override ExpSyntaxNode MakeReference( params object[] options )
{
if( options.Length == 0 || options[ 0 ] is not string str ) {
return null!;
}
if( _constants.Count == 0 ) {
return null!;
}
if( _constants.TryGetValue( str, out ExpElementInstance? token ) ) {
return token;
}
return null!;
}
public bool TryGetConstant( string name, out ExpElementInstance instance )
{
return _constants.TryGetValue( name, out instance );
}
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{
if( _constants.TryGetValue( name, out ExpElementInstance? node ) )
{
memberNode = node;
return true;
}
memberNode = ExpSyntaxNode.Empty;
return false;
}
internal void AddConstant( string name, ExpElementInstance value )
{
_constants.Add( name, value );
}
}
}
@@ -0,0 +1,72 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpEntity.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.Text;
namespace StgSharp.Script.Express
{
public class ExpEntitySource : ExpInstantiableElement
{
private AbstractSyntaxTree<ExpSyntaxNode, IExpElementSource> _expressionTree;
private ScriptSourceTransmitter _source;
private string _name;
public ExpEntitySource( string name, ScriptSourceTransmitter provider )
{
_name = name;
_source = provider;
}
public override ExpElementType ElementType => ExpElementType.Entity;
public override IScriptSourceProvider SourceProvider => _source;
public override string Name => _name;
public override void Analyse()
{
throw new NotImplementedException();
}
public override ExpSyntaxNode CreateInstanceNode( Token t )
{
throw new NotImplementedException();
}
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,97 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpFunction.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.Text;
namespace StgSharp.Script.Express
{
public class ExpFunctionSource : ExpImmutableElement
{
private ScriptSourceTransmitter _transmitter;
private string _name;
public ExpFunctionSource( string name, ScriptSourceTransmitter transmitter )
{
_name = name;
_transmitter = transmitter;
}
public Dictionary<string, ExpElementInstance> FuncParams { get; init; } = new Dictionary<string, ExpElementInstance>(
);
public Dictionary<string, ExpElementInstance> LocalVariables { get; init; } = new Dictionary<string, ExpElementInstance>(
);
public override ExpElementType ElementType => ExpElementType.Function;
public ExpInstantiableElement ReturningType { get; protected set; }
public override IScriptSourceProvider SourceProvider => _transmitter;
public override string Name => _name;
public string CallingFormat { get; private set; }
public override void Analyse()
{
throw new NotImplementedException();
/*
* generate parameter list,
* generate C# code
* generate calling syntax
*/
}
public override ExpSyntaxNode MakeReference( params object[] options )
{
throw new NotImplementedException();
}
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{
if( FuncParams.TryGetValue( name, out ExpElementInstance? param ) )
{
memberNode = param;
return true;
}
if( LocalVariables.TryGetValue( name, out ExpElementInstance? variable ) )
{
memberNode = variable;
return true;
}
memberNode = ExpSyntaxNode.Empty;
return false;
}
}
}
@@ -0,0 +1,64 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpProcedureSource.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 ExpProcedureSource : ExpImmutableElement
{
public override ExpElementType ElementType => ExpElementType.Procedure;
public override IScriptSourceProvider SourceProvider => throw new NotImplementedException();
public override string Name => throw new NotImplementedException();
public override void Analyse()
{
throw new NotImplementedException();
}
public override ExpSyntaxNode MakeReference( params object[] options )
{
throw new NotImplementedException();
}
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,94 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpRule.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.Data;
using System.Reflection.Metadata.Ecma335;
using System.Text;
namespace StgSharp.Script.Express
{
public class ExpRule : ExpElementInstance
{
private ExpRuleSource _source;
public ExpRule( Token source ) : base( source ) { }
public object? value => throw new NotImplementedException();
public override ExpInstantiableElement EqualityTypeConvert => throw new NotImplementedException(
);
public override ExpSyntaxNode Left => throw new NotImplementedException();
public override ExpSyntaxNode Right => throw new NotImplementedException();
public override string TypeName => _source.Name;
}
public class ExpRuleSource : ExpImmutableElement
{
private ScriptSourceTransmitter _transmitter;
private string _name;
public ExpRuleSource( string name, ScriptSourceTransmitter transmitter )
{
_name = name;
_transmitter = transmitter;
}
public override ExpElementType ElementType => ExpElementType.Rule;
public override IScriptSourceProvider SourceProvider => _transmitter;
public override string Name => _name;
public override void Analyse()
{
throw new NotImplementedException();
}
public override ExpSyntaxNode MakeReference( params object[] options )
{
throw new NotImplementedException();
}
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{
memberNode = ExpSyntaxNode.Empty;
return false;
}
}
}
+116
View File
@@ -0,0 +1,116 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpType.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;
using System.Collections.Generic;
namespace StgSharp.Script.Express
{
public class ExpTypeSource : ExpInstantiableElement
{
private ScriptSourceTransmitter _transmitter;
private string _name;
protected bool _isBuiltinType;
protected ExpTypeSource( string name )
{
_name = name;
_transmitter = ScriptSourceTransmitter.Empty;
_isBuiltinType = true;
}
public ExpTypeSource( string name, ScriptSourceTransmitter transmitter )
{
_name = name;
_transmitter = transmitter;
_isBuiltinType = false;
}
public bool IsLanguageBuiltinType
{
get => _isBuiltinType;
}
public override ExpElementType ElementType => ExpElementType.Type;
public static ExpTypeSource Void
{
get => ExpVoidType.Only;
}
public override IScriptSourceProvider SourceProvider => _transmitter;
public override string Name => _name;
public override void Analyse()
{
throw new NotImplementedException();
}
public override ExpElementInstance CreateInstanceNode( Token t )
{
throw new NotImplementedException();
}
public static bool IsNullOrVoid( IExpElementSource type )
{
return type == null || type == ExpVoidType.Only;
}
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{
memberNode = ExpSyntaxNode.Empty;
return false;
}
private class ExpVoidType : ExpTypeSource
{
private static readonly ExpVoidType _onlyInstance = new ExpVoidType();
private ExpVoidType() : base( string.Empty ) { }
public static ExpVoidType Only
{
get => _onlyInstance;
}
public override void Analyse()
{
return;
}
}
}
}