Recent

Author Topic: Not supported: variant record  (Read 2540 times)

peter.dell

  • New Member
  • *
  • Posts: 16
Not supported: variant record
« on: May 02, 2024, 12:07:35 am »
Hello,

I've tried to get the Java Bytecode target working for quite some time, but it looks like that's far from reality. So I now had the idea of using pas2js and then running the Javascript inside die Java VM (e.g. via Nashorn).

The first attempts look promising. I had to change some parts in the code where pas2js appears to be stricter than FPC (e.g. {I+) => {IOCHECK+}; string[32] => array[0..31] of string, ...).

But I think now I've come to the point where pas2js needs an extension. Is there a standard way of requesting an extension, like here, support for variant records?

- Kind regards Peter/JAC!

C:\Users\JAC\Downloads\pas2js-win64-x86_64-3.0.1>bin\pas2js.exe -Mdelphi src\mp.pas
Pas2JS Compiler version 3.0.1 [2024/01/25] for Win32 i386
Copyright (c) 2023 Free Pascal team.
packages\rtl\src\js.pas(1012,15) Warning: Symbol "Int64" is not implemented
packages\rtl\src\js.pas(1014,15) Warning: Symbol "Int64" is not implemented
packages\rtl\src\js.pas(1047,14) Hint: method hides identifier at "packages\rtl\src\js.pas(87,21)". Use reintroduce
packages\rtl\src\js.pas(1050,36) Warning: Symbol "Int64" is not implemented
packages\rtl\src\js.pas(1052,36) Warning: Symbol "Int64" is not implemented
src\Common.pas(407,5) Warning: Symbol "Int64" is not implemented

src\Common.pas(424,23) Error: Not supported: variant record

  TToken = record
    UnitIndex, Column: Smallint;
    Line: Integer;
    case Kind: Byte of
      IDENTTOK:
   (Name: ^TString);
      INTNUMBERTOK:
   (Value: Int64);
      FRACNUMBERTOK:
   (FracValue: Single);
      STRINGLITERALTOK:
   (StrAddress: Word;
    StrLength: Word);
    end;

Fatal: Compilation aborted

Thaddy

  • Hero Member
  • *****
  • Posts: 15526
  • Censorship about opinions does not belong here.
Re: Not supported: variant record
« Reply #1 on: May 02, 2024, 01:22:36 pm »
I've tried to get the Java Bytecode target working for quite some time, but it looks like that's far from reality.
In what sense? I use it daily. I might be able to help, but you did not describe any issue..


Btw:
 string[32] => array[0..31] of string, ...)
is wrong of course, it is a shortstring of length 32, not an array of string, but essentially an array of AnsiChar.
« Last Edit: May 02, 2024, 01:59:54 pm by Thaddy »
My great hero has found the key to the highway. Rest in peace John Mayall.
Playing: "Broken Wings" in your honour. As well as taking out some mouth organs.

peter.dell

  • New Member
  • *
  • Posts: 16
Re: Not supported: variant record
« Reply #2 on: May 03, 2024, 06:28:16 am »
In what sense? I use it daily. I might be able to help, but you did not describe any issue..
That would be great. I'll get in contact with you via DM.

Quote
string[32] => array[0..31] of string, ...)
is wrong of course, it is a shortstring of length 32, not an array of string, but essentially an array of AnsiChar.
Thanks, I was not aware shortstrings existed. But that means pas2js does not support them?
The line
    name : string[32];
results in "src\targets\type.inc(8,18) Error: Expected ";" or "End""

cdbc

  • Hero Member
  • *****
  • Posts: 1497
    • http://www.cdbc.dk
Re: Not supported: variant record
« Reply #3 on: May 03, 2024, 06:42:06 am »
Hey
None of us can read anything from 1 line of code and then deduce what went wrong  >:(
Hazarding a wild guess here:
Code: Pascal  [Select][+][-]
  1. type
  2.   TNameStr = string[32];
  3. ...
  4. var
  5.   Name: TNameStr;
  6. ...
  7.  
...if it were...
/bc
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

peter.dell

  • New Member
  • *
  • Posts: 16
Re: Not supported: variant record
« Reply #4 on: May 03, 2024, 07:51:04 am »
Please excuse me for not providing the whole context. This is the whole "type.inc" file.

Code: Pascal  [Select][+][-]
  1. type
  2.  
  3.   tCPU = (CPU_6502, CPU_65C02, CPU_65816);
  4.  
  5.   tComputer = (___c64, ___c4p, ___a8, ___raw, ___neo, ___x16);
  6.  
  7.   TTarget = Record
  8.     name : string[32];
  9.     id: tComputer;
  10.     cpu: tCPU;
  11.     eol: byte;
  12.     zpage,
  13.     buf,
  14.     codeorigin : word;
  15.     header          : array[0..15] of string;
  16.   end;
  17.  

cdbc

  • Hero Member
  • *****
  • Posts: 1497
    • http://www.cdbc.dk
Re: Not supported: variant record
« Reply #5 on: May 03, 2024, 10:06:35 am »
hey
Code: Pascal  [Select][+][-]
  1. type
  2.  
  3.   tCPU = (CPU_6502, CPU_65C02, CPU_65816);
  4.  
  5.   tComputer = (___c64, ___c4p, ___a8, ___raw, ___neo, ___x16);
  6.  
  7.   TTarget = Record
  8.     name : string[32];
  9.     id: tComputer;
  10.     cpu: tCPU;
  11.     eol: byte;
  12.     zpage,
  13.     buf,
  14.     codeorigin : word;
  15.     header          : array[0..15] of ansichar; //<-- or ~ string[16];
  16.   end;
  17.  
/bc
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

peter.dell

  • New Member
  • *
  • Posts: 16
Re: Not supported: variant record
« Reply #6 on: May 03, 2024, 11:08:06 pm »
It is really intended to be an array of strings. Here's an example of how it is filled:

Code: Pascal  [Select][+][-]
  1. target.header[0]  := 'opt h-f+';
  2. target.header[1]  := 'org $801';
  3. target.header[2]  := 'org [a($801)],$801';
  4. target.header[3]  := 'basic_start(START)';
  5. target.header[4]  := ''; // asm65;
  6. target.header[5]  := 'org $900';
  7. target.header[6]  := ''; // asm65;
  8. target.header[7]  := 'END';
  9.  

 

TinyPortal © 2005-2018