Internal cast preparatory cleanups.

This commit is contained in:
Wilson Snyder 2020-11-29 18:26:06 -05:00
parent 0818d88113
commit d21b4e3fc7
7 changed files with 18 additions and 12 deletions

View File

@ -1175,6 +1175,7 @@ bool AstClass::isClassExtendedFrom(const AstClass* refClassp, const AstClass* ba
// TAIL RECURSIVE
if (!refClassp || !baseClassp) return false;
if (refClassp == baseClassp) return true;
if (!refClassp->extendsp()) return false;
return isClassExtendedFrom(refClassp->extendsp()->classp(), baseClassp);
}
void AstClass::dump(std::ostream& str) const {

View File

@ -5997,12 +5997,17 @@ public:
class AstCast final : public AstNode {
// Cast to appropriate data type - note lhsp is value, to match AstTypedef, AstCCast, etc
public:
AstCast(FileLine* fl, AstNode* lhsp, AstNodeDType* dtp)
AstCast(FileLine* fl, AstNode* lhsp, VFlagChildDType, AstNodeDType* dtp)
: ASTGEN_SUPER(fl) {
setOp1p(lhsp);
setOp2p(dtp);
dtypeFrom(dtp);
}
AstCast(FileLine* fl, AstNode* lhsp, AstNodeDType* dtp)
: ASTGEN_SUPER(fl) {
setOp1p(lhsp);
dtypeFrom(dtp);
}
ASTNODE_NODE_FUNCS(Cast)
virtual bool hasDType() const override { return true; }
virtual string emitVerilog() { return "((%d)'(%l))"; }

View File

@ -4255,9 +4255,9 @@ expr<nodep>: // IEEE: part of expression/constant_expression/primary
//
// // IEEE: cast/constant_cast
// // expanded from casting_type
| simple_type yP_TICK '(' expr ')' { $$ = new AstCast($1->fileline(), $4, $1); }
| simple_type yP_TICK '(' expr ')' { $$ = new AstCast($1->fileline(), $4, VFlagChildDType{}, $1); }
| yTYPE '(' exprOrDataType ')' yP_TICK '(' expr ')'
{ $$ = new AstCast($1, $7, new AstRefDType($1, AstRefDType::FlagTypeOfExpr(), $3)); }
{ $$ = new AstCast($1, $7, VFlagChildDType(), new AstRefDType($1, AstRefDType::FlagTypeOfExpr(), $3)); }
| ySIGNED yP_TICK '(' expr ')' { $$ = new AstSigned($1, $4); }
| yUNSIGNED yP_TICK '(' expr ')' { $$ = new AstUnsigned($1, $4); }
| ySTRING yP_TICK '(' expr ')' { $$ = new AstCvtPackString($1, $4); }

View File

@ -1,9 +0,0 @@
%Error-UNSUPPORTED: t/t_castdyn_bad.v:20:11: Unsupported: $cast. Suggest try static cast.
: ... In instance t
20 | i = $cast(c, b);
| ^~~~~
%Error-UNSUPPORTED: t/t_castdyn_bad.v:23:7: Unsupported: $cast. Suggest try static cast.
: ... In instance t
23 | $cast(c, b);
| ^~~~~
%Error: Exiting due to

View File

@ -0,0 +1,9 @@
%Error-UNSUPPORTED: t/t_castdyn_run_bad.v:20:11: Unsupported: $cast. Suggest try static cast.
: ... In instance t
20 | i = $cast(c, b);
| ^~~~~
%Error-UNSUPPORTED: t/t_castdyn_run_bad.v:23:7: Unsupported: $cast. Suggest try static cast.
: ... In instance t
23 | $cast(c, b);
| ^~~~~
%Error: Exiting due to