static TYPE typeTested( // TEST FOR TYPE PAST MODIFIERS, REFERENCE TYPE type, // - input type type_id id ) // - requested id { if( type != NULL ) { type = TypeReferenced( type ); type = TypedefModifierRemoveOnly( type ); if( id != type->id ) { type = NULL; } } return( type ); }
boolean NodeConvertArgument( // CONVERT AN ARGUMENT VALUE PTREE *a_expr, // - addr( argument value ) TYPE proto ) // - prototype type { boolean retn; // - return: TRUE ==> conversion ok if( NULL != ArrayType( proto ) ) { proto = PointerTypeForArray( proto ); } else { // ( const int ) prototype should be ( int ) at this point proto = TypedefModifierRemoveOnly( proto ); } *a_expr = CastImplicit( *a_expr, proto, CNV_FUNC_ARG, &diagArgConv ); retn = (*a_expr)->op != PT_ERROR; return retn; }
static PTREE castConstant( PTREE expr, TYPE type, bool *happened ) { TYPE type_final; *happened = false; if( notFoldable( expr ) ) { return( expr ); } type_final = TypedefModifierRemoveOnly( type ); type = TypedefModifierRemove( type_final ); switch( expr->op ) { case PT_INT_CONSTANT: expr = CastIntConstant( expr, type, happened ); expr->type = type_final; break; case PT_FLOATING_CONSTANT: expr = castFloatingConstant( expr, type, happened ); expr->type = type_final; break; } return( expr ); }
static TYPE canonicalBaseType( // GET CANONICAL BASE TYPE TYPE type ) // - type { return TypedefModifierRemoveOnly( type ); }
void DumpObjectModelEnum( // DUMP OBJECT MODEL: ENUM TYPE type ) // - enum type { SYMBOL sym; // - current symbol TYPE base; // - base type VBUF buffer; // - printing buffer char buf[16]; // - buffer int numb; // - a numeric value const char *name; // - name to be printed bool sign; // - TRUE ==> signed enum unsigned mask; // - used to mask to true size unsigned val; // - value as unsigned CompFlags.log_note_msgs = TRUE; base = TypedefModifierRemoveOnly( type ); sym = base->u.t.sym; VbufInit( &buffer ); VbufConcStr( &buffer, "Object Model for: " ); if( NULL == sym->name->name || NameStr( sym->name->name )[0] == '.' ) { VbufConcStr( &buffer, "anonymous enum type" ); } else { VbufConcStr( &buffer, NameStr( sym->name->name ) ); } switch( TypedefModifierRemove( base->of ) -> id ) { case TYP_CHAR : case TYP_UCHAR : name = "unsigned char"; sign = FALSE; break; case TYP_SCHAR : name = "signed char"; sign = TRUE; break; case TYP_SSHORT : name = "signed short"; sign = TRUE; break; case TYP_USHORT : name = "unsigned short"; sign = FALSE; break; case TYP_SINT : name = "signed int"; sign = TRUE; break; case TYP_UINT : name = "unsigned int"; sign = FALSE; break; case TYP_SLONG : name = "signed long"; sign = TRUE; break; case TYP_ULONG : name = "unsigned long"; sign = FALSE; break; case TYP_SLONG64 : name = "__int64"; sign = TRUE; break; case TYP_ULONG64 : name = "unsigned __int64"; sign = FALSE; break; DbgDefault( "DumpObjectModelEnum -- bad underlying type" ); } VbufConcStr( &buffer, ", base type is " ); VbufConcStr( &buffer, name ); vbufWrite( &buffer ); mask = CgMemorySize( base ); if( mask == sizeof( unsigned ) ) { mask = -1; } else { mask = ( 1 << ( mask * 8 ) ) - 1; } for( ; ; ) { sym = sym->thread; if( ! SymIsEnumeration( sym ) ) break; VbufRewind( &buffer ); VbufConcStr( &buffer, " " ); VbufConcStr( &buffer, NameStr( sym->name->name ) ); VbufConcStr( &buffer, " = " ); numb = sym->u.sval; if( sign && numb < 0 ) { VbufConcChr( &buffer, '-' ); VbufConcDecimal( &buffer, -numb ); } else { VbufConcDecimal( &buffer, numb ); } val = mask & numb; if( val > 10 ) { itoa( val, buf, 16 ); VbufConcStr( &buffer, " /0x" ); VbufConcStr( &buffer, buf ); } vbufWrite( &buffer ); } VbufFree( &buffer ); CompFlags.log_note_msgs = FALSE; }