File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,16 @@ runtime::Error Module::load_method(
228228 return runtime::Error::Ok;
229229}
230230
231+ ET_NODISCARD runtime::Result<Method*> Module::method (
232+ const std::string& method_name) {
233+ ET_CHECK_OR_RETURN_ERROR (
234+ methods_.count (method_name) > 0 ,
235+ InvalidArgument,
236+ " no such method in program: %s" ,
237+ method_name.c_str ());
238+ return methods_[method_name].method .get ();
239+ }
240+
231241runtime::Result<MethodMeta> Module::method_meta (
232242 const std::string& method_name) {
233243 ET_CHECK_OK_OR_RETURN_ERROR (load ());
Original file line number Diff line number Diff line change @@ -194,6 +194,18 @@ class Module {
194194 return load_method (method_name, nullptr , event_tracer);
195195 }
196196
197+ /* *
198+ * Get a method by it's name. Not recommended to use this method directly as
199+ * an end user. It's exposed to allow for composability of module in apis that
200+ * operate on method.
201+ *
202+ * @param[in] method_name The name of the method to get.
203+ *
204+ * @returns A Result object containing either a pointer to the requested
205+ * method or an error to indicate failure.
206+ */
207+ ET_NODISCARD runtime::Result<Method*> method (const std::string& method_name);
208+
197209 /* *
198210 * Load the 'forward' method from the program and set up memory management if
199211 * needed. The loaded method is cached to reuse the next time it's executed.
You can’t perform that action at this time.
0 commit comments