Compare commits
3 Commits
cdf04acecf
...
02906f836d
| Author | SHA1 | Date | |
|---|---|---|---|
| 02906f836d | |||
| f9446fb0bb | |||
| aca8c86e97 |
@@ -5,7 +5,6 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEditor;
|
|
||||||
|
|
||||||
namespace Convention.RScript.Variable
|
namespace Convention.RScript.Variable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
|
||||||
using static Convention.RScript.RScriptContext;
|
using static Convention.RScript.RScriptContext;
|
||||||
|
|
||||||
namespace Convention.RScript
|
namespace Convention.RScript
|
||||||
@@ -112,7 +111,7 @@ namespace Convention.RScript
|
|||||||
public Tuple<string, int>[] Labels;
|
public Tuple<string, int>[] Labels;
|
||||||
public Tuple<int, int>[] NamespaceLayer;
|
public Tuple<int, int>[] NamespaceLayer;
|
||||||
public Tuple<string, int>[] NamespaceLabels;
|
public Tuple<string, int>[] NamespaceLabels;
|
||||||
public ExpressionParser.SerializableParser CompileParser;
|
//public ExpressionParser.SerializableParser CompileParser;
|
||||||
public Tuple<Tuple<int, int>, Tuple<int, int>>[] JumpPointerCache;
|
public Tuple<Tuple<int, int>, Tuple<int, int>>[] JumpPointerCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,12 +283,10 @@ namespace Convention.RScript
|
|||||||
}
|
}
|
||||||
catch (RScriptException)
|
catch (RScriptException)
|
||||||
{
|
{
|
||||||
Debug.LogError($"current sentence: {sentence}");
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.LogError($"current sentence: {sentence}");
|
|
||||||
throw new RScriptRuntimeException($"Runtime error: {ex.Message}", CurrentRuntimePointer, ex);
|
throw new RScriptRuntimeException($"Runtime error: {ex.Message}", CurrentRuntimePointer, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -367,14 +364,14 @@ namespace Convention.RScript
|
|||||||
public SerializableClass Compile(ExpressionParser parser)
|
public SerializableClass Compile(ExpressionParser parser)
|
||||||
{
|
{
|
||||||
BeforeRun(parser);
|
BeforeRun(parser);
|
||||||
foreach (var item in Sentences)
|
//foreach (var item in Sentences)
|
||||||
{
|
//{
|
||||||
if (SentenceRunners.TryGetValue(item.mode, out var runner))
|
// if (SentenceRunners.TryGetValue(item.mode, out var runner))
|
||||||
runner.Compile(parser, item, this);
|
// runner.Compile(parser, item, this);
|
||||||
}
|
//}
|
||||||
return new SerializableClass()
|
return new SerializableClass()
|
||||||
{
|
{
|
||||||
CompileParser = parser.Serialize(),
|
//CompileParser = parser.Serialize(),
|
||||||
Labels = (from item in Labels select Tuple.Create(item.Key, item.Value)).ToArray(),
|
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(),
|
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(),
|
NamespaceLabels = (from item in NamespaceLabels select Tuple.Create(item.Key, item.Value)).ToArray(),
|
||||||
@@ -386,7 +383,7 @@ namespace Convention.RScript
|
|||||||
{
|
{
|
||||||
return new SerializableClass()
|
return new SerializableClass()
|
||||||
{
|
{
|
||||||
CompileParser = parser.Serialize(),
|
//CompileParser = parser.Serialize(),
|
||||||
Labels = (from item in Labels select Tuple.Create(item.Key, item.Value)).ToArray(),
|
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(),
|
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(),
|
NamespaceLabels = (from item in NamespaceLabels select Tuple.Create(item.Key, item.Value)).ToArray(),
|
||||||
|
|||||||
@@ -89,81 +89,66 @@ namespace Convention.RScript
|
|||||||
|
|
||||||
// 反序列化 Sentences 数组
|
// 反序列化 Sentences 数组
|
||||||
int sentencesLength = reader.ReadInt32();
|
int sentencesLength = reader.ReadInt32();
|
||||||
if (sentencesLength > 0)
|
result.Sentences = new RScriptSentence[sentencesLength];
|
||||||
|
for (int i = 0; i < sentencesLength; i++)
|
||||||
{
|
{
|
||||||
result.Sentences = new RScriptSentence[sentencesLength];
|
var sentence = new RScriptSentence();
|
||||||
for (int i = 0; i < sentencesLength; i++)
|
sentence.content = reader.ReadString();
|
||||||
|
|
||||||
|
int infoLength = reader.ReadInt32();
|
||||||
|
if (infoLength > 0)
|
||||||
{
|
{
|
||||||
var sentence = new RScriptSentence();
|
sentence.info = new string[infoLength];
|
||||||
sentence.content = reader.ReadString();
|
for (int j = 0; j < infoLength; j++)
|
||||||
|
|
||||||
int infoLength = reader.ReadInt32();
|
|
||||||
if (infoLength > 0)
|
|
||||||
{
|
{
|
||||||
sentence.info = new string[infoLength];
|
sentence.info[j] = reader.ReadString();
|
||||||
for (int j = 0; j < infoLength; j++)
|
|
||||||
{
|
|
||||||
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 数组
|
// 反序列化 Labels 数组
|
||||||
int labelsLength = reader.ReadInt32();
|
int labelsLength = reader.ReadInt32();
|
||||||
if (labelsLength > 0)
|
result.Labels = new Tuple<string, int>[labelsLength];
|
||||||
|
for (int i = 0; i < labelsLength; i++)
|
||||||
{
|
{
|
||||||
result.Labels = new Tuple<string, int>[labelsLength];
|
string item1 = reader.ReadString();
|
||||||
for (int i = 0; i < labelsLength; i++)
|
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 数组
|
// 反序列化 NamespaceLayer 数组
|
||||||
int namespaceLayerLength = reader.ReadInt32();
|
int namespaceLayerLength = reader.ReadInt32();
|
||||||
if (namespaceLayerLength > 0)
|
result.NamespaceLayer = new Tuple<int, int>[namespaceLayerLength];
|
||||||
|
for (int i = 0; i < namespaceLayerLength; i++)
|
||||||
{
|
{
|
||||||
result.NamespaceLayer = new Tuple<int, int>[namespaceLayerLength];
|
int item1 = reader.ReadInt32();
|
||||||
for (int i = 0; i < namespaceLayerLength; i++)
|
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 数组
|
// 反序列化 NamespaceLabels 数组
|
||||||
int namespaceLabelsLength = reader.ReadInt32();
|
int namespaceLabelsLength = reader.ReadInt32();
|
||||||
if (namespaceLabelsLength > 0)
|
result.NamespaceLabels = new Tuple<string, int>[namespaceLabelsLength];
|
||||||
|
for (int i = 0; i < namespaceLabelsLength; i++)
|
||||||
{
|
{
|
||||||
result.NamespaceLabels = new Tuple<string, int>[namespaceLabelsLength];
|
string item1 = reader.ReadString();
|
||||||
for (int i = 0; i < namespaceLabelsLength; i++)
|
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 数组
|
// 反序列化 JumpPointerCache 数组
|
||||||
int jumpPointerCacheLength = reader.ReadInt32();
|
int jumpPointerCacheLength = reader.ReadInt32();
|
||||||
if (jumpPointerCacheLength > 0)
|
result.JumpPointerCache = new Tuple<Tuple<int, int>, Tuple<int, int>>[jumpPointerCacheLength];
|
||||||
|
for (int i = 0; i < jumpPointerCacheLength; i++)
|
||||||
{
|
{
|
||||||
result.JumpPointerCache = new Tuple<Tuple<int, int>, Tuple<int, int>>[jumpPointerCacheLength];
|
int x = reader.ReadInt32();
|
||||||
for(int i=0;i<jumpPointerCacheLength;i++)
|
int y = reader.ReadInt32();
|
||||||
{
|
int z = reader.ReadInt32();
|
||||||
int x= reader.ReadInt32();
|
int w = reader.ReadInt32();
|
||||||
int y= reader.ReadInt32();
|
result.JumpPointerCache[i] = Tuple.Create(Tuple.Create(x, y), Tuple.Create(z, w));
|
||||||
int z= reader.ReadInt32();
|
|
||||||
int w= reader.ReadInt32();
|
|
||||||
result.JumpPointerCache[i] = Tuple.Create(Tuple.Create(x, y), Tuple.Create(z, w));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user