Ver Fonte

*pexpr.pas:
- moved "postfixoperators" from local declaration of "factor" to implementation declarations of the unit, so it can be used in "sub_expr"
- for this a parameter "getaddr:boolean" needed to be added, because it used the parameter that was defined by "factor"
=> adjustments inside "factor" for calls to "postfixoperators"
- extended the "_LT" ("<") case of "sub_expr" with handling of inline generic specializations. If a potential generic is detected (Delphi mode, left and right node are type nodes, next token is ">" or ",") it is tried to parse the generic declaration and generate a specialization. If this succeeds, potential postfix operators are parsed and a node <> caddnode is returned.

*pgenutil.pas:
"generate_specialization" was extended so that the first type identifer can already have been parsed (which is the case in inline specializations)

*ptype.pas
adjustments because of the extension of "generate_specialization"

git-svn-id: branches/svenbarth/generics@17405 -

svenbarth há 14 anos atrás
pai
commit
6cee1dc4a4
3 ficheiros alterados com 549 adições e 541 exclusões
  1. 533 534
      compiler/pexpr.pas
  2. 14 5
      compiler/pgenutil.pas
  3. 2 2
      compiler/ptype.pas

Diff do ficheiro suprimidas por serem muito extensas
+ 533 - 534
compiler/pexpr.pas


+ 14 - 5
compiler/pgenutil.pas

@@ -32,7 +32,7 @@ uses
   { symtable }
   symtype,symdef;
 
-    procedure generate_specialization(var tt:tdef;parse_class_parent:boolean);
+    procedure generate_specialization(var tt:tdef;parse_class_parent:boolean;parsedtype:tdef);
     function parse_generic_parameters:TFPObjectList;
     procedure insert_generic_parameter_types(def:tstoreddef;genericdef:tstoreddef;genericlist:TFPObjectList);
 
@@ -54,7 +54,7 @@ uses
   pbase,pexpr,pdecsub,ptype;
 
 
-    procedure generate_specialization(var tt:tdef;parse_class_parent:boolean);
+    procedure generate_specialization(var tt:tdef;parse_class_parent:boolean;parsedtype:tdef);
       var
         st  : TSymtable;
         srsym : tsym;
@@ -126,7 +126,7 @@ uses
             exit;
           end;
 
-        if not try_to_consume(_LT) then
+        if not assigned(parsedtype) and not try_to_consume(_LT) then
           consume(_LSHARPBRACKET);
 
         generictypelist:=TFPObjectList.create(false);
@@ -136,8 +136,17 @@ uses
         if not assigned(genericdef.typesym) then
           internalerror(200710173);
         err:=false;
-        first:=true;
-        specializename:='';
+        { if parsedtype is set, then the first type identifer was already parsed
+          (happens in inline specializations) and thus we only need to parse
+          the remaining types and do as if the first one was already given }
+        first:=not assigned(parsedtype);
+        if assigned(parsedtype) then
+          begin
+            genericdeflist.Add(parsedtype);
+            specializename:='$'+parsedtype.typesym.realname;
+          end
+        else
+          specializename:='';
         while not (token in [_GT,_RSHARPBRACKET]) do
           begin
             if not first then

+ 2 - 2
compiler/ptype.pas

@@ -371,7 +371,7 @@ implementation
            (m_delphi in current_settings.modeswitches) then
           dospecialize:=token=_LSHARPBRACKET;
         if dospecialize then
-          generate_specialization(def,stoParseClassParent in options)
+          generate_specialization(def,stoParseClassParent in options,nil)
         else
           begin
             if assigned(current_specializedef) and (def=current_specializedef.genericdef) then
@@ -831,7 +831,7 @@ implementation
                    if (m_delphi in current_settings.modeswitches) then
                      dospecialize:=token=_LSHARPBRACKET;
                    if dospecialize then
-                     generate_specialization(def,false)
+                     generate_specialization(def,false,nil)
                    else
                      begin
                        if assigned(current_specializedef) and (def=current_specializedef.genericdef) then

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff