本文整理汇总了C#中IAstVisitor.VisitFunction方法的典型用法代码示例。如果您正苦于以下问题:C# IAstVisitor.VisitFunction方法的具体用法?C# IAstVisitor.VisitFunction怎么用?C# IAstVisitor.VisitFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAstVisitor
的用法示例。
在下文中一共展示了IAstVisitor.VisitFunction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallFunctionInScript
/// <summary>
/// Call a function by passing in all the values.
/// </summary>
/// <param name="ctx">The context of the runtime</param>
/// <param name="functionName">The name of the function to call.</param>
/// <param name="paramListExpressions">List of parameters as expressions to evaluate first to actual values</param>
/// <param name="paramVals">List to store the resolved paramter expressions. ( these will be resolved if paramListExpressions is supplied and resolveParams is true. If
/// resolveParams is false, the list is assumed to have the values for the paramters to the function.</param>
/// <param name="resolveParams">Whether or not to resolve the list of parameter expression objects</param>
/// <returns></returns>
public static object CallFunctionInScript(Context ctx, FunctionExpr function, string functionName, List<Expr> paramListExpressions, List<object> paramVals, bool resolveParams, IAstVisitor visitor)
{
// 1. Determine if any parameters provided.
var hasParams = paramListExpressions != null && paramListExpressions.Count > 0;
// 2. Resolve parameters if necessary
var hasArguments = function.Meta.HasArguments();
if (resolveParams && function != null && (hasArguments || hasParams))
ParamHelper.ResolveParametersForScriptFunction(function.Meta, paramListExpressions, paramVals, visitor);
// 3. Assign the argument values to the function and evaluate.
function.ArgumentValues = paramVals;
visitor.VisitFunction(function);
object result = null;
if (function.HasReturnValue)
result = function.ReturnValue;
else
result = LObjects.Null;
return result;
}
示例2: DoEvaluate
public override object DoEvaluate(IAstVisitor visitor)
{
return visitor.VisitFunction(this);
}