expressionsem.d (dmd-2.095.0) | : | expressionsem.d (dmd-2.095.1) | ||
---|---|---|---|---|
skipping to change at line 5982 | skipping to change at line 5982 | |||
escapePath(ob, imod.srcfile.toChars()); | escapePath(ob, imod.srcfile.toChars()); | |||
ob.writestring(") : "); | ob.writestring(") : "); | |||
if (global.params.moduleDepsFile) | if (global.params.moduleDepsFile) | |||
ob.writestring("string : "); | ob.writestring("string : "); | |||
ob.write(se.peekString()); | ob.write(se.peekString()); | |||
ob.writestring(" ("); | ob.writestring(" ("); | |||
escapePath(ob, name); | escapePath(ob, name); | |||
ob.writestring(")"); | ob.writestring(")"); | |||
ob.writenl(); | ob.writenl(); | |||
} | } | |||
if (global.params.makeDeps && global.params.oneobj) | if (global.params.emitMakeDeps) | |||
{ | { | |||
OutBuffer* ob = global.params.makeDeps; | global.params.makeDeps.push(name); | |||
ob.writestringln(" \\"); | ||||
ob.writestring(" "); | ||||
escapePath(ob, toPosixPath(name)); | ||||
} | } | |||
{ | { | |||
auto readResult = File.read(name); | auto readResult = File.read(name); | |||
if (!readResult.success) | if (!readResult.success) | |||
{ | { | |||
e.error("cannot read file `%s`", name); | e.error("cannot read file `%s`", name); | |||
return setError(); | return setError(); | |||
} | } | |||
else | else | |||
skipping to change at line 6058 | skipping to change at line 6055 | |||
{ | { | |||
auto die = op.isDotIdExp(); | auto die = op.isDotIdExp(); | |||
if (die && die.ident == Id.ptr) | if (die && die.ident == Id.ptr) | |||
die.noderef = true; | die.noderef = true; | |||
} | } | |||
op = op.expressionSemantic(sc); | op = op.expressionSemantic(sc); | |||
op = resolveProperties(sc, op); | op = resolveProperties(sc, op); | |||
if (op.hasSideEffect) | if (op.hasSideEffect) | |||
{ | { | |||
// https://issues.dlang.org/show_bug.cgi?id=21590 | ||||
// Don't create unnecessary temporaries and detect `assert(a | ||||
= b)` | ||||
if (op.isAssignExp() || op.isBinAssignExp()) | ||||
{ | ||||
auto left = (cast(BinExp) op).e1; | ||||
// Find leftmost expression to handle other rewrites, | ||||
// e.g. --(++a) => a += 1 -= 1 | ||||
while (left.isAssignExp() || left.isBinAssignExp()) | ||||
left = (cast(BinExp) left).e1; | ||||
// Only use the assignee if it's a variable and skip | ||||
// other lvalues (e.g. ref's returned by functions) | ||||
if (left.isVarExp()) | ||||
return left; | ||||
// Sanity check that `op` can be converted to boolean | ||||
op.toBoolean(sc); | ||||
} | ||||
const stc = op.isLvalue() ? STC.ref_ : 0; | const stc = op.isLvalue() ? STC.ref_ : 0; | |||
auto tmp = copyToTemp(stc, "__assertOp", op); | auto tmp = copyToTemp(stc, "__assertOp", op); | |||
tmp.dsymbolSemantic(sc); | tmp.dsymbolSemantic(sc); | |||
auto decl = new DeclarationExp(op.loc, tmp); | auto decl = new DeclarationExp(op.loc, tmp); | |||
temporariesPrefix = Expression.combine(temporariesPrefix, de cl); | temporariesPrefix = Expression.combine(temporariesPrefix, de cl); | |||
op = new VarExp(op.loc, tmp); | op = new VarExp(op.loc, tmp); | |||
op = op.expressionSemantic(sc); | op = op.expressionSemantic(sc); | |||
} | } | |||
skipping to change at line 8761 | skipping to change at line 8778 | |||
return setError(); | return setError(); | |||
Expression e0; | Expression e0; | |||
Expression.extractLast(e2x, e0); | Expression.extractLast(e2x, e0); | |||
auto e = Expression.combine(e0, ae, cx); | auto e = Expression.combine(e0, ae, cx); | |||
e = e.expressionSemantic(sc); | e = e.expressionSemantic(sc); | |||
result = e; | result = e; | |||
return; | return; | |||
} | } | |||
// https://issues.dlang.org/show_bug.cgi?id=21586 | ||||
// Rewrite CondExp or e1 will miss direct construction, e.g. | ||||
// e1 = a ? S(1) : ...; -> AST: e1 = a ? (S(0)).this(1) : .. | ||||
.; | ||||
// a temporary created and an extra destructor call. | ||||
// AST will be rewritten to: | ||||
// a ? e1 = 0, e1.this(1) : ...; -> blitting plus constructi | ||||
on | ||||
if (e2x.op == TOK.question) | ||||
{ | ||||
/* Rewrite as: | ||||
* a ? e1 = b : e1 = c; | ||||
*/ | ||||
CondExp econd = cast(CondExp)e2x; | ||||
Expression ea1 = new ConstructExp(econd.e1.loc, e1x, eco | ||||
nd.e1); | ||||
Expression ea2 = new ConstructExp(econd.e2.loc, e1x, eco | ||||
nd.e2); | ||||
Expression e = new CondExp(exp.loc, econd.econd, ea1, ea | ||||
2); | ||||
result = e.expressionSemantic(sc); | ||||
return; | ||||
} | ||||
if (sd.postblit || sd.hasCopyCtor) | if (sd.postblit || sd.hasCopyCtor) | |||
{ | { | |||
/* We have a copy constructor for this | /* We have a copy constructor for this | |||
*/ | */ | |||
if (e2x.op == TOK.question) | ||||
{ | ||||
/* Rewrite as: | ||||
* a ? e1 = b : e1 = c; | ||||
*/ | ||||
CondExp econd = cast(CondExp)e2x; | ||||
Expression ea1 = new ConstructExp(econd.e1.loc, e1x, | ||||
econd.e1); | ||||
Expression ea2 = new ConstructExp(econd.e1.loc, e1x, | ||||
econd.e2); | ||||
Expression e = new CondExp(exp.loc, econd.econd, ea1 | ||||
, ea2); | ||||
result = e.expressionSemantic(sc); | ||||
return; | ||||
} | ||||
if (e2x.isLvalue()) | if (e2x.isLvalue()) | |||
{ | { | |||
if (sd.hasCopyCtor) | if (sd.hasCopyCtor) | |||
{ | { | |||
/* Rewrite as: | /* Rewrite as: | |||
* e1 = init, e1.copyCtor(e2); | * e1 = init, e1.copyCtor(e2); | |||
*/ | */ | |||
Expression einit = new BlitExp(exp.loc, exp.e1, getInitExp(sd, exp.loc, sc, t1)); | Expression einit = new BlitExp(exp.loc, exp.e1, getInitExp(sd, exp.loc, sc, t1)); | |||
einit.type = e1x.type; | einit.type = e1x.type; | |||
End of changes. 5 change blocks. | ||||
20 lines changed or deleted | 46 lines changed or added |