Releases: Arc-huangjingtong/UniInk-CSharpInterpreter4AOT
Releases · Arc-huangjingtong/UniInk-CSharpInterpreter4AOT
New Feature !
-
✨Support Control Flow(If Statement)
//Not Support Nested call now like : if ( xxx ) { if ( ) { } }
var script= @" if ( 1 > 2 )
{
123
}
else if ( 3 > 6 )
{
456
}
else if ( 3 < 6 )
{
return 456
}
else
{
return 666
} ";
// you should copy the UniInk_Extensions.cs to your project
// it may enlightened you to write the custom extension
var res = Ink.Evaluate_IfStatement(script) as InkValue;
A full feature Ver
-
✨Support Arithmetic Operations ( Easy extend Operator )
// 1. Create a new instance of the interpreter
var Ink = new UniInk_Speed();
// 2. Evaluate the expression , and as it to InkValue
var res1 = Ink.Evaluate(" +9 * (1+1 + 1 + 1 + 1+1+1)") as InkValue;
// 3. Get the result with the type you want, the result is 63
Console.WriteLine(res1.Value_int);
// PS : the process of calculation is 0 GC and 0 Boxing
// if you want improve the performance further , recycle the InkValue
InkValue.Release(res1); // now the GC is 0 completely!
Other example
var Ink = new UniInk_Speed();
// float type
var res = Ink.Evaluate("3333333.3333333f-3.3f+3.3f+ 3.3f - 3.3f") as InkValue;
Console.WriteLine(res.Value_float);
// double type
var res2 = Ink.Evaluate("+123456789.987654321d + 987654321.123456789d") as InkValue;
Console.WriteLine(res2.Value_double);
-
✨Support Logical Operations ( Easy extend Operator )
// bool type
var res = Ink.Evaluate("1 < 2 || 2 ==1 || 2 < 1") as InkValue;
Console.WriteLine(res.Value_bool);
Evaluate Scripts
-
✨Support Variable Assignment
// the result will return the last expression
var res = Ink.Evaluate("var aaa= 123 ; var bbb =aaa + 1 ; aaa + bbb ") as InkValue;
Console.WriteLine(res.Value_int);
-
✨Support Function Call
// the result will return the last expression
// has API to register the function
var res = Ink.Evaluate("var a = CRE(1,3) ; GET(a, Rarity) == 3 ") as InkValue;
-
✨Support Lambda Expression
// this may be complex, but we also support it
var res = Ink.Evaluate("FLT(Config,var c => GET(c, Rarity) == 2 && GET(c, ID) == 1)") as InkValue;
v0.1.0-alpha
Test02 Update