本文整理汇总了C++中AstNode类的典型用法代码示例。如果您正苦于以下问题:C++ AstNode类的具体用法?C++ AstNode怎么用?C++ AstNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AstNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nafgCreateRecurse
AstNode* nafgCreateRecurse(V3GraphVertex* vertexp, uint32_t generation) {
// Forewards follow user() marked previously and build tree
AstNode* nodep = NULL;
// OR across all edges found at this level
//UINFO(9," nafgEnter: v "<<(void*)(vertexp)<<" "<<vertexp->name()<<endl);
for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) {
if (edgep->user() == generation) {
GaterEdge* cedgep = static_cast<GaterEdge*>(edgep);
AstNode* eqnp = NULL;
//UINFO(9," nafgFollow: "<<(void*)(edgep)<<" "<<edgep->name()<<endl);
if (dynamic_cast<GaterHeadVertex*>(edgep->fromp())) {
// Just OR in all lower terms
eqnp = nafgCreateRecurse(edgep->top(), generation);
} else if (GaterIfVertex* cVxp = dynamic_cast<GaterIfVertex*>(edgep->fromp())) {
// Edges from IFs represent a real IF branch in the equation tree
//UINFO(9," ifver "<<(void*)(edgep)<<" cc"<<edgep->dotColor()<<endl);
eqnp = cVxp->nodep()->condp()->cloneTree(true);
if (eqnp && cedgep->ifelseFalse()) {
eqnp = new AstNot(eqnp->fileline(),eqnp);
}
// We need to AND this term onto whatever was found below it
AstNode* belowp = nafgCreateRecurse(edgep->top(), generation);
if (belowp) eqnp = new AstAnd(eqnp->fileline(),eqnp,belowp);
}
// Top level we could choose to make multiple gaters, or ORs under the gater
// Right now we'll put OR lower down and let other optimizations deal
if (nodep) nodep = new AstOr(eqnp->fileline(),nodep,eqnp);
else nodep = eqnp;
//if (debug()>=9) nodep->dumpTree(cout," followExpr: ");
}
}
//UINFO(9," nafgExit: "<<(void*)(vertexp)<<" "<<vertexp->name()<<endl);
return nodep;
}
示例2: visitBinaryOpNode
void TypeInferenceVisitor::visitBinaryOpNode(BinaryOpNode* node) {
AstNode* left = node->left();
AstNode* right = node->right();
left->visit(this);
right->visit(this);
_types[node] = maxType(_types[left], _types[right]);
}
示例3: TopicDescriptionImpl
MultiTopicImpl::MultiTopicImpl(const char* name,
const char* type_name, const char* subscription_expression,
const DDS::StringSeq& expression_parameters,
DomainParticipantImpl* participant)
: TopicDescriptionImpl(name, type_name,
findTypeSupport(participant, type_name),
participant)
, subscription_expression_(subscription_expression)
, expression_parameters_(expression_parameters)
, filter_eval_(NULL)
{
const char* out = subscription_expression
+ std::strlen(subscription_expression);
yard::SimpleTextParser parser(subscription_expression, out);
if (!parser.Parse<TopicExpressionGrammar::TopicCompleteInput>()) {
reportErrors(parser, subscription_expression);
}
for (AstNode* iter = parser.GetAstRoot()->GetFirstChild(); iter;
iter = iter->GetSibling()) {
if (iter->TypeMatches<TopicExpressionGrammar::SubjectFieldSpec>()) {
AstNode* fieldName = iter->GetFirstChild();
aggregation_.push_back(SubjectFieldSpec(toString(fieldName),
toString(fieldName->GetSibling())));
} else if (iter->TypeMatches<TopicExpressionGrammar::TopicName>()) {
selection_.push_back(toString(iter));
} else {
filter_eval_ = new FilterEvaluator(iter);
}
}
}
示例4: createEnableVar
AstVar* createEnableVar(AstNode* outp, AstVarRef* outrefp, AstNode* enrhsp, int width, string suffix="") {
// this function creates an __en Var that corresponds to
// the outp and outrefp and creates an assignw to enrhsp
AstVar* enp = new AstVar (outrefp->varp()->fileline(),
AstVarType::MODULETEMP,
outrefp->name() + "__en" + suffix + cvtToStr(m_unique++),
AstLogicPacked(), width);
enp->varType2Out();
if (enp->width() != enrhsp->width()) {
if (enrhsp->width1()) { // it seems from my futzing that the linter guarantees this condition
enrhsp = new AstReplicate(enrhsp->fileline(), enrhsp,
new AstConst(enrhsp->fileline(), V3Number(enrhsp->fileline(), 32, enp->width())));
enrhsp->width(enp->width(), enp->width()); //minwidth==width
} else {
enrhsp->v3error("Don't know how to deal with selection logic wider than 1 bit");
}
}
AstNode* newassp = new AstAssignW (enp->fileline(),
new AstVarRef (enp->fileline(), enp, true),
enrhsp);
if (debug()>=9) enp->dumpTreeAndNext(cout,"- cev-out: ");
if (debug()>=9) newassp->dumpTreeAndNext(cout,"- cev-out: ");
m_modp->addStmtp(enp);
m_modp->addStmtp(newassp);
outrefp->user1p(enp); // put __en signal into varref for later usage
outrefp->varp()->user1p(enp); // put __en signal into var as well in the event this is a single lhs driver and this needs passed up one level
return enp;
}
示例5: iteratorNodep
void V3Hashed::erase(iterator it) {
AstNode* nodep = iteratorNodep(it);
UINFO(8," erase "<<nodep<<endl);
if (!nodep->user4p()) nodep->v3fatalSrc("Called removeNode on non-hashed node");
m_hashMmap.erase(it);
nodep->user4p(NULL); // So we don't allow removeNode again
}
示例6: newSubNeg
AstNode* newSubNeg(AstNode* lhsp, vlsint32_t rhs) {
// Return lhs-rhs, but if rhs is negative use an add, so we won't
// have to deal with signed math and related 32bit sign extension problems
if (rhs == 0) {
return lhsp;
} else if (lhsp->castConst()) {
// Optional vs just making add/sub below, but saves constification some work
V3Number num (lhsp->fileline(), lhsp->width());
num.opSub(lhsp->castConst()->num(), V3Number(lhsp->fileline(), 32, rhs));
num.isSigned(lhsp->isSigned());
AstNode* newp = new AstConst(lhsp->fileline(), num);
return newp;
} else if (rhs > 0) {
AstNode* newp = new AstSub(lhsp->fileline(), lhsp,
new AstConst(lhsp->fileline(), AstConst::Unsized32(), rhs));
// We must make sure sub gets sign of original value, not from the constant
newp->dtypeFrom(lhsp);
return newp;
} else { // rhs < 0;
AstNode* newp = new AstAdd(lhsp->fileline(), lhsp,
new AstConst(lhsp->fileline(), AstConst::Unsized32(), -rhs));
// We must make sure sub gets sign of original value, not from the constant
newp->dtypeFrom(lhsp);
return newp;
}
}
示例7: visit
virtual void visit(AstNodeClassDType* nodep, AstNUser*) {
if (m_traVscp) {
if (nodep->packed() && !v3Global.opt.traceStructs()) {
// Everything downstream is packed, so deal with as one trace unit
// This may not be the nicest for user presentation, but is a much faster way to trace
addTraceDecl(VNumRange());
} else {
if (!nodep->packed()) {
addIgnore("Unsupported: Unpacked struct/union");
} else {
for (AstMemberDType* itemp = nodep->membersp(); itemp; itemp=itemp->nextp()->castMemberDType()) {
AstNodeDType* subtypep = itemp->subDTypep()->skipRefp();
string oldShowname = m_traShowname;
AstNode* oldValuep = m_traValuep;
{
m_traShowname += string(" ")+itemp->prettyName();
if (nodep->castStructDType()) {
m_traValuep = new AstSel(nodep->fileline(), m_traValuep->cloneTree(true),
itemp->lsb(), subtypep->width());
subtypep->accept(*this);
m_traValuep->deleteTree(); m_traValuep = NULL;
} else { // Else union, replicate fields
subtypep->accept(*this);
}
}
m_traShowname = oldShowname;
m_traValuep = oldValuep;
}
}
}
}
}
示例8: getCreateLastClk
AstVarScope* getCreateLastClk(AstVarScope* vscp) {
if (vscp->user1p()) return ((AstVarScope*)vscp->user1p());
AstVar* varp = vscp->varp();
if (!varp->width1()) varp->v3error("Unsupported: Clock edge on non-single bit signal: "<<varp->prettyName());
string newvarname = ((string)"__Vclklast__"+vscp->scopep()->nameDotless()+"__"+varp->name());
AstVar* newvarp = new AstVar(vscp->fileline(), AstVarType::MODULETEMP, newvarname, VFlagLogicPacked(), 1);
newvarp->noReset(true); // Reset by below assign
m_modp->addStmtp(newvarp);
AstVarScope* newvscp = new AstVarScope(vscp->fileline(), m_scopep, newvarp);
vscp->user1p(newvscp);
m_scopep->addVarp(newvscp);
// Add init
AstNode* fromp = new AstVarRef(newvarp->fileline(), vscp, false);
if (v3Global.opt.xInitialEdge()) fromp = new AstNot(fromp->fileline(), fromp);
AstNode* newinitp = new AstAssign(vscp->fileline(),
new AstVarRef(newvarp->fileline(), newvscp, true),
fromp);
addToInitial(newinitp);
// At bottom, assign them
AstAssign* finalp
= new AstAssign(vscp->fileline(),
new AstVarRef(vscp->fileline(), newvscp, true),
new AstVarRef(vscp->fileline(), vscp, false));
m_evalFuncp->addFinalsp(finalp);
//
UINFO(4,"New Last: "<<newvscp<<endl);
return newvscp;
}
示例9: funIt
void Printer::printBlockContents(BlockNode* node) {
// functions delcarations
Scope::FunctionIterator funIt(node->scope());
while (funIt.hasNext()) {
funIt.next()->node()->visit(this);
out << '\n';
}
// variables declarations
Scope::VarIterator varIt(node->scope());
while (varIt.hasNext()) {
AstVar* var = varIt.next();
out << typeToName(var->type())
<< " " << var->name() << ";\n";
}
// nodes
for (size_t i = 0; i < node->nodes(); ++i) {
AstNode* subNode = node->nodeAt(i);
subNode->visit(this);
if (!subNode->isIfNode() &&
!subNode->isWhileNode() &&
!subNode->isForNode()) {
out << ';';
}
out << '\n';
}
}
示例10: insertImplicit
AstArraySel* insertImplicit(AstNode* nodep, unsigned start, unsigned count) {
// Insert any implicit slices as explicit slices (ArraySel nodes).
// Return a new pointer to replace nodep() in the ArraySel.
UINFO(9," insertImplicit (start="<<start<<",c="<<count<<") "<<nodep<<endl);
AstVarRef* refp = nodep->user1p()->castNode()->castVarRef();
if (!refp) nodep->v3fatalSrc("No VarRef in user1 of node "<<nodep);
AstVar* varp = refp->varp();
AstNode* topp = nodep;
for (unsigned i = start; i < start + count; ++i) {
AstNodeDType* dtypep = varp->dtypep()->dtypeDimensionp(i-1);
AstUnpackArrayDType* adtypep = dtypep->castUnpackArrayDType();
if (!adtypep) nodep->v3fatalSrc("insertImplicit tried to expand an array without an ArrayDType");
vlsint32_t msb = adtypep->msb();
vlsint32_t lsb = adtypep->lsb();
if (lsb > msb) {
// Below code assumes big bit endian; just works out if we swap
int x = msb; msb = lsb; lsb = x;
}
UINFO(9," ArraySel-child: "<<topp<<endl);
AstArraySel* newp = new AstArraySel(nodep->fileline(), topp,
// "lsb-lsb": Arrays are zero-based so index 0 is always lsb
new AstConst(nodep->fileline(), lsb-lsb));
if (!newp->dtypep()) {
newp->v3fatalSrc("ArraySel dtyping failed when resolving slice"); // see ArraySel constructor
}
newp->user1p(refp);
newp->start(lsb);
newp->length(msb - lsb + 1);
topp = newp;
}
return topp->castArraySel();
}
示例11: visit
virtual void visit(AstUdpTable* nodep, AstNUser*) {
UINFO(5,"UDPTABLE "<<nodep<<endl);
if (!v3Global.opt.bboxUnsup()) {
// We don't warn until V3Inst, so that UDPs that are in libraries and
// never used won't result in any warnings.
} else {
// Massive hack, just tie off all outputs so our analysis can proceed
AstVar* varoutp = NULL;
for (AstNode* stmtp = m_modp->stmtsp(); stmtp; stmtp=stmtp->nextp()) {
if (AstVar* varp = stmtp->castVar()) {
if (varp->isInput()) {
} else if (varp->isOutput()) {
if (varoutp) { varp->v3error("Multiple outputs not allowed in udp modules"); }
varoutp = varp;
// Tie off
m_modp->addStmtp(new AstAssignW(varp->fileline(),
new AstVarRef(varp->fileline(), varp, true),
new AstConst(varp->fileline(), AstConst::LogicFalse())));
} else {
varp->v3error("Only inputs and outputs are allowed in udp modules");
}
}
}
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
}
}
示例12: processBlock
void processBlock(AstNode* nodep) {
if (!nodep) return; // Empty lists are ignorable
// Pass the first node in a list of block items, we'll process them
// Check there's >= 2 sub statements, else nothing to analyze
// Save recursion state
AstNode* firstp = nodep; // We may reorder, and nodep is no longer first.
void* oldBlockUser3 = nodep->user3p(); // May be overloaded in below loop, save it
nodep->user3p(NULL);
if (!nodep->firstAbovep()) nodep->v3fatalSrc("Node passed is in next list; should have processed all list at once");
// Process it
if (!nodep->nextp()) {
// Just one, so can't reorder. Just look for more blocks/statements.
iterate(nodep);
} else {
UINFO(9," processBlock "<<nodep<<endl);
// Process block and followers
scanBlock(nodep);
if (m_noReorderWhy != "") { // Jump or something nasty
UINFO(9," NoReorderBlock because "<<m_noReorderWhy<<endl);
} else {
// Reorder statements in this block
cleanupBlockGraph(nodep);
reorderBlock(nodep);
// Delete old vertexes and edges only applying to this block
while (firstp->backp()->nextp()==firstp) firstp = firstp->backp(); // Walk back to first in list
for (AstNode* nextp=firstp; nextp; nextp=nextp->nextp()) {
SplitLogicVertex* vvertexp = (SplitLogicVertex*)nextp->user3p();
vvertexp->unlinkDelete(&m_graph);
}
}
}
// Again, nodep may no longer be first.
firstp->user3p(oldBlockUser3);
}
示例13: visit
virtual void visit(AstWhile* nodep, AstNUser*) {
nodep->iterateChildren(*this);
if (m_varModeCheck || m_varModeReplace) {
} else {
// Constify before unroll call, as it may change what is underneath.
if (nodep->precondsp()) V3Const::constifyEdit(nodep->precondsp()); // precondsp may change
if (nodep->condp()) V3Const::constifyEdit(nodep->condp()); // condp may change
// Grab initial value
AstNode* initp = NULL; // Should be statement before the while.
if (nodep->backp()->nextp() == nodep) initp=nodep->backp();
if (initp) { V3Const::constifyEdit(initp); VL_DANGLING(initp); }
if (nodep->backp()->nextp() == nodep) initp=nodep->backp();
// Grab assignment
AstNode* incp = NULL; // Should be last statement
if (nodep->incsp()) V3Const::constifyEdit(nodep->incsp());
if (nodep->incsp()) incp = nodep->incsp();
else {
for (incp = nodep->bodysp(); incp && incp->nextp(); incp = incp->nextp()) {}
if (incp) { V3Const::constifyEdit(incp); VL_DANGLING(incp); }
for (incp = nodep->bodysp(); incp && incp->nextp(); incp = incp->nextp()) {} // Again, as may have changed
}
// And check it
if (forUnrollCheck(nodep, initp,
nodep->precondsp(), nodep->condp(),
incp, nodep->bodysp())) {
pushDeletep(nodep); VL_DANGLING(nodep); // Did replacement
}
}
}
示例14: visitBinaryOpNode
void TypeCheckerVisitor::visitBinaryOpNode(BinaryOpNode* node) {
AstNode* left = node->left();
AstNode* right = node->right();
left->visit(this);
right->visit(this);
setNodeType(node, getOperationResultType(node->kind(), left, right));
}
示例15: error
void ByteCodeVisitor::visitCallNode(mathvm::CallNode *node) {
unsigned long stackSize = currStack->size();
AstFunction *astFunction = currScope->lookupFunction(node->name(), true);
AstFunctionInfo *functionInfo = (AstFunctionInfo *) astFunction->info();
Scope *parameterScope = astFunction->scope();
if (node->parametersNumber() != parameterScope->variablesCount()) {
error("parameters number mistmach in calling %s", node->name().c_str());
}
vector<VarType> declaredParameters;
declaredParameters.reserve(parameterScope->variablesCount());
Scope::VarIterator varIterator(parameterScope);
while (varIterator.hasNext()) {
declaredParameters.push_back(varIterator.next()->type());
}
vector<VarType>::reverse_iterator it = declaredParameters.rbegin();
for (uint32_t i = node->parametersNumber(); i > 0; --i, ++it) {
AstNode *n = node->parameterAt(i - 1);
n->visit(this);
cast(topStack(), (*it));
}
insn(BC_CALL);
typed(functionInfo->function->id());
if (astFunction->returnType() != VT_VOID) {
pushStack(astFunction->returnType());
}
}