refactor variable declarations

This commit is contained in:
0-v-0 2024-07-21 10:43:40 +08:00
parent be1242bea8
commit e4fa47e2af
5 changed files with 10 additions and 13 deletions

View file

@ -121,7 +121,6 @@ Expression fieldLookup(Expression e, Scope* sc, Identifier id, bool arrow)
if (e.isErrorExp())
return e;
Dsymbol s;
auto t = e.type;
if (t.isTypePointer())
{
@ -131,6 +130,7 @@ Expression fieldLookup(Expression e, Scope* sc, Identifier id, bool arrow)
error(e.loc, "since `%s` is a pointer, use `%s->%s` instead of `%s.%s`", pe, pe, id.toChars(), pe, id.toChars());
e = new PtrExp(e.loc, e);
}
Dsymbol s;
if (auto ts = t.isTypeStruct())
s = ts.sym.search(e.loc, id, 0);
if (!s)

View file

@ -267,13 +267,11 @@ ulong ld_readull(const longdouble_soft* pthis)
// so we roll our own conversion (it also allows the usual C wrap-around
// instead of the "invalid value" created by the FPU)
int expo = pthis.exponent - 0x3fff;
ulong u;
if(expo < 0 || expo > 127)
return 0;
if(expo < 64)
u = pthis.mantissa >> (63 - expo);
else
u = pthis.mantissa << (expo - 63);
ulong u = expo < 64 ?
pthis.mantissa << (63 - expo) :
pthis.mantissa >> (expo - 63);
if(pthis.sign)
u = ~u + 1;
return u;

View file

@ -154,7 +154,7 @@ void templateDeclarationSemantic(Scope* sc, TemplateDeclaration tempdecl)
/* Calculate TemplateParameter.dependent
*/
TemplateParameters tparams = TemplateParameters(1);
auto tparams = TemplateParameters(1);
for (size_t i = 0; i < tempdecl.parameters.length; i++)
{
TemplateParameter tp = (*tempdecl.parameters)[i];
@ -336,8 +336,7 @@ MATCH matchWithInstance(Scope* sc, TemplateDeclaration td, TemplateInstance ti,
ti.parent = td.parent;
// Similar to doHeaderInstantiation
FuncDeclaration fd = td.onemember ? td.onemember.isFuncDeclaration() : null;
if (fd)
if (FuncDeclaration fd = td.onemember ? td.onemember.isFuncDeclaration() : null)
{
TypeFunction tf = fd.type.isTypeFunction().syntaxCopy();

View file

@ -146,12 +146,12 @@ enum CV8_NAMELENMAX = 0xffff; // length record is 16-bit only
uint cv4_Denum(EnumDeclaration e)
{
//dbg_printf("cv4_Denum(%s)\n", e.toChars());
const uint property = (!e.members || !e.memtype || !e.memtype.isintegral())
const uint property = !e.members || !e.memtype || !e.memtype.isintegral()
? 0x80 // enum is forward referenced or non-integer
: 0;
// Compute the number of fields, and the length of the fieldlist record
CvFieldList mc = CvFieldList(0, 0);
auto mc = CvFieldList(0, 0);
if (!property)
{
for (size_t i = 0; i < e.members.length; i++)

View file

@ -346,7 +346,7 @@ class Node
void expandNonScopeSimple(Scope sc, size_t i, size_t j)
{
Node[1] narray;
Node[1] narray = void;
for(size_t m = i; m < j; )
{
Node n = members[m];
@ -522,7 +522,7 @@ class Node
////////////////////////////////////////////////////////////
version(COUNT) {} else // invariant does not work with destructor
invariant()
invariant
{
if(!__ctfe)
foreach(m; members)