MCPcopy Index your code
hub / github.com/PowerShell/DSC / invoke

Method invoke

lib/dsc-lib/src/parser/functions.rs:110–143  ·  view source on GitHub ↗

Invoke the function. # Errors This function will return an error if the function fails to execute.

(&self, function_dispatcher: &FunctionDispatcher, context: &Context)

Source from the content-addressed store, hash-verified

108 ///
109 /// This function will return an error if the function fails to execute.
110 pub fn invoke(&self, function_dispatcher: &FunctionDispatcher, context: &Context) -> Result<Value, DscError> {
111 // Special handling for lambda() function - pass raw args through context
112 if self.name.to_lowercase() == "lambda" {
113 // Store raw args in context for lambda function to access
114 *context.lambda_raw_args.borrow_mut() = self.args.clone();
115 let result = function_dispatcher.invoke("lambda", &[], context);
116 // Clear raw args
117 *context.lambda_raw_args.borrow_mut() = None;
118 return result;
119 }
120
121 // if any args are expressions, we need to invoke those first
122 let mut resolved_args: Vec<Value> = vec![];
123 if let Some(args) = &self.args {
124 for arg in args {
125 match arg {
126 FunctionArg::Expression(expression) => {
127 debug!("{}", t!("parser.functions.argIsExpression"));
128 let value = expression.invoke(function_dispatcher, context)?;
129 resolved_args.push(value.clone());
130 },
131 FunctionArg::Value(value) => {
132 debug!("{}", t!("parser.functions.argIsValue", value = value : {:?}));
133 resolved_args.push(value.clone());
134 },
135 FunctionArg::Lambda(_lambda) => {
136 return Err(DscError::Parser(t!("parser.functions.unexpectedLambda").to_string()));
137 }
138 }
139 }
140 }
141
142 function_dispatcher.invoke(&self.name, &resolved_args, context)
143 }
144
145 /// Get the name of the function.
146 #[must_use]

Callers 1

parse_and_executeMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected