From 02906f836db6481d6da5c5bf0a4da7575bbf5685 Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Wed, 3 Dec 2025 14:36:36 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=88=A0=E9=99=A4=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E9=A2=84=E7=BC=96=E8=AF=91(=E7=B1=BB=E5=9E=8B=E4=B8=8D?= =?UTF-8?q?=E7=A8=B3=E5=AE=9A)2.=E4=BF=AE=E5=A4=8D=E7=A9=BA=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E7=BC=93=E5=AD=98=E8=AF=BB=E5=8F=96=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RScriptContext.cs | 16 ++++----- RScriptSerializer.cs | 85 ++++++++++++++++++-------------------------- 2 files changed, 43 insertions(+), 58 deletions(-) diff --git a/RScriptContext.cs b/RScriptContext.cs index b90ea34..366c44e 100644 --- a/RScriptContext.cs +++ b/RScriptContext.cs @@ -111,7 +111,7 @@ namespace Convention.RScript public Tuple[] Labels; public Tuple[] NamespaceLayer; public Tuple[] NamespaceLabels; - public ExpressionParser.SerializableParser CompileParser; + //public ExpressionParser.SerializableParser CompileParser; public Tuple, Tuple>[] JumpPointerCache; } @@ -364,14 +364,14 @@ namespace Convention.RScript public SerializableClass Compile(ExpressionParser parser) { BeforeRun(parser); - foreach (var item in Sentences) - { - if (SentenceRunners.TryGetValue(item.mode, out var runner)) - runner.Compile(parser, item, this); - } + //foreach (var item in Sentences) + //{ + // if (SentenceRunners.TryGetValue(item.mode, out var runner)) + // runner.Compile(parser, item, this); + //} return new SerializableClass() { - CompileParser = parser.Serialize(), + //CompileParser = parser.Serialize(), Labels = (from item in Labels select Tuple.Create(item.Key, item.Value)).ToArray(), NamespaceLayer = (from item in NamespaceLayer select Tuple.Create(item.Key, item.Value)).ToArray(), NamespaceLabels = (from item in NamespaceLabels select Tuple.Create(item.Key, item.Value)).ToArray(), @@ -383,7 +383,7 @@ namespace Convention.RScript { return new SerializableClass() { - CompileParser = parser.Serialize(), + //CompileParser = parser.Serialize(), Labels = (from item in Labels select Tuple.Create(item.Key, item.Value)).ToArray(), NamespaceLayer = (from item in NamespaceLayer select Tuple.Create(item.Key, item.Value)).ToArray(), NamespaceLabels = (from item in NamespaceLabels select Tuple.Create(item.Key, item.Value)).ToArray(), diff --git a/RScriptSerializer.cs b/RScriptSerializer.cs index 0ab2735..211a037 100644 --- a/RScriptSerializer.cs +++ b/RScriptSerializer.cs @@ -89,81 +89,66 @@ namespace Convention.RScript // 反序列化 Sentences 数组 int sentencesLength = reader.ReadInt32(); - if (sentencesLength > 0) + result.Sentences = new RScriptSentence[sentencesLength]; + for (int i = 0; i < sentencesLength; i++) { - result.Sentences = new RScriptSentence[sentencesLength]; - for (int i = 0; i < sentencesLength; i++) + var sentence = new RScriptSentence(); + sentence.content = reader.ReadString(); + + int infoLength = reader.ReadInt32(); + if (infoLength > 0) { - var sentence = new RScriptSentence(); - sentence.content = reader.ReadString(); - - int infoLength = reader.ReadInt32(); - if (infoLength > 0) + sentence.info = new string[infoLength]; + for (int j = 0; j < infoLength; j++) { - sentence.info = new string[infoLength]; - for (int j = 0; j < infoLength; j++) - { - sentence.info[j] = reader.ReadString(); - } + sentence.info[j] = reader.ReadString(); } - - sentence.mode = (RScriptSentence.Mode)reader.ReadInt32(); - result.Sentences[i] = sentence; } + + sentence.mode = (RScriptSentence.Mode)reader.ReadInt32(); + result.Sentences[i] = sentence; } // 反序列化 Labels 数组 int labelsLength = reader.ReadInt32(); - if (labelsLength > 0) + result.Labels = new Tuple[labelsLength]; + for (int i = 0; i < labelsLength; i++) { - result.Labels = new Tuple[labelsLength]; - for (int i = 0; i < labelsLength; i++) - { - string item1 = reader.ReadString(); - int item2 = reader.ReadInt32(); - result.Labels[i] = Tuple.Create(item1, item2); - } + string item1 = reader.ReadString(); + int item2 = reader.ReadInt32(); + result.Labels[i] = Tuple.Create(item1, item2); } // 反序列化 NamespaceLayer 数组 int namespaceLayerLength = reader.ReadInt32(); - if (namespaceLayerLength > 0) + result.NamespaceLayer = new Tuple[namespaceLayerLength]; + for (int i = 0; i < namespaceLayerLength; i++) { - result.NamespaceLayer = new Tuple[namespaceLayerLength]; - for (int i = 0; i < namespaceLayerLength; i++) - { - int item1 = reader.ReadInt32(); - int item2 = reader.ReadInt32(); - result.NamespaceLayer[i] = Tuple.Create(item1, item2); - } + int item1 = reader.ReadInt32(); + int item2 = reader.ReadInt32(); + result.NamespaceLayer[i] = Tuple.Create(item1, item2); } // 反序列化 NamespaceLabels 数组 int namespaceLabelsLength = reader.ReadInt32(); - if (namespaceLabelsLength > 0) + result.NamespaceLabels = new Tuple[namespaceLabelsLength]; + for (int i = 0; i < namespaceLabelsLength; i++) { - result.NamespaceLabels = new Tuple[namespaceLabelsLength]; - for (int i = 0; i < namespaceLabelsLength; i++) - { - string item1 = reader.ReadString(); - int item2 = reader.ReadInt32(); - result.NamespaceLabels[i] = Tuple.Create(item1, item2); - } + string item1 = reader.ReadString(); + int item2 = reader.ReadInt32(); + result.NamespaceLabels[i] = Tuple.Create(item1, item2); } // 反序列化 JumpPointerCache 数组 int jumpPointerCacheLength = reader.ReadInt32(); - if (jumpPointerCacheLength > 0) + result.JumpPointerCache = new Tuple, Tuple>[jumpPointerCacheLength]; + for (int i = 0; i < jumpPointerCacheLength; i++) { - result.JumpPointerCache = new Tuple, Tuple>[jumpPointerCacheLength]; - for(int i=0;i