本文整理汇总了C++中TArray::top方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::top方法的具体用法?C++ TArray::top怎么用?C++ TArray::top使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::top方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDebInfo
DebugInfos* getDebInfo(const char* package)
{
SymbolID_t pkgid = gSymbolTable.symbolID(package);
DebugInfos** pdsi = m_debInfos.find(pkgid);
if (pdsi != NULL)
return *pdsi;
hyu32 len = HMD_STRLEN(package);
TArray<char>* fname = new TArray<char>(len + HMD_STRLEN(DEBUGINFO_EXT) + 1);
memcpy(fname->addSpaces(len), package, len);
len = HMD_STRLEN(DEBUGINFO_EXT);
memcpy(fname->addSpaces(len), DEBUGINFO_EXT, len);
fname->add('\0');
return new DebugInfos(fname->top());
}
示例2: addLoadPath
// ロードパスを追加する
void addLoadPath(const char* path)
{
//printf("addLoadPath(%s)\n", path);
hyu32 n = loadPathArr.size();
if (n == 0) {
loadPathArr.add(NULL);
n = 1;
}
hyu32 len = HMD_STRLEN(path);
char* apath = gMemPool->allocT<char>(len+1);
HMD_STRNCPY(apath, path, len+1);
loadPathArr[n-1] = apath; // end mark に上書き
loadPathArr.add(NULL); // 新しい end mark
HMD_LOADPATH = loadPathArr.top();
// n=0;for(const char** p = HMD_LOADPATH; *p != NULL; ++p)HMD_PRINTF("path %d:'%s'\n",n++,*p);
}
示例3: main
//.........这里部分代码省略.........
HMD_PRINTF("parameter for -I is not specified\n");
return 1;
}
incPath[numIncPath++] = param;
break;
case 'M':
param = getParam(i, argc, argv, "-M");
if (param == NULL) {
usage();
HMD_PRINTF("parameter for -M is not specified\n");
return 1;
} else {
memSize = 0;
while('0' <= *param && *param <= '9') {
memSize *= 10;
memSize += (*param++ - '0');
}
if (*param == 'k' || *param == 'K') {
memSize *= 1024;
} else if (*param == 'm' || *param == 'M') {
memSize *= 1024 * 1024;
} else if (*param != '\0') {
printf("bad parameter for -M\n");
memSize = DEFAULT_MEMSIZE;
}
}
break;
case 'f':
param = getParam(i, argc, argv, "-f");
if (param == NULL) {
HMD_PRINTF("symbol file is not specified\n");
return 1;
}
symbolFile = param;
break;
case 's':
bPrintSource = true;
break;
case 'h':
usage(true);
return 1;
default:
usage(true);
HMD_PRINTF("unknown option %s\n", argv[i]);
return 1;
}
} else {
usage(true);
HMD_PRINTF("unknown option %s\n", argv[i]);
return 1;
}
}
hayatMemory = HMD_ALLOC(memSize);
MemPool::initGMemPool(hayatMemory, memSize);
for (int i = 0; i < numIncPath; ++i) {
addLoadPath(incPath[i], "out");
}
addLoadPath(".", "out");
if (symbolFile != NULL) {
if (! gSymbolTable.readFile(symbolFile)) {
HMD_PRINTF("symbol file '%s' load failed\n", symbolFile);
HMD_FREE(hayatMemory);
return 1;
}
} else {
hyu8* fileBuf;
hyu32 len = hmd_loadFile_inPath("symbols.sym", &fileBuf);
if (len != 0)
gSymbolTable.readTable(fileBuf);
else
HMD_PRINTF("could not load symbols.sym\n");
}
// main loop
static const size_t BUF_SIZE = 1024;
char buf[BUF_SIZE];
while (fgets(buf, BUF_SIZE, stdin) != NULL) {
TArray<char>* s = replaceSymbol(buf);
printResolvedLine(s->top());
s->finalize();
}
// normal exit
gSymbolTable.finalize();
HMD_FREE(hayatMemory);
return 0;
}
示例4: dump
void DClass::dump(TArray<SymbolID_t>& parents)
{
hyu8 sbuf[256];
if (bPrimitive)
HMD_PRINTF("flag: primitive\n");
if (numDefaultVal > 0)
HMD_PRINTF("number of default values: %d\n", numDefaultVal);
if (numSuper > 0) {
HMD_PRINTF("%d super classes: ", numSuper);
for (int i = 0; i < numSuper; ++i) {
SymbolID_t supsym = (SymbolID_t)Endian::unpack<hyu32>((const hyu8*)&superTable[i]);
gSymbolTable.id2str_n(sbuf, 256, supsym);
HMD_PRINTF((char*)sbuf);
if (i < numSuper - 1)
HMD_PRINTF(", ");
}
HMD_PRINTF("\n");
}
bool bPrintUsingPath = false;
hyu16 usingInfoSize = Endian::unpack<hyu16>((const hyu8*)usingPaths);
const hyu8* ptr = ((const hyu8*)usingPaths) + 4;
for (;;) {
SymbolID_t sym = Endian::unpackP<SymbolID_t>(&ptr);
if (sym == SYMBOL_ID_ERROR)
break;
if (!bPrintUsingPath) {
bPrintUsingPath = true;
HMD_PRINTF("using paths:\n");
}
if (sym != (SymbolID_t)0) { // 0 == HSym_nil
gSymbolTable.id2str_n(sbuf, 256, sym);
HMD_PRINTF((char*)sbuf);
}
for (;;) {
sym = Endian::unpackP<SymbolID_t>(&ptr);
if (sym == SYMBOL_ID_ERROR)
break;
gSymbolTable.id2str_n(sbuf, 256, sym);
HMD_PRINTF("::%s", sbuf);
}
}
HMD_DEBUG_ASSERT(ptr <= ((const hyu8*)usingPaths) + usingInfoSize);
if (numClassVar > 0) {
HMD_PRINTF("class variables: ");
printSymbols(classVarSymArr.top(), numClassVar, "@@");
}
if (numMembVar > 0) {
HMD_PRINTF("member variables: ");
printSymbols(membVarSymArr.top(), numMembVar, "@");
}
if (numConstVar > 0) {
HMD_PRINTF("constants: ");
printSymbols(constVarSymArr.top(), numConstVar, "");
}
int numBlk = numMethods + numClosures;
TArray<const hyu8*> adrs(numBlk + 2);
adrs.add(codes);
for (int i = 0; i < numBlk; ++i)
adrs.add(codes + methodTable[i]);
if (numInnerClasses > 0)
adrs.add(codes + innerClassTable[0]);
else
adrs.add(bottomAddr);
for (int i = 0; i <= numBlk; ++i) {
if (i == 0)
HMD_PRINTF("***** classInitializer *MAIN *****\n");
else if (i <= numMethods) {
gSymbolTable.id2str_n(sbuf, 256, methodSymTable[i-1]);
HMD_PRINTF("***** method %s *****\n", sbuf);
}
else
HMD_PRINTF("***** closure #%d *****\n", i - numMethods - 1);
dumpMethod(adrs[i], adrs[i+1]);
}
for (int i = 0; i < numInnerClasses; ++i) {
TArray<SymbolID_t> abs(parents.size() + 1);
abs.add(parents);
abs.add(innerClasses[i]->classSymbol);
SymbolID_t sym;
HMD_PRINTF("======== class ");
for (hyu32 j = 0; j < abs.size(); ++j) {
sym = abs[j];
gSymbolTable.id2str_n(sbuf, 256, sym);
HMD_PRINTF("::%s", sbuf);
}
HMD_PRINTF(" ========\n");
innerClasses[i]->dump(abs);
}
}