本文整理汇总了C++中PolyObject::ConstPtrForCode方法的典型用法代码示例。如果您正苦于以下问题:C++ PolyObject::ConstPtrForCode方法的具体用法?C++ PolyObject::ConstPtrForCode怎么用?C++ PolyObject::ConstPtrForCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PolyObject
的用法示例。
在下文中一共展示了PolyObject::ConstPtrForCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exportStore
//.........这里部分代码省略.........
//symTab.stroff is set later
//symTab.strsize is set later
fwrite(&symTab, sizeof(symTab), 1, exportFile);
// Create the symbol table first before we mess up the addresses by turning them
// into relocations.
symTab.symoff = ftell(exportFile);
// Global symbols: Just one. Mach prefixes symbols with an underscore.
writeSymbol("_poly_exports", N_EXT | N_SECT, memTableEntries, 0); // The export table comes first
// We create local symbols because they make debugging easier. They may also
// mean that we can use the usual Unix profiling tools.
writeSymbol("memTable", N_SECT, memTableEntries, sizeof(exportDescription)); // Then the memTable.
for (i = 0; i < memTableEntries; i++)
{
if (i == ioMemEntry)
writeSymbol("ioarea", N_SECT, i, 0);
else {
char buff[50];
sprintf(buff, "area%0d", i);
writeSymbol(buff, N_SECT, i, 0);
#if (SIZEOF_VOIDP == 8)
// See if we can find the names of any functions.
// This seems to break on 32-bit Mac OS X. It seems to align
// some relocations onto an 8-byte boundary so we just disable it.
char *start = (char*)memTable[i].mtAddr;
char *end = start + memTable[i].mtLength;
for (p = (PolyWord*)start; p < (PolyWord*)end; )
{
p++;
PolyObject *obj = (PolyObject*)p;
POLYUNSIGNED length = obj->Length();
if (length != 0 && obj->IsCodeObject())
{
PolyWord *name = obj->ConstPtrForCode();
// Copy as much of the name as will fit and ignore any extra.
// Do we need to worry about duplicates?
(void)Poly_string_to_C(*name, buff, sizeof(buff));
writeSymbol(buff, N_SECT, i, (char*)p - start);
}
p += length;
}
#endif
}
}
symTab.nsyms = symbolCount;
// Create and write out the relocations.
for (i = 0; i < memTableEntries; i++)
{
sections[i].reloff = ftell(exportFile);
relocationCount = 0;
if (i != ioMemEntry) // Don't relocate the IO area
{
// Create the relocation table and turn all addresses into offsets.
char *start = (char*)memTable[i].mtAddr;
char *end = start + memTable[i].mtLength;
for (p = (PolyWord*)start; p < (PolyWord*)end; )
{
p++;
PolyObject *obj = (PolyObject*)p;
POLYUNSIGNED length = obj->Length();
if (length != 0 && obj->IsCodeObject())
machineDependent->ScanConstantsWithinCode(obj, this);
relocateObject(obj);
p += length;
}
示例2: poly_dispatch_c
//.........这里部分代码省略.........
case 101: /* Return the maximum string size (in bytes).
It is the maximum number of bytes in a segment
less one word for the length field. */
return taskData->saveVec.push(TAGGED((MAX_OBJECT_SIZE)*sizeof(PolyWord) - sizeof(PolyWord)));
case 102: /* Test whether the supplied address is in the io area.
This was previously done by having get_flags return
256 but this was changed so that get_flags simply
returns the top byte of the length word. */
{
PolyWord *pt = (PolyWord*)DEREFWORDHANDLE(args);
if (gMem.IsIOPointer(pt))
return Make_arbitrary_precision(taskData, 1);
else return Make_arbitrary_precision(taskData, 0);
}
case 103: /* Return the register mask for the given function.
This is used by the code-generator to find out
which registers are modified by the function and
so need to be saved if they are used by the caller. */
{
PolyObject *pt = DEREFWORDHANDLE(args);
if (gMem.IsIOPointer(pt))
{
/* IO area. We need to get this from the vector. */
int i;
for (i=0; i < POLY_SYS_vecsize; i++)
{
if (pt == (PolyObject*)IoEntry(i))
{
int regMask = taskData->GetIOFunctionRegisterMask(i);
POLYUNSIGNED props = rtsProperties(taskData, i);
return taskData->saveVec.push(TAGGED(regMask | props));
}
}
raise_exception_string(taskData, EXC_Fail, "Io pointer not found");
}
else
{
/* We may have a pointer to the code or a pointer to
a closure. If it's a closure we have to find the
code. */
if (! pt->IsCodeObject() && ! pt->IsByteObject())
pt = pt->Get(0).AsObjPtr();
/* Should now be a code object. */
if (pt->IsCodeObject())
{
/* Compiled code. This is the second constant in the
constant area. */
PolyWord *codePt = pt->ConstPtrForCode();
PolyWord mask = codePt[1];
// A real mask will be an integer.
if (IS_INT(mask)) return SAVE(mask);
else raise_exception_string(taskData, EXC_Fail, "Invalid mask");
}
else raise_exception_string(taskData, EXC_Fail, "Not a code pointer");
}
}
case 104: return Make_arbitrary_precision(taskData, POLY_version_number);
case 105: /* Get the name of the function. */
{
PolyObject *pt = DEREFWORDHANDLE(args);
if (gMem.IsIOPointer(pt))
{
/* IO area. */
int i;
for (i=0; i < POLY_SYS_vecsize; i++)
{
if (pt == (PolyObject*)IoEntry(i))
{
char buff[8];
sprintf(buff, "RTS%d", i);
return SAVE(C_string_to_Poly(taskData, buff));
}
}
raise_syscall(taskData, "Io pointer not found", 0);
}
else if (pt->IsCodeObject()) /* Should now be a code object. */
{
/* Compiled code. This is the first constant in the constant area. */
PolyWord *codePt = pt->ConstPtrForCode();
PolyWord name = codePt[0];
/* May be zero indicating an anonymous segment - return null string. */
if (name == PolyWord::FromUnsigned(0))
return SAVE(C_string_to_Poly(taskData, ""));
else return SAVE(name);
}
else raise_syscall(taskData, "Not a code pointer", 0);
}
default:
{
char msg[100];
sprintf(msg, "Unknown poly-specific function: %d", c);
raise_exception_string(taskData, EXC_Fail, msg);
return 0;
}
}
}