Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
likecg committed Nov 13, 2023
1 parent 94483b3 commit 3a19188
Show file tree
Hide file tree
Showing 29 changed files with 297 additions and 160 deletions.
Binary file modified bin/Debug/netcoreapp3.1/SimpleLanguage.dll
Binary file not shown.
Binary file modified bin/Debug/netcoreapp3.1/SimpleLanguage.exe
Binary file not shown.
Binary file modified bin/Debug/netcoreapp3.1/SimpleLanguage.pdb
Binary file not shown.
4 changes: 4 additions & 0 deletions source/Compile/FileMeta/FileMetaMemberMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ public bool ParseFunction(List<Node> nodeList)
Console.WriteLine("Error 解析位置 Token: " + m_Token?.ToLexemeAllString() );
return false;
}
if( isError )
{
Console.WriteLine("ParseFunction 解析函数");
}
m_VirtualOverrideToken = virtualToken;
m_PermissionToken = permissionToken;
m_StaticToken = staticToken;
Expand Down
8 changes: 4 additions & 4 deletions source/Core/MetaCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,9 +1093,9 @@ public MetaFunctionCall GetMetaFunctionCall()
return mfc;
}
}
else if( m_CallNodeType == ECallNodeType.NewClass )
{
}
//else if( m_CallNodeType == ECallNodeType.NewClass )
//{
//}
return null;
}
public MetaType GetMetaDefineType()
Expand Down Expand Up @@ -1493,7 +1493,7 @@ private void CreateCallLinkNode()
Console.WriteLine("Error 连接串没有找到合适的节点 360!!!");
}
}
public int GetCodeFileLine() { return 0; }
public Token GetToken() { return null; }
public bool Parse( AllowUseConst _useConst )
{
allowUseConst = new AllowUseConst(_useConst);
Expand Down
3 changes: 1 addition & 2 deletions source/Core/MetaExpressBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public virtual int opLevel
protected MetaClass m_OwnerMetaClass = null;
protected MetaBlockStatements m_OwnerMetaBlockStatements = null;
protected MetaType m_MetaDefineType = null;
public virtual int GetCodeFileLine() { return 0; }
public virtual string GetFilePath() { return ""; }
public virtual Token GetToken() { return null; }
public virtual int CalcParseLevel(int level) { return level; }
public virtual void CalcReturnType() { }
public virtual void Parse(AllowUseConst auc) { }
Expand Down
2 changes: 1 addition & 1 deletion source/Core/MetaExpressCalllink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override void Parse( AllowUseConst auc )
m_MetaCallLink.Parse( auc );
}
}
public override int GetCodeFileLine() { if (m_MetaCallLink != null) { return m_MetaCallLink.GetCodeFileLine(); } else return 0; }
public override Token GetToken() { return m_MetaCallLink.GetToken(); }
public override int CalcParseLevel(int level)
{
if (m_MetaCallLink != null)
Expand Down
4 changes: 2 additions & 2 deletions source/Core/MetaExpressConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public override MetaType GetReturnMetaDefineType()
{
return m_MetaDefineType;
}
MetaType mdt = null;
//MetaType mdt = null;
MetaClass mc = CoreMetaClassManager.GetMetaClassByEType(eType);
MetaInputTemplateCollection mitc = new MetaInputTemplateCollection();
if( eType == EType.Array )
Expand All @@ -129,7 +129,7 @@ public override MetaType GetReturnMetaDefineType()
}
return m_MetaDefineType;
}
public override int GetCodeFileLine() { if (m_FileMetaConstValueTerm?.token != null) { return m_FileMetaConstValueTerm.token.sourceBeginLine; } else return 0; }
public override Token GetToken() { return m_FileMetaConstValueTerm?.token; }
public void ComputeAddRight(MetaConstExpressNode right)
{
switch (right.eType)
Expand Down
6 changes: 3 additions & 3 deletions source/Core/MetaExpressNewObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,13 @@ private void Init()
}
}
}
public override int GetCodeFileLine()
public override Token GetToken()
{
if(m_FileMetaConstValueTerm != null)
{
return m_FileMetaConstValueTerm.token.sourceBeginLine;
return m_FileMetaConstValueTerm.token;
}
return base.GetCodeFileLine();
return base.GetToken();
}
public override void Parse(AllowUseConst auc)
{
Expand Down
6 changes: 3 additions & 3 deletions source/Core/MetaExpressOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,13 @@ public void SetRight(MetaExpressNode _right)
{
m_Right = _right;
}
public override int GetCodeFileLine()
public override Token GetToken()
{
if (m_FileMetaBaseTerm != null)
{
return m_FileMetaBaseTerm.token.sourceBeginLine;
return m_FileMetaBaseTerm.token;
}
return base.GetCodeFileLine();
return base.GetToken();
}
public override void Parse(AllowUseConst auc)
{
Expand Down
6 changes: 3 additions & 3 deletions source/Core/MetaMemberFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ public override void SetDeep(int deep)
m_Deep = deep;
m_MetaBlockStatements?.SetDeep(deep);
}
public override int GetCodeFileLine()
public override Token GetToken()
{
if( m_FileMetaMemberFunction?.finalToken != null )
{
return m_FileMetaMemberFunction.finalToken.sourceBeginLine;
return m_FileMetaMemberFunction.finalToken;
}
return base.GetCodeFileLine();
return base.GetToken();
}
public bool IsEqualWithMMFByNameAndParam( MetaMemberFunction mmf )
{
Expand Down
10 changes: 7 additions & 3 deletions source/Core/MetaParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ public MetaDefineParam( string _name, MetaClass ownerMC, MetaBlockStatements mbs
m_MetaVariable.SetFromMetaDefineParamCreate(this);
m_MetaVariable.isArgument = true;
}
public int GetCodeFileLine()
public Compile.Token GetToken()
{
if(m_FileMetaParamter != null )
{
return m_FileMetaParamter.token.sourceBeginLine;
return m_FileMetaParamter.token;
}
return 0;
return null;
}
public override void Parse()
{
Expand Down Expand Up @@ -742,6 +742,10 @@ public MetaClass GetMaxLevelMetaClassType()
}
}
}
if(isAllSame )
{
Console.WriteLine("全都相似");
}
return mc;
}
public override string ToFormatString()
Expand Down
11 changes: 6 additions & 5 deletions source/Core/MetaVariable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Description: all variable 's define, if it's iterator style then use IteratorMetaVariable, other custom same style!
//****************************************************************************

using SimpleLanguage.Compile;
using SimpleLanguage.Core.SelfMeta;
using SimpleLanguage.Core.Statements;
using System;
Expand Down Expand Up @@ -129,21 +130,21 @@ public virtual string ToStatementString()
{
return "";
}
public virtual int GetCodeFileLine()
public virtual Token GetToken()
{
if(m_FromMetaNewStatementsCreate != null )
{
return m_FromMetaNewStatementsCreate.GetCodeFileLine();
return m_FromMetaNewStatementsCreate.GetToken();
}
if( m_FromMetaDefineParamCreate != null )
{
return m_FromMetaDefineParamCreate.GetCodeFileLine();
return m_FromMetaDefineParamCreate.GetToken();
}
if(m_FromExpressNodeCreate != null )
{
return m_FromExpressNodeCreate.GetCodeFileLine();
return m_FromExpressNodeCreate.GetToken();
}
return 0;
return null;
}
public override string ToFormatString()
{
Expand Down
10 changes: 5 additions & 5 deletions source/Core/Statements/MetaNewStatements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ public MetaNewStatements( MetaBlockStatements mbs, FileMetaCallSyntax callSyntax
m_OwnerMetaBlockStatements.AddOnlyNameMetaVariable(m_Name);
Parse();
}
public int GetCodeFileLine()
public Compile.Token GetToken()
{
if (m_FileMetaDefineVariableSyntax != null)
{
return m_FileMetaDefineVariableSyntax.token.sourceBeginLine;
return m_FileMetaDefineVariableSyntax.token;
}
if (m_FileMetaOpAssignSyntax != null)
{
return m_FileMetaOpAssignSyntax.assignToken.sourceBeginLine;
return m_FileMetaOpAssignSyntax.assignToken;
}
if (m_FileMetaCallSyntax != null)
{
return m_FileMetaCallSyntax.token.sourceBeginLine;
return m_FileMetaCallSyntax.token;
}
return 0;
return null;
}
private void Parse()
{
Expand Down
22 changes: 19 additions & 3 deletions source/IR/IRBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;

namespace SimpleLanguage.IR
{
Expand All @@ -29,18 +30,33 @@ protected IRBase( IRMethod irMethod )
}
public void AddIRData( IRData irData )
{
if( irData == null )
{
return;
}
m_IRDataList.Add(irData);
}
public virtual void SetCodeFileLine( int line )
public void AddIRRangeData( IEnumerable<IRData> ienumData )
{

foreach( var v in ienumData )
{
if (v == null)
{
continue;
}
m_IRDataList.Add(v);
}
}
public virtual string ToIRString()
{
StringBuilder sb = new StringBuilder();

for( int i = 0; i < m_IRDataList.Count; i++ )
for (int i = 0; i < m_IRDataList.Count; i++)
{
if (this.m_IRDataList[i] == null)
{
continue;
}
sb.AppendLine(m_IRDataList[i].ToString());
}
return sb.ToString();
Expand Down
24 changes: 13 additions & 11 deletions source/IR/IRBrach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,52 @@
// Description:
//****************************************************************************

using SimpleLanguage.Compile;
using SimpleLanguage.Compile.CoreFileMeta;
using SimpleLanguage.Core;
using SimpleLanguage.IR;
using SimpleLanguage.VM;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace SimpleLanguage.IR
{
public class IRBranch : IRBase
{
public IRData brData = new IRData();
public IRData data = new IRData();
public IRBranch( IRMethod _irMethod, EIROpCode type, IRData brIRData )
{
brData.opCode = type;
brData.opValue = brData;
data.opCode = type;
data.opValue = brIRData;
AddIRData( data );
}
public void SetOpValue(IRData opValue)
{
brData.opValue = opValue;
data.opValue = opValue;
}
public override void SetCodeFileLine(int line)
public void SetDebugInfoByToken(Token token)
{
brData.line = line;
data.SetDebugInfoByToken(token);
}
public override string ToIRString()
{
StringBuilder sb = new StringBuilder();

sb.Append("branch");
sb.Append(base.ToIRString());

return sb.ToString();
}
}
public class IRLabel : IRBase
{
IRData labelIRData = new IRData();
IRData data = new IRData();
public IRLabel(IRMethod _irMethod, string _label, bool isGogo )
{
labelIRData = new IRData();
labelIRData.opCode = isGogo ? EIROpCode.Label : EIROpCode.BrLabel;
labelIRData.opValue = _label;
data = new IRData();
data.opCode = isGogo ? EIROpCode.Label : EIROpCode.BrLabel;
data.opValue = _label;
}
public override string ToIRString()
{
Expand Down
Loading

0 comments on commit 3a19188

Please sign in to comment.