Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Build module namespaces as a hierarchal 'stdio' -> 'std' rather than …
Browse files Browse the repository at this point in the history
…a singular 'std.stdio'
  • Loading branch information
ibuclaw committed Feb 17, 2014
1 parent 91a1863 commit d4a3965
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
6 changes: 6 additions & 0 deletions gcc/d/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2014-02-17 Iain Buclaw <ibuclaw@gdcproject.org>

* d-codegen.cc(d_build_module): New function.
* d-decls.cc(Module::toSymbol): Use d_build_module to build up the
qualified module namespace.

2014-02-16 Iain Buclaw <ibuclaw@gdcproject.org>

* d-decls.cc(Module::toSymbol): Build a NAMESPACE_DECL to populate the
Expand Down
22 changes: 22 additions & 0 deletions gcc/d/d-codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,28 @@ d_decl_context (Dsymbol *dsym)
return NULL_TREE;
}

// Build a complete module namespace, any modules in packages will
// have their DECL_CONTEXT set as the symbol of the parent.

tree
d_build_module (Dsymbol *dsym)
{
if (dsym->isModule() || dsym->isPackage())
{
tree decl = build_decl (UNKNOWN_LOCATION, NAMESPACE_DECL,
get_identifier (dsym->ident->string),
void_type_node);
set_decl_location (decl, dsym);

if (dsym->parent)
DECL_CONTEXT (decl) = d_build_module (dsym->parent);

return decl;
}

gcc_unreachable();
}

// Add local variable VD into the current body of function fd.

void
Expand Down
1 change: 1 addition & 0 deletions gcc/d/d-codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class ArrayScope;

// Code generation routines.
extern tree d_decl_context (Dsymbol *dsym);
extern tree d_build_module (Dsymbol *dsym);

extern tree d_mark_addressable (tree exp);
extern tree d_mark_used (tree exp);
Expand Down
11 changes: 3 additions & 8 deletions gcc/d/d-decls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -590,14 +590,9 @@ Module::toSymbol (void)
TREE_CONSTANT (decl) = 0;
TREE_READONLY (decl) = 0;

// Build the module namespace, any enclosing members will have
// this set as their DECL_CONTEXT, see d_decl_context.
const char *name = this->toPrettyChars();
tree mod = build_decl (UNKNOWN_LOCATION, NAMESPACE_DECL,
get_identifier (name), void_type_node);
set_decl_location (mod, this);
csym->ScontextDecl = mod;
d_keep (mod);
tree module = d_build_module (this);
csym->ScontextDecl = module;
d_keep (module);
}

return csym;
Expand Down

0 comments on commit d4a3965

Please sign in to comment.