Internals: Assert proper AstArgs in place.

This commit is contained in:
Wilson Snyder 2019-11-17 08:43:04 -05:00
parent 2ff22d9050
commit 09ca4ce791
2 changed files with 13 additions and 7 deletions

View File

@ -1661,7 +1661,10 @@ private:
}
void methodOkArguments(AstMethodSel* nodep, int minArg, int maxArg) {
int narg = 0;
for (AstNode* argp = nodep->pinsp(); argp; argp = argp->nextp()) ++narg;
for (AstNode* argp = nodep->pinsp(); argp; argp = argp->nextp()) {
++narg;
UASSERT_OBJ(VN_IS(argp, Arg), nodep, "Method arg without Arg type");
}
bool ok = (narg >= minArg) && (narg <= maxArg);
if (!ok) {
nodep->v3error("The "<<narg<<" arguments passed to ."<<nodep->prettyName()
@ -3903,16 +3906,18 @@ private:
//----------------------------------------------------------------------
// METHODS - data types
AstNodeDType* moveChildDTypeEdit(AstNode* nodep) {
// DTypes at parse time get added as a childDType to some node types such as AstVars.
// We move them to global scope, so removing/changing a variable won't lose the dtype.
AstNodeDType* dtnodep = nodep->getChildDTypep();
UASSERT_OBJ(dtnodep, nodep, "Caller should check for NULL before calling moveChild");
UINFO(9,"moveChildDTypeEdit "<<dtnodep<<endl);
AstNodeDType* moveDTypeEdit(AstNode* nodep, AstNodeDType* dtnodep) {
// DTypes at parse time get added as a e.g. childDType to some node types such as AstVars.
// Move type to global scope, so removing/changing a variable won't lose the dtype.
UASSERT_OBJ(dtnodep, nodep, "Caller should check for NULL before calling moveDTypeEdit");
UINFO(9,"moveDTypeEdit "<<dtnodep<<endl);
dtnodep->unlinkFrBack(); // Make non-child
v3Global.rootp()->typeTablep()->addTypesp(dtnodep);
return dtnodep;
}
AstNodeDType* moveChildDTypeEdit(AstNode* nodep) {
return moveDTypeEdit(nodep, nodep->getChildDTypep());
}
AstNodeDType* iterateEditDTypep(AstNode* parentp, AstNodeDType* nodep) {
// Iterate into a data type to resolve that type. This process
// may eventually create a new data type, but not today

View File

@ -2732,6 +2732,7 @@ patternKey<nodep>: // IEEE: merge structure_pattern_key, array_pattern_key, ass
yaINTNUM { $$ = new AstConst($<fl>1,*$1); }
| yaFLOATNUM { $$ = new AstConst($<fl>1,AstConst::RealDouble(),$1); }
| yaID__ETC { $$ = new AstText($<fl>1,*$1); }
| strAsInt { $$ = $1; }
;
assignment_pattern<patternp>: // ==IEEE: assignment_pattern