mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-14 15:16:07 +03:00
Refactoring: Replace Expression::op check followed by static cast to Expression::is<ExpressionType> (#3141)
This may negatively impact performance, as the (final, i.e., non-virtual) Expression::is... family is implemented in D and not available inline in the C++ headers.
This commit is contained in:
parent
ec1c37a5a4
commit
26673c174f
10 changed files with 112 additions and 132 deletions
|
@ -172,10 +172,11 @@ struct DComputeSemanticAnalyser : public StoppableVisitor {
|
|||
stop = true;
|
||||
}
|
||||
void visit(SwitchStatement *e) override {
|
||||
if (e->condition->op == TOKcall &&
|
||||
static_cast<CallExp *>(e->condition)->f->ident == Id::__switch) {
|
||||
e->error("cannot `switch` on strings in `@compute` code");
|
||||
stop = true;
|
||||
if (auto ce = e->condition->isCallExp()) {
|
||||
if (ce->f->ident == Id::__switch) {
|
||||
e->error("cannot `switch` on strings in `@compute` code");
|
||||
stop = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,8 +203,7 @@ struct DComputeSemanticAnalyser : public StoppableVisitor {
|
|||
// for the host and is therefore allowed to call non @compute functions.
|
||||
// Thus, the if-statement body's code should not be checked for
|
||||
// @compute semantics and the recursive visitor should stop here.
|
||||
else if (stmt->condition->op == TOKcall) {
|
||||
auto ce = (CallExp *)stmt->condition;
|
||||
if (auto ce = stmt->condition->isCallExp()) {
|
||||
if (ce->f && ce->f->ident == Id::dcReflect) {
|
||||
auto arg1 = (DComputeTarget::ID)(*ce->arguments)[0]->toInteger();
|
||||
if (arg1 == DComputeTarget::Host)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue