mirror of
https://github.com/verilator/verilator.git
synced 2025-01-15 11:04:14 +00:00
Internals: Misc prep work for 'with' support.
This commit is contained in:
parent
e6b0479b80
commit
85b05366bc
@ -3071,19 +3071,24 @@ public:
|
|||||||
void cname(const string& cname) { m_cname = cname; }
|
void cname(const string& cname) { m_cname = cname; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class AstWith : public AstNodeStmt {
|
class AstWithParse : public AstNodeStmt {
|
||||||
|
// In early parse, FUNC(index) WITH equation-using-index
|
||||||
|
// Replaced with AstWith
|
||||||
|
// Parents: math|stmt
|
||||||
|
// Children: funcref, math
|
||||||
public:
|
public:
|
||||||
AstWith(FileLine* fl, bool stmt, AstNode* funcrefp, AstNode* argsp)
|
AstWithParse(FileLine* fl, bool stmt, AstNode* funcrefp, AstNode* exprp)
|
||||||
: ASTGEN_SUPER(fl) {
|
: ASTGEN_SUPER(fl) {
|
||||||
statement(stmt);
|
statement(stmt);
|
||||||
setOp1p(funcrefp);
|
setOp1p(funcrefp);
|
||||||
addNOp2p(argsp);
|
addNOp2p(exprp);
|
||||||
}
|
}
|
||||||
ASTNODE_NODE_FUNCS(With)
|
ASTNODE_NODE_FUNCS(WithParse)
|
||||||
virtual V3Hash sameHash() const override { return V3Hash(); }
|
virtual V3Hash sameHash() const override { return V3Hash(); }
|
||||||
virtual bool same(const AstNode* samep) const override { return true; }
|
virtual bool same(const AstNode* samep) const override { return true; }
|
||||||
//
|
//
|
||||||
AstNode* funcrefp() const { return op1p(); }
|
AstNode* funcrefp() const { return op1p(); }
|
||||||
|
AstNode* exprp() const { return op2p(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
|
@ -2400,7 +2400,7 @@ private:
|
|||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void visit(AstWith* nodep) override {
|
virtual void visit(AstWithParse* nodep) override {
|
||||||
nodep->v3warn(E_UNSUPPORTED, "Unsupported: with statements");
|
nodep->v3warn(E_UNSUPPORTED, "Unsupported: with statements");
|
||||||
nodep->replaceWith(nodep->funcrefp()->unlinkFrBack());
|
nodep->replaceWith(nodep->funcrefp()->unlinkFrBack());
|
||||||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||||
|
@ -3496,9 +3496,9 @@ task_subroutine_callNoMethod<nodep>: // function_subroutine_callNoMethod (as tas
|
|||||||
// // IEEE: tf_call
|
// // IEEE: tf_call
|
||||||
taskRef { $$ = $1; }
|
taskRef { $$ = $1; }
|
||||||
// // funcref below not task ref to avoid conflict, must later handle either
|
// // funcref below not task ref to avoid conflict, must later handle either
|
||||||
| funcRef yWITH__PAREN '(' expr ')' { $$ = new AstWith($2, true, $1, $4); }
|
| funcRef yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, true, $1, $4); }
|
||||||
// // can call as method and yWITH without parenthesis
|
// // can call as method and yWITH without parenthesis
|
||||||
| id yWITH__PAREN '(' expr ')' { $$ = new AstWith($2, true, new AstFuncRef($<fl>1, *$1, nullptr), $4); }
|
| id yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, true, new AstFuncRef($<fl>1, *$1, nullptr), $4); }
|
||||||
| system_t_call { $$ = $1; }
|
| system_t_call { $$ = $1; }
|
||||||
// // IEEE: method_call requires a "." so is in expr
|
// // IEEE: method_call requires a "." so is in expr
|
||||||
// // IEEE: ['std::'] not needed, as normal std package resolution will find it
|
// // IEEE: ['std::'] not needed, as normal std package resolution will find it
|
||||||
@ -3511,9 +3511,9 @@ task_subroutine_callNoMethod<nodep>: // function_subroutine_callNoMethod (as tas
|
|||||||
function_subroutine_callNoMethod<nodep>: // IEEE: function_subroutine_call (as function)
|
function_subroutine_callNoMethod<nodep>: // IEEE: function_subroutine_call (as function)
|
||||||
// // IEEE: tf_call
|
// // IEEE: tf_call
|
||||||
funcRef { $$ = $1; }
|
funcRef { $$ = $1; }
|
||||||
| funcRef yWITH__PAREN '(' expr ')' { $$ = new AstWith($2, false, $1, $4); }
|
| funcRef yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, false, $1, $4); }
|
||||||
// // can call as method and yWITH without parenthesis
|
// // can call as method and yWITH without parenthesis
|
||||||
| id yWITH__PAREN '(' expr ')' { $$ = new AstWith($2, false, new AstFuncRef($<fl>1, *$1, nullptr), $4); }
|
| id yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, false, new AstFuncRef($<fl>1, *$1, nullptr), $4); }
|
||||||
| system_f_call { $$ = $1; }
|
| system_f_call { $$ = $1; }
|
||||||
// // IEEE: method_call requires a "." so is in expr
|
// // IEEE: method_call requires a "." so is in expr
|
||||||
// // IEEE: ['std::'] not needed, as normal std package resolution will find it
|
// // IEEE: ['std::'] not needed, as normal std package resolution will find it
|
||||||
@ -3521,7 +3521,7 @@ function_subroutine_callNoMethod<nodep>: // IEEE: function_subroutine_call (as f
|
|||||||
// // We implement randomize as a normal funcRef, since randomize isn't a keyword
|
// // We implement randomize as a normal funcRef, since randomize isn't a keyword
|
||||||
// // Note yNULL is already part of expressions, so they come for free
|
// // Note yNULL is already part of expressions, so they come for free
|
||||||
| funcRef yWITH__CUR constraint_block { $$ = $1; BBUNSUP($2, "Unsupported: randomize() 'with' constraint"); }
|
| funcRef yWITH__CUR constraint_block { $$ = $1; BBUNSUP($2, "Unsupported: randomize() 'with' constraint"); }
|
||||||
| funcRef yWITH__CUR '{' '}' { $$ = new AstWith($2, false, $1, nullptr); }
|
| funcRef yWITH__CUR '{' '}' { $$ = new AstWithParse($2, false, $1, nullptr); }
|
||||||
;
|
;
|
||||||
|
|
||||||
system_t_call<nodep>: // IEEE: system_tf_call (as task)
|
system_t_call<nodep>: // IEEE: system_tf_call (as task)
|
||||||
@ -4028,9 +4028,9 @@ array_methodNoRoot<ftaskrefp>:
|
|||||||
array_methodWith<nodep>:
|
array_methodWith<nodep>:
|
||||||
array_methodNoRoot { $$ = $1; }
|
array_methodNoRoot { $$ = $1; }
|
||||||
| array_methodNoRoot parenE yWITH__PAREN '(' expr ')'
|
| array_methodNoRoot parenE yWITH__PAREN '(' expr ')'
|
||||||
{ $$ = new AstWith($3, false, $1, $5); }
|
{ $$ = new AstWithParse($3, false, $1, $5); }
|
||||||
| array_methodNoRoot '(' expr ')' yWITH__PAREN '(' expr ')'
|
| array_methodNoRoot '(' expr ')' yWITH__PAREN '(' expr ')'
|
||||||
{ $$ = new AstWith($5, false, $1, $7); $1->addPinsp($3); }
|
{ $$ = new AstWithParse($5, false, $1, $7); $1->addPinsp($3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
dpi_import_export<nodep>: // ==IEEE: dpi_import_export
|
dpi_import_export<nodep>: // ==IEEE: dpi_import_export
|
||||||
|
Loading…
Reference in New Issue
Block a user