本文整理汇总了C++中AstVar::name方法的典型用法代码示例。如果您正苦于以下问题:C++ AstVar::name方法的具体用法?C++ AstVar::name怎么用?C++ AstVar::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstVar
的用法示例。
在下文中一共展示了AstVar::name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
virtual void visit(AstPin* nodep, AstNUser*) {
// Check to see if any output pins have __en pins and create the __en pins to match
AstVarRef* refp = findVarRef(nodep);
if (refp && refp->lvalue() && nodep->modVarp()->user1p()) {
AstVar* enchildp = (AstVar*)nodep->modVarp()->user1p();
UINFO(9, " Pulling __en var" << enchildp << endl);
AstVar* enp = new AstVar(enchildp->fileline(),
AstVarType::OUTPUT,
enchildp->name()+cvtToStr(m_unique++),
enchildp);
enp->user2(enchildp->user2());
m_modp->addStmtp(enp);
AstPin* pinp = new AstPin(nodep->fileline(),
nodep->pinNum(),
enp->name(),
new AstVarRef(nodep->fileline(), enp, true));
AstVarRef *rp = findVarRef(pinp);
rp->replaceWith(new AstVarRef(nodep->fileline(), enp, true));
rp->deleteTree(); rp=NULL;
pinp->width(enp->width(),enp->width()); // minwidth==width
pinp->modVarp(enchildp);
m_cellp->addPinsp(pinp);
refp->user1p(enp);
refp->varp()->user1p(enp);
}
// Simplify interconnect in preperation for V3Inst
// (This could be a separate visitor, but we're in the neighborhood)
V3Inst::pinReconnectSimple(nodep, m_cellp, m_modp);
}
示例2: varsExpand
void varsExpand() {
// We didn'e have all m_scopes loaded when we encountered variables, so expand them now
// It would be less code if each module inserted its own variables.
// Someday. For now public isn't common.
for (vector<ScopeModPair>::iterator it = m_scopes.begin(); it != m_scopes.end(); ++it) {
AstScope* scopep = it->first; AstNodeModule* smodp = it->second;
for (vector<ModVarPair>::iterator it = m_modVars.begin(); it != m_modVars.end(); ++it) {
AstNodeModule* modp = it->first;
AstVar* varp = it->second;
if (modp == smodp) {
// Need to split the module + var name into the original-ish full scope and variable name under that scope.
// The module instance name is included later, when we know the scopes this module is under
string whole = scopep->name()+"__DOT__"+varp->name();
string scpName;
string varBase;
if (whole.substr(0,10) == "__DOT__TOP") whole.replace(0,10,"");
string::size_type pos = whole.rfind("__DOT__");
if (pos != string::npos) {
scpName = whole.substr(0,pos);
varBase = whole.substr(pos+strlen("__DOT__"));
} else {
varBase = whole;
}
//UINFO(9,"For "<<scopep->name()<<" - "<<varp->name()<<" Scp "<<scpName<<" Var "<<varBase<<endl);
string varBasePretty = AstNode::prettyName(varBase);
string scpPretty = AstNode::prettyName(scpName);
string scpSym;
{
string out = scpName;
string::size_type pos;
while ((pos=out.find("__PVT__")) != string::npos) {
out.replace(pos, 7, "");
}
if (out.substr(0,10) == "TOP__DOT__") out.replace(0,10,"");
if (out.substr(0,4) == "TOP.") out.replace(0,4,"");
while ((pos=out.find(".")) != string::npos) {
out.replace(pos, 1, "__");
}
while ((pos=out.find("__DOT__")) != string::npos) {
out.replace(pos, 7, "__");
}
scpSym = out;
}
//UINFO(9," scnameins sp "<<scpName<<" sp "<<scpPretty<<" ss "<<scpSym<<endl);
if (m_scopeNames.find(scpSym) == m_scopeNames.end()) {
m_scopeNames.insert(make_pair(scpSym, ScopeNameData(scpSym, scpPretty)));
}
m_scopeVars.insert(make_pair(scpSym + " " + varp->name(),
ScopeVarData(scpSym, varBasePretty, varp, modp, scopep)));
}
}
}
}
示例3: visitBlockNode
void AstPrinterVisitor::visitBlockNode(BlockNode* node) {
if (!isMainScope(node->scope())) {
_output << "{" << endl;
}
Scope::VarIterator varIt(node->scope());
while(varIt.hasNext()) {
AstVar* var = varIt.next();
printVarType(var->type());
_output << " " << var->name();
printSemicolon();
}
Scope::FunctionIterator funcIt(node->scope());
while(funcIt.hasNext()) {
FunctionNode* func = funcIt.next()->node();
func->visit(this);
}
for (uint32_t i = 0; i < node->nodes(); ++i) {
node->nodeAt(i)->visit(this);
if (!(node->nodeAt(i)->isIfNode()
|| node->nodeAt(i)->isWhileNode()
|| node->nodeAt(i)->isForNode()
|| node->nodeAt(i)->isReturnNode()
|| node->nodeAt(i)->isBlockNode())) {
printSemicolon();
}
}
if (!isMainScope(node->scope())) {
_output << "}" << endl;
}
}
示例4: 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;
}
示例5: visit
virtual void visit(AstVarScope* nodep, AstNUser*) {
nodep->iterateChildren(*this);
// Avoid updating this if (), instead see varp->isTrace()
if (!nodep->varp()->isTemp() && !nodep->varp()->isFuncLocal()) {
UINFO(5, " vsc "<<nodep<<endl);
AstVar* varp = nodep->varp();
AstScope* scopep = nodep->scopep();
// Compute show name
// This code assumes SPTRACEVCDC_VERSION >= 1330;
// it uses spaces to separate hierarchy components.
m_traShowname = AstNode::vcdName(scopep->name() + " " + varp->name());
if (m_traShowname.substr(0,4) == "TOP ") m_traShowname.replace(0,4,"");
if (!m_initSubFuncp) nodep->v3fatalSrc("NULL");
m_traVscp = nodep;
m_traValuep = NULL;
if (varIgnoreTrace(varp)) {
addIgnore(varIgnoreTrace(varp));
} else {
++m_statSigs;
if (nodep->valuep()) m_traValuep = nodep->valuep()->cloneTree(true);
else m_traValuep = new AstVarRef(nodep->fileline(), nodep, false);
{
// Recurse into data type of the signal; the visitors will call addTraceDecl()
varp->dtypeSkipRefp()->accept(*this);
}
// Cleanup
if (m_traValuep) { m_traValuep->deleteTree(); m_traValuep=NULL; }
}
m_traVscp = NULL;
m_traValuep = NULL;
m_traShowname = "";
}
}
示例6: printBlockContents
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';
}
}
示例7: drivenBit
void drivenBit (int bit, int width) {
UINFO(9, "set d["<<(bit+width-1)<<":"<<bit<<"] "<<m_varp->name()<<endl);
for (int i=0; i<width; i++) {
if (bitNumOk(bit+i)) {
m_flags[(bit+i)*FLAGS_PER_BIT + FLAG_DRIVEN] = true;
}
}
}
示例8: printVars
void printVars(Scope *scope)
{
Scope::VarIterator iter(scope);
while (iter.hasNext()) {
AstVar *astVar = iter.next();
out << typeToName(astVar->type()) << " " << astVar->name() << ";" << endl;
}
}
示例9: variableDeclaration
void variableDeclaration(Scope* scope) {
Scope::VarIterator iter(scope);
while (iter.hasNext()) {
AstVar* x = iter.next();
indent();
_output << typeToName(x->type()) << " "
<< x->name() << ";"
<< endl;
}
}
示例10: while
ScopeHandler::ScopeHandler(uint16_t iniLocalId, Scope *scope, ScopeHandler *parent)
: m_scope(scope)
, m_parent(parent)
{
Scope::VarIterator it = Scope::VarIterator(m_scope);
while(it.hasNext()) {
AstVar *var = it.next();
m_varNameToId[var->name()] = iniLocalId;
iniLocalId++;
}
}
示例11: printScopeDeclarations
void ASTAnalyzer::printScopeDeclarations (Scope* scope) {
Scope::FunctionIterator fuctions(scope);
while (fuctions.hasNext()) {
fuctions.next()->node()->visit(this);
}
Scope::VarIterator vars(scope);
while (vars.hasNext()) {
AstVar* var = vars.next();
output << typeToName(var->type()) << " " << var->name() << ";\n";
}
}
示例12: visitVarDecls
// private:
// visitBlockNodeImpl
void BytecodeGenerator::visitVarDecls(BlockNode* node) {
Bytecode* bc = _state.currentBcToFill();
Scope::VarIterator varIt(node->scope());
while(varIt.hasNext()) {
AstVar* var = varIt.next();
uint16_t varId = _state.currentCtxAddVar(var->name(), node->position());
Instruction bcLoad0 = typedInsn(var->type(), BC_ILOAD0, BC_DLOAD0, BC_SLOAD0);
bc->addInsn(bcLoad0);
Instruction bcStore = typedInsn(var->type(), BC_STOREIVAR, BC_STOREDVAR, BC_STORESVAR);
genBcInsnWithId(bc, bcStore, varId);
}
}
示例13: visitScope
void visitScope(Scope * scope) {
Scope::VarIterator varIter(scope);
while (varIter.hasNext()) {
addIndent();
AstVar * var = varIter.next();
out<< typeToName(var->type())<< " "<< var->name()<< ";"<< endl;
}
Scope::FunctionIterator funcIter(scope);
while (funcIter.hasNext()) {
funcIter.next()->node()->visit(this);
}
}
示例14: indent
void Ast2SrcVisitor::initScope(Scope* scope) {
std::string indent(_indent, ' ');
Scope::VarIterator varIt(scope);
while (varIt.hasNext()) {
AstVar* var = varIt.next();
_out << indent << mathvm::typeToName(var->type()) << " "<< var->name() << ";" << std::endl;
}
Scope::FunctionIterator funcIt(scope);
while (funcIt.hasNext()) {
funcIt.next()->node()->visit(this);
_out << std::endl;
}
}
示例15: printScope
void PrettyPrinter::printScope(Scope *scope)
{
std::string indentation(m_indent, ' ');
//why constructor doesn't get const pointer?
Scope::VarIterator ivar(scope);
//Java-style iterators in C++?
while (ivar.hasNext())
{
AstVar *var = ivar.next();
m_out << indentation << typeToName(var->type()) << " "
<< var->name() << ";" << std::endl;
}
Scope::FunctionIterator ifun(scope);
while (ifun.hasNext()) ifun.next()->node()->visit(this);
}