mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 16:41:06 +03:00
nested: Use early exit instead of giant if in DtoCreateNestedContextType [nfc]
This commit is contained in:
parent
03429eb60f
commit
0c7660a98b
1 changed files with 95 additions and 92 deletions
|
@ -328,6 +328,7 @@ static void DtoCreateNestedContextType(FuncDeclaration *fd) {
|
||||||
IrFunction &irFunc = *getIrFunc(fd);
|
IrFunction &irFunc = *getIrFunc(fd);
|
||||||
|
|
||||||
if (irFunc.nestedContextCreated) {
|
if (irFunc.nestedContextCreated) {
|
||||||
|
Logger::println("already done");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
irFunc.nestedContextCreated = true;
|
irFunc.nestedContextCreated = true;
|
||||||
|
@ -338,9 +339,22 @@ static void DtoCreateNestedContextType(FuncDeclaration *fd) {
|
||||||
DtoCreateNestedContextType(parentFunc);
|
DtoCreateNestedContextType(parentFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct nested variables array
|
if (fd->closureVars.dim == 0) {
|
||||||
if (fd->closureVars.dim > 0) {
|
// No local variables of this function are captured.
|
||||||
|
if (parentFunc) {
|
||||||
|
// Propagate context arg properties if the context arg is passed on
|
||||||
|
// unmodified.
|
||||||
|
IrFunction &parentIrFunc = *getIrFunc(parentFunc);
|
||||||
|
irFunc.frameType = parentIrFunc.frameType;
|
||||||
|
irFunc.frameTypeAlignment = parentIrFunc.frameTypeAlignment;
|
||||||
|
irFunc.depth = parentIrFunc.depth;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Logger::println("has nested frame");
|
Logger::println("has nested frame");
|
||||||
|
|
||||||
|
// construct nested variables array
|
||||||
// start with adding all enclosing parent frames until a static parent is
|
// start with adding all enclosing parent frames until a static parent is
|
||||||
// reached
|
// reached
|
||||||
|
|
||||||
|
@ -428,17 +442,6 @@ static void DtoCreateNestedContextType(FuncDeclaration *fd) {
|
||||||
// Store type in IrFunction
|
// Store type in IrFunction
|
||||||
irFunc.frameType = frameType;
|
irFunc.frameType = frameType;
|
||||||
irFunc.frameTypeAlignment = builder.overallAlignment();
|
irFunc.frameTypeAlignment = builder.overallAlignment();
|
||||||
} else // no captured variables
|
|
||||||
{
|
|
||||||
if (parentFunc) {
|
|
||||||
// Propagate context arg properties if the context arg is passed on
|
|
||||||
// unmodified.
|
|
||||||
IrFunction &parentIrFunc = *getIrFunc(parentFunc);
|
|
||||||
irFunc.frameType = parentIrFunc.frameType;
|
|
||||||
irFunc.frameTypeAlignment = parentIrFunc.frameTypeAlignment;
|
|
||||||
irFunc.depth = parentIrFunc.depth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoCreateNestedContext(FuncDeclaration *fd) {
|
void DtoCreateNestedContext(FuncDeclaration *fd) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue