Daily update on 20250328-131548 by Nitload Youmu. Additional Message : IF branch can be full functionally compiled. Next will be CASE_OF branch

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-03-28 13:15:48 +08:00
parent 36b6ad5a52
commit 17a226c206
18 changed files with 1069 additions and 74 deletions
+16 -11
View File
@@ -30,6 +30,7 @@
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -41,23 +42,27 @@ namespace StgSharp.Script
public class CompileDepthMark
{
public CompileDepthMark( int operatorBegin, int operandBegin, int usage )
{
OperatorBegin = operatorBegin;
OperandBegin = operandBegin;
}
public CompileDepthMark(
int operatorBegin,
int operandBegin,
int usage,
ICompileDepthState stateCache )
internal CompileDepthMark( int operatorBegin, int operandBegin, int usage )
{
OperatorBegin = operatorBegin;
OperandBegin = operandBegin;
Usage = usage;
}
internal CompileDepthMark(
int operatorBegin,
int operandBegin,
int usage,
ICompileDepthState stateCache )
{
OperatorBegin = operatorBegin;
OperandBegin = operandBegin;
Usage = usage;
StateCache = stateCache;
}
public bool IsBeginOfBlock { get; internal set; }
public ICompileDepthState StateCache { get; internal set; }
public int OperandBegin { get; internal set; }
+23 -1
View File
@@ -50,10 +50,12 @@ namespace StgSharp.Script
private Stack<CompileDepthMark> _depthStack = new Stack<CompileDepthMark>();
private Stack<bool> _isNode = new Stack<bool>();
private Stack<Stack<TNode>> _statementCache = new Stack<Stack<TNode>>();
public CompileStack()
{
_depthStack.Push( new CompileDepthMark( 0, 0, 0 ) );
_depthStack.Push( new CompileDepthMark( 0, 0, 0, null! ) );
_statementCache.Push( new Stack<TNode>() );
}
public CompileDepthMark CurrentDepthMark
@@ -77,19 +79,39 @@ namespace StgSharp.Script
get => OperandCount - _depthStack.Peek().OperandBegin;
}
public Stack<TNode> StatementsInDepth
{
get => _statementCache.Peek();
}
public void DecreaseDepth()
{
CompileDepthMark mark = _depthStack.Pop();
Stack<TNode> statementsInDepth = _statementCache.Pop();
}
public CompileDepthMark IncreaseDepth( int usage )
{
CompileDepthMark mark =
new CompileDepthMark( OperatorCount, OperandCount, usage );
_depthStack.Push( mark );
_statementCache.Push( new Stack<TNode>() );
return mark;
}
public TNode PackAllStatements()
{
if( StatementsInDepth.Count == 0 ) {
return TNode.Empty;
}
TNode first = StatementsInDepth.Peek();
while( StatementsInDepth.Count > 0 ) {
first.PrependNode( StatementsInDepth.Pop() );
}
return first;
}
public bool PeekOperand( out Token t, out TNode n )
{
if( OperandAheadOfDepth <= 0 )