* removed (already unused, because of never taken branch) handling of

interfacecom in subscriptnodes, because a COM interface cannot have fields
    -> replaced with check (that actually is performed) to give an
    internalerror() should a reference-counted class type be subscripted

git-svn-id: trunk@16786 -
This commit is contained in:
Jonas Maebe 2011-01-19 14:50:17 +00:00
parent 88fe11958b
commit 9a6f574f06

View File

@ -294,67 +294,57 @@ implementation
{ several object types must be dereferenced implicitly } { several object types must be dereferenced implicitly }
if is_implicit_pointer_object_type(left.resultdef) then if is_implicit_pointer_object_type(left.resultdef) then
begin begin
{ the contents of a class are aligned to a sizeof(pointer) } if not is_managed_type(left.resultdef) then
location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),sizeof(pint)); begin
case left.location.loc of { the contents of a class are aligned to a sizeof(pointer) }
LOC_CREGISTER, location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),sizeof(pint));
LOC_REGISTER: case left.location.loc of
begin LOC_CREGISTER,
{$ifdef cpu_uses_separate_address_registers} LOC_REGISTER:
if getregtype(left.location.register)<>R_ADDRESSREGISTER then
begin begin
location.reference.base:=rg.getaddressregister(current_asmdata.CurrAsmList); {$ifdef cpu_uses_separate_address_registers}
cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR, if getregtype(left.location.register)<>R_ADDRESSREGISTER then
left.location.register,location.reference.base); begin
end location.reference.base:=rg.getaddressregister(current_asmdata.CurrAsmList);
cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,
left.location.register,location.reference.base);
end
else
{$endif}
location.reference.base := left.location.register;
end;
LOC_CREFERENCE,
LOC_REFERENCE:
begin
location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList);
cg.a_load_loc_reg(current_asmdata.CurrAsmList,OS_ADDR,left.location,location.reference.base);
end;
LOC_CONSTANT:
begin
{ can happen with @classtype(pointerconst).field }
location.reference.offset:=left.location.value;
end;
else else
{$endif} internalerror(2009092401);
location.reference.base := left.location.register; end;
end; { implicit deferencing }
LOC_CREFERENCE, if (cs_use_heaptrc in current_settings.globalswitches) and
LOC_REFERENCE: (cs_checkpointer in current_settings.localswitches) and
not(cs_compilesystem in current_settings.moduleswitches) then
begin begin
location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList); paramanager.getintparaloc(pocall_default,1,paraloc1);
cg.a_load_loc_reg(current_asmdata.CurrAsmList,OS_ADDR,left.location,location.reference.base); cg.a_load_reg_cgpara(current_asmdata.CurrAsmList, OS_ADDR,location.reference.base,paraloc1);
paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
cg.allocallcpuregisters(current_asmdata.CurrAsmList);
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_CHECKPOINTER',false);
cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
end; end;
LOC_CONSTANT: end
begin else
{ can happen with @classtype(pointerconst).field } { reference-counted implicit pointer object types don't have
location.reference.offset:=left.location.value; fields -> cannot be subscripted (calls are handled via call
end; nodes) }
else internalerror(2011011901);
internalerror(2009092401);
end;
{ implicit deferencing }
if (cs_use_heaptrc in current_settings.globalswitches) and
(cs_checkpointer in current_settings.localswitches) and
not(cs_compilesystem in current_settings.moduleswitches) then
begin
paramanager.getintparaloc(pocall_default,1,paraloc1);
cg.a_load_reg_cgpara(current_asmdata.CurrAsmList, OS_ADDR,location.reference.base,paraloc1);
paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
cg.allocallcpuregisters(current_asmdata.CurrAsmList);
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_CHECKPOINTER',false);
cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
end;
end
else if is_interfacecom(left.resultdef) then
begin
location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),sizeof(pint));
tg.GetTempTyped(current_asmdata.CurrAsmList,left.resultdef,tt_normal,location.reference);
cg.a_load_loc_ref(current_asmdata.CurrAsmList,OS_ADDR,left.location,location.reference);
{ implicit deferencing also for interfaces }
if (cs_use_heaptrc in current_settings.globalswitches) and
(cs_checkpointer in current_settings.localswitches) and
not(cs_compilesystem in current_settings.moduleswitches) then
begin
paramanager.getintparaloc(pocall_default,1,paraloc1);
cg.a_load_reg_cgpara(current_asmdata.CurrAsmList, OS_ADDR,location.reference.base,paraloc1);
paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
cg.allocallcpuregisters(current_asmdata.CurrAsmList);
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_CHECKPOINTER',false);
cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
end;
end end
else else
begin begin