コード例 #1
0
ファイル: assist.cpp プロジェクト: 8l/compiler
void assist_find_symbol(Node* n, Scope* sc, Name symbol){
	int max=10;
	MyVec<pair<Name,int>> completions;
	dbprintf("...completions:-");
	find_completions(symbol,
		[&](Name s,int score)->void{
			completions.push_back(std::make_pair(s,score));
		}
	);
	// todo sort them
	for (auto i=0; i<max && i<completions.size();i++){
		auto& c=completions[i];
		auto ni=sc->find_named_items_rec(c.first);
		if (ni){
		// TODO: sort by distance from current locatino;
		// allow searching forward too.
			for (auto fd=ni->fn_defs; fd;fd=fd->next_of_name){
				info(fd,"\t", str(fd->name)); fd->dump_signature();
			}
			for (auto sd=ni->structs; sd;sd=sd->next_of_name){
				info(sd,"\tstruct\t%s", str(sd->name)); 
			}
			for (auto fd=ni->fields; fd;fd=fd->next_of_name){
				info(fd,"\tfield\t%s.'t%s:", fd->owner->name_str(), str(fd->name)); fd->type()->dump_if(-1);
			}
		}
	}	


}
コード例 #2
0
int main()
{
    constexpr size_t NUM_EL = 2;

    MyVec<uint8_t, NUM_EL, alignof(uint64_t)> vec;
    vec.clear();
    vec.push_back(0x11);
    vec.push_back(0x22);

    uint64_t val = * reinterpret_cast<uint64_t *>(vec.data()); // access data with a uint64_t
    assert(
              ( htole64(val)                                          // host_to_little_endian in /usr/include/endian.h
                & static_cast<uint64_t>(UINT64_C(0x000000000000FFFF)) // mask out junk-bits
              )
              == 0x2211
          );
    
    memuse();
}
コード例 #3
0
ファイル: main.cpp プロジェクト: cboettcher/CPP
int main(int argc, char * argv[]) {
    if (argc == 0) {
        cout << "usage: " << argv[0] << "[File1 [File2 [File3 [...]]]]" << endl;
    }
    for (int i = 1; i < argc; i++) {
        cout << "File: " << argv[i] << endl;
        printNames(argv[i]);

        MyMap::iterator it = names.begin();
        while (it != names.end()) {
            //cout << it->first << ": " << it->second << endl;
            sortiert.push_back(it);
            it++;
        }
        //partial_sort (sortiert.begin(), sortiert.bein() + 20, sortiert.end(), mySort);
        partial_sort (sortiert.begin(), sortiert.begin() + 20, sortiert.end(), myObject);

        size_t c = 0;
        for (MyVec::iterator it = sortiert.begin(); it != sortiert.end() && c < 20; it++, c++) {
            cout << (*it)->first << ": " << (*it)->second << endl;
        }
        cout << "==============================" << endl;

        names.clear();
    }
}