Browse Source

* Propagate delphi mode when scanning generated code for wasm (specially generic specialization)

Michaël Van Canneyt 2 months ago
parent
commit
37b3a88fa0
1 changed files with 12 additions and 0 deletions
  1. 12 0
      compiler/symcreat.pas

+ 12 - 0
compiler/symcreat.pas

@@ -1525,8 +1525,12 @@ implementation
   begin
     cn:=ObjDef.GetTypeName;
     for i:=0 to Length(cn) do
+      begin
       if cn[i]='.' then
+        cn[i]:='_'
+      else if (cn[i]='<') or (cn[i]='>') then
         cn[i]:='_';
+      end;
     result:='_t_hidden'+tostr(acount)+cn;
   end;
 
@@ -1815,14 +1819,22 @@ implementation
     recdef : trecorddef absolute def;
     sstate: tscannerstate;
     cn : shortstring;
+    isDelphiMode : boolean;
+    oldsettings: tmodeswitches;
 
   begin
     { skip if any errors have occurred, since then this can only cause more
       errors }
     if ErrorCount<>0 then
       exit;
+    isDelphiMode:=(m_delphi in current_settings.modeswitches);
     replace_scanner('hiddenclass_impl',sstate);
     sstate.new_scanner.allowgenericid:=true;
+    if isDelphiMode then
+      begin
+      oldsettings:=current_settings.modeswitches;
+      current_settings.modeswitches:=current_settings.modeswitches+[m_delphi]-[m_objfpc];
+      end;
     for i:=0 to st.deflist.count-1 do
       begin
       def:=tdef(st.deflist[i]);