+@@ -382,9 +401,28 @@
+ virtual int importDirective(Node *n) {
+ if (shadow) {
+ String *modname = Getattr(n,"module");
+ if (modname) {
+- Printf(f_shadow,"import %s\n", modname);
++ Printf(f_shadow,"import ");
++
++ // Find the module node for this imported module. It should be the
++ // first child but search just in case.
++ Node* mod = firstChild(n);
++ while (mod && Strcmp(nodeType(mod), "module") != 0)
++ mod = nextSibling(mod);
++
++ // Is the imported module in another package? (IOW, does it use the
++ // %module(package="name") option and it's different than the package
++ // of this module.)
++ Node *options = Getattr(mod, "options");
++ if (options && Getattr(options, "package")) {
++ String* pkg = Getattr(options, "package");
++ if (!package || Strcmp(pkg, package) != 0)
++ Printf(f_shadow, "%s.", Getattr(options, "package"));
++ }
++
++ // finally, output the name of the imported module
++ Printf(f_shadow, "%s\n", modname);
+ }
+ }
+ return Language::importDirective(n);
+ }
+@@ -417,17 +455,25 @@