2
$Id: symdef.pas,v 1.240 2004/05/25 18:51:14 peter Exp $
3
Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
5
Symbol table implementation for the definitions
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
****************************************************************************
32
globtype,globals,tokens,
34
symconst,symbase,symtype,
50
{************************************************
52
************************************************}
54
tstoreddef = class(tdef)
56
typesymderef : tderef;
58
{ persistent (available across units) rtti and init tables }
60
inittablesym : tsym; {trttisym}
62
inittablesymderef : tderef;
63
{ local (per module) rtti and init tables }
64
localrttilab : array[trttitype] of tasmlabel;
65
{ linked list of global definitions }
67
fileinfo : tfileposinfo;
71
stab_state : tdefstabstatus;
74
constructor ppuloaddef(ppufile:tcompilerppufile);
76
function getcopy : tstoreddef;virtual;
77
procedure ppuwritedef(ppufile:tcompilerppufile);
78
procedure ppuwrite(ppufile:tcompilerppufile);virtual;abstract;
79
procedure buildderef;override;
80
procedure buildderefimpl;override;
81
procedure deref;override;
82
procedure derefimpl;override;
83
function size:longint;override;
84
function alignment:longint;override;
85
function is_publishable : boolean;override;
86
function needs_inittable : boolean;override;
89
function get_var_value(const s:string):string;
90
function stabstr_evaluate(const s:string;const vars:array of string):Pchar;
91
function stabstring : pchar;virtual;
92
procedure concatstabto(asmlist : taasmoutput);virtual;
93
function numberstring:string;virtual;
94
procedure set_globalnb;virtual;
95
function allstabstring : pchar;virtual;
98
procedure write_rtti_name;
99
procedure write_rtti_data(rt:trttitype);virtual;
100
procedure write_child_rtti_data(rt:trttitype);virtual;
101
function get_rtti_label(rt:trttitype):tasmsymbol;
103
function is_intregable : boolean;
104
function is_fpuregable : boolean;
109
tparaitem = class(TLinkedListItem)
110
paratype : ttype; { required for procvar }
112
parasymderef : tderef;
113
defaultvalue : tsym; { tconstsym }
114
defaultvaluederef : tderef;
115
paratyp : tvarspez; { required for procvar }
116
paraloc : array[tcallercallee] of tparalocation;
117
is_hidden : boolean; { is this a hidden (implicit) parameter }
123
tfiletyp = (ft_text,ft_typed,ft_untyped);
125
tfiledef = class(tstoreddef)
127
typedfiletype : ttype;
128
constructor createtext;
129
constructor createuntyped;
130
constructor createtyped(const tt : ttype);
131
constructor ppuload(ppufile:tcompilerppufile);
132
procedure ppuwrite(ppufile:tcompilerppufile);override;
133
procedure buildderef;override;
134
procedure deref;override;
135
function gettypename:string;override;
136
function getmangledparaname:string;override;
140
function stabstring : pchar;override;
141
procedure concatstabto(asmlist : taasmoutput);override;
145
tvariantdef = class(tstoreddef)
146
varianttype : tvarianttype;
147
constructor create(v : tvarianttype);
148
constructor ppuload(ppufile:tcompilerppufile);
149
function gettypename:string;override;
150
procedure ppuwrite(ppufile:tcompilerppufile);override;
152
function needs_inittable : boolean;override;
153
procedure write_rtti_data(rt:trttitype);override;
155
function numberstring:string;override;
156
function stabstring : pchar;override;
157
procedure concatstabto(asmlist : taasmoutput);override;
161
tformaldef = class(tstoreddef)
163
constructor ppuload(ppufile:tcompilerppufile);
164
procedure ppuwrite(ppufile:tcompilerppufile);override;
165
function gettypename:string;override;
167
function numberstring:string;override;
168
function stabstring : pchar;override;
169
procedure concatstabto(asmlist : taasmoutput);override;
173
tforwarddef = class(tstoreddef)
175
forwardpos : tfileposinfo;
176
constructor create(const s:string;const pos : tfileposinfo);
177
destructor destroy;override;
178
function gettypename:string;override;
181
terrordef = class(tstoreddef)
183
function gettypename:string;override;
184
function getmangledparaname : string;override;
187
function stabstring : pchar;override;
188
procedure concatstabto(asmlist : taasmoutput);override;
192
{ tpointerdef and tclassrefdef should get a common
193
base class, but I derived tclassrefdef from tpointerdef
194
to avoid problems with bugs (FK)
197
tpointerdef = class(tstoreddef)
200
constructor create(const tt : ttype);
201
constructor createfar(const tt : ttype);
202
constructor ppuload(ppufile:tcompilerppufile);
203
procedure ppuwrite(ppufile:tcompilerppufile);override;
204
procedure buildderef;override;
205
procedure deref;override;
206
function gettypename:string;override;
209
function stabstring : pchar;override;
210
procedure concatstabto(asmlist : taasmoutput);override;
214
Trecord_stabgen_state=record
216
stabsize,staballoc,recoffset:integer;
219
tabstractrecorddef= class(tstoreddef)
222
FRTTIType : trttitype;
224
procedure field_addname(p:Tnamedindexitem;arg:pointer);
225
procedure field_concatstabto(p:Tnamedindexitem;arg:pointer);
227
procedure count_field_rtti(sym : tnamedindexitem;arg:pointer);
228
procedure write_field_rtti(sym : tnamedindexitem;arg:pointer);
229
procedure generate_field_rtti(sym : tnamedindexitem;arg:pointer);
231
symtable : tsymtable;
232
function getsymtable(t:tgetsymtable):tsymtable;override;
235
trecorddef = class(tabstractrecorddef)
238
constructor create(p : tsymtable);
239
constructor ppuload(ppufile:tcompilerppufile);
240
destructor destroy;override;
241
procedure ppuwrite(ppufile:tcompilerppufile);override;
242
procedure buildderef;override;
243
procedure deref;override;
244
function size:longint;override;
245
function alignment : longint;override;
246
function gettypename:string;override;
249
function stabstring : pchar;override;
250
procedure concatstabto(asmlist:taasmoutput);override;
252
function needs_inittable : boolean;override;
254
procedure write_child_rtti_data(rt:trttitype);override;
255
procedure write_rtti_data(rt:trttitype);override;
260
timplementedinterfaces = class;
262
tobjectdef = class(tabstractrecorddef)
265
procedure proc_addname(p :tnamedindexitem;arg:pointer);
266
procedure proc_concatstabto(p :tnamedindexitem;arg:pointer);
268
procedure count_published_properties(sym:tnamedindexitem;arg:pointer);
269
procedure write_property_info(sym : tnamedindexitem;arg:pointer);
270
procedure generate_published_child_rtti(sym : tnamedindexitem;arg:pointer);
271
procedure count_published_fields(sym:tnamedindexitem;arg:pointer);
272
procedure writefields(sym:tnamedindexitem;arg:pointer);
274
childof : tobjectdef;
275
childofderef : tderef;
277
objrealname : pstring;
278
objectoptions : tobjectoptions;
279
{ to be able to have a variable vmt position }
280
{ and no vmt field for objects without virtuals }
281
vmt_offset : longint;
283
writing_class_record_stab : boolean;
285
objecttype : tobjectdeftype;
288
lastvtableindex: longint;
289
{ store implemented interfaces defs and name mappings }
290
implementedinterfaces: timplementedinterfaces;
291
constructor create(ot : tobjectdeftype;const n : string;c : tobjectdef);
292
constructor ppuload(ppufile:tcompilerppufile);
293
destructor destroy;override;
294
procedure ppuwrite(ppufile:tcompilerppufile);override;
295
function gettypename:string;override;
296
procedure buildderef;override;
297
procedure deref;override;
298
function getparentdef:tdef;override;
299
function size : longint;override;
300
function alignment:longint;override;
301
function vmtmethodoffset(index:longint):longint;
302
function members_need_inittable : boolean;
303
{ this should be called when this class implements an interface }
304
procedure prepareguid;
305
function is_publishable : boolean;override;
306
function needs_inittable : boolean;override;
307
function vmt_mangledname : string;
308
function rtti_name : string;
309
procedure check_forwards;
310
function is_related(d : tobjectdef) : boolean;
311
function next_free_name_index : longint;
313
procedure set_parent(c : tobjectdef);
314
function searchdestructor : tprocdef;
317
function stabstring : pchar;override;
318
procedure set_globalnb;override;
319
function classnumberstring : string;
320
procedure concatstabto(asmlist : taasmoutput);override;
321
function allstabstring : pchar;override;
324
procedure write_child_rtti_data(rt:trttitype);override;
325
procedure write_rtti_data(rt:trttitype);override;
326
function generate_field_table : tasmlabel;
329
timplementedinterfaces = class
331
destructor destroy; override;
333
function count: longint;
334
function interfaces(intfindex: longint): tobjectdef;
335
function interfacesderef(intfindex: longint): tderef;
336
function ioffsets(intfindex: longint): plongint;
337
function searchintf(def: tdef): longint;
338
procedure addintf(def: tdef);
340
procedure buildderef;
342
{ add interface reference loaded from ppu }
343
procedure addintf_deref(const d:tderef);
345
procedure clearmappings;
346
procedure addmappings(intfindex: longint; const name, newname: string);
347
function getmappings(intfindex: longint; const name: string; var nextexist: pointer): string;
349
procedure clearimplprocs;
350
procedure addimplproc(intfindex: longint; procdef: tprocdef);
351
function implproccount(intfindex: longint): longint;
352
function implprocs(intfindex: longint; procindex: longint): tprocdef;
353
function isimplmergepossible(intfindex, remainindex: longint; var weight: longint): boolean;
356
finterfaces: tindexarray;
357
procedure checkindex(intfindex: longint);
361
tclassrefdef = class(tpointerdef)
362
constructor create(const t:ttype);
363
constructor ppuload(ppufile:tcompilerppufile);
364
procedure ppuwrite(ppufile:tcompilerppufile);override;
365
function gettypename:string;override;
368
function stabstring : pchar;override;
372
tarraydef = class(tstoreddef)
380
IsArrayOfConst : boolean;
382
_elementtype : ttype;
384
function elesize : longint;
385
constructor create_from_pointer(const elemt : ttype);
386
constructor create(l,h : longint;const t : ttype);
387
constructor ppuload(ppufile:tcompilerppufile);
388
procedure ppuwrite(ppufile:tcompilerppufile);override;
389
function gettypename:string;override;
390
function getmangledparaname : string;override;
391
procedure setelementtype(t: ttype);
393
function stabstring : pchar;override;
394
procedure concatstabto(asmlist : taasmoutput);override;
396
procedure buildderef;override;
397
procedure deref;override;
398
function size : longint;override;
399
function alignment : longint;override;
400
{ returns the label of the range check string }
401
function needs_inittable : boolean;override;
402
procedure write_child_rtti_data(rt:trttitype);override;
403
procedure write_rtti_data(rt:trttitype);override;
404
property elementtype : ttype Read _ElementType;
407
torddef = class(tstoreddef)
408
low,high : TConstExprInt;
410
constructor create(t : tbasetype;v,b : TConstExprInt);
411
constructor ppuload(ppufile:tcompilerppufile);
412
function getcopy : tstoreddef;override;
413
procedure ppuwrite(ppufile:tcompilerppufile);override;
414
function is_publishable : boolean;override;
415
function gettypename:string;override;
419
function stabstring : pchar;override;
422
procedure write_rtti_data(rt:trttitype);override;
425
tfloatdef = class(tstoreddef)
427
constructor create(t : tfloattype);
428
constructor ppuload(ppufile:tcompilerppufile);
429
function getcopy : tstoreddef;override;
430
procedure ppuwrite(ppufile:tcompilerppufile);override;
431
function gettypename:string;override;
432
function is_publishable : boolean;override;
436
function stabstring : pchar;override;
437
procedure concatstabto(asmlist:taasmoutput);override;
440
procedure write_rtti_data(rt:trttitype);override;
443
tabstractprocdef = class(tstoreddef)
444
{ saves a definition to the return type }
448
proctypeoption : tproctypeoption;
449
proccalloption : tproccalloption;
450
procoptions : tprocoptions;
451
requiredargarea : aword;
455
fpu_used : byte; { how many stack fpu must be empty }
457
funcret_paraloc : array[tcallercallee] of tparalocation;
458
has_paraloc_info : boolean; { paraloc info is available }
459
constructor create(level:byte);
460
constructor ppuload(ppufile:tcompilerppufile);
461
destructor destroy;override;
462
procedure ppuwrite(ppufile:tcompilerppufile);override;
463
procedure buildderef;override;
464
procedure deref;override;
465
procedure releasemem;
466
function concatpara(afterpara:tparaitem;const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
467
function insertpara(const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
468
procedure removepara(currpara:tparaitem);
469
function typename_paras(showhidden:boolean): string;
470
procedure test_if_fpu_result;
471
function is_methodpointer:boolean;virtual;
472
function is_addressonly:boolean;virtual;
475
function stabstring : pchar;override;
479
tprocvardef = class(tabstractprocdef)
480
constructor create(level:byte);
481
constructor ppuload(ppufile:tcompilerppufile);
482
procedure ppuwrite(ppufile:tcompilerppufile);override;
483
procedure buildderef;override;
484
procedure deref;override;
485
function getsymtable(t:tgetsymtable):tsymtable;override;
486
function size : longint;override;
487
function gettypename:string;override;
488
function is_publishable : boolean;override;
489
function is_methodpointer:boolean;override;
490
function is_addressonly:boolean;override;
493
function stabstring : pchar;override;
494
procedure concatstabto(asmlist:taasmoutput);override;
497
procedure write_rtti_data(rt:trttitype);override;
506
tinlininginfo = record
509
flags : tprocinfoflags;
511
pinlininginfo = ^tinlininginfo;
515
{ register variables }
516
pregvarinfo = ^tregvarinfo;
518
regvars : array[1..maxvarregs] of tsym;
519
regvars_para : array[1..maxvarregs] of boolean;
520
regvars_refs : array[1..maxvarregs] of longint;
522
fpuregvars : array[1..maxfpuvarregs] of tsym;
523
fpuregvars_para : array[1..maxfpuvarregs] of boolean;
524
fpuregvars_refs : array[1..maxfpuvarregs] of longint;
528
tprocdef = class(tabstractprocdef)
530
_mangledname : pstring;
532
isstabwritten : boolean;
536
overloadnumber : word;
537
messageinf : tmessageinf;
539
{ where is this function defined and what were the symbol
540
flags, needed here because there
541
is only one symbol for all overloaded functions
542
EXTDEBUG has fileinfo in tdef (PFV) }
543
fileinfo : tfileposinfo;
545
symoptions : tsymoptions;
546
{ symbol owning this definition }
548
procsymderef : tderef;
550
aliasnames : tstringlist;
554
funcretsymderef : tderef;
561
_classderef : tderef;
563
{ library symbol for AmigaOS/MorphOS }
565
libsymderef : tderef;
567
{ name of the result variable to insert in the localsymtable }
568
resultname : stringid;
569
{ true, if the procedure is only declared
570
(forward procedure) }
572
{ true if the procedure is declared in the interface }
573
interfacedef : boolean;
574
{ true if the procedure has a forward declaration }
575
hasforward : boolean;
576
{ check the problems of manglednames }
577
has_mangledname : boolean;
578
{ info for inlining the subroutine, if this pointer is nil,
579
the procedure can't be inlined }
580
inlininginfo : pinlininginfo;
582
regvarinfo: pregvarinfo;
584
constructor create(level:byte);
585
constructor ppuload(ppufile:tcompilerppufile);
586
destructor destroy;override;
587
procedure ppuwrite(ppufile:tcompilerppufile);override;
588
procedure buildderef;override;
589
procedure buildderefimpl;override;
590
procedure deref;override;
591
procedure derefimpl;override;
592
function getsymtable(t:tgetsymtable):tsymtable;override;
593
function gettypename : string;override;
594
function mangledname : string;
595
procedure setmangledname(const s : string);
596
procedure load_references(ppufile:tcompilerppufile;locals:boolean);
597
function write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
598
{ inserts the local symbol table, if this is not
599
no local symbol table is built. Should be called only
600
when we are sure that a local symbol table will be required.
602
procedure insert_localst;
603
function fullprocname(showhidden:boolean):string;
604
function cplusplusmangledname : string;
605
function is_methodpointer:boolean;override;
606
function is_addressonly:boolean;override;
607
function is_visible_for_object(currobjdef:tobjectdef):boolean;
610
function numberstring:string;override;
611
function stabstring : pchar;override;
612
procedure concatstabto(asmlist : taasmoutput);override;
616
{ single linked list of overloaded procs }
617
pprocdeflist = ^tprocdeflist;
618
tprocdeflist = record
625
tstringdef = class(tstoreddef)
626
string_typ : tstringtype;
628
constructor createshort(l : byte);
629
constructor loadshort(ppufile:tcompilerppufile);
630
constructor createlong(l : longint);
631
constructor loadlong(ppufile:tcompilerppufile);
632
{$ifdef ansistring_bits}
633
constructor createansi(l:longint;bits:Tstringbits);
634
constructor loadansi(ppufile:tcompilerppufile;bits:Tstringbits);
636
constructor createansi(l : longint);
637
constructor loadansi(ppufile:tcompilerppufile);
639
constructor createwide(l : longint);
640
constructor loadwide(ppufile:tcompilerppufile);
641
function getcopy : tstoreddef;override;
642
function stringtypname:string;
643
function size : longint;override;
644
procedure ppuwrite(ppufile:tcompilerppufile);override;
645
function gettypename:string;override;
646
function getmangledparaname:string;override;
647
function is_publishable : boolean;override;
650
function stabstring : pchar;override;
651
procedure concatstabto(asmlist : taasmoutput);override;
654
function needs_inittable : boolean;override;
656
procedure write_rtti_data(rt:trttitype);override;
659
tenumdef = class(tstoreddef)
663
firstenum : tsym; {tenumsym}
665
basedefderef : tderef;
667
constructor create_subrange(_basedef:tenumdef;_min,_max:longint);
668
constructor ppuload(ppufile:tcompilerppufile);
669
destructor destroy;override;
670
procedure ppuwrite(ppufile:tcompilerppufile);override;
671
procedure buildderef;override;
672
procedure deref;override;
673
function gettypename:string;override;
674
function is_publishable : boolean;override;
675
procedure calcsavesize;
676
procedure setmax(_max:longint);
677
procedure setmin(_min:longint);
678
function min:longint;
679
function max:longint;
682
function stabstring : pchar;override;
685
procedure write_rtti_data(rt:trttitype);override;
686
procedure write_child_rtti_data(rt:trttitype);override;
688
procedure correct_owner_symtable;
691
tsetdef = class(tstoreddef)
694
constructor create(const t:ttype;high : longint);
695
constructor ppuload(ppufile:tcompilerppufile);
696
destructor destroy;override;
697
procedure ppuwrite(ppufile:tcompilerppufile);override;
698
procedure buildderef;override;
699
procedure deref;override;
700
function gettypename:string;override;
701
function is_publishable : boolean;override;
704
function stabstring : pchar;override;
705
procedure concatstabto(asmlist : taasmoutput);override;
708
procedure write_rtti_data(rt:trttitype);override;
709
procedure write_child_rtti_data(rt:trttitype);override;
712
Tdefmatch=(dm_exact,dm_equal,dm_convertl1);
715
aktobjectdef : tobjectdef; { used for private functions check !! }
717
writing_def_stabs : boolean;
718
{ for STAB debugging }
719
globaltypecount : word;
720
pglobaltypecount : pword;
724
generrortype, { error in definition }
725
voidpointertype, { pointer for Void-Pointerdef }
726
charpointertype, { pointer for Char-Pointerdef }
728
cformaltype, { unique formal definition }
729
voidtype, { Void (procedure) }
731
cwidechartype, { WideChar }
732
booltype, { boolean type }
733
u8inttype, { 8-Bit unsigned integer }
734
s8inttype, { 8-Bit signed integer }
735
u16inttype, { 16-Bit unsigned integer }
736
s16inttype, { 16-Bit signed integer }
737
u32inttype, { 32-Bit unsigned integer }
738
s32inttype, { 32-Bit signed integer }
739
u64inttype, { 64-bit unsigned integer }
740
s64inttype, { 64-bit signed integer }
741
s32floattype, { pointer for realconstn }
742
s64floattype, { pointer for realconstn }
743
s80floattype, { pointer to type of temp. floats }
744
s64currencytype, { pointer to a currency type }
745
s32fixedtype, { pointer to type of temp. fixed }
746
cshortstringtype, { pointer to type of short string const }
747
clongstringtype, { pointer to type of long string const }
748
{$ifdef ansistring_bits}
749
cansistringtype16, { pointer to type of ansi string const }
750
cansistringtype32, { pointer to type of ansi string const }
751
cansistringtype64, { pointer to type of ansi string const }
753
cansistringtype, { pointer to type of ansi string const }
755
cwidestringtype, { pointer to type of wide string const }
756
openshortstringtype, { pointer to type of an open shortstring,
757
needed for readln() }
758
openchararraytype, { pointer to type of an open array of char,
759
needed for readln() }
760
cfiletype, { get the same definition for all file }
762
methodpointertype, { typecasting of methodpointers to extract self }
763
{ we use only one variant def for every variant class }
767
{ default integer type s32inttype on 32 bit systems, s64bittype on 64 bit systems }
770
{ unsigned ord type with the same size as a pointer }
772
{ several types to simulate more or less C++ objects for GDB }
775
pvmttype : ttype; { type of classrefs, used for stabs }
777
{ pointer to the anchestor of all classes }
778
class_tobject : tobjectdef;
779
{ pointer to the ancestor of all COM interfaces }
780
interface_iunknown : tobjectdef;
781
{ pointer to the TGUID type
783
rec_tguid : trecorddef;
787
pbestrealtype : ^ttype = @s80floattype;
790
pbestrealtype : ^ttype = @s80floattype;
793
pbestrealtype : ^ttype = @s64floattype;
796
pbestrealtype : ^ttype = @s64floattype;
799
pbestrealtype : ^ttype = @s64floattype;
802
pbestrealtype : ^ttype = @s64floattype;
805
pbestrealtype : ^ttype = @s64floattype;
808
pbestrealtype : ^ttype = @s64floattype;
811
pbestrealtype : ^ttype = @s64floattype;
814
function reverseparaitems(p: tparaitem): tparaitem;
815
function make_mangledname(const typeprefix:string;st:tsymtable;const suffix:string):string;
817
{ should be in the types unit, but the types unit uses the node stuff :( }
818
function is_interfacecom(def: tdef): boolean;
819
function is_interfacecorba(def: tdef): boolean;
820
function is_interface(def: tdef): boolean;
821
function is_object(def: tdef): boolean;
822
function is_class(def: tdef): boolean;
823
function is_cppclass(def: tdef): boolean;
824
function is_class_or_interface(def: tdef): boolean;
838
systems,aasmcpu,paramgr,
840
symsym,symtable,symutil,defutil,
851
{****************************************************************************
853
****************************************************************************}
855
function reverseparaitems(p: tparaitem): tparaitem;
864
p:=tparaitem(p.next);
869
reverseparaitems:=hp1;
873
function make_mangledname(const typeprefix:string;st:tsymtable;const suffix:string):string;
879
if not assigned(st) then
880
internalerror(200204212);
882
while (st.symtabletype=localsymtable) do
884
if st.defowner.deftype<>procdef then
885
internalerror(200204173);
886
s:=tprocdef(st.defowner).procsym.name;
887
if tprocdef(st.defowner).overloadnumber>0 then
888
s:=s+'$'+tostr(tprocdef(st.defowner).overloadnumber);
889
prefix:=s+'$'+prefix;
890
st:=st.defowner.owner;
892
{ object/classes symtable }
893
if (st.symtabletype=objectsymtable) then
895
if st.defowner.deftype<>objectdef then
896
internalerror(200204174);
897
prefix:=tobjectdef(st.defowner).objname^+'_$_'+prefix;
898
st:=st.defowner.owner;
900
{ symtable must now be static or global }
901
if not(st.symtabletype in [staticsymtable,globalsymtable]) then
902
internalerror(200204175);
904
if typeprefix<>'' then
905
result:=result+typeprefix+'_';
906
{ Add P$ for program, which can have the same name as
908
if (tsymtable(main_module.localsymtable)=st) and
909
(not main_module.is_unit) then
910
result:=result+'P$'+st.name^
912
result:=result+st.name^;
914
result:=result+'_'+prefix;
916
result:=result+'_'+suffix;
917
{ the Darwin assembler assumes that all symbols starting with 'L' are local }
918
if (target_info.system = system_powerpc_darwin) and
919
(result[1] = 'L') then
920
result := '_' + result;
924
{****************************************************************************
925
TDEF (base class for definitions)
926
****************************************************************************}
928
constructor tstoreddef.create;
933
fileinfo := aktfilepos;
936
symtablestack.registerdef(self);
938
stab_state:=stab_state_unused;
941
fillchar(localrttilab,sizeof(localrttilab),0);
945
constructor tstoreddef.ppuloaddef(ppufile:tcompilerppufile);
949
fillchar(fileinfo,sizeof(fileinfo),0);
952
stab_state:=stab_state_unused;
955
fillchar(localrttilab,sizeof(localrttilab),0);
957
indexnr:=ppufile.getword;
958
ppufile.getderef(typesymderef);
959
ppufile.getsmallset(defoptions);
960
if df_has_rttitable in defoptions then
961
ppufile.getderef(rttitablesymderef);
962
if df_has_inittable in defoptions then
963
ppufile.getderef(inittablesymderef);
967
procedure Tstoreddef.reset;
970
stab_state:=stab_state_unused;
972
if assigned(rttitablesym) then
973
trttisym(rttitablesym).lab := nil;
974
if assigned(inittablesym) then
975
trttisym(inittablesym).lab := nil;
976
localrttilab[initrtti]:=nil;
977
localrttilab[fullrtti]:=nil;
981
function tstoreddef.getcopy : tstoreddef;
983
Message(sym_e_cant_create_unique_type);
984
getcopy:=terrordef.create;
988
procedure tstoreddef.ppuwritedef(ppufile:tcompilerppufile);
990
ppufile.putword(indexnr);
991
ppufile.putderef(typesymderef);
992
ppufile.putsmallset(defoptions);
993
if df_has_rttitable in defoptions then
994
ppufile.putderef(rttitablesymderef);
995
if df_has_inittable in defoptions then
996
ppufile.putderef(inittablesymderef);
1000
if (cs_gdb_dbx in aktglobalswitches) and
1001
assigned(owner) then
1002
globalnb := owner.getnewtypecount
1010
procedure tstoreddef.buildderef;
1012
typesymderef.build(typesym);
1013
rttitablesymderef.build(rttitablesym);
1014
inittablesymderef.build(inittablesym);
1018
procedure tstoreddef.buildderefimpl;
1023
procedure tstoreddef.deref;
1025
typesym:=ttypesym(typesymderef.resolve);
1026
if df_has_rttitable in defoptions then
1027
rttitablesym:=trttisym(rttitablesymderef.resolve);
1028
if df_has_inittable in defoptions then
1029
inittablesym:=trttisym(inittablesymderef.resolve);
1033
procedure tstoreddef.derefimpl;
1038
function tstoreddef.size : longint;
1044
function tstoreddef.alignment : longint;
1046
{ natural alignment by default }
1047
alignment:=size_2_align(savesize);
1052
procedure tstoreddef.set_globalnb;
1054
globalnb:=PGlobalTypeCount^;
1055
inc(PglobalTypeCount^);
1059
function Tstoreddef.get_var_value(const s:string):string;
1061
if s='numberstring' then
1062
get_var_value:=numberstring
1063
else if s='sym_name' then
1064
if assigned(typesym) then
1065
get_var_value:=Ttypesym(typesym).name
1068
else if s='N_LSYM' then
1069
get_var_value:=tostr(N_LSYM)
1070
else if s='savesize' then
1071
get_var_value:=tostr(savesize);
1075
function Tstoreddef.stabstr_evaluate(const s:string;const vars:array of string):Pchar;
1077
stabstr_evaluate:=string_evaluate(s,@get_var_value,vars);
1081
function tstoreddef.stabstring : pchar;
1083
stabstring:=stabstr_evaluate('t${numberstring};',[]);
1087
function tstoreddef.numberstring : string;
1089
{ Stab must already be written, or we must be busy writing it }
1090
if writing_def_stabs and
1091
not(stab_state in [stab_state_writing,stab_state_written]) then
1092
internalerror(200403091);
1093
{ Keep track of used stabs, this info is only usefull for stabs
1094
referenced by the symbols. Definitions will always include all
1096
if stab_state=stab_state_unused then
1097
stab_state:=stab_state_used;
1098
{ Need a new number? }
1101
if (cs_gdb_dbx in aktglobalswitches) and
1102
assigned(owner) then
1103
globalnb := owner.getnewtypecount
1107
if (cs_gdb_dbx in aktglobalswitches) and
1108
assigned(typesym) and
1109
(ttypesym(typesym).owner.unitid<>0) then
1110
result:='('+tostr(ttypesym(typesym).owner.unitid)+','+tostr(tstoreddef(ttypesym(typesym).restype.def).globalnb)+')'
1112
result:=tostr(globalnb);
1116
function tstoreddef.allstabstring : pchar;
1118
stabchar : string[2];
1123
if deftype in tagtypes then
1125
{ Here we maybe generate a type, so we have to use numberstring }
1126
st:=stabstr_evaluate('"${sym_name}:$1$2=',[stabchar,numberstring]);
1127
reallocmem(st,strlen(ss)+512);
1128
{ line info is set to 0 for all defs, because the def can be in an other
1129
unit and then the linenumber is invalid in the current sourcefile }
1130
su:=stabstr_evaluate('",${N_LSYM},0,0,0',[]);
1131
strcopy(strecopy(strend(st),ss),su);
1132
reallocmem(st,strlen(st)+1);
1139
procedure tstoreddef.concatstabto(asmlist : taasmoutput);
1143
if (stab_state in [stab_state_writing,stab_state_written]) then
1145
If cs_gdb_dbx in aktglobalswitches then
1147
{ otherwise you get two of each def }
1148
If assigned(typesym) then
1150
if (ttypesym(typesym).owner = nil) or
1151
((ttypesym(typesym).owner.symtabletype = globalsymtable) and
1152
tglobalsymtable(ttypesym(typesym).owner).dbx_count_ok) then
1154
{with DBX we get the definition from the other objects }
1155
stab_state := stab_state_written;
1160
{ to avoid infinite loops }
1161
stab_state := stab_state_writing;
1162
stab_str := allstabstring;
1163
asmList.concat(Tai_stabs.Create(stab_str));
1164
stab_state := stab_state_written;
1169
procedure tstoreddef.write_rtti_name;
1174
if assigned(typesym) then
1176
str:=ttypesym(typesym).realname;
1177
rttiList.concat(Tai_string.Create(chr(length(str))+str));
1180
rttiList.concat(Tai_string.Create(#0))
1184
procedure tstoreddef.write_rtti_data(rt:trttitype);
1186
rttilist.concat(tai_const.create_8bit(tkUnknown));
1191
procedure tstoreddef.write_child_rtti_data(rt:trttitype);
1196
function tstoreddef.get_rtti_label(rt:trttitype) : tasmsymbol;
1198
{ try to reuse persistent rtti data }
1199
if (rt=fullrtti) and (df_has_rttitable in defoptions) then
1200
get_rtti_label:=trttisym(rttitablesym).get_label
1202
if (rt=initrtti) and (df_has_inittable in defoptions) then
1203
get_rtti_label:=trttisym(inittablesym).get_label
1206
if not assigned(localrttilab[rt]) then
1208
objectlibrary.getdatalabel(localrttilab[rt]);
1209
write_child_rtti_data(rt);
1210
if (cs_create_smart in aktmoduleswitches) then
1211
rttiList.concat(Tai_cut.Create);
1212
rttiList.concat(Tai_align.create(const_align(pointer_size)));
1213
if (cs_create_smart in aktmoduleswitches) then
1214
rttiList.concat(Tai_symbol.Create_global(localrttilab[rt],0))
1216
rttiList.concat(Tai_symbol.Create(localrttilab[rt],0));
1217
write_rtti_data(rt);
1218
rttiList.concat(Tai_symbol_end.Create(localrttilab[rt]));
1220
get_rtti_label:=localrttilab[rt];
1225
{ returns true, if the definition can be published }
1226
function tstoreddef.is_publishable : boolean;
1228
is_publishable:=false;
1232
{ needs an init table }
1233
function tstoreddef.needs_inittable : boolean;
1235
needs_inittable:=false;
1239
function tstoreddef.is_intregable : boolean;
1241
is_intregable:=false;
1245
is_intregable:=true;
1247
is_intregable:=not(po_methodpointer in tprocvardef(self).procoptions);
1249
case torddef(self).typ of
1250
bool8bit,bool16bit,bool32bit,
1251
u8bit,u16bit,u32bit,
1252
s8bit,s16bit,s32bit,
1254
is_intregable:=true;
1257
is_intregable:=is_class(self) or is_interface(self);
1259
is_intregable:=(tsetdef(self).settype=smallset);
1264
function tstoreddef.is_fpuregable : boolean;
1266
is_fpuregable:=(deftype=floatdef);
1271
{****************************************************************************
1273
****************************************************************************}
1275
constructor tstringdef.createshort(l : byte);
1278
string_typ:=st_shortstring;
1285
constructor tstringdef.loadshort(ppufile:tcompilerppufile);
1287
inherited ppuloaddef(ppufile);
1288
string_typ:=st_shortstring;
1290
len:=ppufile.getbyte;
1295
constructor tstringdef.createlong(l : longint);
1298
string_typ:=st_longstring;
1301
savesize:=POINTER_SIZE;
1305
constructor tstringdef.loadlong(ppufile:tcompilerppufile);
1307
inherited ppuloaddef(ppufile);
1309
string_typ:=st_longstring;
1310
len:=ppufile.getlongint;
1311
savesize:=POINTER_SIZE;
1314
{$ifdef ansistring_bits}
1315
constructor tstringdef.createansi(l:longint;bits:Tstringbits);
1320
string_typ:=st_ansistring16;
1322
string_typ:=st_ansistring32;
1324
string_typ:=st_ansistring64;
1328
savesize:=POINTER_SIZE;
1331
constructor tstringdef.loadansi(ppufile:tcompilerppufile;bits:Tstringbits);
1333
inherited ppuloaddef(ppufile);
1337
string_typ:=st_ansistring16;
1339
string_typ:=st_ansistring32;
1341
string_typ:=st_ansistring64;
1343
len:=ppufile.getlongint;
1344
savesize:=POINTER_SIZE;
1347
constructor tstringdef.createansi(l:longint);
1350
string_typ:=st_ansistring;
1353
savesize:=POINTER_SIZE;
1356
constructor tstringdef.loadansi(ppufile:tcompilerppufile);
1359
inherited ppuloaddef(ppufile);
1361
string_typ:=st_ansistring;
1362
len:=ppufile.getlongint;
1363
savesize:=POINTER_SIZE;
1367
constructor tstringdef.createwide(l : longint);
1370
string_typ:=st_widestring;
1373
savesize:=POINTER_SIZE;
1377
constructor tstringdef.loadwide(ppufile:tcompilerppufile);
1379
inherited ppuloaddef(ppufile);
1381
string_typ:=st_widestring;
1382
len:=ppufile.getlongint;
1383
savesize:=POINTER_SIZE;
1387
function tstringdef.getcopy : tstoreddef;
1389
result:=tstringdef.create;
1390
result.deftype:=stringdef;
1391
tstringdef(result).string_typ:=string_typ;
1392
tstringdef(result).len:=len;
1393
tstringdef(result).savesize:=savesize;
1397
function tstringdef.stringtypname:string;
1398
{$ifdef ansistring_bits}
1400
typname:array[tstringtype] of string[9]=('',
1401
'shortstr','longstr','ansistr16','ansistr32','ansistr64','widestr'
1405
typname:array[tstringtype] of string[8]=('',
1406
'shortstr','longstr','ansistr','widestr'
1410
stringtypname:=typname[string_typ];
1414
function tstringdef.size : longint;
1420
procedure tstringdef.ppuwrite(ppufile:tcompilerppufile);
1422
inherited ppuwritedef(ppufile);
1423
if string_typ=st_shortstring then
1426
if len > 255 then internalerror(12122002);
1428
ppufile.putbyte(byte(len))
1431
ppufile.putlongint(len);
1433
st_shortstring : ppufile.writeentry(ibshortstringdef);
1434
st_longstring : ppufile.writeentry(iblongstringdef);
1435
{$ifdef ansistring_bits}
1436
st_ansistring16 : ppufile.writeentry(ibansistring16def);
1437
st_ansistring32 : ppufile.writeentry(ibansistring32def);
1438
st_ansistring64 : ppufile.writeentry(ibansistring64def);
1440
st_ansistring : ppufile.writeentry(ibansistringdef);
1442
st_widestring : ppufile.writeentry(ibwidestringdef);
1448
function tstringdef.stabstring : pchar;
1450
bytest,charst,longst : string;
1455
charst:=tstoreddef(cchartype.def).numberstring;
1456
{ this is what I found in stabs.texinfo but
1457
gdb 4.12 for go32 doesn't understand that !! }
1458
{$IfDef GDBknowsstrings}
1459
stabstring:=stabstr_evaluate('n$1;$2',[charst,tostr(len)]);
1461
bytest:=tstoreddef(u8inttype.def).numberstring;
1462
stabstring:=stabstr_evaluate('s$1length:$2,0,8;st:ar$2;1;$3;$4,8,$5;;',
1463
[tostr(len+1),bytest,tostr(len),charst,tostr(len*8)]);
1468
charst:=tstoreddef(cchartype.def).numberstring;
1469
{ this is what I found in stabs.texinfo but
1470
gdb 4.12 for go32 doesn't understand that !! }
1471
{$IfDef GDBknowsstrings}
1472
stabstring:=stabstr_evaluate('n$1;$2',[charst,tostr(len)]);
1474
bytest:=tstoreddef(u8inttype.def).numberstring;
1475
longst:=tstoreddef(u32inttype.def).numberstring;
1476
stabstring:=stabstr_evaluate('s$1length:$2,0,32;dummy:$6,32,8;st:ar$2;1;$3;$4,40,$5;;',
1477
[tostr(len+5),longst,tostr(len),charst,tostr(len*8),bytest]);
1480
{$ifdef ansistring_bits}
1481
st_ansistring16,st_ansistring32,st_ansistring64:
1486
{ an ansi string looks like a pchar easy !! }
1487
charst:=tstoreddef(cchartype.def).numberstring;
1488
stabstring:=strpnew('*'+charst);
1492
{ an ansi string looks like a pwidechar easy !! }
1493
charst:=tstoreddef(cwidechartype.def).numberstring;
1494
stabstring:=strpnew('*'+charst);
1500
procedure tstringdef.concatstabto(asmlist:taasmoutput);
1502
if (stab_state in [stab_state_writing,stab_state_written]) then
1507
tstoreddef(cchartype.def).concatstabto(asmlist);
1508
{$IfNDef GDBknowsstrings}
1509
tstoreddef(u8inttype.def).concatstabto(asmlist);
1514
tstoreddef(cchartype.def).concatstabto(asmlist);
1515
{$IfNDef GDBknowsstrings}
1516
tstoreddef(u8inttype.def).concatstabto(asmlist);
1517
tstoreddef(u32inttype.def).concatstabto(asmlist);
1520
{$ifdef ansistring_bits}
1521
st_ansistring16,st_ansistring32,st_ansistring64:
1525
tstoreddef(cchartype.def).concatstabto(asmlist);
1527
tstoreddef(cwidechartype.def).concatstabto(asmlist);
1529
inherited concatstabto(asmlist);
1534
function tstringdef.needs_inittable : boolean;
1536
{$ifdef ansistring_bits}
1537
needs_inittable:=string_typ in [st_ansistring16,st_ansistring32,st_ansistring64,st_widestring];
1539
needs_inittable:=string_typ in [st_ansistring,st_widestring];
1544
function tstringdef.gettypename : string;
1545
{$ifdef ansistring_bits}
1547
names : array[tstringtype] of string[20] = ('',
1548
'shortstring','longstring','ansistring16','ansistring32','ansistring64','widestring');
1551
names : array[tstringtype] of string[20] = ('',
1552
'ShortString','LongString','AnsiString','WideString');
1555
gettypename:=names[string_typ];
1559
procedure tstringdef.write_rtti_data(rt:trttitype);
1562
{$ifdef ansistring_bits}
1565
rttiList.concat(Tai_const.Create_8bit(tkA16String));
1570
rttiList.concat(Tai_const.Create_8bit(tkA32String));
1575
rttiList.concat(Tai_const.Create_8bit(tkA64String));
1581
rttiList.concat(Tai_const.Create_8bit(tkAString));
1587
rttiList.concat(Tai_const.Create_8bit(tkWString));
1592
rttiList.concat(Tai_const.Create_8bit(tkLString));
1597
rttiList.concat(Tai_const.Create_8bit(tkSString));
1599
rttiList.concat(Tai_const.Create_8bit(len));
1605
function tstringdef.getmangledparaname : string;
1607
getmangledparaname:='STRING';
1611
function tstringdef.is_publishable : boolean;
1613
is_publishable:=true;
1617
{****************************************************************************
1619
****************************************************************************}
1621
constructor tenumdef.create;
1631
correct_owner_symtable;
1634
constructor tenumdef.create_subrange(_basedef:tenumdef;_min,_max:longint);
1643
firstenum:=basedef.firstenum;
1644
while assigned(firstenum) and (tenumsym(firstenum).value<>minval) do
1645
firstenum:=tenumsym(firstenum).nextenum;
1646
correct_owner_symtable;
1650
constructor tenumdef.ppuload(ppufile:tcompilerppufile);
1652
inherited ppuloaddef(ppufile);
1654
ppufile.getderef(basedefderef);
1655
minval:=ppufile.getlongint;
1656
maxval:=ppufile.getlongint;
1657
savesize:=ppufile.getlongint;
1663
procedure tenumdef.calcsavesize;
1665
if (aktpackenum=4) or (min<0) or (max>65535) then
1668
if (aktpackenum=2) or (min<0) or (max>255) then
1675
procedure tenumdef.setmax(_max:longint);
1682
procedure tenumdef.setmin(_min:longint);
1689
function tenumdef.min:longint;
1695
function tenumdef.max:longint;
1701
procedure tenumdef.buildderef;
1703
inherited buildderef;
1704
basedefderef.build(basedef);
1708
procedure tenumdef.deref;
1711
basedef:=tenumdef(basedefderef.resolve);
1715
destructor tenumdef.destroy;
1721
procedure tenumdef.ppuwrite(ppufile:tcompilerppufile);
1723
inherited ppuwritedef(ppufile);
1724
ppufile.putderef(basedefderef);
1725
ppufile.putlongint(min);
1726
ppufile.putlongint(max);
1727
ppufile.putlongint(savesize);
1728
ppufile.writeentry(ibenumdef);
1732
{ used for enumdef because the symbols are
1733
inserted in the owner symtable }
1734
procedure tenumdef.correct_owner_symtable;
1738
if assigned(owner) and
1739
(owner.symtabletype in [recordsymtable,objectsymtable]) then
1741
owner.defindex.deleteindex(self);
1743
while (st.symtabletype in [recordsymtable,objectsymtable]) do
1745
st.registerdef(self);
1752
function tenumdef.stabstring : pchar;
1757
memsize,stl:cardinal;
1760
memsize:=memsizeinc;
1762
{ we can specify the size with @s<size>; prefix PM }
1763
if savesize <> std_param_align then
1764
strpcopy(st,'@s'+tostr(savesize*8)+';e')
1767
p := tenumsym(firstenum);
1769
while assigned(p) do
1771
s :=p.name+':'+tostr(p.value)+',';
1772
{ place for the ending ';' also }
1773
if (stl+length(s)+1>=memsize) then
1775
inc(memsize,memsizeinc);
1776
reallocmem(st,memsize);
1784
reallocmem(st,stl+2);
1790
procedure tenumdef.write_child_rtti_data(rt:trttitype);
1792
if assigned(basedef) then
1793
basedef.get_rtti_label(rt);
1797
procedure tenumdef.write_rtti_data(rt:trttitype);
1801
rttiList.concat(Tai_const.Create_8bit(tkEnumeration));
1805
rttiList.concat(Tai_const.Create_8bit(otUByte));
1807
rttiList.concat(Tai_const.Create_8bit(otUWord));
1809
rttiList.concat(Tai_const.Create_8bit(otULong));
1811
rttiList.concat(Tai_const.Create_32bit(Cardinal(min)));
1812
rttiList.concat(Tai_const.Create_32bit(Cardinal(max)));
1813
if assigned(basedef) then
1814
rttiList.concat(Tai_const_symbol.Create(basedef.get_rtti_label(rt)))
1816
rttiList.concat(Tai_const.Create_ptr(0));
1817
hp:=tenumsym(firstenum);
1818
while assigned(hp) do
1820
rttiList.concat(Tai_const.Create_8bit(length(hp.realname)));
1821
rttiList.concat(Tai_string.Create(hp.realname));
1824
rttiList.concat(Tai_const.Create_8bit(0));
1828
function tenumdef.is_publishable : boolean;
1830
is_publishable:=true;
1833
function tenumdef.gettypename : string;
1836
gettypename:='<enumeration type>';
1839
{****************************************************************************
1841
****************************************************************************}
1843
constructor torddef.create(t : tbasetype;v,b : TConstExprInt);
1854
constructor torddef.ppuload(ppufile:tcompilerppufile);
1856
inherited ppuloaddef(ppufile);
1858
typ:=tbasetype(ppufile.getbyte);
1859
if sizeof(TConstExprInt)=8 then
1861
low:=ppufile.getint64;
1862
high:=ppufile.getint64;
1866
low:=ppufile.getlongint;
1867
high:=ppufile.getlongint;
1873
function torddef.getcopy : tstoreddef;
1875
result:=torddef.create(typ,low,high);
1876
result.deftype:=orddef;
1877
torddef(result).low:=low;
1878
torddef(result).high:=high;
1879
torddef(result).typ:=typ;
1880
torddef(result).savesize:=savesize;
1884
procedure torddef.setsize;
1886
sizetbl : array[tbasetype] of longint = (
1894
savesize:=sizetbl[typ];
1898
procedure torddef.ppuwrite(ppufile:tcompilerppufile);
1900
inherited ppuwritedef(ppufile);
1901
ppufile.putbyte(byte(typ));
1902
if sizeof(TConstExprInt)=8 then
1904
ppufile.putint64(low);
1905
ppufile.putint64(high);
1909
ppufile.putlongint(low);
1910
ppufile.putlongint(high);
1912
ppufile.writeentry(iborddef);
1917
function torddef.stabstring : pchar;
1919
if cs_gdb_valgrind in aktglobalswitches then
1923
stabstring := strpnew(numberstring);
1927
stabstring := stabstr_evaluate('r${numberstring};0;255;',[]);
1931
stabstring:=stabstr_evaluate('r${numberstring};0;-1;',[]);
1933
stabstring:=stabstr_evaluate('r${numberstring};$1;$2;',[tostr(longint(low)),tostr(longint(high))]);
1940
stabstring := strpnew(numberstring);
1942
stabstring := strpnew('-20;');
1944
stabstring := strpnew('-30;');
1946
stabstring := strpnew('-21;');
1948
stabstring := strpnew('-22;');
1950
stabstring := strpnew('-23;');
1952
stabstring := strpnew('-32;');
1954
stabstring := strpnew('-31;');
1955
{u32bit : stabstring := tstoreddef(s32inttype.def).numberstring+';0;-1;'); }
1957
stabstring:=stabstr_evaluate('r${numberstring};$1;$2;',[tostr(longint(low)),tostr(longint(high))]);
1964
procedure torddef.write_rtti_data(rt:trttitype);
1966
procedure dointeger;
1968
trans : array[tbasetype] of byte =
1970
otUByte,otUWord,otULong,otUByte{otNone},
1971
otSByte,otSWord,otSLong,otUByte{otNone},
1972
otUByte,otUWord,otULong,
1973
otUByte,otUWord,otUByte);
1976
rttiList.concat(Tai_const.Create_8bit(byte(trans[typ])));
1977
rttiList.concat(Tai_const.Create_32bit(Cardinal(low)));
1978
rttiList.concat(Tai_const.Create_32bit(Cardinal(high)));
1985
rttiList.concat(Tai_const.Create_8bit(tkInt64));
1987
{$warning maybe change to create_64bit}
1988
if target_info.endian=endian_little then
1991
rttiList.concat(Tai_const.Create_32bit($0));
1992
rttiList.concat(Tai_const.Create_32bit(cardinal($80000000)));
1994
rttiList.concat(Tai_const.Create_32bit(cardinal($ffffffff)));
1995
rttiList.concat(Tai_const.Create_32bit(cardinal($7fffffff)));
2000
rttiList.concat(Tai_const.Create_32bit(cardinal($80000000)));
2001
rttiList.concat(Tai_const.Create_32bit($0));
2003
rttiList.concat(Tai_const.Create_32bit(cardinal($7fffffff)));
2004
rttiList.concat(Tai_const.Create_32bit(cardinal($ffffffff)));
2009
rttiList.concat(Tai_const.Create_8bit(tkQWord));
2012
rttiList.concat(Tai_const.Create_32bit($0));
2013
rttiList.concat(Tai_const.Create_32bit($0));
2015
rttiList.concat(Tai_const.Create_32bit(cardinal($ffffffff)));
2016
rttiList.concat(Tai_const.Create_32bit(cardinal($ffffffff)));
2020
rttiList.concat(Tai_const.Create_8bit(tkBool));
2025
rttiList.concat(Tai_const.Create_8bit(tkChar));
2030
rttiList.concat(Tai_const.Create_8bit(tkWChar));
2035
rttiList.concat(Tai_const.Create_8bit(tkInteger));
2042
function torddef.is_publishable : boolean;
2044
is_publishable:=(typ<>uvoid);
2048
function torddef.gettypename : string;
2051
names : array[tbasetype] of string[20] = (
2053
'Byte','Word','DWord','QWord',
2054
'ShortInt','SmallInt','LongInt','Int64',
2055
'Boolean','WordBool','LongBool',
2056
'Char','WideChar','Currency');
2059
gettypename:=names[typ];
2062
{****************************************************************************
2064
****************************************************************************}
2066
constructor tfloatdef.create(t : tfloattype);
2075
constructor tfloatdef.ppuload(ppufile:tcompilerppufile);
2077
inherited ppuloaddef(ppufile);
2079
typ:=tfloattype(ppufile.getbyte);
2084
function tfloatdef.getcopy : tstoreddef;
2086
result:=tfloatdef.create(typ);
2087
result.deftype:=floatdef;
2088
tfloatdef(result).savesize:=savesize;
2092
procedure tfloatdef.setsize;
2095
s32real : savesize:=4;
2096
s80real : savesize:=extended_size;
2099
s64comp : savesize:=8;
2106
procedure tfloatdef.ppuwrite(ppufile:tcompilerppufile);
2108
inherited ppuwritedef(ppufile);
2109
ppufile.putbyte(byte(typ));
2110
ppufile.writeentry(ibfloatdef);
2115
function Tfloatdef.stabstring:Pchar;
2119
{ found this solution in stabsread.c from GDB v4.16 }
2120
stabstring:=stabstr_evaluate('r$1;${savesize};0;',[tstoreddef(s32inttype.def).numberstring]);
2121
s64currency,s64comp:
2122
stabstring:=stabstr_evaluate('r$1;-${savesize};0;',[tstoreddef(s32inttype.def).numberstring]);
2124
{ under dos at least you must give a size of twelve instead of 10 !! }
2125
{ this is probably do to the fact that in gcc all is pushed in 4 bytes size }
2126
stabstring:=stabstr_evaluate('r$1;12;0;',[tstoreddef(s32inttype.def).numberstring]);
2128
internalerror(10005);
2133
procedure tfloatdef.concatstabto(asmlist:taasmoutput);
2135
if (stab_state in [stab_state_writing,stab_state_written]) then
2137
tstoreddef(s32inttype.def).concatstabto(asmlist);
2138
inherited concatstabto(asmlist);
2143
procedure tfloatdef.write_rtti_data(rt:trttitype);
2145
{tfloattype = (s32real,s64real,s80real,s64bit,s128bit);}
2146
translate : array[tfloattype] of byte =
2147
(ftSingle,ftDouble,ftExtended,ftComp,ftCurr,ftFloat128);
2149
rttiList.concat(Tai_const.Create_8bit(tkFloat));
2151
rttiList.concat(Tai_const.Create_8bit(translate[typ]));
2155
function tfloatdef.is_publishable : boolean;
2157
is_publishable:=true;
2160
function tfloatdef.gettypename : string;
2163
names : array[tfloattype] of string[20] = (
2164
'Single','Double','Extended','Comp','Currency','Float128');
2167
gettypename:=names[typ];
2170
{****************************************************************************
2172
****************************************************************************}
2174
constructor tfiledef.createtext;
2179
typedfiletype.reset;
2184
constructor tfiledef.createuntyped;
2188
filetyp:=ft_untyped;
2189
typedfiletype.reset;
2194
constructor tfiledef.createtyped(const tt : ttype);
2204
constructor tfiledef.ppuload(ppufile:tcompilerppufile);
2206
inherited ppuloaddef(ppufile);
2208
filetyp:=tfiletyp(ppufile.getbyte);
2209
if filetyp=ft_typed then
2210
ppufile.gettype(typedfiletype)
2212
typedfiletype.reset;
2217
procedure tfiledef.buildderef;
2219
inherited buildderef;
2220
if filetyp=ft_typed then
2221
typedfiletype.buildderef;
2225
procedure tfiledef.deref;
2228
if filetyp=ft_typed then
2229
typedfiletype.resolve;
2233
procedure tfiledef.setsize;
2255
procedure tfiledef.ppuwrite(ppufile:tcompilerppufile);
2257
inherited ppuwritedef(ppufile);
2258
ppufile.putbyte(byte(filetyp));
2259
if filetyp=ft_typed then
2260
ppufile.puttype(typedfiletype);
2261
ppufile.writeentry(ibfiledef);
2266
function tfiledef.stabstring : pchar;
2268
{$IfDef GDBknowsfiles}
2271
stabstring := strpnew('d'+typedfiletype.def.numberstring{+';'});
2273
stabstring := strpnew('d'+voiddef.numberstring{+';'});
2275
stabstring := strpnew('d'+cchartype^.numberstring{+';'});
2279
FileRec = Packed Record
2283
_private : array[1..32] of byte;
2284
UserData : array[1..16] of byte;
2285
name : array[0..255] of char;
2287
{ the buffer part is still missing !! (PM) }
2288
{ but the string could become too long !! }
2289
stabstring:=stabstr_evaluate('s${savesize}HANDLE:$1,0,32;MODE:$1,32,32;RECSIZE:$1,64,32;'+
2290
'_PRIVATE:ar$2;1;32;$3,96,256;USERDATA:ar$2;1;16;$3,352,128;'+
2291
'NAME:ar$2;0;255;$4,480,2048;;',[tstoreddef(u32inttype.def).numberstring,
2292
tstoreddef(u16inttype.def).numberstring,tstoreddef(u8inttype.def).numberstring,
2293
tstoreddef(cchartype.def).numberstring]);
2298
procedure tfiledef.concatstabto(asmlist:taasmoutput);
2300
if (stab_state in [stab_state_writing,stab_state_written]) then
2302
{$IfDef GDBknowsfiles}
2305
tstoreddef(typedfiletype.def).concatstabto(asmlist);
2307
tstoreddef(voidtype.def).concatstabto(asmlist);
2309
tstoreddef(cchartype.def).concatstabto(asmlist);
2312
tstoreddef(u32inttype.def).concatstabto(asmlist);
2313
tstoreddef(u16inttype.def).concatstabto(asmlist);
2314
tstoreddef(u8inttype.def).concatstabto(asmlist);
2315
tstoreddef(cchartype.def).concatstabto(asmlist);
2317
inherited concatstabto(asmlist);
2322
function tfiledef.gettypename : string;
2326
gettypename:='File';
2328
gettypename:='File Of '+typedfiletype.def.typename;
2335
function tfiledef.getmangledparaname : string;
2339
getmangledparaname:='FILE';
2341
getmangledparaname:='FILE$OF$'+typedfiletype.def.mangledparaname;
2343
getmangledparaname:='TEXT'
2348
{****************************************************************************
2350
****************************************************************************}
2352
constructor tvariantdef.create(v : tvarianttype);
2356
deftype:=variantdef;
2361
constructor tvariantdef.ppuload(ppufile:tcompilerppufile);
2363
inherited ppuloaddef(ppufile);
2364
varianttype:=tvarianttype(ppufile.getbyte);
2365
deftype:=variantdef;
2370
procedure tvariantdef.ppuwrite(ppufile:tcompilerppufile);
2372
inherited ppuwritedef(ppufile);
2373
ppufile.putbyte(byte(varianttype));
2374
ppufile.writeentry(ibvariantdef);
2378
procedure tvariantdef.setsize;
2384
function tvariantdef.gettypename : string;
2388
gettypename:='Variant';
2390
gettypename:='OleVariant';
2395
procedure tvariantdef.write_rtti_data(rt:trttitype);
2397
rttiList.concat(Tai_const.Create_8bit(tkVariant));
2401
function tvariantdef.needs_inittable : boolean;
2403
needs_inittable:=true;
2407
function tvariantdef.stabstring : pchar;
2409
stabstring:=stabstr_evaluate('formal${numberstring};',[]);
2413
function tvariantdef.numberstring:string;
2415
result:=tstoreddef(voidtype.def).numberstring;
2419
procedure tvariantdef.concatstabto(asmlist : taasmoutput);
2421
{ don't know how to handle this }
2425
{****************************************************************************
2427
****************************************************************************}
2429
constructor tpointerdef.create(const tt : ttype);
2432
deftype:=pointerdef;
2435
savesize:=POINTER_SIZE;
2439
constructor tpointerdef.createfar(const tt : ttype);
2442
deftype:=pointerdef;
2445
savesize:=POINTER_SIZE;
2449
constructor tpointerdef.ppuload(ppufile:tcompilerppufile);
2451
inherited ppuloaddef(ppufile);
2452
deftype:=pointerdef;
2453
ppufile.gettype(pointertype);
2454
is_far:=(ppufile.getbyte<>0);
2455
savesize:=POINTER_SIZE;
2459
procedure tpointerdef.buildderef;
2461
inherited buildderef;
2462
pointertype.buildderef;
2466
procedure tpointerdef.deref;
2469
pointertype.resolve;
2473
procedure tpointerdef.ppuwrite(ppufile:tcompilerppufile);
2475
inherited ppuwritedef(ppufile);
2476
ppufile.puttype(pointertype);
2477
ppufile.putbyte(byte(is_far));
2478
ppufile.writeentry(ibpointerdef);
2483
function tpointerdef.stabstring : pchar;
2485
stabstring := strpnew('*'+tstoreddef(pointertype.def).numberstring);
2489
procedure tpointerdef.concatstabto(asmlist : taasmoutput);
2493
if (stab_state in [stab_state_writing,stab_state_written]) then
2495
stab_state:=stab_state_writing;
2497
tstoreddef(pointertype.def).concatstabto(asmlist);
2499
if (pointertype.def.deftype in [recorddef,objectdef]) then
2501
if pointertype.def.deftype=objectdef then
2502
nb:=tobjectdef(pointertype.def).classnumberstring
2504
nb:=tstoreddef(pointertype.def).numberstring;
2505
{to avoid infinite recursion in record with next-like fields }
2506
if tstoreddef(pointertype.def).stab_state=stab_state_writing then
2508
if assigned(pointertype.def.typesym) then
2510
if assigned(typesym) then
2511
st := ttypesym(typesym).name
2514
asmlist.concat(Tai_stabs.create(stabstr_evaluate(
2515
'"$1:t${numberstring}=*$2=xs$3:",${N_LSYM},0,0,0',
2516
[st,nb,pointertype.def.typesym.name])));
2518
stab_state:=stab_state_written;
2522
stab_state:=stab_state_used;
2523
inherited concatstabto(asmlist);
2528
stab_state:=stab_state_used;
2529
inherited concatstabto(asmlist);
2535
function tpointerdef.gettypename : string;
2538
gettypename:='^'+pointertype.def.typename+';far'
2540
gettypename:='^'+pointertype.def.typename;
2544
{****************************************************************************
2546
****************************************************************************}
2548
constructor tclassrefdef.create(const t:ttype);
2550
inherited create(t);
2551
deftype:=classrefdef;
2555
constructor tclassrefdef.ppuload(ppufile:tcompilerppufile);
2557
{ be careful, tclassdefref inherits from tpointerdef }
2558
inherited ppuloaddef(ppufile);
2559
deftype:=classrefdef;
2560
ppufile.gettype(pointertype);
2562
savesize:=POINTER_SIZE;
2566
procedure tclassrefdef.ppuwrite(ppufile:tcompilerppufile);
2568
{ be careful, tclassdefref inherits from tpointerdef }
2569
inherited ppuwritedef(ppufile);
2570
ppufile.puttype(pointertype);
2571
ppufile.writeentry(ibclassrefdef);
2576
function tclassrefdef.stabstring : pchar;
2578
stabstring:=strpnew(tstoreddef(pvmttype.def).numberstring);
2583
function tclassrefdef.gettypename : string;
2585
gettypename:='Class Of '+pointertype.def.typename;
2589
{***************************************************************************
2591
***************************************************************************}
2593
constructor tsetdef.create(const t:ttype;high : longint);
2601
{$ifdef testvarsets}
2602
if aktsetalloc=0 THEN { $PACKSET Fixed?}
2604
savesize:=Sizeof(longint)
2605
{$ifdef testvarsets}
2606
else {No, use $PACKSET VALUE for rounding}
2607
savesize:=aktsetalloc*((high+aktsetalloc*8-1) DIV (aktsetalloc*8))
2618
{$ifdef testvarsets}
2622
savesize:=4*((high+31) div 32);
2625
{$endif testvarsets}
2626
Message(sym_e_ill_type_decl_set);
2630
constructor tsetdef.ppuload(ppufile:tcompilerppufile);
2632
inherited ppuloaddef(ppufile);
2634
ppufile.gettype(elementtype);
2635
settype:=tsettype(ppufile.getbyte);
2637
normset : savesize:=32;
2638
varset : savesize:=ppufile.getlongint;
2639
smallset : savesize:=Sizeof(longint);
2644
destructor tsetdef.destroy;
2650
procedure tsetdef.ppuwrite(ppufile:tcompilerppufile);
2652
inherited ppuwritedef(ppufile);
2653
ppufile.puttype(elementtype);
2654
ppufile.putbyte(byte(settype));
2655
if settype=varset then
2656
ppufile.putlongint(savesize);
2657
ppufile.writeentry(ibsetdef);
2662
function tsetdef.stabstring : pchar;
2664
stabstring:=stabstr_evaluate('@s$1;S$2',[tostr(savesize*8),tstoreddef(elementtype.def).numberstring]);
2668
procedure tsetdef.concatstabto(asmlist:taasmoutput);
2670
if (stab_state in [stab_state_writing,stab_state_written]) then
2672
tstoreddef(elementtype.def).concatstabto(asmlist);
2673
inherited concatstabto(asmlist);
2678
procedure tsetdef.buildderef;
2680
inherited buildderef;
2681
elementtype.buildderef;
2685
procedure tsetdef.deref;
2688
elementtype.resolve;
2692
procedure tsetdef.write_child_rtti_data(rt:trttitype);
2694
tstoreddef(elementtype.def).get_rtti_label(rt);
2698
procedure tsetdef.write_rtti_data(rt:trttitype);
2700
rttiList.concat(Tai_const.Create_8bit(tkSet));
2702
rttiList.concat(Tai_const.Create_8bit(otULong));
2703
rttiList.concat(Tai_const_symbol.Create(tstoreddef(elementtype.def).get_rtti_label(rt)));
2707
function tsetdef.is_publishable : boolean;
2709
is_publishable:=(settype=smallset);
2713
function tsetdef.gettypename : string;
2715
if assigned(elementtype.def) then
2716
gettypename:='Set Of '+elementtype.def.typename
2718
gettypename:='Empty Set';
2722
{***************************************************************************
2724
***************************************************************************}
2726
constructor tformaldef.create;
2730
stregdef:=registerdef;
2734
registerdef:=stregdef;
2735
{ formaldef must be registered at unit level !! }
2736
if registerdef and assigned(current_module) then
2737
if assigned(current_module.localsymtable) then
2738
tsymtable(current_module.localsymtable).registerdef(self)
2739
else if assigned(current_module.globalsymtable) then
2740
tsymtable(current_module.globalsymtable).registerdef(self);
2745
constructor tformaldef.ppuload(ppufile:tcompilerppufile);
2747
inherited ppuloaddef(ppufile);
2753
procedure tformaldef.ppuwrite(ppufile:tcompilerppufile);
2755
inherited ppuwritedef(ppufile);
2756
ppufile.writeentry(ibformaldef);
2761
function tformaldef.stabstring : pchar;
2763
stabstring:=stabstr_evaluate('formal${numberstring};',[]);
2767
function tformaldef.numberstring:string;
2769
result:=tstoreddef(voidtype.def).numberstring;
2773
procedure tformaldef.concatstabto(asmlist : taasmoutput);
2775
{ formaldef can't be stab'ed !}
2780
function tformaldef.gettypename : string;
2782
gettypename:='<Formal type>';
2786
{***************************************************************************
2788
***************************************************************************}
2790
constructor tarraydef.create(l,h : longint;const t : ttype);
2799
IsConstructor:=false;
2800
IsArrayOfConst:=false;
2801
IsDynamicArray:=false;
2802
IsConvertedPointer:=false;
2806
constructor tarraydef.create_from_pointer(const elemt : ttype);
2808
self.create(0,$7fffffff,s32inttype);
2809
IsConvertedPointer:=true;
2810
setelementtype(elemt);
2814
constructor tarraydef.ppuload(ppufile:tcompilerppufile);
2816
inherited ppuloaddef(ppufile);
2818
{ the addresses are calculated later }
2819
ppufile.gettype(_elementtype);
2820
ppufile.gettype(rangetype);
2821
lowrange:=ppufile.getlongint;
2822
highrange:=ppufile.getlongint;
2823
IsArrayOfConst:=boolean(ppufile.getbyte);
2824
IsDynamicArray:=boolean(ppufile.getbyte);
2826
IsConstructor:=false;
2830
procedure tarraydef.buildderef;
2832
inherited buildderef;
2833
_elementtype.buildderef;
2834
rangetype.buildderef;
2838
procedure tarraydef.deref;
2841
_elementtype.resolve;
2846
procedure tarraydef.ppuwrite(ppufile:tcompilerppufile);
2848
inherited ppuwritedef(ppufile);
2849
ppufile.puttype(_elementtype);
2850
ppufile.puttype(rangetype);
2851
ppufile.putlongint(lowrange);
2852
ppufile.putlongint(highrange);
2853
ppufile.putbyte(byte(IsArrayOfConst));
2854
ppufile.putbyte(byte(IsDynamicArray));
2855
ppufile.writeentry(ibarraydef);
2860
function tarraydef.stabstring : pchar;
2862
stabstring:=stabstr_evaluate('ar$1;$2;$3;$4',[Tstoreddef(rangetype.def).numberstring,
2863
tostr(lowrange),tostr(highrange),Tstoreddef(_elementtype.def).numberstring]);
2867
procedure tarraydef.concatstabto(asmlist:taasmoutput);
2869
if (stab_state in [stab_state_writing,stab_state_written]) then
2871
tstoreddef(rangetype.def).concatstabto(asmlist);
2872
tstoreddef(_elementtype.def).concatstabto(asmlist);
2873
inherited concatstabto(asmlist);
2878
function tarraydef.elesize : longint;
2880
elesize:=_elementtype.def.size;
2884
function tarraydef.size : longint;
2886
newsize : TConstExprInt;
2888
if IsDynamicArray then
2893
{Tarraydef.size may never be called for an open array!}
2894
if highrange<lowrange then
2895
internalerror(99080501);
2896
newsize:=(int64(highrange)-int64(lowrange)+1)*elesize;
2897
{ prevent an overflow }
2898
if newsize>high(longint) then
2899
result:=high(longint)
2905
procedure tarraydef.setelementtype(t: ttype);
2907
cachedsize : TConstExprInt;
2910
if not(IsDynamicArray or
2911
IsConvertedPointer or
2912
(highrange<lowrange)) then
2914
{ cache element size for performance on multidimensional arrays }
2915
cachedsize := elesize;
2916
if (cachedsize>0) and
2920
{ 1.0.x can't handle this and while bootstrapping with 1.0.x we can forget about it }
2923
(TConstExprInt(highrange)-TConstExprInt(lowrange) > $7fffffffffffffff) or
2925
{ () are needed around cachedsize-1 to avoid a possible
2926
integer overflow for cachedsize=1 !! PM }
2927
(($7fffffffffffffff div cachedsize + (cachedsize -1)) < (int64(highrange) - int64(lowrange)))
2930
(TConstExprInt(highrange)-TConstExprInt(lowrange) > $7fffffff) or
2932
{ () are needed around cachedsize-1 to avoid a possible
2933
integer overflow for cachedsize=1 !! PM }
2934
(($7fffffff div cachedsize + (cachedsize -1)) < (int64(highrange) - int64(lowrange)))
2937
Message(sym_e_segment_too_large);
2942
function tarraydef.alignment : longint;
2944
{ alignment is the size of the elements }
2945
if elementtype.def.deftype=recorddef then
2946
alignment:=elementtype.def.alignment
2952
function tarraydef.needs_inittable : boolean;
2954
needs_inittable:=IsDynamicArray or elementtype.def.needs_inittable;
2958
procedure tarraydef.write_child_rtti_data(rt:trttitype);
2960
tstoreddef(elementtype.def).get_rtti_label(rt);
2964
procedure tarraydef.write_rtti_data(rt:trttitype);
2966
if IsDynamicArray then
2967
rttiList.concat(Tai_const.Create_8bit(tkdynarray))
2969
rttiList.concat(Tai_const.Create_8bit(tkarray));
2971
{ size of elements }
2972
rttiList.concat(Tai_const.Create_32bit(elesize));
2973
{ count of elements, prevent overflow for 0..maxlongint }
2974
if not(IsDynamicArray) then
2975
rttiList.concat(Tai_const.Create_32bit(min(int64(highrange)-lowrange+1,maxlongint)));
2977
rttiList.concat(Tai_const_symbol.Create(tstoreddef(elementtype.def).get_rtti_label(rt)));
2983
function tarraydef.gettypename : string;
2985
if isarrayofconst or isConstructor then
2987
if isvariant or ((highrange=-1) and (lowrange=0)) then
2988
gettypename:='Array Of Const'
2990
gettypename:='Array Of '+elementtype.def.typename;
2992
else if ((highrange=-1) and (lowrange=0)) or IsDynamicArray then
2993
gettypename:='Array Of '+elementtype.def.typename
2996
if rangetype.def.deftype=enumdef then
2997
gettypename:='Array['+rangetype.def.typename+'] Of '+elementtype.def.typename
2999
gettypename:='Array['+tostr(lowrange)+'..'+
3000
tostr(highrange)+'] Of '+elementtype.def.typename
3005
function tarraydef.getmangledparaname : string;
3007
if isarrayofconst then
3008
getmangledparaname:='array_of_const'
3010
if ((highrange=-1) and (lowrange=0)) then
3011
getmangledparaname:='array_of_'+elementtype.def.mangledparaname
3013
internalerror(200204176);
3017
{***************************************************************************
3019
***************************************************************************}
3021
function tabstractrecorddef.getsymtable(t:tgetsymtable):tsymtable;
3024
getsymtable:=symtable
3031
procedure tabstractrecorddef.field_addname(p:Tnamedindexitem;arg:pointer);
3036
state:^Trecord_stabgen_state;
3039
{ static variables from objects are like global objects }
3040
if (Tsym(p).typ=varsym) and not (sp_static in Tsym(p).symoptions) then
3042
if (sp_protected in tsym(p).symoptions) then
3044
else if (sp_private in tsym(p).symoptions) then
3048
varsize:=tvarsym(p).vartype.def.size;
3049
{ open arrays made overflows !! }
3050
if varsize>$fffffff then
3052
newrec:=stabstr_evaluate('$1:$2,$3,$4;',[p.name,
3053
spec+tstoreddef(tvarsym(p).vartype.def).numberstring,
3054
tostr(tvarsym(p).fieldoffset*8),tostr(varsize*8)]);
3055
if state^.stabsize+strlen(newrec)>=state^.staballoc-256 then
3057
inc(state^.staballoc,memsizeinc);
3058
reallocmem(state^.stabstring,state^.staballoc);
3060
strcopy(state^.stabstring+state^.stabsize,newrec);
3061
inc(state^.stabsize,strlen(newrec));
3063
{This should be used for case !!}
3064
inc(state^.recoffset,Tvarsym(p).vartype.def.size);
3069
procedure tabstractrecorddef.field_concatstabto(p:Tnamedindexitem;arg:pointer);
3071
if (Tsym(p).typ=varsym) and not (sp_static in Tsym(p).symoptions) then
3072
tstoreddef(tvarsym(p).vartype.def).concatstabto(taasmoutput(arg));
3079
procedure tabstractrecorddef.count_field_rtti(sym : tnamedindexitem;arg:pointer);
3081
if (FRTTIType=fullrtti) or
3082
((tsym(sym).typ=varsym) and
3083
tvarsym(sym).vartype.def.needs_inittable) then
3088
procedure tabstractrecorddef.generate_field_rtti(sym:tnamedindexitem;arg:pointer);
3090
if (FRTTIType=fullrtti) or
3091
((tsym(sym).typ=varsym) and
3092
tvarsym(sym).vartype.def.needs_inittable) then
3093
tstoreddef(tvarsym(sym).vartype.def).get_rtti_label(FRTTIType);
3097
procedure tabstractrecorddef.write_field_rtti(sym : tnamedindexitem;arg:pointer);
3099
if (FRTTIType=fullrtti) or
3100
((tsym(sym).typ=varsym) and
3101
tvarsym(sym).vartype.def.needs_inittable) then
3103
rttiList.concat(Tai_const_symbol.Create(tstoreddef(tvarsym(sym).vartype.def).get_rtti_label(FRTTIType)));
3104
rttiList.concat(Tai_const.Create_32bit(tvarsym(sym).fieldoffset));
3110
{***************************************************************************
3112
***************************************************************************}
3114
constructor trecorddef.create(p : tsymtable);
3119
symtable.defowner:=self;
3124
constructor trecorddef.ppuload(ppufile:tcompilerppufile);
3126
inherited ppuloaddef(ppufile);
3128
savesize:=ppufile.getlongint;
3129
symtable:=trecordsymtable.create(0);
3130
trecordsymtable(symtable).datasize:=ppufile.getlongint;
3131
trecordsymtable(symtable).fieldalignment:=ppufile.getbyte;
3132
trecordsymtable(symtable).recordalignment:=ppufile.getbyte;
3133
trecordsymtable(symtable).ppuload(ppufile);
3134
symtable.defowner:=self;
3139
destructor trecorddef.destroy;
3141
if assigned(symtable) then
3147
function trecorddef.needs_inittable : boolean;
3149
needs_inittable:=trecordsymtable(symtable).needs_init_final
3153
procedure trecorddef.buildderef;
3155
oldrecsyms : tsymtable;
3157
inherited buildderef;
3158
oldrecsyms:=aktrecordsymtable;
3159
aktrecordsymtable:=symtable;
3160
{ now build the definitions }
3161
tstoredsymtable(symtable).buildderef;
3162
aktrecordsymtable:=oldrecsyms;
3166
procedure trecorddef.deref;
3168
oldrecsyms : tsymtable;
3171
oldrecsyms:=aktrecordsymtable;
3172
aktrecordsymtable:=symtable;
3173
{ now dereference the definitions }
3174
tstoredsymtable(symtable).deref;
3175
aktrecordsymtable:=oldrecsyms;
3176
{ assign TGUID? load only from system unit (unitid=1) }
3177
if not(assigned(rec_tguid)) and
3178
(upper(typename)='TGUID') and
3180
assigned(owner.name) and
3181
(owner.name^='SYSTEM') then
3186
procedure trecorddef.ppuwrite(ppufile:tcompilerppufile);
3188
inherited ppuwritedef(ppufile);
3189
ppufile.putlongint(savesize);
3190
ppufile.putlongint(trecordsymtable(symtable).datasize);
3191
ppufile.putbyte(trecordsymtable(symtable).fieldalignment);
3192
ppufile.putbyte(trecordsymtable(symtable).recordalignment);
3193
ppufile.writeentry(ibrecorddef);
3194
trecordsymtable(symtable).ppuwrite(ppufile);
3198
function trecorddef.size:longint;
3200
result:=trecordsymtable(symtable).datasize;
3204
function trecorddef.alignment:longint;
3206
alignment:=trecordsymtable(symtable).recordalignment;
3211
function trecorddef.stabstring : pchar;
3213
state:Trecord_stabgen_state;
3215
getmem(state.stabstring,memsizeinc);
3216
state.staballoc:=memsizeinc;
3217
strpcopy(state.stabstring,'s'+tostr(size));
3219
state.stabsize:=strlen(state.stabstring);
3220
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}field_addname,@state);
3221
state.stabstring[state.stabsize]:=';';
3222
state.stabstring[state.stabsize+1]:=#0;
3223
reallocmem(state.stabstring,state.stabsize+2);
3224
stabstring:=state.stabstring;
3228
procedure trecorddef.concatstabto(asmlist:taasmoutput);
3230
if (stab_state in [stab_state_writing,stab_state_written]) then
3232
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}field_concatstabto,asmlist);
3233
inherited concatstabto(asmlist);
3238
procedure trecorddef.write_child_rtti_data(rt:trttitype);
3241
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}generate_field_rtti,nil);
3245
procedure trecorddef.write_rtti_data(rt:trttitype);
3247
rttiList.concat(Tai_const.Create_8bit(tkrecord));
3249
rttiList.concat(Tai_const.Create_32bit(size));
3252
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_field_rtti,nil);
3253
rttiList.concat(Tai_const.Create_32bit(Count));
3254
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}write_field_rtti,nil);
3258
function trecorddef.gettypename : string;
3260
gettypename:='<record type>'
3264
{***************************************************************************
3266
***************************************************************************}
3268
constructor tabstractprocdef.create(level:byte);
3271
parast:=tparasymtable.create(level);
3272
parast.defowner:=self;
3274
para:=TLinkedList.Create;
3277
proctypeoption:=potype_none;
3278
proccalloption:=pocall_none;
3284
savesize:=POINTER_SIZE;
3285
has_paraloc_info:=false;
3289
destructor tabstractprocdef.destroy;
3291
if assigned(para) then
3301
if assigned(parast) then
3304
memprocparast.start;
3315
procedure tabstractprocdef.releasemem;
3324
function tabstractprocdef.concatpara(afterpara:tparaitem;const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
3328
hp:=TParaItem.Create;
3329
hp.paratyp:=tvarsym(sym).varspez;
3332
hp.is_hidden:=vhidden;
3333
hp.defaultvalue:=defval;
3334
{ Parameters are stored from left to right }
3335
if assigned(afterpara) then
3336
Para.insertafter(hp,afterpara)
3339
{ Don't count hidden parameters }
3342
if not assigned(defval) then
3350
function tabstractprocdef.insertpara(const tt:ttype;sym : tsym;defval:tsym;vhidden:boolean):tparaitem;
3354
hp:=TParaItem.Create;
3355
hp.paratyp:=tvarsym(sym).varspez;
3358
hp.is_hidden:=vhidden;
3359
hp.defaultvalue:=defval;
3360
{ Parameters are stored from left to right }
3362
{ Don't count hidden parameters }
3363
if (not vhidden) then
3365
if not assigned(defval) then
3373
procedure tabstractprocdef.removepara(currpara:tparaitem);
3375
{ Don't count hidden parameters }
3376
if (not currpara.is_hidden) then
3378
if not assigned(currpara.defaultvalue) then
3382
Para.Remove(currpara);
3387
{ all functions returning in FPU are
3388
assume to use 2 FPU registers
3389
until the function implementation
3391
procedure tabstractprocdef.test_if_fpu_result;
3394
if assigned(rettype.def) and
3395
(rettype.def.deftype=floatdef) then
3396
fpu_used:=maxfpuregs;
3401
procedure tabstractprocdef.buildderef;
3405
{ released procdef? }
3406
if not assigned(parast) then
3408
inherited buildderef;
3411
tparasymtable(parast).buildderef;
3413
hp:=TParaItem(Para.first);
3414
while assigned(hp) do
3416
hp.paratype.buildderef;
3417
hp.defaultvaluederef.build(hp.defaultvalue);
3418
hp.parasymderef.build(hp.parasym);
3419
hp:=TParaItem(hp.next);
3424
procedure tabstractprocdef.deref;
3431
tparasymtable(parast).deref;
3435
hp:=TParaItem(Para.first);
3436
while assigned(hp) do
3438
hp.paratype.resolve;
3439
hp.defaultvalue:=tsym(hp.defaultvaluederef.resolve);
3440
hp.parasym:=tvarsym(hp.parasymderef.resolve);
3441
{ connect parasym to paraitem }
3442
tvarsym(hp.parasym).paraitem:=hp;
3443
{ Don't count hidden parameters }
3444
if (not hp.is_hidden) then
3446
if not assigned(hp.defaultvalue) then
3450
hp:=TParaItem(hp.next);
3455
constructor tabstractprocdef.ppuload(ppufile:tcompilerppufile);
3460
inherited ppuloaddef(ppufile);
3462
Para:=TLinkedList.Create;
3465
ppufile.gettype(rettype);
3467
fpu_used:=ppufile.getbyte;
3471
proctypeoption:=tproctypeoption(ppufile.getbyte);
3472
proccalloption:=tproccalloption(ppufile.getbyte);
3473
ppufile.getsmallset(procoptions);
3474
{ get the number of parameters }
3475
count:=ppufile.getbyte;
3476
savesize:=POINTER_SIZE;
3477
has_paraloc_info:=false;
3478
for i:=1 to count do
3480
hp:=TParaItem.Create;
3481
hp.paratyp:=tvarspez(ppufile.getbyte);
3482
ppufile.gettype(hp.paratype);
3483
ppufile.getderef(hp.defaultvaluederef);
3484
hp.defaultvalue:=nil;
3485
ppufile.getderef(hp.parasymderef);
3487
hp.is_hidden:=boolean(ppufile.getbyte);
3488
if po_explicitparaloc in procoptions then
3490
if po_explicitparaloc in procoptions then
3491
ppufile.getdata(hp.paraloc,sizeof(hp.paraloc));
3492
has_paraloc_info:=true;
3494
{ Parameters are stored left to right in both ppu and memory }
3500
procedure tabstractprocdef.ppuwrite(ppufile:tcompilerppufile);
3503
oldintfcrc : boolean;
3505
{ released procdef? }
3506
if not assigned(parast) then
3508
inherited ppuwritedef(ppufile);
3509
ppufile.puttype(rettype);
3510
oldintfcrc:=ppufile.do_interface_crc;
3511
ppufile.do_interface_crc:=false;
3513
if simplify_ppu then
3515
ppufile.putbyte(fpu_used);
3519
ppufile.putbyte(ord(proctypeoption));
3520
ppufile.putbyte(ord(proccalloption));
3521
ppufile.putsmallset(procoptions);
3522
ppufile.do_interface_crc:=oldintfcrc;
3523
{ we need to store the count including vs_hidden }
3524
ppufile.putbyte(para.count);
3525
hp:=TParaItem(Para.first);
3526
while assigned(hp) do
3528
ppufile.putbyte(byte(hp.paratyp));
3529
ppufile.puttype(hp.paratype);
3530
ppufile.putderef(hp.defaultvaluederef);
3531
ppufile.putderef(hp.parasymderef);
3532
ppufile.putbyte(byte(hp.is_hidden));
3533
if po_explicitparaloc in procoptions then
3534
ppufile.putdata(hp.paraloc,sizeof(hp.paraloc));
3536
hp:=TParaItem(hp.next);
3542
function tabstractprocdef.typename_paras(showhidden:boolean) : string;
3549
hp:=TParaItem(Para.first);
3552
while assigned(hp) do
3554
if (not hp.is_hidden) or
3572
if assigned(hp.paratype.def.typesym) then
3576
hs:=hp.paratype.def.typesym.realname;
3578
s:=s+hp.paratype.def.typesym.realname
3580
s:=s+hp.paratype.def.gettypename;
3583
s:=s+hp.paratype.def.gettypename;
3585
if assigned(hp.defaultvalue) then
3587
hpc:=tconstsym(hp.defaultvalue);
3589
case hpc.consttyp of
3591
constresourcestring :
3592
hs:=strpas(pchar(hpc.value.valueptr));
3594
str(pbestreal(hpc.value.valueptr)^,hs);
3596
hs:=tostr(hpc.value.valueordptr);
3599
if is_boolean(hpc.consttype.def) then
3601
if hpc.value.valueord<>0 then
3607
hs:=tostr(hpc.value.valueord);
3618
hp:=TParaItem(hp.next);
3622
if (po_varargs in procoptions) then
3628
function tabstractprocdef.is_methodpointer:boolean;
3634
function tabstractprocdef.is_addressonly:boolean;
3641
function tabstractprocdef.stabstring : pchar;
3643
stabstring := strpnew('abstractproc'+numberstring+';');
3648
{***************************************************************************
3650
***************************************************************************}
3652
constructor tprocdef.create(level:byte);
3654
inherited create(level);
3656
has_mangledname:=false;
3658
fileinfo:=aktfilepos;
3660
aliasnames:=tstringlist.create;
3666
if (cs_browser in aktmoduleswitches) and make_ref then
3668
defref:=tref.create(defref,@akttokenpos);
3673
interfacedef:=false;
3678
fillchar(inlininginfo^,sizeof(tinlininginfo),0);
3681
isstabwritten := false;
3686
constructor tprocdef.ppuload(ppufile:tcompilerppufile);
3690
inherited ppuload(ppufile);
3693
has_mangledname:=boolean(ppufile.getbyte);
3694
if has_mangledname then
3695
_mangledname:=stringdup(ppufile.getstring)
3698
overloadnumber:=ppufile.getword;
3699
extnumber:=ppufile.getword;
3700
level:=ppufile.getbyte;
3701
ppufile.getderef(_classderef);
3702
ppufile.getderef(procsymderef);
3703
ppufile.getposinfo(fileinfo);
3704
ppufile.getsmallset(symoptions);
3706
{ library symbol for AmigaOS/MorphOS }
3707
ppufile.getderef(libsymderef);
3710
if proccalloption=pocall_inline then
3712
ppufile.getderef(funcretsymderef);
3714
ppufile.getsmallset(inlininginfo^.flags);
3719
{ load para symtable }
3720
parast:=tparasymtable.create(level);
3721
tparasymtable(parast).ppuload(ppufile);
3722
parast.defowner:=self;
3723
{ load local symtable }
3724
if (proccalloption=pocall_inline) or
3725
((current_module.flags and uf_local_browser)<>0) then
3727
localst:=tlocalsymtable.create(level);
3728
tlocalsymtable(localst).ppuload(ppufile);
3729
localst.defowner:=self;
3735
if proccalloption=pocall_inline then
3736
inlininginfo^.code:=ppuloadnodetree(ppufile)
3738
inlininginfo := nil;
3740
{ default values for no persistent data }
3741
if (cs_link_deffile in aktglobalswitches) and
3742
(tf_need_export in target_info.flags) and
3743
(po_exports in procoptions) then
3744
deffile.AddExport(mangledname);
3745
aliasnames:=tstringlist.create;
3747
interfacedef:=false;
3754
isstabwritten := false;
3759
destructor tprocdef.destroy;
3761
if assigned(defref) then
3767
if assigned(localst) and (localst.symtabletype<>staticsymtable) then
3770
memproclocalst.start;
3774
memproclocalst.start;
3777
if (proccalloption=pocall_inline) and assigned(inlininginfo) then
3780
memprocnodetree.start;
3782
tnode(inlininginfo^.code).free;
3784
memprocnodetree.start;
3787
if assigned(inlininginfo) then
3788
dispose(inlininginfo);
3789
if (po_msgstr in procoptions) then
3790
strdispose(messageinf.str);
3791
if assigned(_mangledname) then
3794
memmanglednames.start;
3796
stringdispose(_mangledname);
3798
memmanglednames.stop;
3805
procedure tprocdef.ppuwrite(ppufile:tcompilerppufile);
3807
oldintfcrc : boolean;
3809
oldlocalsymtable : tsymtable;
3811
{ released procdef? }
3812
if not assigned(parast) then
3815
oldparasymtable:=aktparasymtable;
3816
oldlocalsymtable:=aktlocalsymtable;
3817
aktparasymtable:=parast;
3818
aktlocalsymtable:=localst;
3820
inherited ppuwrite(ppufile);
3821
oldintfcrc:=ppufile.do_interface_crc;
3822
ppufile.do_interface_crc:=false;
3823
ppufile.do_interface_crc:=oldintfcrc;
3824
ppufile.putbyte(byte(has_mangledname));
3825
if has_mangledname then
3826
ppufile.putstring(_mangledname^);
3827
ppufile.putword(overloadnumber);
3828
ppufile.putword(extnumber);
3829
ppufile.putbyte(parast.symtablelevel);
3830
ppufile.putderef(_classderef);
3831
ppufile.putderef(procsymderef);
3832
ppufile.putposinfo(fileinfo);
3833
ppufile.putsmallset(symoptions);
3835
{ library symbol for AmigaOS/MorphOS }
3836
ppufile.putderef(libsymderef);
3839
oldintfcrc:=ppufile.do_crc;
3840
ppufile.do_crc:=false;
3841
if proccalloption=pocall_inline then
3843
ppufile.putderef(funcretsymderef);
3844
ppufile.putsmallset(inlininginfo^.flags);
3847
ppufile.do_crc:=oldintfcrc;
3849
{ write this entry }
3850
ppufile.writeentry(ibprocdef);
3852
{ Save the para symtable, this is taken from the interface }
3853
tparasymtable(parast).ppuwrite(ppufile);
3855
{ save localsymtable for inline procedures or when local
3856
browser info is requested, this has no influence on the crc }
3857
if (proccalloption=pocall_inline) or
3858
((current_module.flags and uf_local_browser)<>0) then
3860
oldintfcrc:=ppufile.do_crc;
3861
ppufile.do_crc:=false;
3862
if not assigned(localst) then
3864
tlocalsymtable(localst).ppuwrite(ppufile);
3865
ppufile.do_crc:=oldintfcrc;
3868
{ node tree for inlining }
3869
oldintfcrc:=ppufile.do_crc;
3870
ppufile.do_crc:=false;
3871
if proccalloption=pocall_inline then
3872
ppuwritenodetree(ppufile,inlininginfo^.code);
3874
ppufile.do_crc:=oldintfcrc;
3876
aktparasymtable:=oldparasymtable;
3877
aktlocalsymtable:=oldlocalsymtable;
3881
procedure tprocdef.insert_localst;
3883
localst:=tlocalsymtable.create(parast.symtablelevel);
3884
localst.defowner:=self;
3885
{ this is used by insert
3886
to check same names in parast and localst }
3887
localst.next:=parast;
3891
function tprocdef.fullprocname(showhidden:boolean):string;
3900
if assigned(_class) then
3902
if po_classmethod in procoptions then
3904
s:=s+_class.objrealname^+'.';
3906
if proctypeoption=potype_operator then
3908
for t:=NOTOKEN to last_overloaded do
3909
if procsym.realname='$'+overloaded_names[t] then
3911
s:='operator '+arraytokeninfo[t].str+typename_paras(showhidden);
3916
s:=s+procsym.realname+typename_paras(showhidden);
3917
case proctypeoption of
3919
s:='constructor '+s;
3923
if assigned(rettype.def) and
3924
not(is_void(rettype.def)) then
3925
s:=s+':'+rettype.def.gettypename;
3927
{ forced calling convention? }
3928
if (po_hascallingconvention in procoptions) then
3929
s:=s+';'+ProcCallOptionStr[proccalloption];
3934
function tprocdef.is_methodpointer:boolean;
3936
result:=assigned(_class);
3940
function tprocdef.is_addressonly:boolean;
3942
result:=assigned(owner) and
3943
(owner.symtabletype<>objectsymtable);
3947
function tprocdef.is_visible_for_object(currobjdef:tobjectdef):boolean;
3949
is_visible_for_object:=false;
3951
{ private symbols are allowed when we are in the same
3952
module as they are defined }
3953
if (sp_private in symoptions) and
3954
(owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
3955
(owner.defowner.owner.unitid<>0) then
3958
{ protected symbols are vissible in the module that defines them and
3959
also visible to related objects. The related object must be defined
3960
in the current module }
3961
if (sp_protected in symoptions) and
3964
(owner.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
3965
(owner.defowner.owner.unitid<>0)
3968
assigned(currobjdef) and
3969
(currobjdef.owner.unitid=0) and
3970
currobjdef.is_related(tobjectdef(owner.defowner))
3975
is_visible_for_object:=true;
3979
function tprocdef.getsymtable(t:tgetsymtable):tsymtable;
3983
getsymtable:=localst;
3985
getsymtable:=parast;
3992
procedure tprocdef.load_references(ppufile:tcompilerppufile;locals:boolean);
3995
move_last : boolean;
3997
oldlocalsymtable : tsymtable;
3999
oldparasymtable:=aktparasymtable;
4000
oldlocalsymtable:=aktlocalsymtable;
4001
aktparasymtable:=parast;
4002
aktlocalsymtable:=localst;
4004
move_last:=lastwritten=lastref;
4005
while (not ppufile.endofentry) do
4007
ppufile.getposinfo(pos);
4009
lastref:=tref.create(lastref,@pos);
4010
lastref.is_written:=true;
4015
lastwritten:=lastref;
4016
if ((current_module.flags and uf_local_browser)<>0) and
4019
tparasymtable(parast).load_references(ppufile,locals);
4020
tlocalsymtable(localst).load_references(ppufile,locals);
4023
aktparasymtable:=oldparasymtable;
4024
aktlocalsymtable:=oldlocalsymtable;
4029
local_symtable_index : word = $8001;
4031
function tprocdef.write_references(ppufile:tcompilerppufile;locals:boolean):boolean;
4035
move_last : boolean;
4038
oldlocalsymtable : tsymtable;
4041
move_last:=lastwritten=lastref;
4043
(((current_module.flags and uf_local_browser)=0) or
4046
oldparasymtable:=aktparasymtable;
4047
oldlocalsymtable:=aktlocalsymtable;
4048
aktparasymtable:=parast;
4049
aktlocalsymtable:=localst;
4050
{ write address of this symbol }
4052
ppufile.putderef(d);
4054
if assigned(lastwritten) then
4058
while assigned(ref) do
4060
if ref.moduleindex=current_module.unit_index then
4062
ppufile.putposinfo(ref.posinfo);
4063
ref.is_written:=true;
4067
else if not ref.is_written then
4069
else if move_last then
4073
ppufile.writeentry(ibdefref);
4074
write_references:=true;
4075
if ((current_module.flags and uf_local_browser)<>0) and
4079
if (owner.symtabletype<>localsymtable) then
4080
while assigned(pdo) do
4082
if pdo.symtable<>aktrecordsymtable then
4084
pdo.symtable.unitid:=local_symtable_index;
4085
inc(local_symtable_index);
4089
parast.unitid:=local_symtable_index;
4090
inc(local_symtable_index);
4091
localst.unitid:=local_symtable_index;
4092
inc(local_symtable_index);
4093
tstoredsymtable(parast).write_references(ppufile,locals);
4094
tstoredsymtable(localst).write_references(ppufile,locals);
4096
local_symtable_index:=local_symtable_index-2;
4098
if (owner.symtabletype<>localsymtable) then
4099
while assigned(pdo) do
4101
if pdo.symtable<>aktrecordsymtable then
4102
dec(local_symtable_index);
4106
aktparasymtable:=oldparasymtable;
4107
aktlocalsymtable:=oldlocalsymtable;
4111
function tprocdef.numberstring : string;
4113
{ procdefs are always available }
4114
stab_state:=stab_state_written;
4115
result:=inherited numberstring;
4119
function tprocdef.stabstring: pchar;
4126
obj := procsym.name;
4128
if tprocsym(procsym).is_global then
4132
if assigned(owner) then
4134
if (owner.symtabletype = objectsymtable) then
4135
obj := owner.name^+'__'+procsym.name;
4136
if not(cs_gdb_valgrind in aktglobalswitches) and
4137
(owner.symtabletype=localsymtable) and
4138
assigned(owner.defowner) and
4139
assigned(tprocdef(owner.defowner).procsym) then
4140
info := ','+procsym.name+','+tprocdef(owner.defowner).procsym.name;
4142
stabsstr:=mangledname;
4143
getmem(p,length(stabsstr)+255);
4144
strpcopy(p,'"'+obj+':'+RType
4145
+tstoreddef(rettype.def).numberstring+info+'",'+tostr(n_function)
4147
tostr(fileinfo.line)
4149
strpcopy(strend(p),stabsstr);
4150
stabstring:=strnew(p);
4151
freemem(p,length(stabsstr)+255);
4155
procedure tprocdef.concatstabto(asmlist : taasmoutput);
4157
{ released procdef? }
4158
if not assigned(parast) then
4160
if (proccalloption=pocall_internproc) then
4162
{ be sure to have a number assigned for this def }
4165
stab_state:=stab_state_writing;
4166
asmList.concat(Tai_stabs.Create(stabstring));
4167
if not(po_external in procoptions) then
4169
tstoredsymtable(parast).concatstabto(asmlist);
4170
{ local type defs and vars should not be written
4171
inside the main proc stab }
4172
if assigned(localst) and
4173
(localst.symtablelevel>main_program_level) then
4174
tstoredsymtable(localst).concatstabto(asmlist);
4176
stab_state:=stab_state_written;
4181
procedure tprocdef.buildderef;
4184
oldlocalsymtable : tsymtable;
4186
oldparasymtable:=aktparasymtable;
4187
oldlocalsymtable:=aktlocalsymtable;
4188
aktparasymtable:=parast;
4189
aktlocalsymtable:=localst;
4191
inherited buildderef;
4192
_classderef.build(_class);
4193
{ procsym that originaly defined this definition, should be in the
4195
procsymderef.build(procsym);
4197
{ library symbol for AmigaOS/MorphOS }
4198
libsymderef.build(libsym);
4201
aktparasymtable:=oldparasymtable;
4202
aktlocalsymtable:=oldlocalsymtable;
4206
procedure tprocdef.buildderefimpl;
4209
oldlocalsymtable : tsymtable;
4211
{ released procdef? }
4212
if not assigned(parast) then
4215
oldparasymtable:=aktparasymtable;
4216
oldlocalsymtable:=aktlocalsymtable;
4217
aktparasymtable:=parast;
4218
aktlocalsymtable:=localst;
4220
inherited buildderefimpl;
4223
if assigned(localst) then
4225
tlocalsymtable(localst).buildderef;
4226
tlocalsymtable(localst).buildderefimpl;
4227
funcretsymderef.build(funcretsym);
4231
if (proccalloption=pocall_inline) then
4232
inlininginfo^.code.buildderefimpl;
4234
aktparasymtable:=oldparasymtable;
4235
aktlocalsymtable:=oldlocalsymtable;
4239
procedure tprocdef.deref;
4242
oldlocalsymtable : tsymtable;
4244
{ released procdef? }
4245
if not assigned(parast) then
4248
oldparasymtable:=aktparasymtable;
4249
oldlocalsymtable:=aktlocalsymtable;
4250
aktparasymtable:=parast;
4251
aktlocalsymtable:=localst;
4254
_class:=tobjectdef(_classderef.resolve);
4255
{ procsym that originaly defined this definition, should be in the
4257
procsym:=tprocsym(procsymderef.resolve);
4259
{ library symbol for AmigaOS/MorphOS }
4260
libsym:=tvarsym(libsymderef.resolve);
4263
aktparasymtable:=oldparasymtable;
4264
aktlocalsymtable:=oldlocalsymtable;
4268
procedure tprocdef.derefimpl;
4271
oldlocalsymtable : tsymtable;
4273
oldparasymtable:=aktparasymtable;
4274
oldlocalsymtable:=aktlocalsymtable;
4275
aktparasymtable:=parast;
4276
aktlocalsymtable:=localst;
4279
if assigned(localst) then
4282
{ we can deref both interface and implementation parts }
4283
tlocalsymtable(localst).deref;
4284
tlocalsymtable(localst).derefimpl;
4285
{ funcretsym, this is always located in the localst }
4286
funcretsym:=tsym(funcretsymderef.resolve);
4295
if (proccalloption=pocall_inline) then
4296
inlininginfo^.code.derefimpl;
4298
aktparasymtable:=oldparasymtable;
4299
aktlocalsymtable:=oldlocalsymtable;
4303
function tprocdef.gettypename : string;
4305
gettypename := FullProcName(false);
4309
function tprocdef.mangledname : string;
4313
if assigned(_mangledname) then
4316
mangledname:=minilzw_decode(_mangledname^);
4318
mangledname:=_mangledname^;
4322
{ we need to use the symtable where the procsym is inserted,
4323
because that is visible to the world }
4324
mangledname:=make_mangledname('',procsym.owner,procsym.name);
4325
if overloadnumber>0 then
4326
mangledname:=mangledname+'$'+tostr(overloadnumber);
4327
{ add parameter types }
4328
hp:=TParaItem(Para.first);
4329
while assigned(hp) do
4331
if not hp.is_hidden then
4332
mangledname:=mangledname+'$'+hp.paratype.def.mangledparaname;
4333
hp:=TParaItem(hp.next);
4336
_mangledname:=stringdup(minilzw_encode(mangledname));
4338
_mangledname:=stringdup(mangledname);
4343
function tprocdef.cplusplusmangledname : string;
4345
function getcppparaname(p : tdef) : string;
4348
ordtype2str : array[tbasetype] of string[2] = (
4350
'Uc','Us','Ui','Us',
4361
s:=ordtype2str[torddef(p).typ];
4363
s:='P'+getcppparaname(tpointerdef(p).pointertype.def);
4365
internalerror(2103001);
4375
s := procsym.realname;
4376
if procsym.owner.symtabletype=objectsymtable then
4378
s2:=upper(tobjectdef(procsym.owner.defowner).typesym.realname);
4379
case proctypeoption of
4381
s:='_$_'+tostr(length(s2))+s2;
4383
s:='___'+tostr(length(s2))+s2;
4385
s:='_'+s+'__'+tostr(length(s2))+s2;
4393
{ concat modifiers }
4396
{ now we handle the parameters }
4397
param := TParaItem(Para.first);
4398
if assigned(param) then
4399
while assigned(param) do
4401
s2:=getcppparaname(param.paratype.def);
4402
if param.paratyp in [vs_var,vs_out] then
4405
param:=TParaItem(param.next);
4409
cplusplusmangledname:=s;
4413
procedure tprocdef.setmangledname(const s : string);
4415
stringdispose(_mangledname);
4417
_mangledname:=stringdup(minilzw_encode(s));
4419
_mangledname:=stringdup(s);
4421
has_mangledname:=true;
4425
{***************************************************************************
4427
***************************************************************************}
4429
constructor tprocvardef.create(level:byte);
4431
inherited create(level);
4432
deftype:=procvardef;
4436
constructor tprocvardef.ppuload(ppufile:tcompilerppufile);
4438
inherited ppuload(ppufile);
4439
deftype:=procvardef;
4440
{ load para symtable }
4441
parast:=tparasymtable.create(unknown_level);
4442
tparasymtable(parast).ppuload(ppufile);
4443
parast.defowner:=self;
4447
procedure tprocvardef.ppuwrite(ppufile:tcompilerppufile);
4450
oldlocalsymtable : tsymtable;
4452
oldparasymtable:=aktparasymtable;
4453
oldlocalsymtable:=aktlocalsymtable;
4454
aktparasymtable:=parast;
4455
aktlocalsymtable:=nil;
4457
{ here we cannot get a real good value so just give something }
4459
{ a more secure way would be
4460
to allways store in a temp }
4462
if is_fpu(rettype.def) then
4463
fpu_used:={2}maxfpuregs
4467
inherited ppuwrite(ppufile);
4469
{ Write this entry }
4470
ppufile.writeentry(ibprocvardef);
4472
{ Save the para symtable, this is taken from the interface }
4473
tparasymtable(parast).ppuwrite(ppufile);
4475
aktparasymtable:=oldparasymtable;
4476
aktlocalsymtable:=oldlocalsymtable;
4480
procedure tprocvardef.buildderef;
4483
oldlocalsymtable : tsymtable;
4485
oldparasymtable:=aktparasymtable;
4486
oldlocalsymtable:=aktlocalsymtable;
4487
aktparasymtable:=parast;
4488
aktlocalsymtable:=nil;
4490
inherited buildderef;
4492
aktparasymtable:=oldparasymtable;
4493
aktlocalsymtable:=oldlocalsymtable;
4497
procedure tprocvardef.deref;
4500
oldlocalsymtable : tsymtable;
4502
oldparasymtable:=aktparasymtable;
4503
oldlocalsymtable:=aktlocalsymtable;
4504
aktparasymtable:=parast;
4505
aktlocalsymtable:=nil;
4509
aktparasymtable:=oldparasymtable;
4510
aktlocalsymtable:=oldlocalsymtable;
4514
function tprocvardef.getsymtable(t:tgetsymtable):tsymtable;
4518
getsymtable:=parast;
4525
function tprocvardef.size : longint;
4527
if (po_methodpointer in procoptions) and
4528
not(po_addressonly in procoptions) then
4529
size:=2*POINTER_SIZE
4535
function tprocvardef.is_methodpointer:boolean;
4537
result:=(po_methodpointer in procoptions);
4541
function tprocvardef.is_addressonly:boolean;
4543
result:=not(po_methodpointer in procoptions) or
4544
(po_addressonly in procoptions);
4549
function tprocvardef.stabstring : pchar;
4554
{ i := maxparacount; }
4556
{ it is not a function but a function pointer !! (PM) }
4558
strpcopy(nss,'*f'+tstoreddef(rettype.def).numberstring{+','+tostr(i)});
4559
{ this confuses gdb !!
4560
we should use 'F' instead of 'f' but
4561
as we use c++ language mode
4562
it does not like that either
4563
Please do not remove this part
4565
gdb for pascal is ready PM }
4569
while assigned(param) do
4572
if param^.paratyp = vs_value then vartyp := '1' else vartyp := '0';
4573
{Here we have lost the parameter names !!}
4574
pst := strpnew('p'+tostr(i)+':'+param^.paratype.def.numberstring+','+vartyp+';');
4577
param := param^.next;
4580
{strpcopy(strend(nss),';');}
4581
stabstring := strnew(nss);
4586
procedure tprocvardef.concatstabto(asmlist : taasmoutput);
4588
if (stab_state in [stab_state_writing,stab_state_written]) then
4590
tstoreddef(rettype.def).concatstabto(asmlist);
4591
inherited concatstabto(asmlist);
4596
procedure tprocvardef.write_rtti_data(rt:trttitype);
4599
methodkind, paraspec : byte;
4601
if po_methodpointer in procoptions then
4603
{ write method id and name }
4604
rttiList.concat(Tai_const.Create_8bit(tkmethod));
4607
{ write kind of method (can only be function or procedure)}
4608
if rettype.def = voidtype.def then
4609
methodkind := mkProcedure
4611
methodkind := mkFunction;
4612
rttiList.concat(Tai_const.Create_8bit(methodkind));
4614
{ get # of parameters }
4615
rttiList.concat(Tai_const.Create_8bit(maxparacount));
4617
{ write parameter info. The parameters must be written in reverse order
4618
if this method uses right to left parameter pushing! }
4619
if proccalloption in pushleftright_pocalls then
4620
pdc:=TParaItem(Para.first)
4622
pdc:=TParaItem(Para.last);
4623
while assigned(pdc) do
4625
{ only store user visible parameters }
4626
if not pdc.is_hidden then
4629
vs_value: paraspec := 0;
4630
vs_const: paraspec := pfConst;
4631
vs_var : paraspec := pfVar;
4632
vs_out : paraspec := pfOut;
4634
{ write flags for current parameter }
4635
rttiList.concat(Tai_const.Create_8bit(paraspec));
4636
{ write name of current parameter }
4637
if assigned(pdc.parasym) then
4639
rttiList.concat(Tai_const.Create_8bit(length(pdc.parasym.realname)));
4640
rttiList.concat(Tai_string.Create(pdc.parasym.realname));
4643
rttiList.concat(Tai_const.Create_8bit(0));
4645
{ write name of type of current parameter }
4646
tstoreddef(pdc.paratype.def).write_rtti_name;
4648
if proccalloption in pushleftright_pocalls then
4649
pdc:=TParaItem(pdc.next)
4651
pdc:=TParaItem(pdc.previous);
4654
{ write name of result type }
4655
tstoreddef(rettype.def).write_rtti_name;
4660
function tprocvardef.is_publishable : boolean;
4662
is_publishable:=(po_methodpointer in procoptions);
4666
function tprocvardef.gettypename : string;
4669
showhidden : boolean;
4677
if po_classmethod in procoptions then
4678
s := s+'class method type of'
4680
if po_addressonly in procoptions then
4683
s := s+'procedure variable type of';
4684
if assigned(rettype.def) and
4685
(rettype.def<>voidtype.def) then
4686
s:=s+' function'+typename_paras(showhidden)+':'+rettype.def.gettypename
4688
s:=s+' procedure'+typename_paras(showhidden);
4689
if po_methodpointer in procoptions then
4690
s := s+' of object';
4691
gettypename := s+';'+ProcCallOptionStr[proccalloption]+'>';
4695
{***************************************************************************
4697
***************************************************************************}
4700
constructor tobjectdef.create(ot : tobjectdeftype;const n : string;c : tobjectdef);
4707
symtable:=tobjectsymtable.create(n,aktpackrecords);
4708
{ create space for vmt !! }
4710
symtable.defowner:=self;
4713
objname:=stringdup(upper(n));
4714
objrealname:=stringdup(n);
4715
if objecttype in [odt_interfacecorba,odt_interfacecom] then
4717
{ setup implemented interfaces }
4718
if objecttype in [odt_class,odt_interfacecorba] then
4719
implementedinterfaces:=timplementedinterfaces.create
4721
implementedinterfaces:=nil;
4724
writing_class_record_stab:=false;
4729
constructor tobjectdef.ppuload(ppufile:tcompilerppufile);
4731
i,implintfcount: longint;
4734
inherited ppuloaddef(ppufile);
4736
objecttype:=tobjectdeftype(ppufile.getbyte);
4737
savesize:=ppufile.getlongint;
4738
vmt_offset:=ppufile.getlongint;
4739
objrealname:=stringdup(ppufile.getstring);
4740
objname:=stringdup(upper(objrealname^));
4741
ppufile.getderef(childofderef);
4742
ppufile.getsmallset(objectoptions);
4746
if objecttype in [odt_interfacecom,odt_interfacecorba] then
4749
ppufile.getguid(iidguid^);
4750
iidstr:=stringdup(ppufile.getstring);
4751
lastvtableindex:=ppufile.getlongint;
4754
{ load implemented interfaces }
4755
if objecttype in [odt_class,odt_interfacecorba] then
4757
implementedinterfaces:=timplementedinterfaces.create;
4758
implintfcount:=ppufile.getlongint;
4759
for i:=1 to implintfcount do
4761
ppufile.getderef(d);
4762
implementedinterfaces.addintf_deref(d);
4763
implementedinterfaces.ioffsets(i)^:=ppufile.getlongint;
4767
implementedinterfaces:=nil;
4769
symtable:=tobjectsymtable.create(objrealname^,aktpackrecords);
4770
tobjectsymtable(symtable).datasize:=ppufile.getlongint;
4771
tobjectsymtable(symtable).fieldalignment:=ppufile.getbyte;
4772
tobjectsymtable(symtable).recordalignment:=ppufile.getbyte;
4773
tobjectsymtable(symtable).ppuload(ppufile);
4775
symtable.defowner:=self;
4777
{ handles the predefined class tobject }
4778
{ the last TOBJECT which is loaded gets }
4780
if (childof=nil) and
4781
(objecttype=odt_class) and
4782
(objname^='TOBJECT') then
4783
class_tobject:=self;
4784
if (childof=nil) and
4785
(objecttype=odt_interfacecom) and
4786
(objname^='IUNKNOWN') then
4787
interface_iunknown:=self;
4789
writing_class_record_stab:=false;
4794
destructor tobjectdef.destroy;
4796
if assigned(symtable) then
4798
stringdispose(objname);
4799
stringdispose(objrealname);
4800
if assigned(iidstr) then
4801
stringdispose(iidstr);
4802
if assigned(implementedinterfaces) then
4803
implementedinterfaces.free;
4804
if assigned(iidguid) then
4810
procedure tobjectdef.ppuwrite(ppufile:tcompilerppufile);
4812
implintfcount : longint;
4815
inherited ppuwritedef(ppufile);
4816
ppufile.putbyte(byte(objecttype));
4817
ppufile.putlongint(size);
4818
ppufile.putlongint(vmt_offset);
4819
ppufile.putstring(objrealname^);
4820
ppufile.putderef(childofderef);
4821
ppufile.putsmallset(objectoptions);
4822
if objecttype in [odt_interfacecom,odt_interfacecorba] then
4824
ppufile.putguid(iidguid^);
4825
ppufile.putstring(iidstr^);
4826
ppufile.putlongint(lastvtableindex);
4829
if objecttype in [odt_class,odt_interfacecorba] then
4831
implintfcount:=implementedinterfaces.count;
4832
ppufile.putlongint(implintfcount);
4833
for i:=1 to implintfcount do
4835
ppufile.putderef(implementedinterfaces.interfacesderef(i));
4836
ppufile.putlongint(implementedinterfaces.ioffsets(i)^);
4840
ppufile.putlongint(tobjectsymtable(symtable).datasize);
4841
ppufile.putbyte(tobjectsymtable(symtable).fieldalignment);
4842
ppufile.putbyte(tobjectsymtable(symtable).recordalignment);
4843
ppufile.writeentry(ibobjectdef);
4845
tobjectsymtable(symtable).ppuwrite(ppufile);
4849
function tobjectdef.gettypename:string;
4851
gettypename:=typename;
4855
procedure tobjectdef.buildderef;
4857
oldrecsyms : tsymtable;
4859
inherited buildderef;
4860
childofderef.build(childof);
4861
oldrecsyms:=aktrecordsymtable;
4862
aktrecordsymtable:=symtable;
4863
tstoredsymtable(symtable).buildderef;
4864
aktrecordsymtable:=oldrecsyms;
4865
if objecttype in [odt_class,odt_interfacecorba] then
4866
implementedinterfaces.buildderef;
4870
procedure tobjectdef.deref;
4872
oldrecsyms : tsymtable;
4875
childof:=tobjectdef(childofderef.resolve);
4876
oldrecsyms:=aktrecordsymtable;
4877
aktrecordsymtable:=symtable;
4878
tstoredsymtable(symtable).deref;
4879
aktrecordsymtable:=oldrecsyms;
4880
if objecttype in [odt_class,odt_interfacecorba] then
4881
implementedinterfaces.deref;
4885
function tobjectdef.getparentdef:tdef;
4891
procedure tobjectdef.prepareguid;
4894
if not assigned(iidguid) then
4897
fillchar(iidguid^,sizeof(iidguid^),0); { default null guid }
4900
if not assigned(iidstr) then
4901
iidstr:=stringdup(''); { default is empty string }
4905
procedure tobjectdef.set_parent( c : tobjectdef);
4907
{ nothing to do if the parent was not forward !}
4908
if assigned(childof) then
4911
{ some options are inherited !! }
4914
{ only important for classes }
4915
lastvtableindex:=c.lastvtableindex;
4916
objectoptions:=objectoptions+(c.objectoptions*
4917
[oo_has_virtual,oo_has_private,oo_has_protected,
4918
oo_has_constructor,oo_has_destructor]);
4919
if not (objecttype in [odt_interfacecom,odt_interfacecorba]) then
4921
{ add the data of the anchestor class }
4922
inc(tobjectsymtable(symtable).datasize,tobjectsymtable(c.symtable).datasize);
4923
if (oo_has_vmt in objectoptions) and
4924
(oo_has_vmt in c.objectoptions) then
4925
dec(tobjectsymtable(symtable).datasize,POINTER_SIZE);
4926
{ if parent has a vmt field then
4927
the offset is the same for the child PM }
4928
if (oo_has_vmt in c.objectoptions) or is_class(self) then
4930
vmt_offset:=c.vmt_offset;
4931
include(objectoptions,oo_has_vmt);
4935
savesize := tobjectsymtable(symtable).datasize;
4939
procedure tobjectdef.insertvmt;
4941
if objecttype in [odt_interfacecom,odt_interfacecorba] then
4943
if (oo_has_vmt in objectoptions) then
4944
internalerror(12345)
4947
tobjectsymtable(symtable).datasize:=align(tobjectsymtable(symtable).datasize,
4948
tobjectsymtable(symtable).fieldalignment);
4949
vmt_offset:=tobjectsymtable(symtable).datasize;
4950
inc(tobjectsymtable(symtable).datasize,POINTER_SIZE);
4951
include(objectoptions,oo_has_vmt);
4957
procedure tobjectdef.check_forwards;
4959
if not(objecttype in [odt_interfacecom,odt_interfacecorba]) then
4960
tstoredsymtable(symtable).check_forwards;
4961
if (oo_is_forward in objectoptions) then
4963
{ ok, in future, the forward can be resolved }
4964
Message1(sym_e_class_forward_not_resolved,objrealname^);
4965
exclude(objectoptions,oo_is_forward);
4970
{ true, if self inherits from d (or if they are equal) }
4971
function tobjectdef.is_related(d : tobjectdef) : boolean;
4976
while assigned(hp) do
4989
(* procedure tobjectdef._searchdestructor(sym : tnamedindexitem;arg:pointer);
4995
{ if we found already a destructor, then we exit }
4996
if assigned(sd) then
4998
if tsym(sym).typ=procsym then
5000
p:=tprocsym(sym).defs;
5001
while assigned(p) do
5003
if p^.def.proctypeoption=potype_destructor then
5013
procedure _searchdestructor(sym:Tnamedindexitem;sd:pointer);
5016
{ if we found already a destructor, then we exit }
5017
if (ppointer(sd)^=nil) and
5018
(Tsym(sym).typ=procsym) then
5019
ppointer(sd)^:=Tprocsym(sym).search_procdef_bytype(potype_destructor);
5022
function tobjectdef.searchdestructor : tprocdef;
5028
searchdestructor:=nil;
5031
while assigned(o) do
5033
o.symtable.foreach_static({$ifdef FPCPROCVAR}@{$endif}_searchdestructor,@sd);
5034
if assigned(sd) then
5036
searchdestructor:=sd;
5044
function tobjectdef.size : longint;
5046
if objecttype in [odt_class,odt_interfacecom,odt_interfacecorba] then
5047
result:=POINTER_SIZE
5049
result:=tobjectsymtable(symtable).datasize;
5053
function tobjectdef.alignment:longint;
5055
if objecttype in [odt_class,odt_interfacecom,odt_interfacecorba] then
5056
alignment:=POINTER_SIZE
5058
alignment:=tobjectsymtable(symtable).recordalignment;
5062
function tobjectdef.vmtmethodoffset(index:longint):longint;
5064
{ for offset of methods for classes, see rtl/inc/objpash.inc }
5067
vmtmethodoffset:=(index+12)*POINTER_SIZE;
5068
odt_interfacecom,odt_interfacecorba:
5069
vmtmethodoffset:=index*POINTER_SIZE;
5072
vmtmethodoffset:=(index+4)*POINTER_SIZE;
5074
vmtmethodoffset:=(index+3)*POINTER_SIZE;
5080
function tobjectdef.vmt_mangledname : string;
5082
if not(oo_has_vmt in objectoptions) then
5083
Message1(parser_n_object_has_no_vmt,objrealname^);
5084
vmt_mangledname:=make_mangledname('VMT',owner,objname^);
5088
function tobjectdef.rtti_name : string;
5090
rtti_name:=make_mangledname('RTTI',owner,objname^);
5095
procedure tobjectdef.proc_addname(p :tnamedindexitem;arg:pointer);
5096
var virtualind,argnames : string;
5103
state:^Trecord_stabgen_state;
5107
if tsym(p).typ = procsym then
5109
pd := tprocsym(p).first_procdef;
5110
if (po_virtualmethod in pd.procoptions) then
5112
lindex := pd.extnumber;
5113
{doesnt seem to be necessary
5114
lindex := lindex or $80000000;}
5115
virtualind := '*'+tostr(lindex)+';'+pd._class.classnumberstring+';'
5120
{ used by gdbpas to recognize constructor and destructors }
5121
if (pd.proctypeoption=potype_constructor) then
5123
else if (pd.proctypeoption=potype_destructor) then
5128
{ arguments are not listed here }
5129
{we don't need another definition}
5130
para := TParaItem(pd.Para.first);
5131
while assigned(para) do
5133
if Para.paratype.def.deftype = formaldef then
5135
case Para.paratyp of
5137
argnames := argnames+'3var';
5139
argnames:=argnames+'5const';
5141
argnames:=argnames+'3out';
5146
{ if the arg definition is like (v: ^byte;..
5147
there is no sym attached to data !!! }
5148
if assigned(Para.paratype.def.typesym) then
5150
arglength := length(Para.paratype.def.typesym.name);
5151
argnames := argnames + tostr(arglength)+Para.paratype.def.typesym.name;
5154
argnames:=argnames+'11unnamedtype';
5156
para := TParaItem(Para.next);
5158
{ here 2A must be changed for private and protected }
5159
{ 0 is private 1 protected and 2 public }
5160
if (sp_private in tsym(p).symoptions) then
5162
else if (sp_protected in tsym(p).symoptions) then
5166
newrec:=stabstr_evaluate('$1::$2=##$3;:$4;$5A$6;',[p.name,pd.numberstring,
5167
Tstoreddef(pd.rettype.def).numberstring,argnames,sp,
5169
{ get spare place for a string at the end }
5170
olds:=state^.stabsize;
5171
inc(state^.stabsize,strlen(newrec));
5172
if state^.stabsize>=state^.staballoc-256 then
5174
inc(state^.staballoc,memsizeinc);
5175
reallocmem(state^.stabstring,state^.staballoc);
5177
strcopy(state^.stabstring+olds,newrec);
5179
{This should be used for case !!
5180
RecOffset := RecOffset + pd.size;}
5185
procedure tobjectdef.proc_concatstabto(p :tnamedindexitem;arg:pointer);
5189
if tsym(p).typ = procsym then
5191
pd := tprocsym(p).first_procdef;
5192
tstoreddef(pd.rettype.def).concatstabto(taasmoutput(arg));
5197
function tobjectdef.stabstring : pchar;
5198
var anc : tobjectdef;
5199
state:Trecord_stabgen_state;
5202
if not (objecttype=odt_class) or writing_class_record_stab then
5204
state.staballoc:=memsizeinc;
5205
getmem(state.stabstring,state.staballoc);
5206
strpcopy(state.stabstring,'s'+tostr(tobjectsymtable(symtable).datasize));
5207
if assigned(childof) then
5209
{only one ancestor not virtual, public, at base offset 0 }
5211
strpcopy(strend(state.stabstring),'!1,020,'+childof.classnumberstring+';');
5213
{virtual table to implement yet}
5215
state.stabsize:=strlen(state.stabstring);
5216
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}field_addname,@state);
5217
if (oo_has_vmt in objectoptions) then
5218
if not assigned(childof) or not(oo_has_vmt in childof.objectoptions) then
5220
ts:='$vf'+classnumberstring+':'+tstoreddef(vmtarraytype.def).numberstring+','+tostr(vmt_offset*8)+';';
5221
strpcopy(state.stabstring+state.stabsize,ts);
5222
inc(state.stabsize,length(ts));
5224
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}proc_addname,@state);
5225
if (oo_has_vmt in objectoptions) then
5228
while assigned(anc.childof) and (oo_has_vmt in anc.childof.objectoptions) do
5230
{ just in case anc = self }
5231
ts:=';~%'+anc.classnumberstring+';';
5235
strpcopy(state.stabstring+state.stabsize,ts);
5236
inc(state.stabsize,length(ts));
5237
reallocmem(state.stabstring,state.stabsize+1);
5238
stabstring:=state.stabstring;
5242
stabstring:=strpnew('*'+classnumberstring);
5246
procedure tobjectdef.set_globalnb;
5248
globalnb:=PglobalTypeCount^;
5249
inc(PglobalTypeCount^);
5250
{ classes need two type numbers, the globalnb is set to the ptr }
5251
if objecttype=odt_class then
5253
globalnb:=PGlobalTypeCount^;
5254
inc(PglobalTypeCount^);
5259
function tobjectdef.classnumberstring : string;
5261
if objecttype=odt_class then
5266
classnumberstring:=numberstring;
5270
classnumberstring:=numberstring;
5274
function tobjectdef.allstabstring : pchar;
5276
stabchar : string[2];
5281
getmem(st,strlen(ss)+512);
5283
if deftype in tagtypes then
5285
if assigned(typesym) then
5286
sname := typesym.name
5289
if writing_class_record_stab then
5290
strpcopy(st,'"'+sname+':'+stabchar+classnumberstring+'=')
5292
strpcopy(st,'"'+sname+':'+stabchar+numberstring+'=');
5293
strpcopy(strecopy(strend(st),ss),'",'+tostr(N_LSYM)+',0,0,0');
5294
allstabstring := strnew(st);
5295
freemem(st,strlen(ss)+512);
5300
procedure tobjectdef.concatstabto(asmlist : taasmoutput);
5306
if (stab_state in [stab_state_writing,stab_state_written]) then
5308
stab_state:=stab_state_writing;
5309
tstoreddef(vmtarraytype.def).concatstabto(asmlist);
5310
{ first the parents }
5312
while assigned(anc.childof) do
5315
anc.concatstabto(asmlist);
5317
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}field_concatstabto,asmlist);
5318
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}proc_concatstabto,asmlist);
5319
stab_state:=stab_state_used;
5320
if objecttype=odt_class then
5322
{ Write the record class itself }
5323
writing_class_record_stab:=true;
5324
inherited concatstabto(asmlist);
5325
writing_class_record_stab:=false;
5326
{ Write the invisible pointer class }
5327
oldtypesym:=typesym;
5329
stab_str := allstabstring;
5330
asmList.concat(Tai_stabs.Create(stab_str));
5331
typesym:=oldtypesym;
5334
inherited concatstabto(asmlist);
5339
function tobjectdef.needs_inittable : boolean;
5343
needs_inittable:=false;
5345
needs_inittable:=true;
5347
needs_inittable:=is_related(interface_iunknown);
5349
needs_inittable:=tobjectsymtable(symtable).needs_init_final;
5351
internalerror(200108267);
5356
function tobjectdef.members_need_inittable : boolean;
5358
members_need_inittable:=tobjectsymtable(symtable).needs_init_final;
5362
procedure tobjectdef.count_published_properties(sym:tnamedindexitem;arg:pointer);
5364
if needs_prop_entry(tsym(sym)) and
5365
(tsym(sym).typ<>varsym) then
5370
procedure tobjectdef.write_property_info(sym : tnamedindexitem;arg:pointer);
5372
proctypesinfo : byte;
5374
procedure writeproc(proc : tsymlist; shiftvalue : byte);
5382
if not(assigned(proc) and assigned(proc.firstsym)) then
5384
rttiList.concat(Tai_const.Create_32bit(1));
5387
else if proc.firstsym^.sym.typ=varsym then
5392
while assigned(hp) do
5397
def:=tvarsym(hp^.sym).vartype.def;
5398
inc(address,tvarsym(hp^.sym).fieldoffset);
5402
if not(assigned(def) and (def.deftype=recorddef)) then
5403
internalerror(200402171);
5404
inc(address,tvarsym(hp^.sym).fieldoffset);
5405
def:=tvarsym(hp^.sym).vartype.def;
5409
if not(assigned(def) and (def.deftype=arraydef)) then
5410
internalerror(200402172);
5411
def:=tarraydef(def).elementtype.def;
5412
inc(address,def.size*hp^.value);
5417
rttiList.concat(Tai_const.Create_32bit(address));
5422
{ When there was an error then procdef is not assigned }
5423
if not assigned(proc.procdef) then
5425
if not(po_virtualmethod in tprocdef(proc.procdef).procoptions) then
5427
rttiList.concat(Tai_const_symbol.Createname(tprocdef(proc.procdef).mangledname,AT_FUNCTION,0));
5432
{ virtual method, write vmt offset }
5433
rttiList.concat(Tai_const.Create_32bit(
5434
tprocdef(proc.procdef)._class.vmtmethodoffset(tprocdef(proc.procdef).extnumber)));
5438
proctypesinfo:=proctypesinfo or (typvalue shl shiftvalue);
5442
if needs_prop_entry(tsym(sym)) then
5443
case tsym(sym).typ of
5447
if not(tvarsym(sym).vartype.def.deftype=objectdef) or
5448
not(tobjectdef(tvarsym(sym).vartype.def).is_class) then
5449
internalerror(1509992);
5450
{ access to implicit class property as field }
5451
proctypesinfo:=(0 shl 0) or (0 shl 2) or (0 shl 4);
5452
rttiList.concat(Tai_const_symbol.Createname(tvarsym(sym.vartype.def.get_rtti_label),AT_DATA,0));
5453
rttiList.concat(Tai_const.Create_32bit(tvarsym(sym.address)));
5454
rttiList.concat(Tai_const.Create_32bit(tvarsym(sym.address)));
5455
{ per default stored }
5456
rttiList.concat(Tai_const.Create_32bit(1));
5457
{ index as well as ... }
5458
rttiList.concat(Tai_const.Create_32bit(0));
5459
{ default value are zero }
5460
rttiList.concat(Tai_const.Create_32bit(0));
5461
rttiList.concat(Tai_const.Create_16bit(count));
5463
rttiList.concat(Tai_const.Create_8bit(proctypesinfo));
5464
rttiList.concat(Tai_const.Create_8bit(length(tvarsym(sym.realname))));
5465
rttiList.concat(Tai_string.Create(tvarsym(sym.realname)));
5470
if ppo_indexed in tpropertysym(sym).propoptions then
5474
rttiList.concat(Tai_const_symbol.Create(tstoreddef(tpropertysym(sym).proptype.def).get_rtti_label(fullrtti)));
5475
writeproc(tpropertysym(sym).readaccess,0);
5476
writeproc(tpropertysym(sym).writeaccess,2);
5477
{ isn't it stored ? }
5478
if not(ppo_stored in tpropertysym(sym).propoptions) then
5480
rttiList.concat(Tai_const.Create_ptr(0));
5481
proctypesinfo:=proctypesinfo or (3 shl 4);
5484
writeproc(tpropertysym(sym).storedaccess,4);
5485
rttiList.concat(Tai_const.Create_32bit(tpropertysym(sym).index));
5486
rttiList.concat(Tai_const.Create_32bit(cardinal(tpropertysym(sym).default)));
5487
rttiList.concat(Tai_const.Create_16bit(count));
5489
rttiList.concat(Tai_const.Create_8bit(proctypesinfo));
5490
rttiList.concat(Tai_const.Create_8bit(length(tpropertysym(sym).realname)));
5491
rttiList.concat(Tai_string.Create(tpropertysym(sym).realname));
5493
else internalerror(1509992);
5498
procedure tobjectdef.generate_published_child_rtti(sym : tnamedindexitem;arg:pointer);
5500
if needs_prop_entry(tsym(sym)) then
5502
case tsym(sym).typ of
5504
tstoreddef(tpropertysym(sym).proptype.def).get_rtti_label(fullrtti);
5506
tstoreddef(tvarsym(sym).vartype.def).get_rtti_label(fullrtti);
5508
internalerror(1509991);
5514
procedure tobjectdef.write_child_rtti_data(rt:trttitype);
5519
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}generate_field_rtti,nil);
5521
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}generate_published_child_rtti,nil);
5523
internalerror(200108301);
5529
tclasslistitem = class(TLinkedListItem)
5535
classtablelist : tlinkedlist;
5536
tablecount : longint;
5538
function searchclasstablelist(p : tobjectdef) : tclasslistitem;
5541
hp : tclasslistitem;
5544
hp:=tclasslistitem(classtablelist.first);
5545
while assigned(hp) do
5548
searchclasstablelist:=hp;
5552
hp:=tclasslistitem(hp.next);
5553
searchclasstablelist:=nil;
5557
procedure tobjectdef.count_published_fields(sym:tnamedindexitem;arg:pointer);
5559
hp : tclasslistitem;
5561
if needs_prop_entry(tsym(sym)) and
5562
(tsym(sym).typ=varsym) then
5564
if tvarsym(sym).vartype.def.deftype<>objectdef then
5565
internalerror(0206001);
5566
hp:=searchclasstablelist(tobjectdef(tvarsym(sym).vartype.def));
5567
if not(assigned(hp)) then
5569
hp:=tclasslistitem.create;
5570
hp.p:=tobjectdef(tvarsym(sym).vartype.def);
5571
hp.index:=tablecount;
5572
classtablelist.concat(hp);
5580
procedure tobjectdef.writefields(sym:tnamedindexitem;arg:pointer);
5582
hp : tclasslistitem;
5584
if needs_prop_entry(tsym(sym)) and
5585
(tsym(sym).typ=varsym) then
5587
rttiList.concat(Tai_const.Create_32bit(tvarsym(sym).fieldoffset));
5588
hp:=searchclasstablelist(tobjectdef(tvarsym(sym).vartype.def));
5589
if not(assigned(hp)) then
5590
internalerror(0206002);
5591
rttiList.concat(Tai_const.Create_16bit(hp.index));
5592
rttiList.concat(Tai_const.Create_8bit(length(tvarsym(sym).realname)));
5593
rttiList.concat(Tai_string.Create(tvarsym(sym).realname));
5598
function tobjectdef.generate_field_table : tasmlabel;
5601
classtable : tasmlabel;
5602
hp : tclasslistitem;
5605
classtablelist:=TLinkedList.Create;
5606
objectlibrary.getdatalabel(fieldtable);
5607
objectlibrary.getdatalabel(classtable);
5610
symtable.foreach({$ifdef FPC}@{$endif}count_published_fields,nil);
5611
if (cs_create_smart in aktmoduleswitches) then
5612
rttiList.concat(Tai_cut.Create);
5613
rttilist.concat(tai_align.create(const_align(pointer_size)));
5614
rttiList.concat(Tai_label.Create(fieldtable));
5615
rttiList.concat(Tai_const.Create_16bit(count));
5616
rttiList.concat(Tai_const_symbol.Create(classtable));
5617
symtable.foreach({$ifdef FPC}@{$endif}writefields,nil);
5619
{ generate the class table }
5620
rttilist.concat(tai_align.create(const_align(pointer_size)));
5621
rttiList.concat(Tai_label.Create(classtable));
5622
rttiList.concat(Tai_const.Create_16bit(tablecount));
5623
hp:=tclasslistitem(classtablelist.first);
5624
while assigned(hp) do
5626
rttiList.concat(Tai_const_symbol.Createname(tobjectdef(hp.p).vmt_mangledname,AT_DATA,0));
5627
hp:=tclasslistitem(hp.next);
5630
generate_field_table:=fieldtable;
5631
classtablelist.free;
5635
function tobjectdef.next_free_name_index : longint;
5639
if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
5640
i:=childof.next_free_name_index
5644
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_published_properties,nil);
5645
next_free_name_index:=i+count;
5649
procedure tobjectdef.write_rtti_data(rt:trttitype);
5653
rttiList.concat(Tai_const.Create_8bit(tkclass));
5655
rttiList.concat(Tai_const.Create_8bit(tkobject));
5657
rttiList.concat(Tai_const.Create_8bit(tkinterface));
5659
rttiList.concat(Tai_const.Create_8bit(tkinterfaceCorba));
5664
{ generate the name }
5665
rttiList.concat(Tai_const.Create_8bit(length(objrealname^)));
5666
rttiList.concat(Tai_string.Create(objrealname^));
5671
rttiList.concat(Tai_const.Create_32bit(size));
5672
if objecttype in [odt_class,odt_object] then
5676
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_field_rtti,nil);
5677
rttiList.concat(Tai_const.Create_32bit(count));
5678
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}write_field_rtti,nil);
5683
if (oo_has_vmt in objectoptions) and
5684
not(objecttype in [odt_interfacecom,odt_interfacecorba]) then
5685
rttiList.concat(Tai_const_symbol.Createname(vmt_mangledname,AT_DATA,0))
5687
rttiList.concat(Tai_const.Create_ptr(0));
5689
{ write owner typeinfo }
5690
if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
5691
rttiList.concat(Tai_const_symbol.Create(childof.get_rtti_label(fullrtti)))
5693
rttiList.concat(Tai_const.Create_ptr(0));
5695
{ count total number of properties }
5696
if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
5697
count:=childof.next_free_name_index
5702
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_published_properties,nil);
5703
rttiList.concat(Tai_const.Create_16bit(count));
5706
rttiList.concat(Tai_const.Create_8bit(length(current_module.realmodulename^)));
5707
rttiList.concat(Tai_string.Create(current_module.realmodulename^));
5709
{ write published properties count }
5711
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_published_properties,nil);
5712
rttiList.concat(Tai_const.Create_16bit(count));
5714
{ count is used to write nameindex }
5716
{ but we need an offset of the owner }
5717
{ to give each property an own slot }
5718
if assigned(childof) and (oo_can_have_published in childof.objectoptions) then
5719
count:=childof.next_free_name_index
5723
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}write_property_info,nil);
5729
function tobjectdef.is_publishable : boolean;
5731
is_publishable:=objecttype in [odt_class,odt_interfacecom,odt_interfacecorba];
5735
{****************************************************************************
5736
TIMPLEMENTEDINTERFACES
5737
****************************************************************************}
5739
tnamemap = class(TNamedIndexItem)
5741
constructor create(const aname, anewname: string);
5742
destructor destroy; override;
5745
constructor tnamemap.create(const aname, anewname: string);
5747
inherited createname(name);
5748
newname:=stringdup(anewname);
5751
destructor tnamemap.destroy;
5753
stringdispose(newname);
5759
tprocdefstore = class(TNamedIndexItem)
5761
constructor create(aprocdef: tprocdef);
5764
constructor tprocdefstore.create(aprocdef: tprocdef);
5772
timplintfentry = class(TNamedIndexItem)
5776
namemappings: tdictionary;
5777
procdefs: TIndexArray;
5778
constructor create(aintf: tobjectdef);
5779
constructor create_deref(const d:tderef);
5780
destructor destroy; override;
5783
constructor timplintfentry.create(aintf: tobjectdef);
5793
constructor timplintfentry.create_deref(const d:tderef);
5804
destructor timplintfentry.destroy;
5806
if assigned(namemappings) then
5808
if assigned(procdefs) then
5814
constructor timplementedinterfaces.create;
5816
finterfaces:=tindexarray.create(1);
5819
destructor timplementedinterfaces.destroy;
5821
finterfaces.destroy;
5824
function timplementedinterfaces.count: longint;
5826
count:=finterfaces.count;
5829
procedure timplementedinterfaces.checkindex(intfindex: longint);
5831
if (intfindex<1) or (intfindex>count) then
5832
InternalError(200006123);
5835
function timplementedinterfaces.interfaces(intfindex: longint): tobjectdef;
5837
checkindex(intfindex);
5838
interfaces:=timplintfentry(finterfaces.search(intfindex)).intf;
5841
function timplementedinterfaces.interfacesderef(intfindex: longint): tderef;
5843
checkindex(intfindex);
5844
interfacesderef:=timplintfentry(finterfaces.search(intfindex)).intfderef;
5847
function timplementedinterfaces.ioffsets(intfindex: longint): plongint;
5849
checkindex(intfindex);
5850
ioffsets:=@timplintfentry(finterfaces.search(intfindex)).ioffs;
5853
function timplementedinterfaces.searchintf(def: tdef): longint;
5858
while (i<=count) and (tdef(interfaces(i))<>def) do inc(i);
5866
procedure timplementedinterfaces.buildderef;
5870
for i:=1 to count do
5871
with timplintfentry(finterfaces.search(i)) do
5872
intfderef.build(intf);
5876
procedure timplementedinterfaces.deref;
5880
for i:=1 to count do
5881
with timplintfentry(finterfaces.search(i)) do
5882
intf:=tobjectdef(intfderef.resolve);
5885
procedure timplementedinterfaces.addintf_deref(const d:tderef);
5887
finterfaces.insert(timplintfentry.create_deref(d));
5890
procedure timplementedinterfaces.addintf(def: tdef);
5892
if not assigned(def) or (searchintf(def)<>-1) or (def.deftype<>objectdef) or
5893
not (tobjectdef(def).objecttype in [odt_interfacecom,odt_interfacecorba]) then
5894
internalerror(200006124);
5895
finterfaces.insert(timplintfentry.create(tobjectdef(def)));
5898
procedure timplementedinterfaces.clearmappings;
5902
for i:=1 to count do
5903
with timplintfentry(finterfaces.search(i)) do
5905
if assigned(namemappings) then
5911
procedure timplementedinterfaces.addmappings(intfindex: longint; const name, newname: string);
5913
checkindex(intfindex);
5914
with timplintfentry(finterfaces.search(intfindex)) do
5916
if not assigned(namemappings) then
5917
namemappings:=tdictionary.create;
5918
namemappings.insert(tnamemap.create(name,newname));
5922
function timplementedinterfaces.getmappings(intfindex: longint; const name: string; var nextexist: pointer): string;
5924
checkindex(intfindex);
5925
if not assigned(nextexist) then
5926
with timplintfentry(finterfaces.search(intfindex)) do
5928
if assigned(namemappings) then
5929
nextexist:=namemappings.search(name)
5933
if assigned(nextexist) then
5935
getmappings:=tnamemap(nextexist).newname^;
5936
nextexist:=tnamemap(nextexist).listnext;
5942
procedure timplementedinterfaces.clearimplprocs;
5946
for i:=1 to count do
5947
with timplintfentry(finterfaces.search(i)) do
5949
if assigned(procdefs) then
5955
procedure timplementedinterfaces.addimplproc(intfindex: longint; procdef: tprocdef);
5957
checkindex(intfindex);
5958
with timplintfentry(finterfaces.search(intfindex)) do
5960
if not assigned(procdefs) then
5961
procdefs:=tindexarray.create(4);
5962
procdefs.insert(tprocdefstore.create(procdef));
5966
function timplementedinterfaces.implproccount(intfindex: longint): longint;
5968
checkindex(intfindex);
5969
with timplintfentry(finterfaces.search(intfindex)) do
5970
if assigned(procdefs) then
5971
implproccount:=procdefs.count
5976
function timplementedinterfaces.implprocs(intfindex: longint; procindex: longint): tprocdef;
5978
checkindex(intfindex);
5979
with timplintfentry(finterfaces.search(intfindex)) do
5980
if assigned(procdefs) then
5981
implprocs:=tprocdefstore(procdefs.search(procindex)).procdef
5983
internalerror(200006131);
5986
function timplementedinterfaces.isimplmergepossible(intfindex, remainindex: longint; var weight: longint): boolean;
5993
checkindex(intfindex);
5994
checkindex(remainindex);
5995
iiep1:=timplintfentry(finterfaces.search(intfindex)).procdefs;
5996
iiep2:=timplintfentry(finterfaces.search(remainindex)).procdefs;
5997
if not assigned(iiep1) then { empty interface is mergeable :-) }
6004
possible:=assigned(iiep2) and (iiep1.count<=iiep2.count);
6006
while (possible) and (i<=iiep1.count) do
6009
(tprocdefstore(iiep1.search(i)).procdef=tprocdefstore(iiep2.search(i)).procdef);
6013
weight:=iiep1.count;
6015
isimplmergepossible:=possible;
6019
{****************************************************************************
6021
****************************************************************************}
6023
constructor tforwarddef.create(const s:string;const pos : tfileposinfo);
6025
oldregisterdef : boolean;
6027
{ never register the forwarddefs, they are disposed at the
6028
end of the type declaration block }
6029
oldregisterdef:=registerdef;
6032
registerdef:=oldregisterdef;
6033
deftype:=forwarddef;
6034
tosymname:=stringdup(s);
6039
function tforwarddef.gettypename:string;
6041
gettypename:='unresolved forward to '+tosymname^;
6044
destructor tforwarddef.destroy;
6046
if assigned(tosymname) then
6047
stringdispose(tosymname);
6052
{****************************************************************************
6054
****************************************************************************}
6056
constructor terrordef.create;
6064
function terrordef.stabstring : pchar;
6066
stabstring:=strpnew('error'+numberstring);
6069
procedure terrordef.concatstabto(asmlist : taasmoutput);
6071
{ No internal error needed, an normal error is already
6076
function terrordef.gettypename:string;
6079
gettypename:='<erroneous type>';
6082
function terrordef.getmangledparaname:string;
6085
getmangledparaname:='error';
6089
{****************************************************************************
6091
****************************************************************************}
6093
function is_interfacecom(def: tdef): boolean;
6097
(def.deftype=objectdef) and
6098
(tobjectdef(def).objecttype=odt_interfacecom);
6101
function is_interfacecorba(def: tdef): boolean;
6105
(def.deftype=objectdef) and
6106
(tobjectdef(def).objecttype=odt_interfacecorba);
6109
function is_interface(def: tdef): boolean;
6113
(def.deftype=objectdef) and
6114
(tobjectdef(def).objecttype in [odt_interfacecom,odt_interfacecorba]);
6118
function is_class(def: tdef): boolean;
6122
(def.deftype=objectdef) and
6123
(tobjectdef(def).objecttype=odt_class);
6126
function is_object(def: tdef): boolean;
6130
(def.deftype=objectdef) and
6131
(tobjectdef(def).objecttype=odt_object);
6134
function is_cppclass(def: tdef): boolean;
6138
(def.deftype=objectdef) and
6139
(tobjectdef(def).objecttype=odt_cppclass);
6142
function is_class_or_interface(def: tdef): boolean;
6144
is_class_or_interface:=
6146
(def.deftype=objectdef) and
6147
(tobjectdef(def).objecttype in [odt_class,odt_interfacecom,odt_interfacecorba]);
6152
$Log: symdef.pas,v $
6153
Revision 1.240 2004/05/25 18:51:14 peter
6156
Revision 1.239 2004/05/23 20:57:10 peter
6157
* removed unused voidprocdef
6159
Revision 1.238 2004/05/23 15:23:30 peter
6160
* fixed qword(longint) that removed sign from the number
6161
* removed code in the compiler that relied on wrong qword(longint)
6164
Revision 1.237 2004/05/22 23:33:18 peter
6165
fix range check error when array size > maxlongint
6167
Revision 1.236 2004/05/01 22:05:01 florian
6168
+ added lib support for Amiga/MorphOS syscalls
6170
Revision 1.235 2004/04/29 19:56:37 daniel
6171
* Prepare compiler infrastructure for multiple ansistring types
6173
Revision 1.234 2004/04/18 15:22:24 florian
6174
+ location support for arguments, currently PowerPC/MorphOS only
6176
Revision 1.233 2004/03/23 22:34:49 peter
6177
* constants ordinals now always have a type assigned
6178
* integer constants have the smallest type, unsigned prefered over
6181
Revision 1.232 2004/03/18 11:43:57 olle
6182
* change AT_FUNCTION to AT_DATA where appropriate
6184
Revision 1.231 2004/03/14 22:51:46 peter
6185
* valgrind doesn't like nested procedure info in stabs
6187
Revision 1.230 2004/03/14 20:06:40 peter
6188
* don't write line numbers in stabs for defs
6190
Revision 1.229 2004/03/10 22:52:57 peter
6192
* special mode -gv for valgrind compatible stabs
6194
Revision 1.228 2004/03/09 22:18:22 peter
6195
* first write parent classes
6197
Revision 1.227 2004/03/09 20:45:04 peter
6198
* more stabs updates
6200
Revision 1.226 2004/03/08 22:07:47 peter
6201
* stabs updates to write stabs for def for all implictly used
6204
Revision 1.225 2004/03/03 22:01:44 peter
6205
* fix hidden pointer for stabs
6207
Revision 1.224 2004/03/02 00:36:33 olle
6208
* big transformation of Tai_[const_]Symbol.Create[data]name*
6210
Revision 1.223 2004/02/26 16:16:38 peter
6211
* tai_const.create_ptr added
6213
Revision 1.222 2004/02/22 19:55:25 daniel
6214
* Revert my latest change
6216
Revision 1.221 2004/02/22 18:49:03 daniel
6217
* Fixed minor bug in Tenumdef.stabstring
6219
Revision 1.220 2004/02/19 17:07:42 florian
6220
* fixed arg. area calculation
6222
Revision 1.219 2004/02/17 15:57:49 peter
6223
- fix rtti generation for properties containing sl_vec
6224
- fix crash when overloaded operator is not available
6225
- fix record alignment for C style variant records
6227
Revision 1.218 2004/02/12 15:54:03 peter
6228
* make extcycle is working again
6230
Revision 1.217 2004/02/08 18:08:59 jonas
6231
* fixed regvars support. Needs -doldregvars to activate. Only tested with
6232
ppc, other processors should however only require maxregvars and
6233
maxfpuregvars constants in cpubase.pas. Remember to take scratch-
6234
registers into account when defining that value.
6236
Revision 1.216 2004/02/06 22:37:00 daniel
6237
* Removed not very usefull nextglobal & previousglobal fields from
6238
Tstoreddef, saving 78 kb of memory
6240
Revision 1.215 2004/02/05 01:24:08 florian
6241
* several fixes to compile x86-64 system
6243
Revision 1.214 2004/02/03 22:32:54 peter
6244
* renamed xNNbittype to xNNinttype
6245
* renamed registers32 to registersint
6246
* replace some s32bit,u32bit with torddef([su]inttype).def.typ
6248
Revision 1.213 2004/01/28 22:16:31 peter
6249
* more record alignment fixes
6251
Revision 1.212 2004/01/28 21:05:56 florian
6252
* fixed alignment of classes
6254
Revision 1.211 2004/01/28 20:30:18 peter
6255
* record alignment splitted in fieldalignment and recordalignment,
6256
the latter is used when this record is inserted in another record.
6258
Revision 1.210 2004/01/27 10:29:32 daniel
6259
* Fix string type stab generation. String constant still unsupported.
6261
Revision 1.209 2004/01/26 19:54:42 daniel
6264
Revision 1.208 2004/01/26 19:43:49 daniel
6265
* Try to recude stack usage of Tpointerdef.concatstabsto
6267
Revision 1.207 2004/01/26 16:12:28 daniel
6268
* reginfo now also only allocated during register allocation
6269
* third round of gdb cleanups: kick out most of concatstabto
6271
Revision 1.206 2004/01/25 20:23:28 daniel
6272
* More gdb cleanup: make record & object stab generation linear instead
6275
Revision 1.205 2004/01/25 13:18:59 daniel
6276
* Made varags parameter constant
6278
Revision 1.204 2004/01/25 12:37:15 daniel
6279
* Last commit broke debug info for records. Fixed.
6281
Revision 1.203 2004/01/25 11:33:48 daniel
6282
* 2nd round of gdb cleanup
6284
Revision 1.202 2004/01/22 21:33:54 peter
6285
* procvardef rtti fixed
6287
Revision 1.201 2004/01/22 16:33:22 peter
6288
* enum value rtti is now in orginal case
6290
Revision 1.200 2004/01/20 12:59:37 florian
6291
* common addnode code for x86-64 and i386
6293
Revision 1.199 2004/01/15 15:16:18 daniel
6295
* Managed to eliminate speed effects of string compression
6297
Revision 1.198 2004/01/11 23:56:20 daniel
6298
* Experiment: Compress strings to save memory
6299
Did not save a single byte of mem; clearly the core size is boosted by
6300
temporary memory usage...
6302
Revision 1.197 2004/01/04 21:10:04 jonas
6303
* Darwin's assembler assumes that all labels starting with 'L' are local
6304
-> rename symbols starting with 'L'
6306
Revision 1.196 2003/12/24 20:51:11 peter
6307
* don't lowercase enumnames
6309
Revision 1.195 2003/12/24 01:47:22 florian
6310
* first fixes to compile the x86-64 system unit
6312
Revision 1.194 2003/12/21 19:42:43 florian
6313
* fixed ppc inlining stuff
6314
* fixed wrong unit writing
6315
+ added some sse stuff
6317
Revision 1.193 2003/12/16 21:29:24 florian
6318
+ inlined procedures inherit procinfo flags
6320
Revision 1.192 2003/12/12 12:09:40 marco
6321
* always generate RTTI patch from peter
6323
Revision 1.191 2003/12/08 22:34:24 peter
6324
* tai_const.create_32bit changed to cardinal
6326
Revision 1.190 2003/11/10 22:02:52 peter
6327
* cross unit inlining fixed
6329
Revision 1.189 2003/11/08 23:31:27 florian
6330
* tstoreddef.getcopy returns now an errordef instead of nil; this
6331
allows easier error recovery
6333
Revision 1.188 2003/11/05 14:18:03 marco
6334
* fix from Peter arraysize warning (nav Newsgroup msg)
6336
Revision 1.187 2003/11/01 15:50:03 peter
6337
* fix check for valid procdef in property rtti
6339
Revision 1.186 2003/10/29 21:56:28 peter
6340
* procsym.deref derefs only own procdefs
6341
* reset paracount in procdef.deref so a second deref doesn't increase
6342
the paracounts to invalid values
6344
Revision 1.185 2003/10/29 19:48:51 peter
6345
* renamed mangeldname_prefix to make_mangledname and made it more
6347
* make_mangledname is now also used for internal threadvar/resstring
6349
* Add P$ in front of program modulename to prevent duplicated symbols
6350
at assembler level, because the main program can have the same name
6351
as a unit, see webtbs/tw1251b
6353
Revision 1.184 2003/10/23 14:44:07 peter
6354
* splitted buildderef and buildderefimpl to fix interface crc
6357
Revision 1.183 2003/10/22 20:40:00 peter
6358
* write derefdata in a separate ppu entry
6360
Revision 1.182 2003/10/21 18:14:49 peter
6361
* fix counting of parameters when loading ppu
6363
Revision 1.181 2003/10/17 15:08:34 peter
6364
* commented out more obsolete constants
6366
Revision 1.180 2003/10/17 14:52:07 peter
6369
Revision 1.179 2003/10/17 14:38:32 peter
6370
* 64k registers supported
6371
* fixed some memory leaks
6373
Revision 1.178 2003/10/13 14:05:12 peter
6374
* removed is_visible_for_proc
6375
* search also for class overloads when finding interface
6378
Revision 1.177 2003/10/11 16:06:42 florian
6379
* fixed some MMX<->SSE
6380
* started to fix ppc, needs an overhaul
6381
+ stabs info improve for spilling, not sure if it works correctly/completly
6382
- MMX_SUPPORT removed from Makefile.fpc
6384
Revision 1.176 2003/10/10 17:48:14 peter
6385
* old trgobj moved to x86/rgcpu and renamed to trgx86fpu
6386
* tregisteralloctor renamed to trgobj
6387
* removed rgobj from a lot of units
6388
* moved location_* and reference_* to cgobj
6389
* first things for mmx register allocation
6391
Revision 1.175 2003/10/07 20:43:49 peter
6392
* Add calling convention in fullprocname when it is specified
6394
Revision 1.174 2003/10/07 16:06:30 peter
6395
* tsymlist.def renamed to tsymlist.procdef
6396
* tsymlist.procdef is now only used to store the procdef
6398
Revision 1.173 2003/10/06 22:23:41 florian
6399
+ added basic olevariant support
6401
Revision 1.172 2003/10/05 21:21:52 peter
6402
* c style array of const generates callparanodes
6403
* varargs paraloc fixes
6405
Revision 1.171 2003/10/05 12:56:35 peter
6406
* don't write procdefs that are released to ppu
6408
Revision 1.170 2003/10/03 22:00:33 peter
6409
* parameter alignment fixes
6411
Revision 1.169 2003/10/02 21:19:42 peter
6412
* protected visibility fixes
6414
Revision 1.168 2003/10/01 20:34:49 peter
6415
* procinfo unit contains tprocinfo
6416
* cginfo renamed to cgbase
6417
* moved cgmessage to verbose
6418
* fixed ppc and sparc compiles
6420
Revision 1.167 2003/10/01 16:49:05 florian
6421
* para items are now reversed for pascal calling conventions
6423
Revision 1.166 2003/10/01 15:32:58 florian
6424
* fixed FullProcName to handle constructors, destructors and operators correctly
6426
Revision 1.165 2003/10/01 15:00:02 peter
6427
* don't write parast,localst debug info for externals
6429
Revision 1.164 2003/09/23 21:03:35 peter
6430
* connect parasym to paraitem
6432
Revision 1.163 2003/09/23 17:56:06 peter
6433
* locals and paras are allocated in the code generation
6434
* tvarsym.localloc contains the location of para/local when
6435
generating code for the current procedure
6437
Revision 1.162 2003/09/07 22:09:35 peter
6438
* preparations for different default calling conventions
6441
Revision 1.161 2003/09/06 22:27:09 florian
6442
* fixed web bug 2669
6443
* cosmetic fix in printnode
6444
* tobjectdef.gettypename implemented
6446
Revision 1.160 2003/09/03 15:55:01 peter
6447
* NEWRA branch merged
6449
Revision 1.159 2003/09/03 11:18:37 florian
6450
* fixed arm concatcopy
6451
+ arm support in the common compiler sources added
6452
* moved some generic cg code around
6456
Revision 1.158.2.2 2003/08/29 17:28:59 peter
6457
* next batch of updates
6459
Revision 1.158.2.1 2003/08/27 19:55:54 peter
6460
* first tregister patch
6462
Revision 1.158 2003/08/11 21:18:20 peter
6463
* start of sparc support for newra
6465
Revision 1.157 2003/07/08 15:20:56 peter
6466
* don't allow add/assignments for formaldef
6467
* formaldef size changed to 0
6469
Revision 1.156 2003/07/06 21:50:33 jonas
6470
* fixed ppc compilation problems and changed VOLATILE_REGISTERS for x86
6471
so that it doesn't include ebp and esp anymore
6473
Revision 1.155 2003/07/06 15:31:21 daniel
6474
* Fixed register allocator. *Lots* of fixes.
6476
Revision 1.154 2003/07/02 22:18:04 peter
6477
* paraloc splitted in callerparaloc,calleeparaloc
6478
* sparc calling convention updates
6480
Revision 1.153 2003/06/25 18:31:23 peter
6481
* sym,def resolving partly rewritten to support also parent objects
6482
not directly available through the uses clause
6484
Revision 1.152 2003/06/17 16:34:44 jonas
6485
* lots of newra fixes (need getfuncretparaloc implementation for i386)!
6486
* renamed all_intregisters to paramanager.get_volatile_registers_int(pocall_default) and made it
6489
Revision 1.151 2003/06/08 11:41:21 peter
6490
* set parast.next to the owner of the procdef
6492
Revision 1.150 2003/06/07 20:26:32 peter
6493
* re-resolving added instead of reloading from ppu
6494
* tderef object added to store deref info for resolving
6496
Revision 1.149 2003/06/05 20:05:55 peter
6497
* removed changesettype because that will change the definition
6498
of the setdef forever and can result in a different between
6499
original interface and current implementation definition
6501
Revision 1.148 2003/06/03 13:01:59 daniel
6502
* Register allocator finished
6504
Revision 1.147 2003/06/02 22:55:28 florian
6505
* classes and interfaces can be stored in integer registers
6507
Revision 1.146 2003/05/26 21:17:18 peter
6508
* procinlinenode removed
6509
* aktexit2label removed, fast exit removed
6510
+ tcallnode.inlined_pass_2 added
6512
Revision 1.145 2003/05/25 11:34:17 peter
6513
* methodpointer self pushing fixed
6515
Revision 1.144 2003/05/15 18:58:53 peter
6516
* removed selfpointer_offset, vmtpointer_offset
6517
* tvarsym.adjusted_address
6518
* address in localsymtable is now in the real direction
6519
* removed some obsolete globals
6521
Revision 1.143 2003/05/13 08:13:16 jonas
6522
* patch from Peter for rtti symbols
6524
Revision 1.142 2003/05/11 21:37:03 peter
6525
* moved implicit exception frame from ncgutil to psub
6526
* constructor/destructor helpers moved from cobj/ncgutil to psub
6528
Revision 1.141 2003/05/09 17:47:03 peter
6529
* self moved to hidden parameter
6530
* removed hdisposen,hnewn,selfn
6532
Revision 1.140 2003/05/05 14:53:16 peter
6533
* vs_hidden replaced by is_hidden boolean
6535
Revision 1.139 2003/05/01 07:59:43 florian
6536
* introduced defaultordconsttype to decribe the default size of ordinal constants
6537
on 64 bit CPUs it's equal to cs64bitdef while on 32 bit CPUs it's equal to s32bitdef
6538
+ added defines CPU32 and CPU64 for 32 bit and 64 bit CPUs
6539
* int64s/qwords are allowed as for loop counter on 64 bit CPUs
6541
Revision 1.138 2003/04/27 11:21:34 peter
6542
* aktprocdef renamed to current_procdef
6543
* procinfo renamed to current_procinfo
6544
* procinfo will now be stored in current_module so it can be
6546
* gen_main_procsym changed to create_main_proc and release_main_proc
6547
to also generate a tprocinfo structure
6548
* fixed unit implicit initfinal
6550
Revision 1.137 2003/04/27 07:29:51 peter
6551
* current_procdef cleanup, current_procdef is now always nil when parsing
6552
a new procdef declaration
6553
* aktprocsym removed
6554
* lexlevel removed, use symtable.symtablelevel instead
6555
* implicit init/final code uses the normal genentry/genexit
6556
* funcret state checking updated for new funcret handling
6558
Revision 1.136 2003/04/25 20:59:35 peter
6559
* removed funcretn,funcretsym, function result is now in varsym
6560
and aliases for result and function name are added using absolutesym
6561
* vs_hidden parameter for funcret passed in parameter
6563
* writenode changed to printnode and released from extdebug
6564
* -vp option added to generate a tree.log with the nodetree
6565
* nicer printnode for statements, callnode
6567
Revision 1.135 2003/04/23 20:16:04 peter
6568
+ added currency support based on int64
6569
+ is_64bit for use in cg units instead of is_64bitint
6570
* removed cgmessage from n386add, replace with internalerrors
6572
Revision 1.134 2003/04/23 12:35:34 florian
6573
* fixed several issues with powerpc
6574
+ applied a patch from Jonas for nested function calls (PowerPC only)
6577
Revision 1.133 2003/04/10 17:57:53 peter
6578
* vs_hidden released
6580
Revision 1.132 2003/03/18 16:25:50 peter
6581
* no itnernalerror for errordef.concatstabto()
6583
Revision 1.131 2003/03/17 16:54:41 peter
6584
* support DefaultHandler and anonymous inheritance fixed
6587
Revision 1.130 2003/03/17 15:54:22 peter
6588
* store symoptions also for procdef
6589
* check symoptions (private,public) when calculating possible
6592
Revision 1.129 2003/02/19 22:00:14 daniel
6593
* Code generator converted to new register notation
6594
- Horribily outdated todo.txt removed
6596
Revision 1.128 2003/02/02 19:25:54 carl
6597
* Several bugfixes for m68k target (register alloc., opcode emission)
6599
+ Generic add more complete (still not verified)
6601
Revision 1.127 2003/01/21 14:36:44 pierre
6602
* set sizes needs to be passes in bits not bytes to stabs info
6604
Revision 1.126 2003/01/16 22:11:33 peter
6605
* fixed tprocdef.is_addressonly
6607
Revision 1.125 2003/01/15 01:44:33 peter
6608
* merged methodpointer fixes from 1.0.x
6610
Revision 1.124 2003/01/09 21:52:37 peter
6611
* merged some verbosity options.
6612
* V_LineInfo is a verbosity flag to include line info
6614
Revision 1.123 2003/01/06 21:16:52 peter
6615
* po_addressonly added to retrieve the address of a methodpointer
6616
only, this is used for @tclass.method which has no self pointer
6618
Revision 1.122 2003/01/05 15:54:15 florian
6619
+ added proper support of type = type <type>; for simple types
6621
Revision 1.121 2003/01/05 13:36:53 florian
6623
+ very basic support for float128 type (x86-64 only)
6625
Revision 1.120 2003/01/02 19:49:00 peter
6626
* update self parameter only for methodpointer and methods
6628
Revision 1.119 2002/12/29 18:25:59 peter
6629
* tprocdef.gettypename implemented
6631
Revision 1.118 2002/12/27 15:23:09 peter
6632
* write class methods in fullname
6634
Revision 1.117 2002/12/15 19:34:31 florian
6635
+ some front end stuff for vs_hidden added
6637
Revision 1.116 2002/12/15 11:26:02 peter
6638
* ignore vs_hidden parameters when choosing overloaded proc
6640
Revision 1.115 2002/12/07 14:27:09 carl
6641
* 3% memory optimization
6642
* changed some types
6643
+ added type checking with different size for call node and for
6646
Revision 1.114 2002/12/01 22:05:27 carl
6647
* no more warnings for structures over 32K since this is
6648
handled correctly in this version of the compiler.
6650
Revision 1.113 2002/11/27 20:04:09 peter
6651
* tvarsym.get_push_size replaced by paramanager.push_size
6653
Revision 1.112 2002/11/25 21:05:53 carl
6654
* several mistakes fixed in message files
6656
Revision 1.111 2002/11/25 18:43:33 carl
6657
- removed the invalid if <> checking (Delphi is strange on this)
6658
+ implemented abstract warning on instance creation of class with
6660
* some error message cleanups
6662
Revision 1.110 2002/11/25 17:43:24 peter
6663
* splitted defbase in defutil,symutil,defcmp
6664
* merged isconvertable and is_equal into compare_defs(_ext)
6665
* made operator search faster by walking the list only once
6667
Revision 1.109 2002/11/23 22:50:06 carl
6668
* some small speed optimizations
6669
+ added several new warnings/hints
6671
Revision 1.108 2002/11/22 22:48:10 carl
6672
* memory optimization with tconstsym (1.5%)
6674
Revision 1.107 2002/11/19 16:21:29 pierre
6675
* correct several stabs generation problems
6677
Revision 1.106 2002/11/18 17:31:59 peter
6678
* pass proccalloption to ret_in_xxx and push_xxx functions
6680
Revision 1.105 2002/11/17 16:31:57 carl
6681
* memory optimization (3-4%) : cleanup of tai fields,
6682
cleanup of tdef and tsym fields.
6683
* make it work for m68k
6685
Revision 1.104 2002/11/16 19:53:18 carl
6686
* avoid Range check errors
6688
Revision 1.103 2002/11/15 16:29:09 peter
6689
* fixed rtti for int64 (merged)
6691
Revision 1.102 2002/11/15 01:58:54 peter
6692
* merged changes from 1.0.7 up to 04-11
6693
- -V option for generating bug report tracing
6694
- more tracing for option parsing
6695
- errors for cdecl and high()
6696
- win32 import stabs
6697
- win32 records<=8 are returned in eax:edx (turned off by default)
6699
- more info for temp management in .s file with EXTDEBUG
6701
Revision 1.101 2002/11/09 15:31:02 carl
6704
Revision 1.100 2002/10/19 15:09:25 peter
6705
+ tobjectdef.members_need_inittable that is used to generate only the
6706
inittable when it is really used. This saves a lot of useless calls
6707
to fpc_finalize when destroying classes
6709
Revision 1.99 2002/10/07 21:30:27 peter
6710
* removed obsolete rangecheck stuff
6712
Revision 1.98 2002/10/05 15:14:26 peter
6713
* getparamangeldname for errordef
6715
Revision 1.97 2002/10/05 12:43:28 carl
6716
* fixes for Delphi 6 compilation
6717
(warning : Some features do not work under Delphi)
6719
Revision 1.96 2002/09/27 21:13:29 carl
6720
* low-highval always checked if limit ober 2GB is reached (to avoid overflow)
6722
Revision 1.95 2002/09/16 09:31:10 florian
6723
* fixed currency size
6725
Revision 1.94 2002/09/09 17:34:15 peter
6726
* tdicationary.replace added to replace and item in a dictionary. This
6727
is only allowed for the same name
6728
* varsyms are inserted in symtable before the types are parsed. This
6729
fixes the long standing "var longint : longint" bug
6730
- consume_idlist and idstringlist removed. The loops are inserted
6731
at the callers place and uses the symtable for duplicate id checking
6733
Revision 1.93 2002/09/07 15:25:07 peter
6734
* old logs removed and tabs fixed
6736
Revision 1.92 2002/09/05 19:29:42 peter
6737
* memdebug enhancements
6739
Revision 1.91 2002/08/25 19:25:20 peter
6740
* sym.insert_in_data removed
6741
* symtable.insertvardata/insertconstdata added
6742
* removed insert_in_data call from symtable.insert, it needs to be
6743
called separatly. This allows to deref the address calculation
6744
* procedures now calculate the parast addresses after the procedure
6745
directives are parsed. This fixes the cdecl parast problem
6746
* push_addr_param has an extra argument that specifies if cdecl is used
6749
Revision 1.90 2002/08/18 20:06:25 peter
6750
* inlining is now also allowed in interface
6751
* renamed write/load to ppuwrite/ppuload
6752
* tnode storing in ppu
6753
* nld,ncon,nbas are already updated for storing in ppu
6755
Revision 1.89 2002/08/11 15:28:00 florian
6756
+ support of explicit type case <any ordinal type>->pointer
6759
Revision 1.88 2002/08/11 14:32:28 peter
6760
* renamed current_library to objectlibrary
6762
Revision 1.87 2002/08/11 13:24:13 peter
6763
* saving of asmsymbols in ppu supported
6764
* asmsymbollist global is removed and moved into a new class
6765
tasmlibrarydata that will hold the info of a .a file which
6766
corresponds with a single module. Added librarydata to tmodule
6767
to keep the library info stored for the module. In the future the
6768
objectfiles will also be stored to the tasmlibrarydata class
6769
* all getlabel/newasmsymbol and friends are moved to the new class
6771
Revision 1.86 2002/08/09 07:33:03 florian
6772
* a couple of interface related fixes
6774
Revision 1.85 2002/07/23 09:51:24 daniel
6775
* Tried to make Tprocsym.defs protected. I didn't succeed but the cleanups
6776
are worth comitting.
6778
Revision 1.84 2002/07/20 11:57:57 florian
6779
* types.pas renamed to defbase.pas because D6 contains a types
6780
unit so this would conflicts if D6 programms are compiled
6781
+ Willamette/SSE2 instructions to assembler added
6783
Revision 1.83 2002/07/11 14:41:30 florian
6784
* start of the new generic parameter handling
6786
Revision 1.82 2002/07/07 09:52:32 florian
6787
* powerpc target fixed, very simple units can be compiled
6788
* some basic stuff for better callparanode handling, far from being finished
6790
Revision 1.81 2002/07/01 18:46:26 peter
6792
* reorganized aasm layer
6794
Revision 1.80 2002/07/01 16:23:54 peter
6796
* basics for currency
6797
* asnode updates for class and interface (not finished)
6799
Revision 1.79 2002/05/18 13:34:18 peter
6800
* readded missing revisions
6802
Revision 1.78 2002/05/16 19:46:44 carl
6803
+ defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
6804
+ try to fix temp allocation (still in ifdef)
6805
+ generic constructor calls
6806
+ start of tassembler / tmodulebase class cleanup
6808
Revision 1.76 2002/05/12 16:53:10 peter
6809
* moved entry and exitcode to ncgutil and cgobj
6810
* foreach gets extra argument for passing local data to the
6812
* -CR checks also class typecasts at runtime by changing them
6814
* fixed compiler to cycle with the -CR option
6815
* fixed stabs with elf writer, finally the global variables can
6817
* removed a lot of routines from cga unit and replaced them by
6819
* u32bit-s32bit updates for and,or,xor nodes. When one element is
6820
u32bit then the other is typecasted also to u32bit without giving
6821
a rangecheck warning/error.
6822
* fixed pascal calling method with reversing also the high tree in
6823
the parast, detected by tcalcst3 test
6825
Revision 1.75 2002/04/25 20:16:39 peter
6826
* moved more routines from cga/n386util
6828
Revision 1.74 2002/04/23 19:16:35 peter
6829
* add pinline unit that inserts compiler supported functions using
6830
one or more statements
6831
* moved finalize and setlength from ninl to pinline
6833
Revision 1.73 2002/04/21 19:02:05 peter
6834
* removed newn and disposen nodes, the code is now directly
6836
* -an option that will write the secondpass nodes to the .s file, this
6837
requires EXTDEBUG define to actually write the info
6838
* fixed various internal errors and crashes due recent code changes
6840
Revision 1.72 2002/04/20 21:32:25 carl
6841
+ generic FPC_CHECKPOINTER
6842
+ first parameter offset in stack now portable
6843
* rename some constants
6844
+ move some cpu stuff to other units
6845
- remove unused constents
6846
* fix stacksize for some targets
6847
* fix generic size problems which depend now on EXTEND_SIZE constant