Branch: Tag:

2018-11-04

2018-11-04 11:36:36 by mkrawczuk <krawczukmat@gmail.com>

Enable string import of single files. Throw error on failed import.

Previously, string-style import would only work with pmod
directories. Now it also works with single-file pmods.
Additionally, the interpreter would be silent about invalid pathes.
Now it throws an error if it fails to stat a path.

2934:    module_node node = module_node_cache[current_handler][path] =    module_node("import::"+path, 0, current_handler);   #endif /* 0 */ -  joinnode node = joinnode(({}), current_handler); +  auto path_stat = file_stat(path); +  if (!path_stat) +  compile_cb_error("Failed to stat file: %O\n", path); +  joinnode node; +  if (path_stat->isreg) { +  node = low_cast_to_object(path, current_file, current_handler); +  } +  if (path_stat->isdir) { +  node = joinnode(({}), current_handler);   #ifdef PIKE_MODULE_RELOC    // If we have PIKE_MODULE_RELOC enabled,    // we might need to map to multiple directories.
2947:    } else   #endif /* PIKE_MODULE_RELOC */    node->add_path(path); +  }    return node;   }