* move the common sequence to build a VMT for an objectdef into a separate procedure (based on a patch by Blaise.ru)

git-svn-id: trunk@43674 -
This commit is contained in:
svenbarth 2019-12-11 22:42:53 +00:00
parent a6354741e6
commit bf5d75e594
4 changed files with 20 additions and 18 deletions

View File

@ -140,7 +140,6 @@ implementation
procedure jvm_maybe_create_enum_class(const name: TIDString; def: tdef);
var
vmtbuilder: tvmtbuilder;
arrdef: tarraydef;
arrsym: ttypesym;
juhashmap: tdef;
@ -319,9 +318,7 @@ implementation
symtablestack.pop(enumclass.symtable);
vmtbuilder:=TVMTBuilder.Create(enumclass);
vmtbuilder.generate_vmt;
vmtbuilder.free;
build_vmt(enumclass);
restore_after_new_class(sstate,islocal,oldsymtablestack);
current_structdef:=old_current_structdef;
@ -330,7 +327,6 @@ implementation
procedure jvm_create_procvar_class_intern(const name: TIDString; def: tdef; force_no_callback_intf: boolean);
var
vmtbuilder: tvmtbuilder;
oldsymtablestack: tsymtablestack;
pvclass,
pvintf: tobjectdef;
@ -429,9 +425,7 @@ implementation
symtablestack.pop(pvclass.symtable);
vmtbuilder:=TVMTBuilder.Create(pvclass);
vmtbuilder.generate_vmt;
vmtbuilder.free;
build_vmt(pvclass);
restore_after_new_class(sstate,islocal,oldsymtablestack);
end;

View File

@ -54,6 +54,12 @@ interface
end;
{ convenince routine to build the VMT for an objectdef
Note: also ensures that the procdefs of the objectdef have their hidden
parameters inserted }
procedure build_vmt(def:tobjectdef);
implementation
uses
@ -979,4 +985,14 @@ implementation
end;
end;
procedure build_vmt(def:tobjectdef);
var
vmtbuilder : TVMTBuilder;
begin
vmtbuilder:=TVMTBuilder.create(def);
vmtbuilder.generate_vmt;
vmtbuilder.free;
end;
end.

View File

@ -661,7 +661,6 @@ implementation
istyperenaming : boolean;
generictypelist : tfphashobjectlist;
generictokenbuf : tdynamicarray;
vmtbuilder : TVMTBuilder;
p:tnode;
gendef : tstoreddef;
s : shortstring;
@ -1088,11 +1087,7 @@ implementation
{ Build VMT indexes, skip for type renaming and forward classes }
if (hdef.typesym=newtype) and
not(oo_is_forward in tobjectdef(hdef).objectoptions) then
begin
vmtbuilder:=TVMTBuilder.Create(tobjectdef(hdef));
vmtbuilder.generate_vmt;
vmtbuilder.free;
end;
build_vmt(tobjectdef(hdef));
{ In case of an objcclass, verify that all methods have a message
name set. We only check this now, because message names can be set

View File

@ -675,7 +675,6 @@ uses
oldcurrent_filepos : tfileposinfo;
recordbuf : tdynamicarray;
hadtypetoken : boolean;
vmtbuilder : tvmtbuilder;
i,
replaydepth : longint;
item : tobject;
@ -1000,9 +999,7 @@ uses
consume(_SEMICOLON);
end;
vmtbuilder:=TVMTBuilder.Create(tobjectdef(result));
vmtbuilder.generate_vmt;
vmtbuilder.free;
build_vmt(tobjectdef(result));
end;
{ handle params, calling convention, etc }
procvardef: