mirror of
https://github.com/dlang/dmd.git
synced 2025-04-28 22:20:37 +03:00
refactor variable declarations
This commit is contained in:
parent
be1242bea8
commit
e4fa47e2af
5 changed files with 10 additions and 13 deletions
|
@ -121,7 +121,6 @@ Expression fieldLookup(Expression e, Scope* sc, Identifier id, bool arrow)
|
||||||
if (e.isErrorExp())
|
if (e.isErrorExp())
|
||||||
return e;
|
return e;
|
||||||
|
|
||||||
Dsymbol s;
|
|
||||||
auto t = e.type;
|
auto t = e.type;
|
||||||
if (t.isTypePointer())
|
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());
|
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);
|
e = new PtrExp(e.loc, e);
|
||||||
}
|
}
|
||||||
|
Dsymbol s;
|
||||||
if (auto ts = t.isTypeStruct())
|
if (auto ts = t.isTypeStruct())
|
||||||
s = ts.sym.search(e.loc, id, 0);
|
s = ts.sym.search(e.loc, id, 0);
|
||||||
if (!s)
|
if (!s)
|
||||||
|
|
|
@ -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
|
// so we roll our own conversion (it also allows the usual C wrap-around
|
||||||
// instead of the "invalid value" created by the FPU)
|
// instead of the "invalid value" created by the FPU)
|
||||||
int expo = pthis.exponent - 0x3fff;
|
int expo = pthis.exponent - 0x3fff;
|
||||||
ulong u;
|
|
||||||
if(expo < 0 || expo > 127)
|
if(expo < 0 || expo > 127)
|
||||||
return 0;
|
return 0;
|
||||||
if(expo < 64)
|
ulong u = expo < 64 ?
|
||||||
u = pthis.mantissa >> (63 - expo);
|
pthis.mantissa << (63 - expo) :
|
||||||
else
|
pthis.mantissa >> (expo - 63);
|
||||||
u = pthis.mantissa << (expo - 63);
|
|
||||||
if(pthis.sign)
|
if(pthis.sign)
|
||||||
u = ~u + 1;
|
u = ~u + 1;
|
||||||
return u;
|
return u;
|
||||||
|
|
|
@ -154,7 +154,7 @@ void templateDeclarationSemantic(Scope* sc, TemplateDeclaration tempdecl)
|
||||||
|
|
||||||
/* Calculate TemplateParameter.dependent
|
/* Calculate TemplateParameter.dependent
|
||||||
*/
|
*/
|
||||||
TemplateParameters tparams = TemplateParameters(1);
|
auto tparams = TemplateParameters(1);
|
||||||
for (size_t i = 0; i < tempdecl.parameters.length; i++)
|
for (size_t i = 0; i < tempdecl.parameters.length; i++)
|
||||||
{
|
{
|
||||||
TemplateParameter tp = (*tempdecl.parameters)[i];
|
TemplateParameter tp = (*tempdecl.parameters)[i];
|
||||||
|
@ -336,8 +336,7 @@ MATCH matchWithInstance(Scope* sc, TemplateDeclaration td, TemplateInstance ti,
|
||||||
ti.parent = td.parent;
|
ti.parent = td.parent;
|
||||||
|
|
||||||
// Similar to doHeaderInstantiation
|
// Similar to doHeaderInstantiation
|
||||||
FuncDeclaration fd = td.onemember ? td.onemember.isFuncDeclaration() : null;
|
if (FuncDeclaration fd = td.onemember ? td.onemember.isFuncDeclaration() : null)
|
||||||
if (fd)
|
|
||||||
{
|
{
|
||||||
TypeFunction tf = fd.type.isTypeFunction().syntaxCopy();
|
TypeFunction tf = fd.type.isTypeFunction().syntaxCopy();
|
||||||
|
|
||||||
|
|
|
@ -146,12 +146,12 @@ enum CV8_NAMELENMAX = 0xffff; // length record is 16-bit only
|
||||||
uint cv4_Denum(EnumDeclaration e)
|
uint cv4_Denum(EnumDeclaration e)
|
||||||
{
|
{
|
||||||
//dbg_printf("cv4_Denum(%s)\n", e.toChars());
|
//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
|
? 0x80 // enum is forward referenced or non-integer
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
// Compute the number of fields, and the length of the fieldlist record
|
// Compute the number of fields, and the length of the fieldlist record
|
||||||
CvFieldList mc = CvFieldList(0, 0);
|
auto mc = CvFieldList(0, 0);
|
||||||
if (!property)
|
if (!property)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < e.members.length; i++)
|
for (size_t i = 0; i < e.members.length; i++)
|
||||||
|
|
|
@ -346,7 +346,7 @@ class Node
|
||||||
|
|
||||||
void expandNonScopeSimple(Scope sc, size_t i, size_t j)
|
void expandNonScopeSimple(Scope sc, size_t i, size_t j)
|
||||||
{
|
{
|
||||||
Node[1] narray;
|
Node[1] narray = void;
|
||||||
for(size_t m = i; m < j; )
|
for(size_t m = i; m < j; )
|
||||||
{
|
{
|
||||||
Node n = members[m];
|
Node n = members[m];
|
||||||
|
@ -522,7 +522,7 @@ class Node
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
version(COUNT) {} else // invariant does not work with destructor
|
version(COUNT) {} else // invariant does not work with destructor
|
||||||
invariant()
|
invariant
|
||||||
{
|
{
|
||||||
if(!__ctfe)
|
if(!__ctfe)
|
||||||
foreach(m; members)
|
foreach(m; members)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue