@@ -1466,7 +1466,9 @@ namespace Slang
1466
1466
// For now we will do this in a completely ad hoc fashion,
1467
1467
// but it would be nice to have some generic routine to
1468
1468
// do the needed type checking/coercion.
1469
- if (getText (hlslUncheckedAttribute->getName ()) == " numthreads" )
1469
+ auto attribText = getText (hlslUncheckedAttribute->getName ());
1470
+
1471
+ if (attribText == " numthreads" )
1470
1472
{
1471
1473
if (hlslUncheckedAttribute->args .Count () != 3 )
1472
1474
return m;
@@ -1490,8 +1492,33 @@ namespace Slang
1490
1492
1491
1493
return hlslNumThreadsAttribute;
1492
1494
}
1493
- }
1495
+ else if (attribText == " maxvertexcount" )
1496
+ {
1497
+ if (hlslUncheckedAttribute->args .Count () != 1 )
1498
+ return m;
1499
+ auto val = checkConstantIntVal (hlslUncheckedAttribute->args [0 ]);
1500
+ auto hlslMaxVertexCountAttrib = new HLSLMaxVertexCountAttribute ();
1501
+
1502
+ hlslMaxVertexCountAttrib->loc = hlslUncheckedAttribute->loc ;
1503
+ hlslMaxVertexCountAttrib->name = hlslUncheckedAttribute->getName ();
1504
+ hlslMaxVertexCountAttrib->args = hlslUncheckedAttribute->args ;
1505
+ hlslMaxVertexCountAttrib->value = (int32_t )val->value ;
1506
+ return hlslMaxVertexCountAttrib;
1507
+ }
1508
+ else if (attribText == " instance" )
1509
+ {
1510
+ if (hlslUncheckedAttribute->args .Count () != 1 )
1511
+ return m;
1512
+ auto val = checkConstantIntVal (hlslUncheckedAttribute->args [0 ]);
1513
+ auto attrib = new HLSLInstanceAttribute ();
1494
1514
1515
+ attrib->loc = hlslUncheckedAttribute->loc ;
1516
+ attrib->name = hlslUncheckedAttribute->getName ();
1517
+ attrib->args = hlslUncheckedAttribute->args ;
1518
+ attrib->value = (int32_t )val->value ;
1519
+ return attrib;
1520
+ }
1521
+ }
1495
1522
// Default behavior is to leave things as they are,
1496
1523
// and assume that modifiers are mostly already checked.
1497
1524
//
@@ -2202,9 +2229,10 @@ namespace Slang
2202
2229
// to avoid recursion here.
2203
2230
if (functionNode->Body )
2204
2231
{
2232
+ auto oldFunc = function;
2205
2233
this ->function = functionNode;
2206
2234
checkStmt (functionNode->Body );
2207
- this ->function = nullptr ;
2235
+ this ->function = oldFunc ;
2208
2236
}
2209
2237
}
2210
2238
}
@@ -2630,6 +2658,7 @@ namespace Slang
2630
2658
{
2631
2659
if (functionNode->IsChecked (DeclCheckState::CheckedHeader)) return ;
2632
2660
functionNode->SetCheckState (DeclCheckState::CheckingHeader);
2661
+ auto oldFunc = this ->function ;
2633
2662
this ->function = functionNode;
2634
2663
auto returnType = CheckProperType (functionNode->ReturnType );
2635
2664
functionNode->ReturnType = returnType;
@@ -2648,7 +2677,7 @@ namespace Slang
2648
2677
else
2649
2678
paraNames.Add (para->getName ());
2650
2679
}
2651
- this ->function = NULL ;
2680
+ this ->function = oldFunc ;
2652
2681
functionNode->SetCheckState (DeclCheckState::CheckedHeader);
2653
2682
2654
2683
// One last bit of validation: check if we are redeclaring an existing function
@@ -5745,6 +5774,13 @@ namespace Slang
5745
5774
AddDeclRefOverloadCandidates (item, context);
5746
5775
}
5747
5776
}
5777
+ else if (auto overloadedExpr2 = funcExpr.As <OverloadedExpr2>())
5778
+ {
5779
+ for (auto item : overloadedExpr2->candidiateExprs )
5780
+ {
5781
+ AddOverloadCandidates (item, context);
5782
+ }
5783
+ }
5748
5784
else if (auto typeType = funcExprType->As <TypeType>())
5749
5785
{
5750
5786
// If none of the above cases matched, but we are
@@ -5944,6 +5980,10 @@ namespace Slang
5944
5980
{
5945
5981
context.baseExpr = funcOverloadExpr->base ;
5946
5982
}
5983
+ else if (auto funcOverloadExpr2 = funcExpr.As <OverloadedExpr2>())
5984
+ {
5985
+ context.baseExpr = funcOverloadExpr2->base ;
5986
+ }
5947
5987
AddOverloadCandidates (funcExpr, context);
5948
5988
5949
5989
if (context.bestCandidates .Count () > 0 )
@@ -6172,15 +6212,14 @@ namespace Slang
6172
6212
// There were multiple viable candidates, but that isn't an error: we just need
6173
6213
// to complete all of them and create an overloaded expression as a result.
6174
6214
6175
- LookupResult result;
6215
+ auto overloadedExpr = new OverloadedExpr2 ();
6216
+ overloadedExpr->base = context.baseExpr ;
6176
6217
for (auto candidate : context.bestCandidates )
6177
6218
{
6178
6219
auto candidateExpr = CompleteOverloadCandidate (context, candidate);
6220
+ overloadedExpr->candidiateExprs .Add (candidateExpr);
6179
6221
}
6180
-
6181
- throw " what now?" ;
6182
- // auto overloadedExpr = new OverloadedExpr();
6183
- // return overloadedExpr;
6222
+ return overloadedExpr;
6184
6223
}
6185
6224
}
6186
6225
else if (context.bestCandidate )
@@ -6400,6 +6439,13 @@ namespace Slang
6400
6439
return expr;
6401
6440
}
6402
6441
6442
+ RefPtr<Expr> visitOverloadedExpr2 (OverloadedExpr2* expr)
6443
+ {
6444
+ SLANG_DIAGNOSE_UNEXPECTED (getSink (), expr, " should not appear in input syntax" );
6445
+ return expr;
6446
+ }
6447
+
6448
+
6403
6449
RefPtr<Expr> visitAggTypeCtorExpr (AggTypeCtorExpr* expr)
6404
6450
{
6405
6451
SLANG_DIAGNOSE_UNEXPECTED (getSink (), expr, " should not appear in input syntax" );
0 commit comments