void pass2( void ) { memory_check(); process_section_list(); allocate(); update_linker_information(); output_object(); if( mflag ) memory_map(); }
int main(int argc, char* argv[]) { if (argc < 2) { fprintf(stderr, "No input file specified\n"); return 1; } PycModule mod; mod.loadFromFile(argv[1]); const char* dispname = strrchr(argv[1], PATHSEP); dispname = (dispname == NULL) ? argv[1] : dispname + 1; fprintf(pyc_output, "%s (Python %d.%d%s)\n", dispname, mod.majorVer(), mod.minorVer(), (mod.majorVer() < 3 && mod.isUnicode()) ? " -U" : ""); output_object(mod.code().cast<PycObject>(), &mod, 0); return 0; }
static bool output_value(uint8_t *source, uint8_t *sourcelimit, uint8_t typecode, dynbuffer_t *dest) { uint8_t subtype; /* switch on type */ switch (typecode) { case JSONBINARY_TYPE_OBJECT: return output_object(source, sourcelimit, dest); case JSONBINARY_TYPE_ARRAY: return output_array(source, sourcelimit, dest); case JSONBINARY_TYPE_STRING: dynbuffer_append_byte(dest, '"'); json_escape_string(dest, source, sourcelimit-source, true, '"'); dynbuffer_append_byte(dest, '"'); break; case JSONBINARY_TYPE_NUMBER: dynbuffer_append(dest, source, sourcelimit-source); break; case JSONBINARY_TYPE_SS: if (source>=sourcelimit) return false; subtype=*source; switch (subtype) { case JSONBINARY_SS_DATA_FALSE: dynbuffer_append(dest, "false", 5); break; case JSONBINARY_SS_DATA_TRUE: dynbuffer_append(dest, "true", 4); break; case JSONBINARY_SS_DATA_NULL: dynbuffer_append(dest, "null", 4); break; case JSONBINARY_SS_DATA_UNDEFINED: dynbuffer_append(dest, "undefined", 9); break; default: return false; } break; } return true; }
void output_BLOCK_HEADER(Dwg_Object_Ref* ref) { Dwg_Object* obj; Dwg_Object_BLOCK_HEADER* hdr; if (!ref) { fprintf(stderr, "Found null object reference. Could not output an SVG symbol for this BLOCK_HEADER\n"); return; } if (!ref->obj) { fprintf(stderr, "Found null ref->obj\n"); return; } /* TODO: Review. (This check avoids a segfault, but it is still unclear whether or not the condition is valid.) */ if (!ref->obj->tio.object) { fprintf(stderr, "Found null ref->obj->tio.object\n"); return; } hdr = ref->obj->tio.object->tio.BLOCK_HEADER; printf( "\t<g id=\"symbol-%lu\" >\n\t\t<!-- %s -->\n", ref->absolute_ref, hdr->entry_name); obj = get_first_owned_object(ref->obj, hdr); while(obj) { output_object(obj); obj = get_next_owned_object(ref->obj, obj, hdr); } printf("\t</g>\n"); }
void output (Log& log) const { if (action.get ()) output_object (action, "do", log); }
void output (Log& log) const { output_object (condition, "condition", log); }
void output_object(PycRef<PycObject> obj, PycModule* mod, int indent) { switch (obj->type()) { case PycObject::TYPE_CODE: case PycObject::TYPE_CODE2: { PycRef<PycCode> codeObj = obj.cast<PycCode>(); iprintf(indent, "[Code]\n"); iprintf(indent + 1, "File Name: %s\n", codeObj->fileName()->value()); iprintf(indent + 1, "Object Name: %s\n", codeObj->name()->value()); iprintf(indent + 1, "Arg Count: %d\n", codeObj->argCount()); if (mod->majorVer() >= 3) iprintf(indent + 1, "KW Only Arg Count: %d\n", codeObj->kwOnlyArgCount()); iprintf(indent + 1, "Locals: %d\n", codeObj->numLocals()); iprintf(indent + 1, "Stack Size: %d\n", codeObj->stackSize()); iprintf(indent + 1, "Flags: 0x%08X", codeObj->flags()); print_coflags(codeObj->flags()); if (codeObj->names() != Pyc_NULL) { iprintf(indent + 1, "[Names]\n"); for (int i=0; i<codeObj->names()->size(); i++) output_object(codeObj->names()->get(i), mod, indent + 2); } if (codeObj->varNames() != Pyc_NULL) { iprintf(indent + 1, "[Var Names]\n"); for (int i=0; i<codeObj->varNames()->size(); i++) output_object(codeObj->varNames()->get(i), mod, indent + 2); } if (codeObj->freeVars() != Pyc_NULL) { iprintf(indent + 1, "[Free Vars]\n"); for (int i=0; i<codeObj->freeVars()->size(); i++) output_object(codeObj->freeVars()->get(i), mod, indent + 2); } if (codeObj->cellVars() != Pyc_NULL) { iprintf(indent + 1, "[Cell Vars]\n"); for (int i=0; i<codeObj->cellVars()->size(); i++) output_object(codeObj->cellVars()->get(i), mod, indent + 2); } if (codeObj->consts() != Pyc_NULL) { iprintf(indent + 1, "[Constants]\n"); for (int i=0; i<codeObj->consts()->size(); i++) output_object(codeObj->consts()->get(i), mod, indent + 2); } iprintf(indent + 1, "[Disassembly]\n"); bc_disasm(codeObj, mod, indent + 2); } break; case PycObject::TYPE_STRING: iprintf(indent, ""); OutputString(obj.cast<PycString>(), (mod->majorVer() == 3) ? 'b' : 0); fprintf(pyc_output, "\n"); break; case PycObject::TYPE_UNICODE: iprintf(indent, ""); OutputString(obj.cast<PycString>(), (mod->majorVer() == 3) ? 0 : 'u'); fprintf(pyc_output, "\n"); break; case PycObject::TYPE_STRINGREF: case PycObject::TYPE_INTERNED: case PycObject::TYPE_ASCII: case PycObject::TYPE_ASCII_INTERNED: case PycObject::TYPE_SHORT_ASCII: case PycObject::TYPE_SHORT_ASCII_INTERNED: iprintf(indent, ""); OutputString(obj.cast<PycString>(), 0); fprintf(pyc_output, "\n"); break; case PycObject::TYPE_TUPLE: case PycObject::TYPE_SMALL_TUPLE: { iprintf(indent, "(\n"); PycTuple::value_t values = obj.cast<PycTuple>()->values(); for (PycTuple::value_t::const_iterator i = values.begin(); i != values.end(); i++) output_object(*i, mod, indent + 1); iprintf(indent, ")\n"); } break; case PycObject::TYPE_LIST: { iprintf(indent, "[\n"); PycList::value_t values = obj.cast<PycList>()->values(); for (PycList::value_t::const_iterator i = values.begin(); i != values.end(); i++) output_object(*i, mod, indent + 1); iprintf(indent, "]\n"); } break; case PycObject::TYPE_DICT: { iprintf(indent, "{\n"); PycDict::key_t keys = obj.cast<PycDict>()->keys(); PycDict::value_t values = obj.cast<PycDict>()->values(); PycDict::key_t::const_iterator ki = keys.begin(); PycDict::value_t::const_iterator vi = values.begin(); while (ki != keys.end()) { output_object(*ki, mod, indent + 1); output_object(*vi, mod, indent + 2); ++ki, ++vi; } iprintf(indent, "}\n"); } break; case PycObject::TYPE_SET: { iprintf(indent, "{\n"); PycSet::value_t values = obj.cast<PycSet>()->values(); for (PycSet::value_t::const_iterator i = values.begin(); i != values.end(); i++) output_object(*i, mod, indent + 1); iprintf(indent, "}\n"); } break; case PycObject::TYPE_NONE: iprintf(indent, "None\n"); break; case PycObject::TYPE_FALSE: iprintf(indent, "False\n"); break; case PycObject::TYPE_TRUE: iprintf(indent, "True\n"); break; case PycObject::TYPE_ELLIPSIS: iprintf(indent, "...\n"); break; case PycObject::TYPE_INT: iprintf(indent, "%d\n", obj.cast<PycInt>()->value()); break; case PycObject::TYPE_LONG: iprintf(indent, "%s\n", obj.cast<PycLong>()->repr().c_str()); break; case PycObject::TYPE_FLOAT: iprintf(indent, "%s\n", obj.cast<PycFloat>()->value()); break; case PycObject::TYPE_COMPLEX: iprintf(indent, "(%s+%sj)\n", obj.cast<PycComplex>()->value(), obj.cast<PycComplex>()->imag()); break; case PycObject::TYPE_BINARY_FLOAT: iprintf(indent, "%g\n", obj.cast<PycCFloat>()->value()); break; case PycObject::TYPE_BINARY_COMPLEX: iprintf(indent, "(%g+%gj)\n", obj.cast<PycCComplex>()->value(), obj.cast<PycCComplex>()->imag()); break; default: iprintf(indent, "<TYPE: %d>\n", obj->type()); } }
int main(int argc, char *argv[]) { static ML mst[NPTS]; /* mst of at most NPTS points */ object_struct *obj; lines_struct *lines; Point p; FILE *fp; VIO_Status stat; VIO_progress_struct progress; long int i, count, total; if (argc!=3) { print("usage: %s in_mst output.obj\n", argv[0]); exit(EXIT_FAILURE); } stat = open_file( argv[1] , READ_FILE, ASCII_FORMAT, &fp); if (stat != OK) { print("error: cannot open %s for input.\n", argv[1]); exit(EXIT_FAILURE); } count = 0L; total = 0L; while( fscanf( fp, "%d%d%f%f%f%f", &mst[total].index, &mst[total].parent_index, &mst[total].xyz[0], &mst[total].xyz[1], &mst[total].xyz[2], &mst[total].err) != EOF ) { ++total; if ( total >= NPTS ) { printf("\ntoo much data!"); fclose( fp ); exit( 0 ); } } if ( close_file( fp ) != OK ){ print("error: cannot close %s.\n", argv[1]); exit(EXIT_FAILURE); } stat = open_file( argv[2] , WRITE_FILE, BINARY_FORMAT, &fp); if (stat != OK) { print("error: cannot open %s for output.\n", argv[2]); exit(EXIT_FAILURE); } obj = create_object(LINES); lines = get_lines_ptr(obj); initialize_lines(lines, YELLOW); initialize_progress_report(&progress, FALSE, total+1, "Building vectors"); for(i=1; i<total; i++) { start_new_line(lines); count = mst[i].index; fill_Point(p, mst[count].xyz[0],mst[count].xyz[1],mst[count].xyz[2]); add_point_to_line(lines, &p); count = mst[i].parent_index; fill_Point(p, mst[count].xyz[0],mst[count].xyz[1],mst[count].xyz[2]); add_point_to_line(lines, &p); update_progress_report( &progress, i ); } terminate_progress_report(&progress); print ("Saving data...\n"); output_object(fp, ASCII_FORMAT, obj); close_file(fp); delete_object(obj); exit(EXIT_SUCCESS); }