Skip to content

Commit

Permalink
Put in more comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
csyonghe authored Sep 5, 2024
1 parent 2aa4a4d commit a291f47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions source/slang/slang-ast-iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,13 @@ void ASTIterator<CallbackFunc, FilterFunc>::visitDecl(DeclBase* decl)
{
if (auto genericTypeConstraint = as<GenericTypeConstraintDecl>(typeConstraint))
{
// A generic constraint decl has a left hand side and right hand side expression
// for the base and super type of the constraint.
// In the case of a folded-in constraint syntax as in `Foo<T:IBar>`,
// the left hand side of the constraint is represented by the same token
// as the parameter decl itself, so we don't need to traverse into it.
// In the case of `Foo<T> where T:IBar`, the left hand side is its own
// expression so we do want to traverse it.
if (genericTypeConstraint->whereTokenLoc.isValid())
visitExpr(genericTypeConstraint->sub.exp);
}
Expand Down
6 changes: 5 additions & 1 deletion source/slang/slang-check-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,12 @@ namespace Slang
InheritanceInfo _getInheritanceInfo(DeclRef<Decl> declRef, DeclRefType* correspondingType, InheritanceCircularityInfo* circularityInfo);
InheritanceInfo _calcInheritanceInfo(Type* type, InheritanceCircularityInfo* circularityInfo);
InheritanceInfo _calcInheritanceInfo(DeclRef<Decl> declRef, DeclRefType* correspondingType, InheritanceCircularityInfo* circularityInfo);
void getDependentGenericParentImpl(DeclRef<GenericDecl>& genericParent, DeclRef<Decl> declRef);

// Get the inner most generic decl that a decl-ref is dependent on.
// For example, `Foo<T>` depends on the generic decl that defines `T`.
//
DeclRef<GenericDecl> getDependentGenericParent(DeclRef<Decl> declRef);
void getDependentGenericParentImpl(DeclRef<GenericDecl>& genericParent, DeclRef<Decl> declRef);

struct DirectBaseInfo
{
Expand Down
5 changes: 5 additions & 0 deletions source/slang/slang-lower-to-ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5001,6 +5001,11 @@ struct ExprLoweringVisitorBase : public ExprVisitor<Derived, LoweredValInfo>
// First, we check if the witness is a type equality witness.
// If so, we can simply emit a bit cast to the target type that should eventually
// fold out to a no-op.
// Note: if we are going to equivalent but not identical types in the future,
// then the cast between equivalent types shouldn't be as simple as a bit cast
// and will require actual coercion logic between the two types.
// For now, we don't support type equivalence witness so this is safe for
// equal types.
if (isTypeEqualityWitness(expr->witnessArg))
{
return LoweredValInfo::simple(getBuilder()->emitBitCast(superType, getSimpleVal(context, value)));
Expand Down

0 comments on commit a291f47

Please sign in to comment.