summaryrefslogtreecommitdiffstats
path: root/source/slang/check.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-09-11 09:33:46 -0700
committerTim Foley <tfoley@nvidia.com>2017-09-11 14:06:02 -0700
commit2055d540c5dd420448a6924d784d5aed0efcd93d (patch)
tree29167b8abb5001cd3c2803807ec5c8eb3bc2329f /source/slang/check.cpp
parent80fb7b05b851e645d821331fdbbcea1add686c9a (diff)
Support IR-based codegen for a few more examples.
The main interesting change here is around support for lowering of calls to "subscript" operations (what a C++ programmer would think of as `operator[]`). An important infrastructure change here was to add an explicit AST-node representation for a "static member expression" which we use whenever a member is looked up in a type as opposed to a value. The implementation of this probably isn't robust yet, but it turns out to be important to be able to tell such cases apart.
Diffstat (limited to 'source/slang/check.cpp')
-rw-r--r--source/slang/check.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp
index ce9b2de55..e22db4186 100644
--- a/source/slang/check.cpp
+++ b/source/slang/check.cpp
@@ -146,13 +146,26 @@ namespace Slang
{
if (baseExpr)
{
- auto expr = new MemberExpr();
- expr->loc = loc;
- expr->BaseExpression = baseExpr;
- expr->name = declRef.GetName();
- expr->type = GetTypeForDeclRef(declRef);
- expr->declRef = declRef;
- return expr;
+ if (baseExpr->type->As<TypeType>())
+ {
+ auto expr = new StaticMemberExpr();
+ expr->loc = loc;
+ expr->BaseExpression = baseExpr;
+ expr->name = declRef.GetName();
+ expr->type = GetTypeForDeclRef(declRef);
+ expr->declRef = declRef;
+ return expr;
+ }
+ else
+ {
+ auto expr = new MemberExpr();
+ expr->loc = loc;
+ expr->BaseExpression = baseExpr;
+ expr->name = declRef.GetName();
+ expr->type = GetTypeForDeclRef(declRef);
+ expr->declRef = declRef;
+ return expr;
+ }
}
else
{
@@ -4978,6 +4991,11 @@ namespace Slang
}
}
+ RefPtr<Expr> visitStaticMemberExpr(StaticMemberExpr* expr)
+ {
+ SLANG_UNEXPECTED("should not occur in unchecked AST");
+ return expr;
+ }
RefPtr<Expr> visitMemberExpr(MemberExpr * expr)
{