Explorar el Código

* put single quotes around identifiers so they cannot be confused with
opcodes by Jasmin

git-svn-id: branches/jvmbackend@18540 -

Jonas Maebe hace 14 años
padre
commit
8ec1ba797d
Se han modificado 1 ficheros con 20 adiciones y 4 borrados
  1. 20 4
      compiler/jvmdef.pas

+ 20 - 4
compiler/jvmdef.pas

@@ -381,6 +381,7 @@ implementation
         owningcontainer: tsymtable;
         owningcontainer: tsymtable;
         tmpresult: string;
         tmpresult: string;
         module: tmodule;
         module: tmodule;
+        nameendpos: longint;
       begin
       begin
         { see tprocdef.jvmmangledbasename for description of the format }
         { see tprocdef.jvmmangledbasename for description of the format }
         owningcontainer:=owner;
         owningcontainer:=owner;
@@ -412,6 +413,11 @@ implementation
             internalerror(2010122605);
             internalerror(2010122605);
         end;
         end;
         name:=tmpresult+name;
         name:=tmpresult+name;
+        nameendpos:=pos(' ',name);
+        if nameendpos=0 then
+          nameendpos:=length(name)+1;
+        insert('''',name,nameendpos);
+        name:=''''+name;
       end;
       end;
 
 
 
 
@@ -512,13 +518,18 @@ implementation
                 end;
                 end;
               if (vsym.typ=paravarsym) and
               if (vsym.typ=paravarsym) and
                  (vo_is_self in tparavarsym(vsym).varoptions) then
                  (vo_is_self in tparavarsym(vsym).varoptions) then
-                result:='this ' +result
+                result:='''this'' ' +result
               else if (vsym.typ in [paravarsym,localvarsym]) and
               else if (vsym.typ in [paravarsym,localvarsym]) and
                       ([vo_is_funcret,vo_is_result] * tabstractnormalvarsym(vsym).varoptions <> []) then
                       ([vo_is_funcret,vo_is_result] * tabstractnormalvarsym(vsym).varoptions <> []) then
-                result:='result '+result
+                result:='''result'' '+result
               else
               else
                 begin
                 begin
-                  result:=usesymname+' '+result;
+                  { single quotes for definitions to prevent clashes with Java
+                    opcodes }
+                  if withsignature then
+                    result:=usesymname+''' '+result
+                  else
+                    result:=usesymname+' '+result;
                   { we have to mangle staticvarsyms in localsymtables to
                   { we have to mangle staticvarsyms in localsymtables to
                     prevent name clashes... }
                     prevent name clashes... }
                   if (vsym.typ=staticvarsym) then
                   if (vsym.typ=staticvarsym) then
@@ -535,6 +546,8 @@ implementation
                           container:=container.defowner.owner;
                           container:=container.defowner.owner;
                         end;
                         end;
                     end;
                     end;
+                  if withsignature then
+                    result:=''''+result
                 end;
                 end;
             end;
             end;
           constsym:
           constsym:
@@ -572,7 +585,10 @@ implementation
                       internalerror(2011040703);
                       internalerror(2011040703);
                   end;
                   end;
                 end;
                 end;
-              result:=usesymname+' '+result;
+              if withsignature then
+                result:=''''+usesymname+''' '+result
+              else
+                result:=usesymname+' '+result
             end;
             end;
           else
           else
             internalerror(2011021703);
             internalerror(2011021703);