Move ClassDeclaration.vtblSymbol to dsymbolsem (#20956)

This commit is contained in:
Matthew Qiu 2025-03-06 03:02:40 -05:00 committed by GitHub
parent 57e7419c4d
commit 325ef115e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 24 additions and 18 deletions

View file

@ -47,6 +47,7 @@ namespace dmd
void semanticTypeInfoMembers(StructDeclaration *sd);
bool fill(StructDeclaration* sd, Loc loc, Expressions &elements, bool ctorinit);
bool isFuncHidden(ClassDeclaration* cd, FuncDeclaration* fd);
Dsymbol* vtblSymbol(ClassDeclaration *cd);
}
enum class ClassKind : uint8_t
@ -300,7 +301,6 @@ public:
// Back end
Dsymbol *vtblsym;
Dsymbol *vtblSymbol();
void accept(Visitor *v) override { v->visit(this); }
};

View file

@ -185,6 +185,12 @@ bool isFuncHidden(ClassDeclaration cd, FuncDeclaration fd)
return dmd.dsymbolsem.isFuncHidden(cd, fd);
}
Dsymbol vtblSymbol(ClassDeclaration cd)
{
import dmd.dsymbolsem;
return dmd.dsymbolsem.vtblSymbol(cd);
}
/***********************************************************
* dtemplate.d
*/

View file

@ -888,21 +888,6 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
// Back end
Dsymbol vtblsym;
final Dsymbol vtblSymbol()
{
if (!vtblsym)
{
auto vtype = Type.tvoidptr.immutableOf().sarrayOf(vtbl.length);
auto var = new VarDeclaration(loc, vtype, Identifier.idPool("__vtbl"), null, STC.immutable_ | STC.static_);
var.addMember(null, this);
var.isdataseg = 1;
var._linkage = LINK.d;
var.semanticRun = PASS.semanticdone; // no more semantic wanted
vtblsym = var;
}
return vtblsym;
}
extern (D) final bool isErrorException()
{
return errorException && (this == errorException || errorException.isBaseOf(this, null));

View file

@ -8195,3 +8195,18 @@ extern(C++) bool isFuncHidden(ClassDeclaration cd, FuncDeclaration fd)
return !fd.parent.isTemplateMixin();
}
}
Dsymbol vtblSymbol(ClassDeclaration cd)
{
if (!cd.vtblsym)
{
auto vtype = Type.tvoidptr.immutableOf().sarrayOf(cd.vtbl.length);
auto var = new VarDeclaration(cd.loc, vtype, Identifier.idPool("__vtbl"), null, STC.immutable_ | STC.static_);
var.addMember(null, cd);
var.isdataseg = 1;
var._linkage = LINK.d;
var.semanticRun = PASS.semanticdone; // no more semantic wanted
cd.vtblsym = var;
}
return cd.vtblsym;
}

View file

@ -6689,7 +6689,6 @@ public:
const char* kind() const override;
void addObjcSymbols(Array<ClassDeclaration* >* classes, Array<ClassDeclaration* >* categories) final override;
Dsymbol* vtblsym;
Dsymbol* vtblSymbol();
void accept(Visitor* v) override;
};

View file

@ -29,6 +29,7 @@ import dmd.dmdparams;
import dmd.dmodule;
import dmd.dstruct;
import dmd.dsymbol;
import dmd.dsymbolsem : vtblSymbol;
import dmd.dtemplate;
import dmd.e2ir;
import dmd.errors;

View file

@ -1342,7 +1342,7 @@ public:
}
}
(void)d->csym;
(void)d->vtblSymbol()->csym;
(void)dmd::vtblSymbol(d)->csym;
(void)d->sinit;
NewExp *ne = NewExp::create(d->loc, NULL, NULL, d->type, NULL);
ne->type = d->type;