static void PushBaseSize( void ) { DIPHDL( type, th ); dig_type_info ti; DIPTypeBase( ExprSP->th, th, NULL, NULL ); DIPTypeInfo( th, ExprSP->lc, &ti ); PushNum( ti.size ); }
void DoAPoints( stack_entry *stk, type_kind def ) { stack_flags was_imp_addr; addr_off off; LRValue( stk ); was_imp_addr = stk->flags & SF_IMP_ADDR; switch( stk->info.kind ) { case TK_BOOL: case TK_ENUM: case TK_CHAR: case TK_INTEGER: //NYI: 64 bit offsets off = U32FetchTrunc( stk->v.uint ); stk->v.addr = DefAddrSpaceForAddr( Context.execution ); stk->v.addr.mach.offset = off; stk->info.modifier = TM_NEAR; /* fall through */ case TK_POINTER: case TK_ADDRESS: if( stk->th != NULL ) { LocationCreate( &stk->v.loc, LT_ADDR, &stk->v.addr ); DIPTypeBase( stk->th, stk->th, stk->lc, &stk->v.loc ); ClassifyEntry( stk, &stk->info ); if( stk->info.kind == TK_VOID ) { Error( ERR_NONE, LIT_ENG( ERR_VOID_BASE ) ); } } else { if( def == TK_NONE ) def = TK_INTEGER; stk->info.kind = def; switch( def ) { case TK_INTEGER: stk->info.modifier = TM_UNSIGNED; stk->info.size = DefaultSize( DK_INT ); break; case TK_ADDRESS: ExprSetAddrInfo( stk, false ); break; } LocationCreate( &stk->v.loc, LT_ADDR, &stk->v.addr ); } stk->flags |= SF_LOCATION | was_imp_addr; break; default: Error( ERR_NONE, LIT_ENG( ERR_ILL_TYPE ) ); break; } stk->flags &= ~SF_CONST; }
static bool IsCodePointer( stack_entry *entry ) { DIPHDL( type, base_th ); dip_type_info ti; if( entry->th == NULL ) return( false ); if( DIPTypeBase( entry->th, base_th, NULL, NULL ) != DS_OK ) return( false ); if( DIPTypeInfo( base_th, entry->lc, &ti ) != DS_OK ) return( false ); switch( ti.kind ) { case TK_CODE: case TK_FUNCTION: return( true ); } return( false ); }
void LRValue( stack_entry *entry ) { location_list ll; item_mach tmp; bool extend; mad_type_info mti; DIPHDL( type, th ); ExprResolve( entry ); if( entry->flags & SF_LOCATION ) { if( entry->info.kind == TK_FUNCTION || entry->info.kind == TK_CODE ) { /* rvalue of procedure is its address */ entry->v.addr = entry->v.loc.e[0].u.addr; ExprSetAddrInfo( entry, false ); entry->info.kind = TK_ADDRESS; } else if( !AddressExpression( entry ) ) { extend = false; switch( entry->info.kind ) { case TK_ARRAY: /* rvalue of array is its address */ entry->v.addr = entry->v.loc.e[0].u.addr; if( entry->th != NULL ) { /* change typing from "array of..." to "pointer to..." */ GetMADTypeDefaultAt( entry->v.addr, MTK_ADDRESS, &mti ); DIPTypeBase( entry->th, th, NULL, NULL ); DIPTypePointer( th, TM_FAR, BITS2BYTES( mti.b.bits ), entry->th ); DIPTypeInfo( entry->th, entry->lc, &entry->info ); } else { ExprSetAddrInfo( entry, false ); } break; case TK_STRING: _ChkAlloc( entry->v.string.allocated, entry->info.size, LIT_ENG( ERR_NO_MEMORY_FOR_EXPR ) ); LocationCreate( &ll, LT_INTERNAL, entry->v.string.allocated ); if( LocationAssign( &ll, &entry->v.loc, entry->info.size, false ) != DS_OK ) { _Free( entry->v.string.allocated ); Error( ERR_NONE, LIT_ENG( ERR_NO_ACCESS ) ); } entry->v.string.loc = ll; break; case TK_BOOL: case TK_CHAR: case TK_ENUM: case TK_INTEGER: if( (entry->info.modifier & TM_MOD_MASK) == TM_SIGNED ) extend = true; /* fall through */ default: LocationCreate( &ll, LT_INTERNAL, &tmp ); if( LocationAssign( &ll, &entry->v.loc, entry->info.size, extend ) != DS_OK ) { Error( ERR_NONE, LIT_ENG( ERR_NO_ACCESS ) ); } FromItem( &tmp, entry ); break; } } entry->flags &= ~(SF_LOCATION | SF_IMP_ADDR); } if( entry->info.kind == TK_POINTER && (entry->info.modifier & TM_MOD_MASK) == TM_NEAR ) { NearToFar( entry ); } }
static ssl_value MechDo( unsigned select, ssl_value parm ) { unsigned long size; ssl_value result; DIPHDL( type, th ); dig_type_info ti; mad_type_info mti; result = 0; switch( select ) { case 0: DoAssign(); break; case 1: DoMul(); break; case 2: DoDiv(); break; case 3: DoMod(); break; case 4: DoMinus(); break; case 5: DoShift(); break; case 6: DoAnd(); break; case 7: DoXor(); break; case 8: DoOr(); break; case 9: DoAddr(); break; case 10: ClassToTypeInfo( parm, &ti ); DoPoints( ti.kind ); break; case 11: DoField(); break; case 12: DoCall( Num, SSL2BOOL( parm ) ); break; case 13: DoConvert(); break; case 14: DoPlus(); break; case 15: MakeAddr(); break; case 16: result = ( TstEQ( SSL2INT( parm ) ) != 0 ); break; case 17: result = ( TstLT( SSL2INT( parm ) ) != 0 ); break; case 18: result = ( TstTrue( SSL2INT( parm ) ) != 0 ); break; case 19: result = ( TstExist( SSL2INT( parm ) ) != 0 ); break; case 20: size = ExprSP->ti.size; PopEntry(); PushNum( size ); break; case 21: DIPTypeBase( ExprSP->th, th, NULL, NULL ); PopEntry(); PushType( th ); break; case 22: GetMADTypeDefault( MTK_ADDRESS, &mti ); size = BITS2BYTES( mti.b.bits - mti.a.seg.bits ); if( parm ) { size += sizeof( addr_seg ); DIPTypePointer( ExprSP->th, TM_FAR, size, th ); } else { DIPTypePointer( ExprSP->th, TM_NEAR, size, th ); } PopEntry(); PushType( th ); break; case 23: result = UserType( th ); if( result ) { PopEntry(); PushType( th ); } break; case 24: DoMakeComplex(); break; case 25: DoStringConcat(); break; case 26: DoLConvert(); break; case 27: DoPlusScaled(); break; case 28: DoMinusScaled(); break; case 29: DoPoints( TI_KIND_EXTRACT( parm ) ); break; case 30: ti.kind = TK_POINTER; ti.size = TI_SIZE_EXTRACT( parm ); ti.modifier = TI_MOD_EXTRACT( parm ); ti.deref = false; FillInDefaults( &ti ); DIPTypePointer( ExprSP->th, ti.modifier, ti.size, th ); PopEntry(); PushType( th ); break; case 31: if( SSL2BOOL( parm ) ) { /* file scope */ if( ExprSP->flags & SF_NAME ) { ExprSP->v.li.file_scope = true; } else { Error( ERR_LOC, LIT_ENG( ERR_WANT_NAME ) ); } } else { /* in a namespace */ DoScope(); } break; } return( result ); }