Daily update on 20250309-063111 by Nitload Youmu. Additional Message : Building AST generator, Name property removed from AST Node, Line And Colum property added as replacement.

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-03-09 06:31:12 +08:00
parent df321a3bae
commit 6f494f25ef
9 changed files with 110 additions and 27 deletions
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Common")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+825e68853cd1738287eecc8a4390ee9c78550308")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+df321a3bae3d97d043473f4595cc8d229d0f2722")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Common")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Common")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/825e68853cd1738287eecc8a4390ee9c78550308/*"}}
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/df321a3bae3d97d043473f4595cc8d229d0f2722/*"}}
+61 -11
View File
@@ -74,14 +74,16 @@ namespace StgSharp.Script
CompileDepthMark mark = _depthStack.Pop();
}
public void IncreaseDepth()
public CompileDepthMark IncreaseDepth()
{
_depthStack.Push(
CompileDepthMark mark =
new CompileDepthMark
{
OperandBegin = OperandCount,
OperatorBegin = OperatorCount
} );
{
OperandBegin = OperandCount,
OperatorBegin = OperatorCount
};
_depthStack.Push( mark );
return mark;
}
public bool PeekOperand( out Token t, out TNode n )
@@ -112,6 +114,11 @@ namespace StgSharp.Script
public bool PopOperand( out Token t, out TNode n )
{
if( OperandAheadOfDepth <= 0 ) {
t = Token.Empty;
n = TNode.Empty;
return false;
}
if( _isNode.Pop() ) {
t = Token.Empty;
n = _nodeArray[ --_nodeCount ];
@@ -125,8 +132,11 @@ namespace StgSharp.Script
public Token PopOperator()
{
_operatorCount--;
return _operatorArray[ _operatorCount ];
if( OperatorAheadOfDepth > 0 ) {
_operatorCount--;
return _operatorArray[ _operatorCount ];
}
return Token.Empty;
}
public void PushOperand( TNode node )
@@ -159,13 +169,53 @@ namespace StgSharp.Script
_isNode.Push( false );
}
public bool TryPopOperand( out bool isNode, out Token t, out TNode n )
{
if( OperandAheadOfDepth <= 0 ) {
t = Token.Empty;
n = TNode.Empty;
isNode = false;
return false;
}
if( _isNode.Pop() ) {
t = Token.Empty;
n = _nodeArray[ --_nodeCount ];
isNode = true;
return true;
} else {
t = _tokenArray[ --_tokenCount ];
n = TNode.Empty;
isNode = false;
return false;
}
}
public bool TryPopOperator( out Token op )
{
if( OperatorAheadOfDepth > 0 ) {
op = _operatorArray[ --_operatorCount ];
return true;
}
op = Token.Empty;
return false;
}
}
public struct CompileDepthMark
public class CompileDepthMark
{
public int OperandBegin;
public int OperatorBegin;
public int OperandBegin
{
get;
set;
}
public int OperatorBegin
{
get;
set;
}
}
}
+7 -2
View File
@@ -43,12 +43,17 @@ namespace StgSharp.Script
where TType: ITypeSource<TType>
{
long NodeFlag
int Line
{
get;
}
string Name
int Column
{
get;
}
long NodeFlag
{
get;
}
@@ -95,8 +95,6 @@ namespace StgSharp.Script.Express
init;
}
public string Name => _name;
public void AppendNode( ExpNode nextNode )
{
Next.Previous = nextNode;
@@ -42,31 +42,61 @@ namespace StgSharp.Script.Express
{
private bool _isCallingFunction = false;
private Stack<int> _callDepth = new Stack<int>();
private List<CompileDepthMark> _funcCallDepthCount = new List<CompileDepthMark>(
);
private void EnterFunctionCalling( Token funcNameToken )
private void EnterFunctionCalling()
{
_isCallingFunction = true;
_callDepth.Push( _operandsToken.Count );
CompileDepthMark mark = _cache.IncreaseDepth();
_funcCallDepthCount.Add( mark );
}
private void ExitFunctionCalling()
{
_callDepth.Pop();
if( _callDepth.Count == 0 ) {
CompileDepthMark mark = _funcCallDepthCount.Last();
if( _funcCallDepthCount.Count == 0 ) {
_isCallingFunction = false;
}
}
//TODO cannot process occasion of void input or null at first
//checking _operandAheadOfDepth can be used to check if the function calling has no param.
//put one of param to tail of function calling pram expression node
/// <summary>
/// Compile a parameter expression and add it to head of function parameter node list.
/// </summary>
private void MergeFunctionCallingParameter()
{
if( _cache.OperandAheadOfDepth == 1 ) {
if( _cache.PopOperand( out Token t, out ExpNode? n ) ) {
n!.PrependNode(
ExpNode.NonOperation( PoolString( "FuncParam" ) ) );
} else { }
} else {
switch( t.Flag ) {
case TokenFlag.Number:
if( int.TryParse( t.Value, out int intVal ) ) {
n = new ExpLiteralGenericNode<int>(
t.Value, intVal );
} else if( float.TryParse(
t.Value, out float floatVal ) ) {
n = new ExpLiteralGenericNode<float>(
t.Value, floatVal );
}
break;
case TokenFlag.String:
n = new ExpLiteralGenericNode<string>(
t.Value, t.Value );
break;
case TokenFlag.Member:
// case1: name of a instance, make ref copy
// case2: name of a function, make a function call
// case3: unknown, make a instance member node, check while link
break;
default:
break;
}
}
} else {
//TODO compile the param expression
}
@@ -74,4 +104,3 @@ namespace StgSharp.Script.Express
}
}
}
@@ -110,6 +110,7 @@ namespace StgSharp.Script.Express
private void ConvertOneOperator()
{
Token @operator = _cache.PopOperator();
switch( @operator.Flag ) {
case TokenFlag.Symbol_Unary:
TryGenerateUnaryNode( @operator, out ExpNode? node );
@@ -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+8460bfd56ad622a66ba2c972a2de7e7f4d5f80d3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+df321a3bae3d97d043473f4595cc8d229d0f2722")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/825e68853cd1738287eecc8a4390ee9c78550308/*"}}
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/df321a3bae3d97d043473f4595cc8d229d0f2722/*"}}