static void recordBlkScopeIns // RECORD A BLK-SCOPE INSTRUCTION ( SCOPE scope ) // - scope for instruction { if( canWriteIc() ) { SCPINS* ins; ACTBLK* act = findActiveScope( scope ); if( NULL == act ) { act = RingCarveAlloc( carve_blk_scope, &ring_active_blks ); act->scope = scope; act->ins = NULL; } ins = RingCarveAlloc( carve_scope_ins, &act->ins ); ins->scope_ins = CgioLastWrite( virtual_file ); } }
DTREG_OBJ* DtregObj( // LOCATE RW_DTREG_OBJ SYMBOL FN_CTL* fctl ) // - current function information { DTREG_OBJ* curr; // - current entry DTREG_OBJ* obj; // - entry for function obj = NULL; RingIterBeg( ringDtregObj, curr ) { if( ! curr->in_use ) { obj = curr; break; } } RingIterEnd( curr ) if( obj == NULL ) { obj = RingCarveAlloc( carveDTREG_OBJ, &ringDtregObj ); obj->cg_sym = NULL; } if( ! DtmTabular( fctl ) ) { obj->sym = NULL; } else { if( obj->cg_sym == NULL ) { obj->cg_sym = CgVarRw( 3 * CgbkInfo.size_data_ptr, SC_AUTO ); AutoRelRegister( obj->cg_sym, &obj->offset ); } obj->sym = obj->cg_sym; } obj->in_use = TRUE; return obj; }
static THROW_RO *throwRoGet( // GET THROW R/O BLOCK TYPE type ) // - type being thrown { THROW_RO *srch; // - search R/O block for symbol THROW_RO *ro; // - R/O block for symbol SYMBOL sym; // - symbol for throw object THROW_CNV_CTL ctl; // - control area target_offset_t offset; // - offset ( not used ) type = TypeCanonicalThr( type ); ro = NULL; RingIterBeg( ring_throw_ro, srch ) { if( TypesIdentical( srch->sig->type, type ) ) { ro = srch; break; } } RingIterEnd( srch ); if( ro == NULL ) { ro = RingCarveAlloc( carveTHROW_RO, &ring_throw_ro ); ro->sig = BeTypeSignature( type ); ro->emitted = false; sym = CgVarRo( CgbkInfo.size_offset + sizeOfThrowCnv() * ThrowCnvInit( &ctl, type ), SC_PUBLIC, CppNameThrowRo( type ) ); ro->sym = sym; for( ; ; ) { type = ThrowCnvType( &ctl, &offset ); if( type == NULL ) break; BeTypeSignature( type ); } ThrowCnvFini( &ctl ); } return( ro ); }
static void vftAdd( // ADD A VFT ENTRY SYMBOL vft ) // - symbol to be added { VFTGEN* gen; // - entry for VFT gen = RingCarveAlloc( carve_gen, &vfts ); gen->sym = vft; }
static POOL_CON* allocPoolCon // ALLOCATE CONSTANT-POOL ENTRY ( POOL_CON** a_hdr ) // - addr[ ring hdr ] { POOL_CON* pool = RingCarveAlloc( carvePOOL_CON, a_hdr ); pool->free = false; pool->i64 = false; pool->flt = false; return pool; }
static void set_buffering( // SET BUFFERING FOR AN OPEN FILE FILE *fp, // - opened file size_t buf_size, // - buffer size int mode ) // - buffering mode { BUF_ALLOC* ba = RingCarveAlloc( carve_buf, &buffers ); ba->file = fp; ba->buffer = CMemAlloc( buf_size ); setvbuf( fp, ba->buffer, mode, buf_size ); }
REPO_REC_FUN* RepoFunAdd( // ADD FUNCTION TO REPOSITORY const char* name, // - function name REPO_FUN_FLAGS flags ) // - function flags { REPO_REC_FUN* frec; // - new function record frec = RingCarveAlloc( carveFunRepository, &funRepository ); frec->name = name; frec->flags = flags; return frec; }
void CgCdArgDefine( // DEFINE CDOPT VALUE unsigned value ) // - cdopt value { cg_name expr; // - expression under construction cg_type type; // - expression type cdtor_entry* cd_entry; // - cdopt entry type = CgTypeOffset(); expr = CgOffset( value ); cd_entry = RingCarveAlloc( carver_cdtors, &ring_cdtors ); cd_entry->value = value; cd_entry->handle = CallStackTopHandle(); CgExprPush( expr, type ); }
static void makeThrowCnvAccess( // MAKE A THROW CONVERSION, WITH ACCESS THROW_CNV_CTL *ctl, // - control area TYPE type, // - conversion type target_offset_t offset, // - conversion offset TYPE_SIG_ACCESS access ) // - type of access { THROW_CNV *cnv; // - conversion entry bool err_occurred; // - set to true if error occurred cnv = RingCarveAlloc( ctl->carver, &ctl->hdr ); cnv->offset = offset; cnv->sig = TypeSigFind( access, type, &ctl->err_locn, &err_occurred ); if( err_occurred ) { ctl->error_occurred = true; } }
static void queue // PLACE INSTRUCTION ON QUEUE ( CGINTEROP opcode // - opcode , void const * parm // - parm for instruction , TOKEN_LOCN const * locn ) // - location for instruction { if( cursor.src_file == locn->src_file && NULL != cursor.src_file && opcode != IC_BR_SRC_END ) { writeIns( opcode, parm, locn ); } else { PP_INS* ins = RingCarveAlloc( carvePpIns, &ins_queue ); ins->opcode = opcode; ins->parm = parm; TokenLocnAssign( ins->locn, *locn ); IfDbgToggle( browse ) { DbgStmt( printf( "queued %s %x\n ", DbgIcOpcode( opcode ), parm ) ); DbgStmt( DbgDumpTokenLocn( locn ) ); DbgStmt( printf( "\n" ) ); } } }
TYPE_SIG *TypeSigFind( // FIND TYPE SIGNATURE TYPE_SIG_ACCESS acc, // - access type TYPE type, // - type for signature TOKEN_LOCN* err_locn, // - error location for access errors bool *error_occurred ) // - to set error indication { TYPE_SIG *srch; // - signature for searching TYPE_SIG *sig; // - signature SYMBOL sym; // - symbol unsigned size; // - size of R/O data NAME typesig_name; // - name of type signature TYPE typesig_type; // - type of type signature bool err_this_time; // - true ==> we have error TYPE_SIG_ACCESS acc_ind; // - indirect access err_this_time = false; type = TypeCanonicalThr( type ); sig = NULL; RingIterBeg( type_sigs, srch ) { if( TypesSameExclude( srch->type, type, TC1_NOT_ENUM_CHAR ) ) { sig = srch; break; } } RingIterEnd( srch ); if( sig == NULL ) { THROBJ thr; // - category of object DbgVerify( 0 == ( acc & TSA_GEN ) , "TypeSigFind -- no type signature & TSA_GEN" ); sig = RingCarveAlloc( carveTYPE_SIG, &type_sigs ); sig->type = type; sig->default_ctor = NULL; sig->copy_ctor = NULL; sig->dtor = NULL; sig->sym = NULL; sig->base = NULL; sig->cgref = false; sig->cggen = false; sig->free = false; thr = ThrowCategory( type ); if( acc & TSA_INDIRECT ) { acc_ind = acc | TSA_INDIRECT_ACCESS; } else if( acc & TSA_INDIRECT_ACCESS ) { acc_ind = ( acc & ~ TSA_INDIRECT ) | TSA_INDIRECT_GEN; } else { acc_ind = acc; } size = 0; switch( thr ) { case THROBJ_PTR_SCALAR : case THROBJ_PTR_CLASS : sig->base = TypeSigFind( acc_ind & TSA_INDIRECT , TypePointedAtModified( type ) , err_locn , &err_this_time ); size = typeSigHdrSize(); break; case THROBJ_SCALAR : case THROBJ_PTR_FUN : case THROBJ_VOID_STAR : size = typeSigHdrSize() + SizeTargetSizeT(); break; case THROBJ_REFERENCE : sig->base = TypeSigFind( acc_ind , TypeReference( type ) , err_locn , &err_this_time ); break; case THROBJ_CLASS : case THROBJ_CLASS_VIRT : size = 3 * CgCodePtrSize() + CgDataPtrSize() + typeSigHdrSize(); break; case THROBJ_ANYTHING : break; default : DbgStmt( CFatal( "cgTypeSignature -- invalid throw category" ) ); } size += typeSigNameSize( thr ); if( size == 0 ) { sym = NULL; } else { // - type for TYPE SIGNATURE variable typesig_name = CppNameTypeSig( type ); sym = ScopeAlreadyExists( GetFileScope(), typesig_name ); if( sym == NULL ) { typesig_type = MakeInternalType( size ); typesig_type = MakeCompilerConstCommonData( typesig_type ); sym = SymCreateFileScope( typesig_type , SC_PUBLIC , SF_REFERENCED | SF_ADDR_TAKEN , typesig_name ); LinkageSet( sym, "C++" ); CgSegId( sym ); } } sig->sym = sym; } if( err_this_time ) { *error_occurred = true; } else { if( NULL != sig->sym ) { SegmentMarkUsed( sig->sym->segid ); } *error_occurred = false; typeSigAccess( acc, sig, err_locn, error_occurred ); } return( sig ); }