void DumpLevel(const osmscout::TypeConfigRef& typeConfig, const osmscout::StyleConfigRef& styleConfig, size_t level) { osmscout::MagnificationConverter magConverter; std::string magName; if (level>0) { std::cout << std::endl; } std::cout << " [MAG "; if (magConverter.Convert(level, magName)) { std::cout << magName << " /* " << level << " */"; } else { std::cout << level; } std::cout << "] {" << std::endl; for (const auto& type : typeConfig->GetTypes()) { DumpType(typeConfig, styleConfig, level, type); } std::cout << " }" << std::endl; }
static void DumpTypes(IDiaSession *session) { IDiaSymbol * globalScope = NULL; IDiaEnumSymbols * enumSymbols = NULL; IDiaSymbol * symbol = NULL; HRESULT hr = session->get_globalScope(&globalScope); if (FAILED(hr)) return; AddReportSepLine(); g_report.Append("Types:\n"); DWORD flags = nsfCaseInsensitive|nsfUndecoratedName; // nsNone ? hr = globalScope->findChildren(SymTagUDT, 0, flags, &enumSymbols); if (FAILED(hr)) goto Exit; ULONG celt = 0; for (;;) { hr = enumSymbols->Next(1, &symbol, &celt); if (FAILED(hr) || (celt != 1)) break; DumpType(symbol, 0); symbol->Release(); } Exit: UnkReleaseSafe(enumSymbols); UnkReleaseSafe(globalScope); }
static void DumpType(IDiaSymbol *symbol, int deep) { IDiaEnumSymbols * enumChilds = NULL; HRESULT hr; const char * nameStr = NULL; const char * type; LONG offset; ULONGLONG length; ULONG celt = 0; ULONG symtag; DWORD locType; bool typeSeen; #if 0 if (deep > 2) return; #endif if (symbol->get_symTag(&symtag) != S_OK) return; nameStr = GetTypeName(symbol); g_typesSeen.Intern(nameStr, &typeSeen); if (typeSeen) return; symbol->get_length(&length); symbol->get_offset(&offset); if (SymTagData == symtag) { if (symbol->get_locationType(&locType) != S_OK) return; // must be a symbol in optimized code // TODO: use get_offsetInUdt (http://msdn.microsoft.com/en-us/library/dd997149.aspx) ? // TODO: use get_type (http://msdn.microsoft.com/en-US/library/cwx3656b(v=vs.80).aspx) ? // TODO: see what else we can get http://msdn.microsoft.com/en-US/library/w8ae4k32(v=vs.80).aspx if (LocIsThisRel == locType) { g_report.AppendFmt("%s%s|%d\n", spaces(deep), nameStr, (int)offset); } } else if (SymTagUDT == symtag) { // TODO: why is it always "struct" even for classes? type = GetUdtType(symbol); g_report.AppendFmt("%s%s|%s|%d\n", spaces(deep), type, nameStr, (int)length); hr = symbol->findChildren(SymTagNull, NULL, nsNone, &enumChilds); if (!SUCCEEDED(hr)) return; IDiaSymbol* child; while (SUCCEEDED(enumChilds->Next(1, &child, &celt)) && (celt == 1)) { DumpType(child, deep+1); child->Release(); } enumChilds->Release(); } else { if (symbol->get_locationType(&locType) != S_OK) return; // must be a symbol in optimized code // TODO: assert? } }
void GNullRetIdx( void ) { //===================== // No alternate return. PushConst( 0 ); EmitOp( FC_ASSIGN_ALT_RET ); DumpType( FT_INTEGER, TypeSize( FT_INTEGER ) ); }
void AsgnChar( void ) { //======================== // Perform character assignment. itnode *save_cit; uint num_args; uint i; uint j; save_cit = CITNode; AdvanceITPtr(); num_args = AsgnCat(); i = SrcChar( CITNode ); j = TargChar( save_cit ); if( ( num_args == 1 ) && ( i > 0 ) && ( j > 0 ) ) { if( OptimalChSize( i ) && OptimalChSize( j ) && ( i == j ) ) { PushOpn( save_cit ); EmitOp( FC_CHAR_1_MOVE ); DumpType( MapTypes( FT_INTEGER, i ), i ); GenChar1Op( CITNode ); if( ( CITNode->opn.us & USOPN_WHAT ) == USOPN_CON ) { CITNode->sym_ptr->u.lt.flags &= ~LT_SCB_TMP_REFERENCE; } CITNode = save_cit; } else { #if ( _CPU == 386 || _CPU == 8086 ) if( j < i ) { i = j; } CITNode = save_cit; PushOpn( CITNode ); EmitOp( FC_CHAR_N_MOVE ); OutInt( i ); OutInt( j ); #else CatArgs( num_args ); CITNode = save_cit; PushOpn( CITNode ); EmitOp( FC_CAT ); OutU16( (uint_16)num_args ); #endif } } else { CatArgs( num_args ); CITNode = save_cit; PushOpn( CITNode ); EmitOp( FC_CAT ); OutU16( (uint_16)num_args ); } }
void DumpExpandedType( // DUMP EXPANDED TYPE TYPE tp ) // - type { if( tp == NULL ) { printf( "NULL type\n" ); return; } while( tp != NULL ) { DumpType( tp ); if( tp->id == TYP_FUNCTION ) { dumpFnType( tp ); } else if( tp->id == TYP_CLASS ) { dumpClassType( tp ); } tp = tp->of; } }
static void DoLoop( TYPE do_type ) { //===================================== // Generate code for DO statement or implied-DO. do_entry *doptr; uint do_size; intstar4 incr; intstar4 limit; sym_id loop_ctrl; TYPE e1_type; uint e1_size; itnode *e2_node; itnode *e3_node; bool e2_const; doptr = CSHead->cs_info.do_parms; do_size = CITNode->sym_ptr->u.ns.xt.size; doptr->do_parm = CITNode->sym_ptr; // save ptr to do variable AdvanceITPtr(); // bump past the '=' EatDoParm(); // process e1 PushOpn( CITNode ); e1_type = CITNode->typ; e1_size = CITNode->size; AdvanceITPtr(); if( ReqComma() ) { EatDoParm(); // process e2 e2_const = CITNode->opn.us == USOPN_CON; PushOpn( CITNode ); e2_node = CITNode; AdvanceITPtr(); e3_node = NULL; if( RecComma() ) { EatDoParm(); // process e3 e3_node = CITNode; if( !AError ) { if( (CITNode->opn.us == USOPN_CON) && _IsTypeInteger( do_type ) ) { incr = GetIntValue( CITNode ); doptr->incr_value = incr; doptr->increment = NULL; if( (OZOpts & OZOPT_O_FASTDO) == 0 ) { if( e2_const ) { limit = GetIntValue( e2_node ); if( NeedIncrement( limit, incr, do_type ) ) { PushOpn( CITNode ); doptr->increment = StaticAlloc( do_size, do_type ); } } else { PushOpn( CITNode ); doptr->increment = StaticAlloc( do_size, do_type ); } } } else { PushOpn( CITNode ); doptr->increment = StaticAlloc( do_size, do_type ); } AdvanceITPtr(); } } else { if( _IsTypeInteger( do_type ) ) { doptr->increment = NULL; doptr->incr_value = 1; if( (OZOpts & OZOPT_O_FASTDO) == 0 ) { if( e2_const ) { limit = GetIntValue( e2_node ); if( NeedIncrement( limit, 1, do_type ) ) { PushConst( 1 ); doptr->increment = StaticAlloc( do_size, do_type ); } } else { PushConst( 1 ); doptr->increment = StaticAlloc( do_size, do_type ); } } } else { PushConst( 1 ); doptr->increment = StaticAlloc( do_size, do_type ); } } EmitOp( FC_DO_BEGIN ); OutPtr( doptr->do_parm ); OutPtr( doptr->increment ); if( doptr->increment == NULL ) { // INTEGER do-loop with constant incr loop_ctrl = StaticAlloc( do_size, do_type ); OutConst32( doptr->incr_value ); OutPtr( loop_ctrl ); } else { if( _IsTypeInteger( do_type ) ) { loop_ctrl = StaticAlloc( do_size, do_type ); } else { loop_ctrl = StaticAlloc( sizeof( intstar4 ), FT_INTEGER ); } doptr->iteration = loop_ctrl; OutPtr( loop_ctrl ); if( e3_node == NULL ) { DumpType( FT_INTEGER, TypeSize( FT_INTEGER ) ); } else { GenType( e3_node ); } } GenType( e2_node ); DumpType( e1_type, e1_size ); OutU16( CSHead->branch ); OutU16( CSHead->bottom ); } }
void RelOp( TYPE typ1, TYPE typ2, OPTR optr ) { //================================================ // Generate code for a relational operator. bool flip; bool associative; bool char_1_cmp; uint i; uint j; OPR opr_code; FCODE op_code; optr = optr; // must check for "flip" before we call "CharLength" since they may // call "PushOpn" flip = FALSE; if( ( ( CITNode->opn.us & USOPN_WHERE ) == USOPN_SAFE ) && ( ( CITNode->link->opn.us & USOPN_WHERE ) != USOPN_SAFE ) ) { flip = TRUE; } // must do "CITNode->link" first to get operands in the right order i = CharLength( CITNode->link ); j = CharLength( CITNode ); opr_code = CITNode->link->opr; if( ( opr_code == OPR_EQ ) || ( opr_code == OPR_NE ) ) { char_1_cmp = OptimalChSize( i ) && OptimalChSize( j ) && ( i == j ); associative = TRUE; } else { char_1_cmp = (i == 1 ) && ( j == 1 ); associative = FALSE; } PushOpn( CITNode->link ); PushOpn( CITNode ); op_code = opr_code - OPR_FIRST_RELOP; if( TypeCmplx( typ1 ) && TypeCmplx( typ2 ) ) { op_code += FC_CC_RELOPS; } else if( TypeCmplx( typ1 ) ) { if( flip ) { op_code += FC_XC_RELOPS; } else { op_code += FC_CX_RELOPS; } } else if( TypeCmplx( typ2 ) ) { if( flip ) { op_code += FC_CX_RELOPS; } else { op_code += FC_XC_RELOPS; } } else { if( flip && !associative ) { EmitOp( FC_FLIP ); } if( typ1 == TY_CHAR ) { if( char_1_cmp ) { op_code += FC_CHAR_1_RELOPS; } else { op_code += FC_CHAR_RELOPS; } } else { op_code += FC_RELOPS; } } EmitOp( op_code ); if( char_1_cmp ) { if( associative ) { DumpType( MapTypes( TY_INTEGER, i ), i ); } else { // Assert: comparing CHARACTER*1 with LT, LE, GT, or GE // Consider: CHARACTER A/'a'/ // IF( A .lt. CHAR(159) ) PRINT *, 'OK' // we must generate an unsigned comparison DumpType( MapTypes( TY_LOGICAL, i ), i ); } if( flip && associative ) { GenChar1Op( CITNode->link ); GenChar1Op( CITNode ); } else { GenChar1Op( CITNode ); GenChar1Op( CITNode->link ); } } else if( typ1 != TY_CHAR ) { if( flip && associative ) { GenTypes( CITNode->link, CITNode ); } else { GenTypes( CITNode, CITNode->link ); } } }