Browse Source

pastojs: untypedpointer:=typedpointer

git-svn-id: trunk@40083 -
Mattias Gaertner 6 years ago
parent
commit
8554623084
2 changed files with 8 additions and 1 deletions
  1. 2 1
      packages/pastojs/src/fppas2js.pp
  2. 6 0
      packages/pastojs/tests/tcmodules.pas

+ 2 - 1
packages/pastojs/src/fppas2js.pp

@@ -8125,7 +8125,8 @@ begin
         or (C=TPasRecordType)
         or (C=TPasRecordType)
         or (C=TPasEnumType)
         or (C=TPasEnumType)
         or (C=TPasRangeType)
         or (C=TPasRangeType)
-        or (C=TPasArrayType) then
+        or (C=TPasArrayType)
+        or (C=TPasPointerType) then
       begin
       begin
       // typecast
       // typecast
       // default is to simply replace  "aType(value)" with "value"
       // default is to simply replace  "aType(value)" with "value"

+ 6 - 0
packages/pastojs/tests/tcmodules.pas

@@ -18244,6 +18244,7 @@ begin
   '  r: TRec;',
   '  r: TRec;',
   '  p: PRec;',
   '  p: PRec;',
   '  q: ^TRec;',
   '  q: ^TRec;',
+  '  Ptr: pointer;',
   'begin',
   'begin',
   '  new(p);',
   '  new(p);',
   '  p:=@r;',
   '  p:=@r;',
@@ -18255,6 +18256,8 @@ begin
   '  dispose(p);',
   '  dispose(p);',
   '  new(q);',
   '  new(q);',
   '  dispose(q);',
   '  dispose(q);',
+  '  Ptr:=p;',
+  '  p:=PRec(ptr);',
   '']);
   '']);
   ConvertProgram;
   ConvertProgram;
   CheckSource('TestPointer_Record',
   CheckSource('TestPointer_Record',
@@ -18272,6 +18275,7 @@ begin
     'this.r = new $mod.TRec();',
     'this.r = new $mod.TRec();',
     'this.p = null;',
     'this.p = null;',
     'this.q = null;',
     'this.q = null;',
+    'this.Ptr = null;',
     '']),
     '']),
     LinesToStr([ // $mod.$main
     LinesToStr([ // $mod.$main
     '$mod.p = new $mod.TRec();',
     '$mod.p = new $mod.TRec();',
@@ -18284,6 +18288,8 @@ begin
     '$mod.p = null;',
     '$mod.p = null;',
     '$mod.q = new $mod.TRec();',
     '$mod.q = new $mod.TRec();',
     '$mod.q = null;',
     '$mod.q = null;',
+    '$mod.Ptr = $mod.p;',
+    '$mod.p = $mod.Ptr;',
     '']));
     '']));
 end;
 end;