How can we make it easier to experiment with the compiler?
Basile B.
b2.temp at gmx.com
Sun Jun 6 09:19:45 UTC 2021
On Monday, 24 May 2021 at 19:42:00 UTC, user1234 wrote:
> Eventually what could be done for the biggest methods of
> visitors is to extract parts of the content to several
> **non-nested** free functions, so that no more low level
> implementation details, like control loops, are visible and
> instead you just see do_this; do_that; with just a few,
> nzzcessarily unavoidable, flow statements.
I've had the opportunity to do quch a refact yesterday in styx.
It makes things very clear, for example the expression semantic
for binary assign exps :
```d
override void visit(BinAssExpressionAstNode node)
{
processBinaryOperands(node);
if (tryRewritingToOperatorOverload(node, [node.left,
node.right]))
return;
if (tryToSetLengthExp(node))
return;
if (checkIfInvalidEnumSetOp(node))
return;
if (checkPtrArithmeticOp(node))
return;
ensureAssignedParamIsLvalue(node);
tryOneWayAssImplicitConv(node);
checkIfAssignable(node.left);
}
```
or for binary exps that are not assign and not cmp:
```d
override void visit(BinaryExpressionAstNode node)
{
processBinaryOperands(node);
if (tryRewritingToOperatorOverload(node, [node.left,
node.right]))
return;
if (checkIfInvalidEnumSetOp(node))
return;
if (checkPtrArithmeticOp(node))
return;
tryTwoWaysBinaryImplicitConv(node);
}
```
It was like 200 lines before.
More information about the Digitalmars-d
mailing list