コード例 #1
0
ファイル: dmpobjmd.c プロジェクト: jossk/open-watcom-v2
static DUMP_INFO* dumpStruct(   // DUMP A STRUCTURE
    TYPE type,                  // - structure type
    DUMP_INFO* di,              // - dump information
    char* title,                // - title for dump
    ds_control control )        // - control word
{
    CLASSINFO* info;            // - class information
    NAME *parent;               // - where parent ptr is stored

    control = control;
    type = StructType( type );
    info = type->u.c.info;
    parent = VstkPush( &di->stack );
    *parent = info->name;
    di = dumpTitle( di, title, NameStr( info->name ) );
    if( type != di->original ) {
        di = bufferInit( di );
        di = bufferStr( di, "embedded size: " );
        di = bufferNmb( di, info->vsize );
        di = bufferWrite( di );
        di = dumpOffset( di );
        di = dumpParentage( di );
    } else {
        di = bufferInit( di );
        di = bufferStr( di, "size: " );
        di = bufferNmb( di, info->size );
        di = bufferWrite( di );
    }
    if( info->has_vbptr ) {
        di = dumpDataMemb( di
                           , "[virtual"
                           , "base pointer]"
                           , info->vb_offset + di->offset
                           , CgMemorySize( TypePtrToVoid() ) );
    }
    if( info->has_vfptr ) {
        di = dumpDataMemb( di
                           , "[virtual"
                           , "functions pointer]"
                           , info->vf_offset + di->offset
                           , CgMemorySize( TypePtrToVoid() ) );
    }
    ScopeWalkDataMembers( type->u.c.scope, dumpMember, di );
    if( type == di->original ) {
        ScopeWalkVirtualBases( type->u.c.scope, dumpVirtual, di );
    }
    ScopeWalkDirectBases( type->u.c.scope, dumpDirect, di );
    VstkPop( &di->stack );
    return di;
}
コード例 #2
0
int main(void)
{
	FILE *fp;
	unsigned char levelBuf[READ_LEVEL_DATA_SIZE];
	unsigned char *levelData;
	int curLevel = 0;
	int readSize= 0, isGood = 1;
	unsigned long curPos = MAP_START_POSITION;
	unsigned long dspPos = curPos;
	
	if((fp = fopen(FILE_NAME, "rb")) ==NULL) {
		printf("Open file \"%s\" failed !\n", FILE_NAME);
		return 1;
	}
	
	if(fseek(fp, curPos, SEEK_SET) != 0) {
		printf("Fseek error ! @%d\n", __LINE__);
		fclose(fp);
		return 1;
	}

	dumpTitle();

	printf("var %s = [\n", DATA_VAR_NAME);	

	while(
#ifndef START_ALL_ISGOOD	
		   isGood &&
#endif
		   curLevel < MAX_LEVEL && 
	       (readSize = fread(levelBuf, sizeof(char), READ_LEVEL_DATA_SIZE, fp)) ==  READ_LEVEL_DATA_SIZE 
	){
		levelData = levelBuf;	
#ifdef START_GOOD_BYTE
		unsigned char startByte = *(levelData++);
		
		switch(startByte) {
		case START_SKIP_BYTE1:
#ifdef START_SKIP_BYTE2			
		case START_SKIP_BYTE2:
#endif			
#ifdef START_SKIP_BYTE3
		case START_SKIP_BYTE3:
#endif			
#ifdef START_SKIP_BYTE4
		case START_SKIP_BYTE4:
#endif			
			//printf("SKIP0 - %x\n", dspPos);
			break;
		case 0:	 //good if not allzero
			if(allZero(levelData)){
				//printf("SKIP1 - %x\n", dspPos);
				break;
			}
#ifdef START_ALL_ISGOOD			
		default:	
#endif		
		case START_GOOD_BYTE:
#endif	       
			if((isGood = goodLevel(levelData))) {
				//dumpLevel(++curLevel, levelData);
				//printf("%x", dspPos);
				dumpLevel4JavaScript(++curLevel, levelData);
			}
#ifdef START_GOOD_BYTE
			break;
#ifndef START_ALL_ISGOOD
		default:
			isGood = 0;
			printf("%x", dspPos);
			break;
#endif			
		}
#endif	
		dspPos += READ_LEVEL_DATA_SIZE;
	}
	printf("];\n");
	
	fclose(fp);	
}