File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -373,6 +373,13 @@ Result<const void*> Program::get_constant_buffer_data(
373373  }
374374}
375375
376+ Result<const  NamedDataMap*> Program::get_named_data_map () const  {
377+   if  (core_data_map_.has_value ()) {
378+     return  &core_data_map_.value ();
379+   }
380+   return  Error::NotFound;
381+ }
382+ 
376383Result<const  char *> Program::get_output_flattening_encoding (
377384    const  char * method_name) const  {
378385  auto  plan = get_execution_plan (internal_program_, method_name);
Original file line number Diff line number Diff line change @@ -107,6 +107,12 @@ class Program final {
107107  Result<const  void *> get_constant_buffer_data (size_t  buffer_idx, size_t  nbytes)
108108      const ;
109109
110+   /* *
111+    * Get the named data map from the program. 
112+    * @return The named data map. 
113+    */  
114+   Result<const  NamedDataMap*> get_named_data_map () const ;
115+ 
110116  /* *
111117   * Returns the number of methods in the program. 
112118   */  
Original file line number Diff line number Diff line change @@ -371,6 +371,18 @@ TEST_F(ProgramTest, getMethods) {
371371  EXPECT_EQ (strcmp (res2.get (), " forward2" 0 );
372372}
373373
374+ TEST_F (ProgramTest, GetNamedDataMap_Fail) {
375+   Result<Program> program =
376+       Program::load (add_loader_.get (), kDefaultVerification );
377+   ASSERT_EQ (program.error (), Error::Ok);
378+ 
379+   //  Get the named data map. Expect to fail, as add.pte does not have any
380+   //  named data segments.
381+   Result<const  executorch::runtime::NamedDataMap*> named_data_map =
382+       program->get_named_data_map ();
383+   EXPECT_EQ (named_data_map.error (), Error::NotFound);
384+ }
385+ 
374386//  Test that the deprecated Load method (capital 'L') still works.
375387TEST_F (ProgramTest, DEPRECATEDLoad) {
376388  //  Parse the Program from the data.
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments