From 8ec1ba797d62b817836af677931496113d1899e6 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 20 Aug 2011 08:08:44 +0000 Subject: [PATCH] * put single quotes around identifiers so they cannot be confused with opcodes by Jasmin git-svn-id: branches/jvmbackend@18540 - --- compiler/jvmdef.pas | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/compiler/jvmdef.pas b/compiler/jvmdef.pas index 4716c840b7..3cb46dcd5a 100644 --- a/compiler/jvmdef.pas +++ b/compiler/jvmdef.pas @@ -381,6 +381,7 @@ implementation owningcontainer: tsymtable; tmpresult: string; module: tmodule; + nameendpos: longint; begin { see tprocdef.jvmmangledbasename for description of the format } owningcontainer:=owner; @@ -412,6 +413,11 @@ implementation internalerror(2010122605); end; name:=tmpresult+name; + nameendpos:=pos(' ',name); + if nameendpos=0 then + nameendpos:=length(name)+1; + insert('''',name,nameendpos); + name:=''''+name; end; @@ -512,13 +518,18 @@ implementation end; if (vsym.typ=paravarsym) and (vo_is_self in tparavarsym(vsym).varoptions) then - result:='this ' +result + result:='''this'' ' +result else if (vsym.typ in [paravarsym,localvarsym]) and ([vo_is_funcret,vo_is_result] * tabstractnormalvarsym(vsym).varoptions <> []) then - result:='result '+result + result:='''result'' '+result else 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 prevent name clashes... } if (vsym.typ=staticvarsym) then @@ -535,6 +546,8 @@ implementation container:=container.defowner.owner; end; end; + if withsignature then + result:=''''+result end; end; constsym: @@ -572,7 +585,10 @@ implementation internalerror(2011040703); end; end; - result:=usesymname+' '+result; + if withsignature then + result:=''''+usesymname+''' '+result + else + result:=usesymname+' '+result end; else internalerror(2011021703);