mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Placeholder implementation for constraint expressions
This commit is contained in:
parent
dead14fac6
commit
6e38c1c3b6
3 changed files with 81 additions and 13 deletions
|
@ -3000,11 +3000,21 @@ public:
|
||||||
BfSizedArray<ASTREF(BfTokenNode*)> mCommas;
|
BfSizedArray<ASTREF(BfTokenNode*)> mCommas;
|
||||||
}; BF_AST_DECL(BfGenericConstraint, BfAstNode);
|
}; BF_AST_DECL(BfGenericConstraint, BfAstNode);
|
||||||
|
|
||||||
|
class BfGenericConstraintExpression : public BfAstNode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BF_AST_TYPE(BfGenericConstraintExpression, BfAstNode);
|
||||||
|
|
||||||
|
BfTokenNode* mWhereToken;
|
||||||
|
BfExpression* mExpression;
|
||||||
|
}; BF_AST_DECL(BfGenericConstraintExpression, BfAstNode);
|
||||||
|
|
||||||
class BfGenericConstraintsDeclaration : public BfAstNode
|
class BfGenericConstraintsDeclaration : public BfAstNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BF_AST_TYPE(BfGenericConstraintsDeclaration, BfAstNode);
|
BF_AST_TYPE(BfGenericConstraintsDeclaration, BfAstNode);
|
||||||
BfSizedArray<BfGenericConstraint*> mGenericConstraints;
|
BfSizedArray<BfAstNode*> mGenericConstraints;
|
||||||
|
bool mHasExpressions;
|
||||||
}; BF_AST_DECL(BfGenericConstraintsDeclaration, BfAstNode);
|
}; BF_AST_DECL(BfGenericConstraintsDeclaration, BfAstNode);
|
||||||
|
|
||||||
class BfMethodDeclaration : public BfMemberDeclaration
|
class BfMethodDeclaration : public BfMemberDeclaration
|
||||||
|
|
|
@ -83,15 +83,23 @@ void BfElementVisitor::Visit(BfGenericConstraintsDeclaration* genericConstraints
|
||||||
{
|
{
|
||||||
Visit(genericConstraints->ToBase());
|
Visit(genericConstraints->ToBase());
|
||||||
|
|
||||||
for (auto genericConstraint : genericConstraints->mGenericConstraints)
|
for (auto genericConstraintNode : genericConstraints->mGenericConstraints)
|
||||||
{
|
{
|
||||||
VisitChild(genericConstraint->mWhereToken);
|
if (auto genericConstraint = BfNodeDynCast<BfGenericConstraint>(genericConstraintNode))
|
||||||
VisitChild(genericConstraint->mTypeRef);
|
{
|
||||||
VisitChild(genericConstraint->mColonToken);
|
VisitChild(genericConstraint->mWhereToken);
|
||||||
for (auto val : genericConstraint->mConstraintTypes)
|
VisitChild(genericConstraint->mTypeRef);
|
||||||
VisitChild(val);
|
VisitChild(genericConstraint->mColonToken);
|
||||||
for (auto val : genericConstraint->mCommas)
|
for (auto val : genericConstraint->mConstraintTypes)
|
||||||
VisitChild(val);
|
VisitChild(val);
|
||||||
|
for (auto val : genericConstraint->mCommas)
|
||||||
|
VisitChild(val);
|
||||||
|
}
|
||||||
|
else if (auto genericConstraintExpr = BfNodeDynCast<BfGenericConstraintExpression>(genericConstraintNode))
|
||||||
|
{
|
||||||
|
VisitChild(genericConstraintExpr->mWhereToken);
|
||||||
|
VisitChild(genericConstraintExpr->mExpression);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9945,11 +9945,61 @@ BfGenericConstraintsDeclaration* BfReducer::CreateGenericConstraintsDeclaration(
|
||||||
{
|
{
|
||||||
auto constraintsDeclaration = mAlloc->Alloc<BfGenericConstraintsDeclaration>();
|
auto constraintsDeclaration = mAlloc->Alloc<BfGenericConstraintsDeclaration>();
|
||||||
|
|
||||||
BfDeferredAstSizedArray<BfGenericConstraint*> genericConstraintsArr(constraintsDeclaration->mGenericConstraints, mAlloc);
|
BfDeferredAstSizedArray<BfAstNode*> genericConstraintsArr(constraintsDeclaration->mGenericConstraints, mAlloc);
|
||||||
|
|
||||||
bool isDone = false;
|
bool isDone = false;
|
||||||
for (int constraintIdx = 0; !isDone; constraintIdx++)
|
for (int constraintIdx = 0; !isDone; constraintIdx++)
|
||||||
{
|
{
|
||||||
|
// if (auto nextToken = BfNodeDynCast<BfTokenNode>(mVisitorPos.GetNext()))
|
||||||
|
// {
|
||||||
|
// if (nextToken->mToken == BfToken_LParen)
|
||||||
|
// {
|
||||||
|
// BfGenericConstraintExpression* genericConstraint = mAlloc->Alloc<BfGenericConstraintExpression>();
|
||||||
|
// ReplaceNode(tokenNode, genericConstraint);
|
||||||
|
// genericConstraint->mWhereToken = tokenNode;
|
||||||
|
// constraintsDeclaration->mHasExpressions = true;
|
||||||
|
//
|
||||||
|
// genericConstraintsArr.push_back(genericConstraint);
|
||||||
|
//
|
||||||
|
// auto expr = CreateExpressionAfter(genericConstraint, CreateExprFlags_EarlyExit);
|
||||||
|
// if (expr == NULL)
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// MEMBER_SET(genericConstraint, mExpression, expr);
|
||||||
|
//
|
||||||
|
// BfTokenNode* nextWhereToken = NULL;
|
||||||
|
// if (auto checkToken = BfNodeDynCast<BfTokenNode>(mVisitorPos.GetNext()))
|
||||||
|
// {
|
||||||
|
// if (checkToken->mToken != BfToken_Where)
|
||||||
|
// nextWhereToken = checkToken;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// auto nextNode = mVisitorPos.GetNext();
|
||||||
|
// if (BfNodeDynCast<BfBlock>(nextNode))
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// bool handled = false;
|
||||||
|
// if (auto tokenNode = BfNodeDynCast<BfTokenNode>(nextNode))
|
||||||
|
// {
|
||||||
|
// if (tokenNode->mToken == BfToken_FatArrow)
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// tokenNode = ExpectTokenAfter(genericConstraint, BfToken_LBrace, BfToken_Where, BfToken_Semicolon);
|
||||||
|
// if (tokenNode == NULL)
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// BfToken token = tokenNode->GetToken();
|
||||||
|
// if (token != BfToken_Where)
|
||||||
|
// {
|
||||||
|
// mVisitorPos.mReadPos--;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
BfGenericConstraint* genericConstraint = mAlloc->Alloc<BfGenericConstraint>();
|
BfGenericConstraint* genericConstraint = mAlloc->Alloc<BfGenericConstraint>();
|
||||||
BfDeferredAstSizedArray<BfAstNode*> constraintTypes(genericConstraint->mConstraintTypes, mAlloc);
|
BfDeferredAstSizedArray<BfAstNode*> constraintTypes(genericConstraint->mConstraintTypes, mAlloc);
|
||||||
BfDeferredAstSizedArray<BfTokenNode*> commas(genericConstraint->mCommas, mAlloc);
|
BfDeferredAstSizedArray<BfTokenNode*> commas(genericConstraint->mCommas, mAlloc);
|
||||||
|
@ -9957,7 +10007,7 @@ BfGenericConstraintsDeclaration* BfReducer::CreateGenericConstraintsDeclaration(
|
||||||
ReplaceNode(tokenNode, genericConstraint);
|
ReplaceNode(tokenNode, genericConstraint);
|
||||||
genericConstraint->mWhereToken = tokenNode;
|
genericConstraint->mWhereToken = tokenNode;
|
||||||
|
|
||||||
genericConstraintsArr.push_back(genericConstraint);
|
genericConstraintsArr.push_back(genericConstraint);
|
||||||
|
|
||||||
auto genericParamName = CreateTypeRefAfter(genericConstraint);
|
auto genericParamName = CreateTypeRefAfter(genericConstraint);
|
||||||
if (genericParamName != NULL)
|
if (genericParamName != NULL)
|
||||||
|
@ -9975,7 +10025,6 @@ BfGenericConstraintsDeclaration* BfReducer::CreateGenericConstraintsDeclaration(
|
||||||
else
|
else
|
||||||
isDone = true;
|
isDone = true;
|
||||||
|
|
||||||
|
|
||||||
for (int typeIdx = 0; !isDone; typeIdx++)
|
for (int typeIdx = 0; !isDone; typeIdx++)
|
||||||
{
|
{
|
||||||
if (typeIdx > 0)
|
if (typeIdx > 0)
|
||||||
|
@ -9987,13 +10036,14 @@ BfGenericConstraintsDeclaration* BfReducer::CreateGenericConstraintsDeclaration(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool handled = false;
|
||||||
if (auto tokenNode = BfNodeDynCast<BfTokenNode>(nextNode))
|
if (auto tokenNode = BfNodeDynCast<BfTokenNode>(nextNode))
|
||||||
{
|
{
|
||||||
if (tokenNode->mToken == BfToken_FatArrow)
|
if (tokenNode->mToken == BfToken_FatArrow)
|
||||||
{
|
{
|
||||||
isDone = true;
|
isDone = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenNode = ExpectTokenAfter(genericConstraint, BfToken_Comma, BfToken_LBrace, BfToken_Where, BfToken_Semicolon);
|
tokenNode = ExpectTokenAfter(genericConstraint, BfToken_Comma, BfToken_LBrace, BfToken_Where, BfToken_Semicolon);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue