本文整理汇总了C++中StatementList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ StatementList::size方法的具体用法?C++ StatementList::size怎么用?C++ StatementList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatementList
的用法示例。
在下文中一共展示了StatementList::size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printTree
void printTree(std::ostream& os, int depth =0){
os<<string(depth,' ')<<"NBlock: {"<<endl;
for(int i=0;i<statements.size();i++){
statements[i]->printTree(os,depth+1);
}
os<<string(depth,' ')<<"}"<<endl;
}
示例2: typeChk
TType* typeChk(Symtable& t,TType* expected = NULL){
t.begScope();
bool err=false;
TType* s;
for(int i=0;i<statements.size();i++){
#ifdef DEBUG
cout << "statement "<< i << " " << statements[i] <<endl;
#endif
s=statements[i]->typeChk(t,expected);
if(s==NULL){
cerr<<"Error in the statement "<<i<<" of block."<<endl;
err=true;
}
}
t.endScope();
if(err) {
#ifdef DEBUG
cerr << "error in block"<<endl;
#endif
return NULL;
}
#ifdef DEBUG
cout << "void " << t.lookupType("void") << endl;
#endif
return t.lookupType("void");
}
示例3: getLibraryDefines
// Return a list of locations defined by library calls
void PPCSignature::getLibraryDefines(StatementList &defs)
{
if (defs.size() > 0) {
return; // Do only once
}
for (int r = REG_PPC_G3; r <= REG_PPC_G12; ++r) {
defs.append(
new ImplicitAssign(Location::regOf(r))); // Registers 3-12 are volatile (caller save)
}
}
示例4: main
int main(int argc, char **argv)
{
vector<Token> tokens = lexerFile(argv[1]);
Parser parser(tokens, &std::cout);
StatementList * list = parser.file();
Printer p(std::cout);
cout << "Statements " << list->size() << endl;
for( Statement *s : *list )
s->print(p);
return 0;
}
示例5: findInterpolatable
CodeNodePtr findInterpolatable(StatementPtr stmt) {
if (CodeNodePtr e = stmt->getExpression()) {
if (CodeNodePtr f = findInterpolatable(e)) {
return f;
}
}
StatementList children = stmt->getChildren();
for (size_t i = 0; i < children.size(); ++i) {
if (CodeNodePtr f = findInterpolatable(children[i])) {
return f;
}
}
return CodeNodePtr();
}
示例6: getLibraryDefines
void SPARCSignature::getLibraryDefines(StatementList &defs)
{
if (defs.size() > 0) {
return; // Do only once
}
// o0-o7 (r8-r15) modified
defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O0)));
defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O1)));
defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O2)));
defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O3)));
defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O4)));
defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O5)));
defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O6)));
defs.append(new ImplicitAssign(Location::regOf(REG_SPARC_O7)));
}
示例7: doCountReferences
static void doCountReferences(
StatementPtr statement,
ReferenceMap& refs,
ReferencePath path
) {
assert(statement);
path.push_back(statement);
if (CodeNodePtr e = statement->getExpression()) {
countReferences(e, refs, path);
}
StatementList children = statement->getChildren();
for (size_t i = 0; i < children.size(); ++i) {
doCountReferences(children[i], refs, path);
}
}
示例8: replace
void replace(StatementPtr st, CodeNodePtr node, CodeNodePtr with) {
assert(st);
assert(node);
assert(with);
if (CodeNodePtr e = st->getExpression()) {
if (e == node) {
st->setExpression(with);
} else {
replace(e, node, with);
}
}
StatementList children = st->getChildren();
for (size_t i = 0; i < children.size(); ++i) {
replace(children[i], node, with);
}
}
示例9: findBranch
IfCodeNodePtr findBranch(StatementPtr stmt, StatementPtr& ref) {
assert(stmt);
if (CodeNodePtr e = stmt->getExpression()) {
if (IfCodeNodePtr f = findBranch(e)) {
ref = stmt;
return f;
}
}
StatementList children = stmt->getChildren();
for (size_t i = 0; i < children.size(); ++i) {
if (IfCodeNodePtr f = findBranch(children[i], ref)) {
return f;
}
}
return IfCodeNodePtr();
}
示例10: findMultiplyReferenced
CodeNodePtr findMultiplyReferenced(
StatementPtr stmt,
const ReferenceMap& refs
) {
assert(stmt);
if (CodeNodePtr e = stmt->getExpression()) {
if (CodeNodePtr f = findMultiplyReferenced(e, refs)) {
return f;
}
}
StatementList children = stmt->getChildren();
for (size_t i = 0; i < children.size(); ++i) {
if (CodeNodePtr f = findMultiplyReferenced(children[i], refs)) {
return f;
}
}
return CodeNodePtr();
}
示例11: main
int main(int argc, char **argv)
{
InitializeNativeTarget();
InitializeNativeTargetAsmPrinter();
InitializeNativeTargetAsmParser();
executor = mtexecutor_new();
vector<Token> tokens = lexerFile(argv[1]);
Parser parser(tokens, &std::cout);
StatementList * list = parser.file();
Printer p(std::cout);
cout << "Statements " << list->size() << endl;
for( Statement *s : *list )
s->print(p);
std::cerr.flush();
std::cout.flush();
usleep(10000);
llvm::LLVMContext &llvmContext = llvm::getGlobalContext();
SMDiagnostic error;
//Module *m = parseIRFile("decl.ll", error, llvmContext);
//std::unique_ptr<llvm::Module> Owner = llvm::make_unique<llvm::Module>("my cool jit", llvmContext);
//std::unique_ptr<llvm::Module> Owner = std::unique_ptr<llvm::Module>(m);
std::unique_ptr<llvm::Module> Owner = parseIRFile("decl.ll", error, llvmContext);
Module *TheModule = Owner.get();
/*TheModule->addModuleFlag(Module::Warning, "Debug Info Version",
DEBUG_METADATA_VERSION);*/
/*if (Triple(sys::getProcessTriple()).isOSDarwin())
TheModule->addModuleFlag(llvm::Module::Warning, "Dwarf Version", 2);*/
ContextStorage s;
Context ctx(&s);
std::string ErrStr;
TheExecutionEngine =
EngineBuilder(std::move(Owner))
.setErrorStr(&ErrStr)
.setMCJITMemoryManager(llvm::make_unique<SectionMemoryManager>())
.create();
if (!TheExecutionEngine) {
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
exit(1);
}
TheExecutionEngine->addGlobalMapping(TheModule->getFunction("system_init"), (void*)system_init);
//FunctionPassManager OurFPM(TheModule);
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
TheModule->setDataLayout(*TheExecutionEngine->getDataLayout());
#if 0
OurFPM.add(new DataLayoutPass());
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Do simple "peephole" optimizations and bit-twiddling optzns.
OurFPM.add(createInstructionCombiningPass());
// Reassociate expressions.
OurFPM.add(createReassociatePass());
// Eliminate Common SubExpressions.
OurFPM.add(createGVNPass());
// Simplify the control flow graph (deleting unreachable blocks, etc).
OurFPM.add(createCFGSimplificationPass());
OurFPM.doInitialization();
#endif
// Set the global so the code gen can use this.
//TheFPM = &OurFPM;
s.module = TheModule;
register_printf(TheModule);
register_malloc(TheModule);
stdio_register(&ctx);
for( Statement *s : *list )
s->codegen(&ctx);
//s.module->dump();
TheExecutionEngine->finalizeObject();
std::cerr.flush();
std::cout.flush();
usleep(1000);
asyncIoInitialize();
// JIT the function, returning a function pointer.
Function *LF = TheModule->getFunction("main");
void *FPtr = TheExecutionEngine->getPointerToFunction(LF);
// Cast it to the right type (takes no arguments, returns a double) so we
// can call it as a native function.
//.........这里部分代码省略.........