PTREE NodeMakeCall( // FABRICATE A FUNCTION CALL EXPRESSION SYMBOL proc, // - procedure TYPE type, // - return type PTREE args ) // - arguments { DbgVerify( (PointerTypeEquivalent( type ) == NULL) == (PointerTypeEquivalent( SymFuncReturnType( proc ) ) == NULL) , "NodeMakeCall -- return type mismatch" ); return makeCall( NodeMakeCallee( proc ), type, args, TRUE ); }
PTREE RunTimeCall( // GENERATE A RUN-TIME CALL PARSE SUBTREE PTREE expr, // - expression for operands TYPE type, // - type for function return RTF code ) // - code for function { SYMBOL func; func = RunTimeCallSymbol( code ); DbgVerify( (PointerTypeEquivalent( type ) == NULL) == (PointerTypeEquivalent( SymFuncReturnType( func ) ) == NULL) , "RunTimeCall -- return type mismatch" ); return NodeMakeCall( func, type, expr ); }
static TYPE canonicalPtrType( // GET CANONICAL PTR TYPE TYPE type ) // - type { TYPE test; // - used to test type test = PointerTypeEquivalent( type ); if( test == NULL ) { type = canonicalBaseType( type ); } else if( FunctionDeclarationType( test ) ) { type = MakePointerTo( canonicalBaseType( test ) ); } else { type = MakePointerTo( canonicalBaseType( test->of ) ); } return type; }
bool PointerToFuncEquivalent( // TEST IF EQUIVALENT TO PTR(FUNCTION) TYPE type ) { bool ok; // - return: true ==> equiv. to ptr to funct. type_flag not_used; ok = false; type = TypedefModifierRemove( type ); if( type->id == TYP_FUNCTION ) { ok = true; } else if( PointerTypeEquivalent( type ) ) { type = TypePointedAt( type, ¬_used ); if( type->id == TYP_FUNCTION ) { ok = true; } } return( ok ); }
static void infMsgType( // DISPLAY INFORMATION FOR A CONVERSION TYPE MSG_NUM msg_num, // - message number TYPE type ) // - TYPE in error { TYPE cl_type; // - type, when class or ref to class InfMsgPtr( msg_num, type ); cl_type = ClassTypeForType( type ); if( cl_type != NULL && !TypeDefined( cl_type ) ) { InfMsgPtr( INF_CLASS_NOT_DEFINED, cl_type ); } else { TYPE ptr_type = PointerTypeEquivalent( type ); if( NULL != ptr_type ) { type_flag not_used; cl_type = StructType( TypePointedAt( type, ¬_used ) ); if( NULL != cl_type && !TypeDefined( cl_type ) ) { InfMsgPtr( INF_CLASS_NOT_DEFINED, cl_type ); } } } }
CNV_RETN CgTypeTruncation( // GET CNV_... FOR TRUNCATION TYPE tgt, // - target type TYPE src ) // - source type { CNV_RETN retn; // - CNV_OK or CNV_OK_TRUNC type_flag src_flags; // - flags for pointed source type type_flag tgt_flags; // - flags for pointed target type TYPE umod; // - unmodified type for item TYPE ptr_type; // - pointer type umod = TypePointedAt( tgt, &tgt_flags ); if( ( umod != NULL ) && ( tgt_flags & ( TF1_BASED | TF1_FAR16 ) ) ) { retn = CNV_OK; } else { umod = TypePointedAt( src, &src_flags ); if( ( umod != NULL ) && ( src_flags & ( TF1_BASED | TF1_FAR16 ) ) ) { src = TypeConvertFromPcPtr( src ); } if( cgTypeTruncSize( tgt ) < cgTypeTruncSize( src ) ) { retn = CNV_OK_TRUNC; if( tgt_flags & TF1_NEAR ) { if( src_flags & (TF1_FAR|TF1_HUGE) ) { ptr_type = PointerTypeEquivalent( src ); if( ptr_type->id == TYP_POINTER ) { /* far to near cnv of a ptr/ref */ if( ( ptr_type->flag & TF1_FAR_BUT_NEAR ) != 0 ) { /* but the far is really near */ retn = CNV_OK; } } } } } else { retn = CNV_OK; } } return( retn ); }
THROBJ ThrowCategory( // GET THROW-OBJECT CATEGORY FOR A TYPE TYPE type ) // - type { TYPE cltype; // - class type or NULL THROBJ retn; // - category of object if( type == NULL ) { retn = THROBJ_ANYTHING; } else if( NULL != FunctionDeclarationType( type ) ) { retn = THROBJ_PTR_FUN; } else if( NULL != TypeReference( type ) ) { retn = THROBJ_REFERENCE; } else if( NULL != (cltype = StructType( type ) ) ) { if( cltype->u.c.info->last_vbase == 0 ) { retn = THROBJ_CLASS; } else { retn = THROBJ_CLASS_VIRT; } } else { type = PointerTypeEquivalent( type ); if( type == NULL ) { retn = THROBJ_SCALAR; } else if( StructType( type->of ) ) { retn = THROBJ_PTR_CLASS; } else { type = TypedefModifierRemove( type->of ); if( type->id == TYP_VOID ) { retn = THROBJ_VOID_STAR; } else if( type->id == TYP_FUNCTION ) { retn = THROBJ_PTR_FUN; } else { retn = THROBJ_PTR_SCALAR; } } } return retn; }