forked from github/verilator
Avoid dynamic_cast for classes with no children, bug1021.
Signed-off-by: Wilson Snyder <wsnyder@wsnyder.org>
This commit is contained in:
parent
b738d1960a
commit
340cc02171
5
Changes
5
Changes
@ -3,6 +3,11 @@ Revision history for Verilator
|
||||
The contributors that suggested a given feature are shown in []. [by ...]
|
||||
indicates the contributor was also the author of the fix; Thanks!
|
||||
|
||||
* Verilator 3.881 devel
|
||||
|
||||
**** Internal Verilation-time performance enhancements, bug1021. [Johan Bjork]
|
||||
|
||||
|
||||
* Verilator 3.880 2015-12-19
|
||||
|
||||
*** Support display %u, %v, %p, %z, bug989. [Johan Bjork]
|
||||
|
11
src/astgen
11
src/astgen
@ -248,8 +248,15 @@ sub write_impl {
|
||||
my $fh = open_file(@_);
|
||||
foreach my $type (sort (keys %Classes)) {
|
||||
next if $type eq "Node"; # Special, just a return (this);
|
||||
printf $fh "inline Ast%-16s AstNode::cast${type}() { return (dynamic_cast<Ast${type}*>(this)); }\n"
|
||||
,$type."*";
|
||||
# For performance, prefer static_cast where we can
|
||||
if (children_of($type)) {
|
||||
printf $fh "inline Ast%-16s AstNode::cast${type}() { return (dynamic_cast<Ast${type}*>(this)); }\n"
|
||||
,$type."*";
|
||||
} else {
|
||||
my $ucType = uc $type;
|
||||
printf $fh "inline Ast%-16s AstNode::cast${type}() { return (this && this->type() == AstType::at${ucType}) ? static_cast<Ast${type}*>(this) : NULL; }\n"
|
||||
,$type."*";
|
||||
}
|
||||
}
|
||||
$fh->close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user