/// <summary> /// Queues a Coral function to run asynchronously. /// </summary> public static void CallFunction( State state, FValue func, object[] args, StackTrace.StackFrame frame ) { // Convert the arguments. AstNode[] wrapped = WrapArgs( args ); // Construct a synthetic AstIdentifier for the name. AstNode funcNode = new WrapperAstObject( func ); // Construct a synthetic AstCall. AstCall call = new AstCall( funcNode, wrapped, frame ); call.run( state ); }
// Wraps the arguments in AstNodes that can be executed. static AstNode[] WrapArgs( object[] args ) { AstNode[] wrapped = new AstNode[args.Length]; for( int i=0; i<args.Length; ++i ) wrapped[i] = new WrapperAstObject( Util.CoerceFromDotNet( args[i] ) ); return wrapped; }