From f4f70f99b2c018c487c95a2f6f6470c677aa16fd Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 11 Dec 2011 17:25:42 +0000 Subject: [PATCH] * call all operators with invokestatic, since they are always class methods git-svn-id: branches/jvmbackend@19823 - --- .gitattributes | 1 + compiler/jvm/hlcgcpu.pas | 6 ++++-- tests/test/jvm/testall.bat | 4 ++++ tests/test/jvm/testall.sh | 2 ++ tests/test/jvm/topovl.pp | 29 +++++++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tests/test/jvm/topovl.pp diff --git a/.gitattributes b/.gitattributes index ea3d014c99..ab4e687f75 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9797,6 +9797,7 @@ tests/test/jvm/tintstr.pp svneol=native#text/plain tests/test/jvm/tnestdynarr.pp svneol=native#text/plain tests/test/jvm/tnestedset.pp svneol=native#text/plain tests/test/jvm/tnestproc.pp svneol=native#text/plain +tests/test/jvm/topovl.pp svneol=native#text/plain tests/test/jvm/tprop.pp svneol=native#text/plain tests/test/jvm/tprop2.pp svneol=native#text/plain tests/test/jvm/tpvar.pp svneol=native#text/plain diff --git a/compiler/jvm/hlcgcpu.pas b/compiler/jvm/hlcgcpu.pas index 004caa7d37..426fda46f8 100644 --- a/compiler/jvm/hlcgcpu.pas +++ b/compiler/jvm/hlcgcpu.pas @@ -2280,7 +2280,8 @@ implementation case tobjectdef(pd.owner.defowner).objecttype of odt_javaclass: begin - if (po_classmethod in pd.procoptions) then + if (po_classmethod in pd.procoptions) or + (pd.proctypeoption=potype_operator) then opc:=a_invokestatic else if (pd.visibility=vis_strictprivate) or (pd.proctypeoption=potype_constructor) or @@ -2298,7 +2299,8 @@ implementation end; recordsymtable: begin - if (po_staticmethod in pd.procoptions) then + if (po_staticmethod in pd.procoptions) or + (pd.proctypeoption=potype_operator) then opc:=a_invokestatic else if (pd.visibility=vis_strictprivate) or (pd.proctypeoption=potype_constructor) or diff --git a/tests/test/jvm/testall.bat b/tests/test/jvm/testall.bat index 3ff48a90af..6276052fcb 100644 --- a/tests/test/jvm/testall.bat +++ b/tests/test/jvm/testall.bat @@ -224,4 +224,8 @@ ppcjvm -O2 -g -B tnestdynarr if %errorlevel% neq 0 exit /b %errorlevel% java -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. tnestdynarr if %errorlevel% neq 0 exit /b %errorlevel% +ppcjvm -O2 -g -B topovl +if %errorlevel% neq 0 exit /b %errorlevel% +java -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. topovl +if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/tests/test/jvm/testall.sh b/tests/test/jvm/testall.sh index fdb859bff0..c55032f038 100755 --- a/tests/test/jvm/testall.sh +++ b/tests/test/jvm/testall.sh @@ -122,3 +122,5 @@ $PPC -O2 -g -B tdynarrnil java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/jvm-java:. tdynarrnil $PPC -O2 -g -B tnestdynarr java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/jvm-java:. tnestdynarr +$PPC -O2 -g -B topovl +java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/jvm-java:. topovl diff --git a/tests/test/jvm/topovl.pp b/tests/test/jvm/topovl.pp new file mode 100644 index 0000000000..a2c778ea1d --- /dev/null +++ b/tests/test/jvm/topovl.pp @@ -0,0 +1,29 @@ +{$mode delphi} + +program topovl; + +type + complex = record + re,im: real; + + class operator multiply(r : real; const z1 : complex): complex; + end; + +class Operator complex.multiply (r : real; const z1 : complex): complex; + +begin + result.re := z1.re * r; + result.im := z1.im * r; +end; + +var + R : real; + C,Z : complex; + +begin + r:=2.0; + c.re:=3.0; + c.im:=4.0; + C:=R*Z; +end. +