Skip to content

A full feature Ver

Compare
Choose a tag to compare
@Arc-huangjingtong Arc-huangjingtong released this 06 Jul 09:18
· 35 commits to main since this release
  • ✨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;