/// <summary> /// /// </summary> /// <param name="tokens"></param> public FunctionCallNode(string[] tokens) : base(tokens) { var parser = new Parse.FunctionCall(tokens); FunctionName = parser.FunctionName; FunctionArgs = parser.FunctionArgs; }
private void CEFunctionCall(Parse.FunctionCall Item, Parse.Block Parent, Block Compiled) { int first_runnable_execution_index = Compiled.Count; //Clear any temps that are left if (Item.Arguments.Count > 0) { Compiled.AddItem(new PushTemporariesCount()); } //Get the arguments foreach (var el in Item.Arguments) { //Get the argument CompileElement(el, Parent, Compiled); //Push in temprary Compiled.AddItem(new ResultToTemp()); } //Get the arguments and call the function var tar = Item.Target; if (!Functions.ContainsKey(tar)) { var fun = new Function(tar.ArgumentsCount, tar.Variables.Count, Item.Name); Functions.Add(tar, fun); //Create a unique function name (functions from imports may define same named functions if (IDE.ExecutionTree.Functions.ContainsKey(tar.Name)) { var i = 1; string new_name; do { new_name = string.Format("{0}_{1}", tar.Name, i); i++; } while (IDE.ExecutionTree.Functions.ContainsKey(new_name)); IDE.ExecutionTree.Functions.Add(new_name, fun); } else { IDE.ExecutionTree.Functions.Add(tar.Name, fun); } //Compile the function ComplileFunction(tar); IDE.CompiledAnnotations.Add(tar.Annotation.CompiledPosition, tar.Annotation); } Compiled.AddItem(new CallFunction(Functions[tar])); int last_runnable_execution_index = Compiled.Count - 1; //Clear any temps that are left if (Item.Arguments.Count > 0) { var ct = new PopClearTemporaries(); Compiled.AddItem(ct); CESetOnJumpFailTo(Compiled, first_runnable_execution_index, last_runnable_execution_index, ct); } }
/// <summary> /// /// </summary> /// <param name="tokens"></param> public FunctionResNode(string[] tokens) : base(tokens) { var lhsParser = new Parse.Var(tokens); var rhsParser = new Parse.FunctionCall(tokens.Skip(3)); lhsParser.ParseLhs(); Lhs = lhsParser.Lhs; FunctionName = rhsParser.FunctionName; FunctionArgs = rhsParser.FunctionArgs; }