diff options
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
| -rw-r--r-- | source/slang/slang-check-expr.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index 7b8be7a33..a91ec1e98 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -3677,4 +3677,43 @@ namespace Slang } } + Expr* SemanticsExprVisitor::visitFuncTypeExpr(FuncTypeExpr* expr) + { + // The input and output to a function type must both be types + for(auto& t : expr->parameters) + t = CheckProperType(t); + expr->result = CheckProperType(expr->result); + + // TODO: Kind checking? Where are we stopping someone passing + // constraints around as value-inhabitable types + + // The result of this expression is a `FuncType`, which we need + // to wrap in a `TypeType` to indicate that the result is the type + // itself and not a value of that type. + List<Type*> types; + types.reserve(expr->parameters.getCount()); + for(const auto& t : expr->parameters) + types.add(t.type); + auto funcType = m_astBuilder->getFuncType(std::move(types), expr->result.type); + expr->type = m_astBuilder->getTypeType(funcType); + + return expr; + } + + Expr* SemanticsExprVisitor::visitTupleTypeExpr(TupleTypeExpr* expr) + { + // All tuple members must be types + for(auto& t : expr->members) + t = CheckProperType(t); + + // As in the other cases above, wrap in TypeType + List<Type*> types; + types.reserve(expr->members.getCount()); + for(auto t : expr->members) + types.add(t.type); + auto tupleType = m_astBuilder->getTupleType(types); + expr->type = m_astBuilder->getTypeType(tupleType); + + return expr; + } } |
