From f92a688c7763d63e15cf6eae1445e1d735423d0b Mon Sep 17 00:00:00 2001 From: ninemine <106434473+NINEMINEsigma@users.noreply.github.com> Date: Mon, 30 Jun 2025 20:20:26 +0800 Subject: [PATCH] EP 0.1.1 Symbolization --- .../[Symbolization]/Internal/Functional.cs | 44 ++++++++++++++++ .../[Symbolization]/Internal/Modification.cs | 12 +++++ .../[Symbolization]/Internal/Variable.cs | 40 ++++++++++++++ Convention/[Symbolization]/Reader/Reader.cs | 32 ------------ Convention/[Symbolization]/Symbolization.cs | 52 +++++-------------- 5 files changed, 109 insertions(+), 71 deletions(-) create mode 100644 Convention/[Symbolization]/Internal/Functional.cs create mode 100644 Convention/[Symbolization]/Internal/Modification.cs create mode 100644 Convention/[Symbolization]/Internal/Variable.cs delete mode 100644 Convention/[Symbolization]/Reader/Reader.cs diff --git a/Convention/[Symbolization]/Internal/Functional.cs b/Convention/[Symbolization]/Internal/Functional.cs new file mode 100644 index 0000000..e8c8f93 --- /dev/null +++ b/Convention/[Symbolization]/Internal/Functional.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Convention.Symbolization.Internal +{ + public class Function : Variable + { + public Variable Invoke(Variable[] parameters) + { + + } + } + + public readonly struct FunctionSymbol + { + public readonly string SymbolName; + public readonly Type ReturnType; + public readonly Type[] ParameterTypes; + public readonly Modification[] Modifiers; + public readonly string FullName; + + public FunctionSymbol(string symbolName, Type returnType, Type[] parameterTypes, Modification[] modifiers) + { + this.SymbolName = symbolName; + this.ReturnType = returnType; + this.ParameterTypes = parameterTypes; + this.Modifiers = modifiers; + this.FullName = $"{returnType.FullName} {symbolName}({string.Join(',', parameterTypes.ToList().ConvertAll(x => x.FullName))}) {string.Join(' ', modifiers.ToList().ConvertAll(x => x.ToString()))}"; + } + + public bool Equals(FunctionSymbol other) + { + return other.FullName.Equals(FullName); + } + + public override int GetHashCode() + { + return FullName.GetHashCode(); + } + } +} diff --git a/Convention/[Symbolization]/Internal/Modification.cs b/Convention/[Symbolization]/Internal/Modification.cs new file mode 100644 index 0000000..b2e4562 --- /dev/null +++ b/Convention/[Symbolization]/Internal/Modification.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Convention.Symbolization.Internal +{ + public class Modification : Variable + { + } +} diff --git a/Convention/[Symbolization]/Internal/Variable.cs b/Convention/[Symbolization]/Internal/Variable.cs new file mode 100644 index 0000000..305777b --- /dev/null +++ b/Convention/[Symbolization]/Internal/Variable.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Convention.Symbolization.Internal +{ + public class Variable + { + + } + + public readonly struct VariableSymbol + { + public readonly string SymbolName; + public readonly Type VariableType; + + public VariableSymbol(string symbolName, Type variableType) + { + this.SymbolName = symbolName; + this.VariableType = variableType; + } + + public bool Equals(VariableSymbol other) + { + return other.SymbolName.Equals(SymbolName) && other.VariableType.Equals(VariableType); + } + + public override int GetHashCode() + { + return new Tuple(SymbolName, VariableType).GetHashCode(); + } + } + + public class VariableContext + { + public Dictionary Variables = new(); + } +} diff --git a/Convention/[Symbolization]/Reader/Reader.cs b/Convention/[Symbolization]/Reader/Reader.cs deleted file mode 100644 index 7b30999..0000000 --- a/Convention/[Symbolization]/Reader/Reader.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Convention.Symbolization.Internal -{ - internal class Reader - { - private ToolFile FileCore; - - public Reader(string file) - { - FileCore = new(file); - if (FileCore.Exists() == false) - throw new FileNotFoundException($"{file} not exists"); - FileCore.Open(FileMode.Open); - } - - public SymbolizationContext BuildContext() - { - SymbolizationContext context = new(); - using StreamReader reader = new(FileCore.OriginControlStream); - for (; reader.EndOfStream==false;) - { - var line = reader.ReadLine(); - } - } - } -} diff --git a/Convention/[Symbolization]/Symbolization.cs b/Convention/[Symbolization]/Symbolization.cs index c373b52..07421d9 100644 --- a/Convention/[Symbolization]/Symbolization.cs +++ b/Convention/[Symbolization]/Symbolization.cs @@ -6,52 +6,26 @@ using System.Threading.Tasks; namespace Convention.Symbolization { - public sealed class SymbolizationContext + public class SymbolizationContext { - public SymbolizationContext() { } - public SymbolizationContext(SymbolizationContext forward) - { - ParentContext = forward; - } - - private readonly SymbolizationContext ParentContext; - - public void Execute(string commandsBlock) - { - - } + public Internal.VariableContext Context = new(); } - public sealed class SymbolizationCore + public class SymbolizationRunner { - internal SymbolizationCore(Internal.Reader reader) + private readonly SymbolizationContext Context; + + public SymbolizationRunner(SymbolizationContext context) + { + Context = context; + } + public SymbolizationRunner() :this(new()){ } + + public void Execute(string funcName) { } - public SymbolizationContext Context { get; private set; } - - } - - public static class Symbolization - { - public static SymbolizationCore Build(string file) - { - return new SymbolizationCore(new(file)); - } - - public static SymbolizationContext Execute(string commandsBlock) - { - SymbolizationContext context = new(); - context.Execute(commandsBlock); - return context; - } - - public static SymbolizationContext Execute(SymbolizationContext forward,string commandsBlock) - { - SymbolizationContext context = new(forward); - context.Execute(commandsBlock); - return context; - } + public void Execute()=>Execute("main") } }