瀏覽代碼

* call all operators with invokestatic, since they are always
class methods

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

Jonas Maebe 13 年之前
父節點
當前提交
f4f70f99b2
共有 5 個文件被更改,包括 40 次插入2 次删除
  1. 1 0
      .gitattributes
  2. 4 2
      compiler/jvm/hlcgcpu.pas
  3. 4 0
      tests/test/jvm/testall.bat
  4. 2 0
      tests/test/jvm/testall.sh
  5. 29 0
      tests/test/jvm/topovl.pp

+ 1 - 0
.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/tnestdynarr.pp svneol=native#text/plain
 tests/test/jvm/tnestedset.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/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/tprop.pp svneol=native#text/plain
 tests/test/jvm/tprop2.pp svneol=native#text/plain
 tests/test/jvm/tprop2.pp svneol=native#text/plain
 tests/test/jvm/tpvar.pp svneol=native#text/plain
 tests/test/jvm/tpvar.pp svneol=native#text/plain

+ 4 - 2
compiler/jvm/hlcgcpu.pas

@@ -2280,7 +2280,8 @@ implementation
             case tobjectdef(pd.owner.defowner).objecttype of
             case tobjectdef(pd.owner.defowner).objecttype of
               odt_javaclass:
               odt_javaclass:
                 begin
                 begin
-                  if (po_classmethod in pd.procoptions) then
+                  if (po_classmethod in pd.procoptions) or
+                     (pd.proctypeoption=potype_operator) then
                     opc:=a_invokestatic
                     opc:=a_invokestatic
                   else if (pd.visibility=vis_strictprivate) or
                   else if (pd.visibility=vis_strictprivate) or
                      (pd.proctypeoption=potype_constructor) or
                      (pd.proctypeoption=potype_constructor) or
@@ -2298,7 +2299,8 @@ implementation
           end;
           end;
         recordsymtable:
         recordsymtable:
           begin
           begin
-            if (po_staticmethod in pd.procoptions) then
+            if (po_staticmethod in pd.procoptions) or
+               (pd.proctypeoption=potype_operator) then
               opc:=a_invokestatic
               opc:=a_invokestatic
             else if (pd.visibility=vis_strictprivate) or
             else if (pd.visibility=vis_strictprivate) or
                (pd.proctypeoption=potype_constructor) or
                (pd.proctypeoption=potype_constructor) or

+ 4 - 0
tests/test/jvm/testall.bat

@@ -224,4 +224,8 @@ ppcjvm -O2 -g -B tnestdynarr
 if %errorlevel% neq 0 exit /b %errorlevel%
 if %errorlevel% neq 0 exit /b %errorlevel%
 java -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. tnestdynarr
 java -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. tnestdynarr
 if %errorlevel% neq 0 exit /b %errorlevel%
 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%
 
 

+ 2 - 0
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
 java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/jvm-java:. tdynarrnil
 $PPC -O2 -g -B tnestdynarr
 $PPC -O2 -g -B tnestdynarr
 java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/jvm-java:. 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

+ 29 - 0
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.
+