diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2020-08-20 08:23:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-20 08:23:51 -0700 |
| commit | 11748a75e66c2bd3fa7ef7635fd35363465f599c (patch) | |
| tree | c1920f54ac59dcd79806b475df3e4c1ba85756ba /source/slang/slang-lower-to-ir.cpp | |
| parent | b5a4161a801a573179b1f552e5c53748d2667b03 (diff) | |
Initial support for a using construct (#1506)
The basic idea is that if you have a namespace:
namespace MyCoolNamespace { void f() { ... } ... }
then you can bring the declarations from that namespace into scope with:
using MyCoolNamespace;
f();
The `using` construct is allowed in any scope where declarations are allowed. As an additional feature, the construct allows and then ignores the keyword `namespace` if it occurs right after `using`:
using namespace MyCoolNamespace;
Note that unlike in C++, `using` a namespace inside another namespace doesn't implicitly make the symbols available to clients of that namespace:
namespace hidden { void secret() {...} ... }
namespace api { using hidden; ... }
api.secret(); // ERROR: `secret()` isn't a member of `api`
The implementation of this feature was relatively simple, although it does leave out more advanced features that might be desirable in the future:
* No support for `using MCN = MyCoolNamespace` sorts of tricks to define a short name
* No support for `using` anything that isn't a namespace (e.g., to make the members of a type available without qualification)
* No support for cases where multiple visible modules have a namespace of the same name (or dealing with overloaded namespaces in general)
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 864491f7e..f87b6bd69 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -5032,6 +5032,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> LoweredValInfo visit##NAME(NAME*) { return LoweredValInfo(); } IGNORED_CASE(ImportDecl) + IGNORED_CASE(UsingDecl) IGNORED_CASE(EmptyDecl) IGNORED_CASE(SyntaxDecl) IGNORED_CASE(AttributeDecl) |
