mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 05:09:19 +02:00
* moved import_lib (for JVM package name) and jvm_full_typename()
from tobjectdef to tabstractrecorddef, since records are implemented via Java classes on the JVM target (and hence have an associated package name, and we have to be able to generate their JVM-style mangled name) * adapted ppudump to this change git-svn-id: branches/jvmbackend@18449 -
This commit is contained in:
parent
88df6573a0
commit
f17936e598
@ -177,6 +177,9 @@ interface
|
|||||||
tabstractrecorddef= class(tstoreddef)
|
tabstractrecorddef= class(tstoreddef)
|
||||||
objname,
|
objname,
|
||||||
objrealname : PShortString;
|
objrealname : PShortString;
|
||||||
|
{ for C++ classes: name of the library this class is imported from }
|
||||||
|
{ for Java classes/records: package name }
|
||||||
|
import_lib : PShortString;
|
||||||
symtable : TSymtable;
|
symtable : TSymtable;
|
||||||
cloneddef : tabstractrecorddef;
|
cloneddef : tabstractrecorddef;
|
||||||
cloneddefderef : tderef;
|
cloneddefderef : tderef;
|
||||||
@ -194,6 +197,8 @@ interface
|
|||||||
function search_enumerator_get: tprocdef; virtual;
|
function search_enumerator_get: tprocdef; virtual;
|
||||||
function search_enumerator_move: tprocdef; virtual;
|
function search_enumerator_move: tprocdef; virtual;
|
||||||
function search_enumerator_current: tsym; virtual;
|
function search_enumerator_current: tsym; virtual;
|
||||||
|
{ JVM }
|
||||||
|
function jvm_full_typename(with_package_name: boolean): string;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
trecorddef = class(tabstractrecorddef)
|
trecorddef = class(tabstractrecorddef)
|
||||||
@ -263,8 +268,6 @@ interface
|
|||||||
{ for Object Pascal helpers }
|
{ for Object Pascal helpers }
|
||||||
extendeddef : tabstractrecorddef;
|
extendeddef : tabstractrecorddef;
|
||||||
extendeddefderef: tderef;
|
extendeddefderef: tderef;
|
||||||
{ for C++ classes: name of the library this class is imported from }
|
|
||||||
import_lib,
|
|
||||||
{ for Objective-C: protocols and classes can have the same name there }
|
{ for Objective-C: protocols and classes can have the same name there }
|
||||||
objextname : pshortstring;
|
objextname : pshortstring;
|
||||||
{ to be able to have a variable vmt position }
|
{ to be able to have a variable vmt position }
|
||||||
@ -336,8 +339,6 @@ interface
|
|||||||
function check_objc_types: boolean;
|
function check_objc_types: boolean;
|
||||||
{ C++ }
|
{ C++ }
|
||||||
procedure finish_cpp_data;
|
procedure finish_cpp_data;
|
||||||
{ JVM }
|
|
||||||
function jvm_full_typename(with_package_name: boolean): string;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
tclassrefdef = class(tabstractpointerdef)
|
tclassrefdef = class(tabstractpointerdef)
|
||||||
@ -2847,6 +2848,10 @@ implementation
|
|||||||
inherited ppuload(dt,ppufile);
|
inherited ppuload(dt,ppufile);
|
||||||
objrealname:=stringdup(ppufile.getstring);
|
objrealname:=stringdup(ppufile.getstring);
|
||||||
objname:=stringdup(upper(objrealname^));
|
objname:=stringdup(upper(objrealname^));
|
||||||
|
import_lib:=stringdup(ppufile.getstring);
|
||||||
|
{ only used for external C++ classes and Java classes/records }
|
||||||
|
if (import_lib^='') then
|
||||||
|
stringdispose(import_lib);
|
||||||
ppufile.getsmallset(objectoptions);
|
ppufile.getsmallset(objectoptions);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2854,6 +2859,10 @@ implementation
|
|||||||
begin
|
begin
|
||||||
inherited ppuwrite(ppufile);
|
inherited ppuwrite(ppufile);
|
||||||
ppufile.putstring(objrealname^);
|
ppufile.putstring(objrealname^);
|
||||||
|
if assigned(import_lib) then
|
||||||
|
ppufile.putstring(import_lib^)
|
||||||
|
else
|
||||||
|
ppufile.putstring('');
|
||||||
ppufile.putsmallset(objectoptions);
|
ppufile.putsmallset(objectoptions);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2861,6 +2870,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
stringdispose(objname);
|
stringdispose(objname);
|
||||||
stringdispose(objrealname);
|
stringdispose(objrealname);
|
||||||
|
stringdispose(import_lib);
|
||||||
inherited destroy;
|
inherited destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3002,6 +3012,39 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function tabstractrecorddef.jvm_full_typename(with_package_name: boolean): string;
|
||||||
|
var
|
||||||
|
st: tsymtable;
|
||||||
|
enclosingobj: tabstractrecorddef;
|
||||||
|
begin
|
||||||
|
if typ=objectdef then
|
||||||
|
result:=tobjectdef(self).objextname^
|
||||||
|
else if assigned(typesym) then
|
||||||
|
result:=typesym.realname
|
||||||
|
{ have to generate anonymous nested type in current unit/class/record }
|
||||||
|
else
|
||||||
|
internalerror(2011032601);
|
||||||
|
|
||||||
|
st:=owner;
|
||||||
|
while assigned(st) and
|
||||||
|
(st.symtabletype in [objectsymtable,recordsymtable]) do
|
||||||
|
begin
|
||||||
|
{ nested classes are named as "OuterClass$InnerClass" }
|
||||||
|
enclosingobj:=tabstractrecorddef(st.defowner);
|
||||||
|
if enclosingobj.typ=objectdef then
|
||||||
|
result:=tobjectdef(enclosingobj).objextname^+'$'+result
|
||||||
|
else if assigned(enclosingobj.typesym) then
|
||||||
|
result:=enclosingobj.typesym.realname+'$'+result;
|
||||||
|
st:=enclosingobj.owner;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if with_package_name and
|
||||||
|
assigned(import_lib) then
|
||||||
|
result:=import_lib^+'/'+result;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{***************************************************************************
|
{***************************************************************************
|
||||||
trecorddef
|
trecorddef
|
||||||
***************************************************************************}
|
***************************************************************************}
|
||||||
@ -3055,6 +3098,8 @@ implementation
|
|||||||
result:=trecorddef.create(objrealname^,symtable.getcopy);
|
result:=trecorddef.create(objrealname^,symtable.getcopy);
|
||||||
trecorddef(result).isunion:=isunion;
|
trecorddef(result).isunion:=isunion;
|
||||||
include(trecorddef(result).defoptions,df_copied_def);
|
include(trecorddef(result).defoptions,df_copied_def);
|
||||||
|
if assigned(import_lib) then
|
||||||
|
trecorddef(result).import_lib:=stringdup(import_lib^);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -4544,10 +4589,6 @@ implementation
|
|||||||
{ only used for external Objective-C classes/protocols }
|
{ only used for external Objective-C classes/protocols }
|
||||||
if (objextname^='') then
|
if (objextname^='') then
|
||||||
stringdispose(objextname);
|
stringdispose(objextname);
|
||||||
import_lib:=stringdup(ppufile.getstring);
|
|
||||||
{ only used for external C++ classes }
|
|
||||||
if (import_lib^='') then
|
|
||||||
stringdispose(import_lib);
|
|
||||||
symtable:=tObjectSymtable.create(self,objrealname^,0);
|
symtable:=tObjectSymtable.create(self,objrealname^,0);
|
||||||
tObjectSymtable(symtable).datasize:=ppufile.getasizeint;
|
tObjectSymtable(symtable).datasize:=ppufile.getasizeint;
|
||||||
tObjectSymtable(symtable).paddingsize:=ppufile.getword;
|
tObjectSymtable(symtable).paddingsize:=ppufile.getword;
|
||||||
@ -4639,7 +4680,6 @@ implementation
|
|||||||
symtable:=nil;
|
symtable:=nil;
|
||||||
end;
|
end;
|
||||||
stringdispose(objextname);
|
stringdispose(objextname);
|
||||||
stringdispose(import_lib);
|
|
||||||
stringdispose(iidstr);
|
stringdispose(iidstr);
|
||||||
if assigned(ImplementedInterfaces) then
|
if assigned(ImplementedInterfaces) then
|
||||||
begin
|
begin
|
||||||
@ -4724,10 +4764,6 @@ implementation
|
|||||||
ppufile.putstring(objextname^)
|
ppufile.putstring(objextname^)
|
||||||
else
|
else
|
||||||
ppufile.putstring('');
|
ppufile.putstring('');
|
||||||
if assigned(import_lib) then
|
|
||||||
ppufile.putstring(import_lib^)
|
|
||||||
else
|
|
||||||
ppufile.putstring('');
|
|
||||||
ppufile.putasizeint(tObjectSymtable(symtable).datasize);
|
ppufile.putasizeint(tObjectSymtable(symtable).datasize);
|
||||||
ppufile.putword(tObjectSymtable(symtable).paddingsize);
|
ppufile.putword(tObjectSymtable(symtable).paddingsize);
|
||||||
ppufile.putbyte(byte(tObjectSymtable(symtable).fieldalignment));
|
ppufile.putbyte(byte(tObjectSymtable(symtable).fieldalignment));
|
||||||
@ -5575,28 +5611,6 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function tobjectdef.jvm_full_typename(with_package_name: boolean): string;
|
|
||||||
var
|
|
||||||
st: tsymtable;
|
|
||||||
enclosingobj: tobjectdef;
|
|
||||||
begin
|
|
||||||
result:=objextname^;
|
|
||||||
st:=owner;
|
|
||||||
while assigned(st) and
|
|
||||||
(st.symtabletype=objectsymtable) do
|
|
||||||
begin
|
|
||||||
{ nested classes are named as "OuterClass$InnerClass" }
|
|
||||||
enclosingobj:=tobjectdef(st.defowner);
|
|
||||||
result:=enclosingobj.objextname^+'$'+result;
|
|
||||||
st:=enclosingobj.owner;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if with_package_name and
|
|
||||||
assigned(import_lib) then
|
|
||||||
result:=import_lib^+'/'+result;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
TImplementedInterface
|
TImplementedInterface
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
@ -1974,6 +1974,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
readcommondef('Record definition',defoptions);
|
readcommondef('Record definition',defoptions);
|
||||||
writeln(space,' Name of Record : ',getstring);
|
writeln(space,' Name of Record : ',getstring);
|
||||||
|
writeln(space,' Import lib/pkg : ',getstring);
|
||||||
write (space,' Options : ');
|
write (space,' Options : ');
|
||||||
readobjectdefoptions;
|
readobjectdefoptions;
|
||||||
writeln(space,' FieldAlign : ',shortint(getbyte));
|
writeln(space,' FieldAlign : ',shortint(getbyte));
|
||||||
@ -1997,6 +1998,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
readcommondef('Object/Class definition',defoptions);
|
readcommondef('Object/Class definition',defoptions);
|
||||||
writeln(space,' Name of Class : ',getstring);
|
writeln(space,' Name of Class : ',getstring);
|
||||||
|
writeln(space,' Import lib/pkg : ',getstring);
|
||||||
write (space,' Options : ');
|
write (space,' Options : ');
|
||||||
readobjectdefoptions;
|
readobjectdefoptions;
|
||||||
b:=getbyte;
|
b:=getbyte;
|
||||||
@ -2014,7 +2016,6 @@ begin
|
|||||||
else writeln('!! Warning: Invalid object type ',b);
|
else writeln('!! Warning: Invalid object type ',b);
|
||||||
end;
|
end;
|
||||||
writeln(space,' External name : ',getstring);
|
writeln(space,' External name : ',getstring);
|
||||||
writeln(space,' Import lib : ',getstring);
|
|
||||||
writeln(space,' DataSize : ',getasizeint);
|
writeln(space,' DataSize : ',getasizeint);
|
||||||
writeln(space,' PaddingSize : ',getword);
|
writeln(space,' PaddingSize : ',getword);
|
||||||
writeln(space,' FieldAlign : ',shortint(getbyte));
|
writeln(space,' FieldAlign : ',shortint(getbyte));
|
||||||
|
Loading…
Reference in New Issue
Block a user