Merge uncommitted changes from old SVN copy

This commit is contained in:
Michael Hansen
2010-09-03 21:50:35 -07:00
parent b45c30cc59
commit 7ffa2562c3
4 changed files with 109 additions and 25 deletions

View File

@@ -5,6 +5,48 @@
#include "bytecode.h"
#include "numeric.h"
#ifdef WIN32
# define PATHSEP '\\'
#else
# define PATHSEP '/'
#endif
static const char* flag_names[] = {
"CO_OPTIMIZED", "CO_NEWLOCALS", "CO_VARARGS", "CO_VARKEYWORDS",
"CO_NESTED", "CO_GENERATOR", "CO_NOFREE", "<0x80>", "<0x100>", "<0x200>",
"<0x400>", "<0x800>", "CO_GENERATOR_ALLOWED", "CO_FUTURE_DIVISION",
"CO_FUTURE_ABSOLUTE_IMPORT", "CO_FUTURE_WITH_STATEMENT",
"CO_FUTURE_PRINT_FUNCTION", "CO_FUTURE_UNICODE_LITERALS",
"CO_FUTURE_BARRY_AS_BDFL", "<0x80000>", "<0x100000>", "<0x200000>",
"<0x400000>", "<0x800000>", "<0x1000000>", "<0x2000000>", "<0x4000000>",
"<0x8000000>", "<0x10000000>", "<0x20000000>", "<0x40000000>",
"<0x80000000>"
};
static void print_coflags(unsigned long flags)
{
if (flags == 0) {
printf("\n");
return;
}
printf(" (");
unsigned long f = 1;
int k = 0;
while (k < 32) {
if ((flags & f) != 0) {
flags &= ~f;
if (flags == 0)
printf("%s", flag_names[k]);
else
printf("%s | ", flag_names[k]);
}
++k;
f <<= 1;
}
printf(")\n");
}
static void ivprintf(int indent, const char* fmt, va_list varargs)
{
for (int i=0; i<indent; i++)
@@ -33,7 +75,8 @@ void output_object(PycRef<PycObject> obj, PycModule* mod, int indent)
iprintf(indent + 1, "Arg Count: %d\n", codeObj->argCount());
iprintf(indent + 1, "Locals: %d\n", codeObj->numLocals());
iprintf(indent + 1, "Stack Size: %d\n", codeObj->stackSize());
iprintf(indent + 1, "Flags: 0x%08X\n", codeObj->flags());
iprintf(indent + 1, "Flags: 0x%08X", codeObj->flags());
print_coflags(codeObj->flags());
if (codeObj->names() != Pyc_NULL) {
iprintf(indent + 1, "[Names]\n");
@@ -154,12 +197,6 @@ void output_object(PycRef<PycObject> obj, PycModule* mod, int indent)
}
}
#ifdef WIN32
# define PATHSEP '\\'
#else
# define PATHSEP '/'
#endif
int main(int argc, char* argv[])
{
if (argc < 2) {