void CgAssign( // EMIT AN ASSIGNMENT cg_name lhs, // - lhs argument cg_name rhs, // - rhs argument cg_type type ) // - type for assignment { CgDone( CGLVAssign( lhs, rhs, type ), TY_POINTER ); }
void CgExprDtored( // DTOR CG EXPRESSION cg_name expr, // - expression cg_type type, // - expression type DGRP_FLAGS pop_type, // - type of popping destruction FN_CTL* fctl ) // - function control { #if 0 cg_type type; // - expression type switch( CgExprStackSize() ) { case 0 : break; case 1 : { boolean temp_dtoring = fctl->temp_dtoring; SYMBOL temp = getExprTempSym( &type, fctl, pop_type ); if( temp_dtoring ) { if( fctl->ctor_test ) { pop_type |= DGRP_CTOR; } CgDestructExprTemps( pop_type, fctl ); if( NULL != temp ) { CgExprPush( CgFetchSym( temp ), type ); } } } break; DbgDefault( "CgExprDtored -- too many temps" ); } #else SYMBOL temp; // - NULL or copied temp DbgVerify( 0 == CgExprStackSize(), "CgExprDtored -- more than one expr" ); if( expr != NULL ) { if( pop_type & DGRP_DONE ) { CGDone( expr ); temp = NULL; } else if( pop_type & DGRP_TRASH ) { CGTrash( expr ); temp = NULL; } else if( fctl->temp_dtoring ) { temp = CgVarTempTyped( type ); CGDone( CGLVAssign( CgSymbol( temp ), expr, type ) ); } else { CgExprPush( expr, type ); temp = NULL; } if( fctl->temp_dtoring ) { fctl->temp_dtoring = FALSE; if( fctl->ctor_test ) { pop_type |= DGRP_CTOR; } CgDestructExprTemps( pop_type, fctl ); if( NULL != temp ) { CgExprPush( CgFetchSym( temp ), type ); } } } #endif }
cg_name CgAssignStateVar( // ASSIGN STATE-VAR VALUE SYMBOL blk, // - R/W Block SE* se, // - state entry target_offset_t offset ) // - offset of state variable { return CGLVAssign( CgSymbolPlusOffset( blk, offset ) , CgOffset( SeStateVar( se ) ) , CgTypeOffset() ); }
cg_name CgSaveAsTemp( // SAVE INTO A TEMPORARY temp_handle* a_hand, // - addr[ temp handle ] cg_name expr, // - expression to be saved cg_type type ) // - and its type { temp_handle handle; // - allocated temporary handle handle = CGTemp( type ); *a_hand = handle; return CGLVAssign( CGTempName( handle, type ), expr, type ); }
void FCChar1Move( void ) { //===================== // Perform single character assignment. cg_type typ; cg_name dest; typ = GetType( GetU16() ); dest = XPop(); XPush( CGLVAssign( SCBPointer( dest ), GetChOp( typ ), typ ) ); }
void MakeSCB( sym_id scb, cg_name len ) { //========================================== // Make an SCB. CGTrash( CGAssign( SCBLenAddr( CGFEName( scb, TY_CHAR ) ), len, TY_INTEGER ) ); // assumption is that the pointer in the SCB is the first field in // the SCB so that when we push the cg_name returned by CGAssign() // it is a pointer to the SCB XPush( CGLVAssign( SCBPtrAddr( CGFEName( scb, TY_CHAR ) ), XPop(), TY_POINTER ) ); // Don't do it the following way: // CGTrash( CGAssign( SCBPtrAddr( CGFEName( scb, TY_CHAR ) ), XPop(), TY_POINTER ) ); // XPush( CGFEName( scb, TY_CHAR ) ); }
SE* DtorForDelBeg( // DTORING AREA TO BE DELETED: start FN_CTL* fctl, // - function information target_size_t elem_size, // - size of one element in area unsigned dlt1, // - entry type when one arg unsigned dlt2, // - entry type when two args SYMBOL op_del ) // - operator delete to be used { SE* se_dlt; // - entry allocated SYMBOL var; // - var containing address of delete area cg_name top_expr; // - top expression cg_type top_type; // - type of top expression cg_name emit; // - expression for state update patch_handle patch; // - patch handle for area if( DtmTabular( fctl ) ) { if( 2 == SymFuncArgList( op_del )->num_args ) { se_dlt = SeAlloc( dlt2 ); se_dlt->del_2_array.size = elem_size; } else { se_dlt = SeAlloc( dlt1 ); } se_dlt->del_1_array.op_del = op_del; var = CgVarRw( TY_POINTER, SC_AUTO ); if( se_dlt->base.gen ) { AutoRelRegister( var, &se_dlt->del_1_array.offset ); } top_expr = CgExprPopType( &top_type ); top_expr = CGLVAssign( CgSymbol( var ), top_expr, top_type ); top_expr = CgFetchType( top_expr, top_type ); emit = emitPatch( &patch ); top_expr = emitPatchCallBack( top_expr , emit , top_type , &patchForDtorDelBeg , patch , se_dlt ); CgExprPush( top_expr, top_type ); DbgSetState( "patchForDtorDelBeg", se_dlt ); } else { se_dlt = NULL; } return se_dlt; }
static SYMBOL getExprTempSym( // EMIT CGDone, CGTrash, OR COPY TO TEMP cg_name expr, // - expression cg_type type, // - type of expression FN_CTL* fctl, // - function control DGRP_FLAGS pop_type ) // - type of popping destruction { SYMBOL temp; // - NULL or copied temp if( pop_type & DGRP_DONE ) { CGDone( expr ); temp = NULL; } else if( pop_type & DGRP_TRASH ) { CGTrash( expr ); temp = NULL; } else if( fctl->temp_dtoring ) { temp = CgVarTemp( BETypeLength( type ) ); CGDone( CGLVAssign( CgSymbol( temp ), expr, type ) ); } else { temp = NULL; } fctl->temp_dtoring = FALSE; return temp; }
void FCSubString( void ) { //===================== // Do substring operation. sym_id char_var; sym_id dest; cg_name src; cg_name first_1; cg_name first_2; cg_name last; unsigned_16 typ_info; cg_name len; cg_name ptr; call_handle call; char_var = GetPtr(); typ_info = GetU16(); src = XPop(); first_1 = XPopValue( GetType1( typ_info ) ); if( char_var == NULL ) { // i.e. chr(i:i) len = CGInteger( GetInt(), TY_INTEGER ); if( Options & OPT_BOUNDS ) { CloneCGName( first_1, &first_1, &last ); last = CGBinary( O_PLUS, last, len, TY_INTEGER ); last = CGBinary( O_MINUS, last, CGInteger( 1, TY_INTEGER ), TY_INTEGER ); } } else { last = XPop(); if( last == NULL ) { if( char_var->ns.xt.size == 0 ) { last = CharItemLen( char_var ); } else { last = CGInteger( char_var->ns.xt.size, TY_INTEGER ); } } else { XPush( last ); last = XPopValue( GetType2( typ_info ) ); } if( !( Options & OPT_BOUNDS ) ) { CloneCGName( first_1, &first_1, &first_2 ); len = CGBinary( O_MINUS, last, first_2, TY_INTEGER ); len = CGBinary( O_PLUS, len, CGInteger( 1, TY_INTEGER ), TY_INTEGER ); } } dest = GetPtr(); if( Options & OPT_BOUNDS ) { call = InitCall( RT_SUBSTRING ); CGAddParm( call, CGFEName( dest, TY_CHAR ), TY_LOCAL_POINTER ); CGAddParm( call, last, TY_INT_4 ); CGAddParm( call, first_1, TY_INT_4 ); CGAddParm( call, src, TY_LOCAL_POINTER ); XPush( CGBinary( O_COMMA, CGCall( call ), CGFEName( dest, TY_CHAR ), TY_LOCAL_POINTER ) ); } else { ptr = CGBinary( O_PLUS, SCBPointer( src ), CGBinary( O_MINUS, first_1, CGInteger( 1, TY_INTEGER ), TY_INTEGER ), TY_GLOBAL_POINTER ); CGTrash( CGAssign( SCBLenAddr( CGFEName( dest, TY_CHAR ) ), len, TY_INTEGER ) ); // Assumption is that the pointer in the SCB is the first field in // the SCB so that when we push the cg_name returned by CGAssign() // it is a pointer to the SCB. We must leave the assignment of the // pointer into the SCB in the tree so that the aliasing information // is not lost. XPush( CGLVAssign( SCBPtrAddr( CGFEName( dest, TY_CHAR ) ), ptr, TY_GLOBAL_POINTER ) ); // Don't do it the following way: // CGTrash( CGAssign( SCBPtrAddr( CGFEName( dest, TY_CHAR ) ), // ptr, TY_GLOBAL_POINTER ) ); // XPush( CGFEName( dest, TY_CHAR ) ); } }