Update RScript
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
alwaysApply: false
|
||||
alwaysApply: true
|
||||
---
|
||||
## RIPER-5 + O1 思维 + 代理执行协议
|
||||
|
||||
|
||||
Submodule Convention/[FLEE] updated: 47b12f4bc0...5c561fc69c
Submodule Convention/[RScript] updated: 971baf8c9e...29dd4f5d96
@@ -1,62 +1,39 @@
|
||||
using Convention;
|
||||
using Convention.EasySave;
|
||||
using Convention.RScript;
|
||||
using Convention.RScript.Variable;
|
||||
using Convention.RScript.Variable.Attr;
|
||||
using Convention.RScript.Variable.CStyle;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
public class Program
|
||||
{
|
||||
static class Test
|
||||
[Description(@"
|
||||
测试注释1
|
||||
测试注释二
|
||||
")]
|
||||
[Default(@"
|
||||
this.Log(1);
|
||||
")]
|
||||
public class Test
|
||||
{
|
||||
public static object Func(object x)
|
||||
[Method]
|
||||
public void Log(object o)
|
||||
{
|
||||
Console.WriteLine(x);
|
||||
return x;
|
||||
Console.WriteLine(o);
|
||||
}
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
RScriptEngine engine = new();
|
||||
RScriptImportClass import = new()
|
||||
{
|
||||
typeof(Math),
|
||||
typeof(ExpressionMath),
|
||||
typeof(Test)
|
||||
};
|
||||
|
||||
|
||||
var result = engine.Compile(@"
|
||||
int i= 2;
|
||||
int count = 0;
|
||||
label(test);
|
||||
goto(true,func1);
|
||||
Func(i);
|
||||
goto(100>i,test);
|
||||
|
||||
goto(context.ExistNamespace(""x""),end);
|
||||
namespace(x)
|
||||
{
|
||||
Func(""xxx"");
|
||||
}
|
||||
|
||||
namespace(func1)
|
||||
{
|
||||
i = Pow(i,2);
|
||||
count = count + 1;
|
||||
Func(count);
|
||||
}
|
||||
|
||||
label(end);
|
||||
", import);
|
||||
var data = RScriptSerializer.SerializeClass(result);
|
||||
var file = new ToolFile("F:\\test_after_run.dat");
|
||||
file.SaveAsBinary(data);
|
||||
data = file.LoadAsBinary();
|
||||
engine.Run(RScriptSerializer.DeserializeClass(data), import);
|
||||
return;
|
||||
var data2 = RScriptSerializer.SerializeClass(engine.GetCompileResultFromCurrent());
|
||||
var file2 = new ToolFile("F:\\test_after_run.dat");
|
||||
file2.SaveAsBinary(data2);
|
||||
var engine = new RScriptEngine();
|
||||
var testClass = new CScriptRScriptVariableGenerater(typeof(Test), () => new Test(), null, nameof(Test));
|
||||
testClass.Register();
|
||||
engine.Run(@"
|
||||
var t = New(Test);
|
||||
t.Log(114514);
|
||||
");
|
||||
Console.WriteLine(testClass.scriptIndicator);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user