ソースを参照

+ support for typecasting ansistrings into pchars on the JVM platform
+ support for indexing pointers as arrays on the JVM platform (with
JVM-provided range checking, obviously)

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

Jonas Maebe 14 年 前
コミット
224aae8993
2 ファイル変更30 行追加1 行削除
  1. 29 1
      compiler/jvm/njvmcnv.pas
  2. 1 0
      rtl/java/astringh.inc

+ 29 - 1
compiler/jvm/njvmcnv.pas

@@ -39,6 +39,7 @@ interface
           function first_set_to_set : tnode;override;
           function first_nil_to_methodprocvar: tnode; override;
           function first_proc_to_procvar: tnode; override;
+          function first_ansistring_to_pchar: tnode; override;
 
           procedure second_int_to_int;override;
          { procedure second_string_to_string;override; }
@@ -46,7 +47,7 @@ interface
          { procedure second_string_to_chararray;override; }
          { procedure second_array_to_pointer;override; }
           function first_int_to_real: tnode; override;
-         { procedure second_pointer_to_array;override; }
+          procedure second_pointer_to_array;override;
          { procedure second_chararray_to_string;override; }
          { procedure second_char_to_string;override; }
           procedure second_int_to_real;override;
@@ -452,6 +453,26 @@ implementation
       end;
 
 
+    function tjvmtypeconvnode.first_ansistring_to_pchar: tnode;
+      var
+        ps: tsym;
+      begin
+        result:=ctypeconvnode.create_explicit(left,java_ansistring);
+        ps:=search_struct_member(java_ansistring,'INTERNCHARS');
+        if not assigned(ps) or
+           (ps.typ<>propertysym) then
+          internalerror(2011081401);
+        ps:=tpropertysym(ps).propaccesslist[palt_read].firstsym^.sym;
+        if (ps.typ<>procsym) then
+          internalerror(2011081402);
+        result:=ccallnode.create(nil,tprocsym(ps),ps.owner,result,[]);
+        include(result.flags,nf_isproperty);
+        result:=ctypeconvnode.create_explicit(result,resultdef);
+        { reused }
+        left:=nil;
+      end;
+
+
 {*****************************************************************************
                              SecondTypeConv
 *****************************************************************************}
@@ -527,6 +548,13 @@ implementation
       end;
 
 
+    procedure tjvmtypeconvnode.second_pointer_to_array;
+      begin
+        { arrays are implicit pointers in Java -> same location }
+        location_copy(location,left.location);
+      end;
+
+
     procedure tjvmtypeconvnode.second_int_to_real;
       var
         srcsize, ressize: longint;

+ 1 - 0
rtl/java/astringh.inc

@@ -34,6 +34,7 @@ type
 //    function concat(const a: ansistring): ansistring;
 //    function concatmultiple(const arr: array of ansistring): ansistring;
     function length: jint;
+    property internChars: TAnsiCharArray read fdata;
   end;
 
 Function Pos (Const Substr : Ansistring; Const Source : Ansistring) : SizeInt;