|
@@ -29,6 +29,8 @@ interface
|
|
uses
|
|
uses
|
|
finput,tokens,scanner,globtype,
|
|
finput,tokens,scanner,globtype,
|
|
aasmdata,
|
|
aasmdata,
|
|
|
|
+ node,
|
|
|
|
+ psub,
|
|
symconst,symbase,symtype,symdef,symsym;
|
|
symconst,symbase,symtype,symdef,symsym;
|
|
|
|
|
|
|
|
|
|
@@ -62,7 +64,7 @@ interface
|
|
* save the scanner state before calling this routine, and restore when done.
|
|
* save the scanner state before calling this routine, and restore when done.
|
|
* the code *must* be written in objfpc style
|
|
* the code *must* be written in objfpc style
|
|
}
|
|
}
|
|
- function str_parse_method_impl(str: ansistring; usefwpd: tprocdef; is_classdef: boolean):boolean;
|
|
|
|
|
|
+ function str_parse_method_impl(str: ansistring; get_code_block_func: tcggetcodeblockfunc; usefwpd: tprocdef; is_classdef: boolean):boolean;
|
|
|
|
|
|
{ parses a typed constant assignment to ssym
|
|
{ parses a typed constant assignment to ssym
|
|
|
|
|
|
@@ -120,11 +122,11 @@ implementation
|
|
uses
|
|
uses
|
|
cutils,cclasses,globals,verbose,systems,comphook,fmodule,
|
|
cutils,cclasses,globals,verbose,systems,comphook,fmodule,
|
|
symtable,defutil,
|
|
symtable,defutil,
|
|
- pbase,pdecobj,pdecsub,psub,ptconst,
|
|
|
|
|
|
+ pbase,pdecobj,pdecsub,ptconst,
|
|
{$ifdef jvm}
|
|
{$ifdef jvm}
|
|
pjvm,jvmdef,
|
|
pjvm,jvmdef,
|
|
{$endif jvm}
|
|
{$endif jvm}
|
|
- node,nbas,nld,nmem,ngenutil,
|
|
|
|
|
|
+ nbas,nld,nmem,ngenutil,
|
|
defcmp,
|
|
defcmp,
|
|
paramgr;
|
|
paramgr;
|
|
|
|
|
|
@@ -216,7 +218,7 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- function str_parse_method_impl(str: ansistring; usefwpd: tprocdef; is_classdef: boolean):boolean;
|
|
|
|
|
|
+ function str_parse_method_impl(str: ansistring; get_code_block_func: tcggetcodeblockfunc; usefwpd: tprocdef; is_classdef: boolean):boolean;
|
|
var
|
|
var
|
|
oldparse_only: boolean;
|
|
oldparse_only: boolean;
|
|
tmpstr: ansistring;
|
|
tmpstr: ansistring;
|
|
@@ -242,7 +244,7 @@ implementation
|
|
current_scanner.substitutemacro('meth_impl_macro',@str[1],length(str),current_scanner.line_no,current_scanner.inputfile.ref_index);
|
|
current_scanner.substitutemacro('meth_impl_macro',@str[1],length(str),current_scanner.line_no,current_scanner.inputfile.ref_index);
|
|
current_scanner.readtoken(false);
|
|
current_scanner.readtoken(false);
|
|
{ and parse it... }
|
|
{ and parse it... }
|
|
- read_proc(is_classdef,usefwpd);
|
|
|
|
|
|
+ read_proc(is_classdef,usefwpd,get_code_block_func);
|
|
parse_only:=oldparse_only;
|
|
parse_only:=oldparse_only;
|
|
{ remove the temporary macro input file again }
|
|
{ remove the temporary macro input file again }
|
|
current_scanner.closeinputfile;
|
|
current_scanner.closeinputfile;
|
|
@@ -355,7 +357,7 @@ implementation
|
|
not is_void(pd.returndef) then
|
|
not is_void(pd.returndef) then
|
|
str:=str+'result:=';
|
|
str:=str+'result:=';
|
|
str:=str+'inherited end;';
|
|
str:=str+'inherited end;';
|
|
- str_parse_method_impl(str,pd,isclassmethod);
|
|
|
|
|
|
+ str_parse_method_impl(str,nil,pd,isclassmethod);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -399,7 +401,7 @@ implementation
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
str:=str+'end;';
|
|
str:=str+'end;';
|
|
- str_parse_method_impl(str,pd,false);
|
|
|
|
|
|
+ str_parse_method_impl(str,nil,pd,false);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -431,7 +433,7 @@ implementation
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
str:=str+'end;';
|
|
str:=str+'end;';
|
|
- str_parse_method_impl(str,pd,false);
|
|
|
|
|
|
+ str_parse_method_impl(str,nil,pd,false);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -464,7 +466,7 @@ implementation
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
str:=str+'end;';
|
|
str:=str+'end;';
|
|
- str_parse_method_impl(str,pd,false);
|
|
|
|
|
|
+ str_parse_method_impl(str,nil,pd,false);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure implement_empty(pd: tprocdef);
|
|
procedure implement_empty(pd: tprocdef);
|
|
@@ -476,7 +478,7 @@ implementation
|
|
(po_classmethod in pd.procoptions) and
|
|
(po_classmethod in pd.procoptions) and
|
|
not(pd.proctypeoption in [potype_constructor,potype_destructor]);
|
|
not(pd.proctypeoption in [potype_constructor,potype_destructor]);
|
|
str:='begin end;';
|
|
str:='begin end;';
|
|
- str_parse_method_impl(str,pd,isclassmethod);
|
|
|
|
|
|
+ str_parse_method_impl(str,nil,pd,isclassmethod);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -518,7 +520,7 @@ implementation
|
|
str:=str+callpd.procsym.realname+'(';
|
|
str:=str+callpd.procsym.realname+'(';
|
|
addvisibibleparameters(str,pd);
|
|
addvisibibleparameters(str,pd);
|
|
str:=str+') end;';
|
|
str:=str+') end;';
|
|
- str_parse_method_impl(str,pd,isclassmethod);
|
|
|
|
|
|
+ str_parse_method_impl(str,nil,pd,isclassmethod);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -837,7 +839,7 @@ implementation
|
|
begin
|
|
begin
|
|
callthroughprop:=tpropertysym(pd.skpara);
|
|
callthroughprop:=tpropertysym(pd.skpara);
|
|
str:='begin result:='+callthroughprop.realname+'; end;';
|
|
str:='begin result:='+callthroughprop.realname+'; end;';
|
|
- str_parse_method_impl(str,pd,po_classmethod in pd.procoptions)
|
|
|
|
|
|
+ str_parse_method_impl(str,nil,pd,po_classmethod in pd.procoptions)
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -848,7 +850,35 @@ implementation
|
|
begin
|
|
begin
|
|
callthroughprop:=tpropertysym(pd.skpara);
|
|
callthroughprop:=tpropertysym(pd.skpara);
|
|
str:='begin '+callthroughprop.realname+':=__fpc_newval__; end;';
|
|
str:='begin '+callthroughprop.realname+':=__fpc_newval__; end;';
|
|
- str_parse_method_impl(str,pd,po_classmethod in pd.procoptions)
|
|
|
|
|
|
+ str_parse_method_impl(str,nil,pd,po_classmethod in pd.procoptions)
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ function get_attribute_code_block(pd: tprocdef) : tnode;
|
|
|
|
+ var
|
|
|
|
+ attribute: trtti_attribute;
|
|
|
|
+ load: tloadnode;
|
|
|
|
+ statement: tstatementnode;
|
|
|
|
+ assignment: tassignmentnode;
|
|
|
|
+ begin
|
|
|
|
+ attribute:=trtti_attribute(pd.skpara);
|
|
|
|
+
|
|
|
|
+ load := cloadnode.create(pd.funcretsym,pd.funcretsym.Owner);
|
|
|
|
+ assignment := cassignmentnode.create(load,Attribute.constructorcall);
|
|
|
|
+ assignment.resultdef := voidtype;
|
|
|
|
+
|
|
|
|
+ statement := cstatementnode.Create(assignment,nil);
|
|
|
|
+ result := cblocknode.create(statement);
|
|
|
|
+ result.resultdef := voidtype;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ procedure implement_get_attribute(pd: tprocdef);
|
|
|
|
+ var
|
|
|
|
+ old_parse_only: boolean;
|
|
|
|
+ begin
|
|
|
|
+ old_parse_only:=parse_only;
|
|
|
|
+ parse_only:=false;
|
|
|
|
+ read_proc(po_classmethod in pd.procoptions,pd,@get_attribute_code_block);
|
|
|
|
+ parse_only:=old_parse_only;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -922,6 +952,8 @@ implementation
|
|
implement_field_getter(pd);
|
|
implement_field_getter(pd);
|
|
tsk_field_setter:
|
|
tsk_field_setter:
|
|
implement_field_setter(pd);
|
|
implement_field_setter(pd);
|
|
|
|
+ tsk_get_rttiattribute:
|
|
|
|
+ implement_get_attribute(pd)
|
|
else
|
|
else
|
|
internalerror(2011032801);
|
|
internalerror(2011032801);
|
|
end;
|
|
end;
|
|
@@ -935,9 +967,6 @@ implementation
|
|
def: tdef;
|
|
def: tdef;
|
|
sstate: tscannerstate;
|
|
sstate: tscannerstate;
|
|
begin
|
|
begin
|
|
- { only necessary for the JVM target currently }
|
|
|
|
- if not (target_info.system in systems_jvm) then
|
|
|
|
- exit;
|
|
|
|
replace_scanner('synthetic_impl',sstate);
|
|
replace_scanner('synthetic_impl',sstate);
|
|
add_synthetic_method_implementations_for_st(st);
|
|
add_synthetic_method_implementations_for_st(st);
|
|
for i:=0 to st.deflist.count-1 do
|
|
for i:=0 to st.deflist.count-1 do
|
|
@@ -948,6 +977,8 @@ implementation
|
|
{ not true for the "main" procedure, whose localsymtable is the staticsymtable }
|
|
{ not true for the "main" procedure, whose localsymtable is the staticsymtable }
|
|
(tprocdef(def).localst.symtabletype=localsymtable) then
|
|
(tprocdef(def).localst.symtabletype=localsymtable) then
|
|
add_synthetic_method_implementations(tprocdef(def).localst)
|
|
add_synthetic_method_implementations(tprocdef(def).localst)
|
|
|
|
+ else if (def.typ=objectdef) then
|
|
|
|
+ add_synthetic_method_implementations(tobjectdef(def).symtable)
|
|
else if (is_javaclass(def) and
|
|
else if (is_javaclass(def) and
|
|
not(oo_is_external in tobjectdef(def).objectoptions)) or
|
|
not(oo_is_external in tobjectdef(def).objectoptions)) or
|
|
(def.typ=recorddef) then
|
|
(def.typ=recorddef) then
|