|
1 |
| -{ uPSCompiler.pas } // version: 2022.1123.1400 |
| 1 | +{ uPSCompiler.pas } // version: 2022.1123.1500 |
2 | 2 | {----------------------------------------------------------------------------}
|
3 | 3 | { RemObjects Pascal Script }
|
4 | 4 | {----------------------------------------------------------------------------}
|
@@ -939,8 +939,31 @@ TPSPascalCompiler = class
|
939 | 939 | function AddTypeS(const Name, Decl: tbtString): TPSType;
|
940 | 940 | function AddTypeCopy(const Name: tbtString; TypeNo: TPSType): TPSType;
|
941 | 941 | function AddTypeCopyN(const Name, FType: tbtString): TPSType;
|
942 |
| - function AddConstant(const Name: tbtString; FType: TPSType): TPSConstant; |
| 942 | + function AddConstant(const Name: tbtString; FType: TPSType): TPSConstant; overload; |
943 | 943 | function AddConstantN(const Name, FType: tbtString): TPSConstant;
|
| 944 | + |
| 945 | +// function AddConstant(const Name: tbtString; const Value ): TPSConstant; overload; |
| 946 | + function AddConstant(const Name: tbtString; const Value: Integer): TPSConstant; overload; |
| 947 | + function AddConstant(const Name: tbtString; const Value: Cardinal): TPSConstant; overload; |
| 948 | + {$IFNDEF PS_NOINT64} |
| 949 | + function AddConstant(const Name: tbtString; const Value: Int64): TPSConstant; overload; |
| 950 | + {$ENDIF PS_NOINT64} |
| 951 | +// {$IFNDEF PS_NOUINT64} |
| 952 | +// function AddConstant(const Name: tbtString; const Value: UInt64): TPSConstant; overload; |
| 953 | +// {$ENDIF PS_NOUINT64} |
| 954 | + function AddConstant(const Name: tbtString; const Value: tbtString): TPSConstant; overload; |
| 955 | + function AddConstant(const Name: tbtString; const Value: tbtChar): TPSConstant; overload; |
| 956 | + {$IFNDEF PS_NOWIDESTRING} |
| 957 | + {$if defined(UNICODE) and not defined(PS_BTSTRINGNATIVE)} // WideChar == tbtChar |
| 958 | + function AddConstant(const Name: tbtString; const Value: WideChar): TPSConstant; overload; |
| 959 | + {$ifend} |
| 960 | + function AddConstant(const Name: tbtString; const Value: tbtWideString): TPSConstant; overload; |
| 961 | + {$IFDEF UNICODE} |
| 962 | + function AddConstant(const Name: tbtString; const Value: tbtUnicodeString): TPSConstant; overload; |
| 963 | + {$ENDIF} |
| 964 | + {$ENDIF PS_NOWIDESTRING} |
| 965 | + function AddConstant(const Name: tbtString; const Value: Extended): TPSConstant; overload; |
| 966 | + |
944 | 967 | function AddVariable(const Name: tbtString; FType: TPSType): TPSVar;
|
945 | 968 | function AddVariableN(const Name, FType: tbtString): TPSVar;
|
946 | 969 | function AddUsedVariable(const Name: tbtString; FType: TPSType): TPSVar;
|
@@ -11280,7 +11303,7 @@ function TPSPascalCompiler.Compile(const s: TbtString): Boolean;
|
11280 | 11303 | end;
|
11281 | 11304 | fUnit.AddUses(S);
|
11282 | 11305 | if Parse then begin
|
11283 |
| - {$ENDIF PS_USESSUPPORT} |
| 11306 | + //{$ENDIF PS_USESSUPPORT} |
11284 | 11307 | FUses.Add(s);
|
11285 | 11308 | if @FOnUses <> nil then begin
|
11286 | 11309 | try
|
@@ -11315,9 +11338,13 @@ function TPSPascalCompiler.Compile(const s: TbtString): Boolean;
|
11315 | 11338 | end;
|
11316 | 11339 | end;
|
11317 | 11340 | end;
|
11318 |
| - {$IFDEF PS_USESSUPPORT} |
| 11341 | + //{$IFDEF PS_USESSUPPORT} |
11319 | 11342 | end;
|
11320 |
| - {$ENDIF} |
| 11343 | + {$ELSE ! PS_USESSUPPORT} |
| 11344 | + MakeError('', ecUnknownIdentifier, S); |
| 11345 | + Result := False; |
| 11346 | + Exit; |
| 11347 | + {$ENDIF ! PS_USESSUPPORT} |
11321 | 11348 | FParser.Next;
|
11322 | 11349 | if FParser.CurrTokenID = CSTI_Semicolon then
|
11323 | 11350 | Break
|
@@ -11724,6 +11751,7 @@ procedure TPSPascalCompiler.DefineStandardTypes;
|
11724 | 11751 | i: Longint;
|
11725 | 11752 | begin
|
11726 | 11753 | AddType('Byte', btU8);
|
| 11754 | + AddTypeCopyN('UCHAR', 'Byte'); // Unsigned Char |
11727 | 11755 | FDefaultBoolType := AddTypeS('Boolean', '(False, True)');
|
11728 | 11756 | FDefaultBoolType.ExportName := True;
|
11729 | 11757 |
|
@@ -11807,25 +11835,36 @@ procedure TPSPascalCompiler.DefineStandardTypes;
|
11807 | 11835 | FAnyMethod := AddTypeS('AnyMethod', 'procedure');
|
11808 | 11836 | AddType('ShortInt', btS8);
|
11809 | 11837 | AddType('Word', btU16);
|
| 11838 | + AddTypeCopyN('USHORT', 'Word'); |
11810 | 11839 | AddType('SmallInt', btS16);
|
| 11840 | + AddTypeCopyN('SHORT', 'SmallInt'); |
11811 | 11841 | AddType('LongInt', btS32);
|
| 11842 | + AddTypeCopyN('LONG', 'LongInt'); |
11812 | 11843 | at2ut(AddType('___Pointer', btPointer));
|
11813 | 11844 | AddType('LongWord', btU32);
|
11814 | 11845 | AddTypeCopyN('Integer', 'LongInt');
|
| 11846 | + AddTypeCopyN('FixedInt', 'LongInt'); |
11815 | 11847 | AddTypeCopyN('Cardinal', 'LongWord');
|
11816 | 11848 | {+} {+.}
|
| 11849 | + AddTypeCopyN('UINT', 'LongWord'); |
| 11850 | + AddTypeCopyN('ULONG', 'LongWord'); |
| 11851 | + AddTypeCopyN('ULONG32', 'LongWord'); |
11817 | 11852 | {$IFNDEF PS_NOINT64}
|
11818 | 11853 | AddType('Int64', btS64);
|
11819 | 11854 | AddType('UInt64', btU64);
|
| 11855 | + AddTypeCopyN('LONG64', 'Int64'); |
| 11856 | + AddTypeCopyN('LONGLONG', 'Int64'); |
11820 | 11857 | {$ENDIF}
|
11821 | 11858 | {+}
|
11822 | 11859 | //PointerSize = IPointer({$IFDEF CPU64}8{$ELSE}4{$ENDIF});
|
11823 | 11860 | {$IFNDEF PS_NOINT64}
|
11824 | 11861 | AddType('NativeInt', {$IFDEF CPU64}btS64{$ELSE}btS32{$ENDIF});
|
11825 | 11862 | AddType('NativeUInt', {$IFDEF CPU64}btU64{$ELSE}btU32{$ENDIF});
|
| 11863 | + //AddTypeCopyN('THandle', 'Int64'); //unit uPSC_classes |
11826 | 11864 | {$ELSE}
|
11827 | 11865 | AddType('NativeInt', btS32);
|
11828 | 11866 | AddType('NativeUInt', btU32);
|
| 11867 | + //AddTypeCopyN('THandle', 'LongWord'); //unit uPSC_classes |
11829 | 11868 | {$ENDIF}
|
11830 | 11869 | //AddType('Pointer', btPointer);
|
11831 | 11870 | AddTypeCopyN('Pointer', 'NativeUInt');
|
@@ -12846,6 +12885,80 @@ function TPSPascalCompiler.AddConstantN(const Name, FType: tbtString): TPSConsta
|
12846 | 12885 | Result := AddConstant(Name, FindType(FType)); // is handle nil type
|
12847 | 12886 | end;
|
12848 | 12887 |
|
| 12888 | +//function TPSPascalCompiler.AddConstant(const Name: tbtString; const Value ): TPSConstant; |
| 12889 | +//begin |
| 12890 | +// Result := AddConstant(Name, FindType('Set') ); |
| 12891 | +// Result.SetSet(Value); |
| 12892 | +//end; |
| 12893 | + |
| 12894 | +function TPSPascalCompiler.AddConstant(const Name: tbtString; const Value: Integer): TPSConstant; |
| 12895 | +begin |
| 12896 | + Result := AddConstant(Name, FindType('Integer') ); // LONGINT |
| 12897 | + Result.SetInt(Value); |
| 12898 | +end; |
| 12899 | + |
| 12900 | +function TPSPascalCompiler.AddConstant(const Name: tbtString; const Value: Cardinal): TPSConstant; |
| 12901 | +begin |
| 12902 | + Result := AddConstant(Name, FindType('Cardinal') ); // LONGWORD |
| 12903 | + Result.SetUInt(Value); |
| 12904 | +end; |
| 12905 | + |
| 12906 | +{$IFNDEF PS_NOINT64} |
| 12907 | +function TPSPascalCompiler.AddConstant(const Name: tbtString; const Value: Int64): TPSConstant; |
| 12908 | +begin |
| 12909 | + Result := AddConstant(Name, FindType('Int64') ); // INT64 |
| 12910 | + Result.SetInt64(Value); |
| 12911 | +end; |
| 12912 | +{$ENDIF PS_NOINT64} |
| 12913 | + |
| 12914 | +//{$IFNDEF PS_NOUINT64} |
| 12915 | +//function TPSPascalCompiler.AddConstant(const Name: tbtString; const Value: UInt64): TPSConstant; |
| 12916 | +//begin |
| 12917 | +// Result := AddConstant(Name, FindType('UInt64') ); // UINT64 |
| 12918 | +// Result.SetUInt64(Value); |
| 12919 | +//end; |
| 12920 | +//{$ENDIF PS_NOUINT64} |
| 12921 | + |
| 12922 | +function TPSPascalCompiler.AddConstant(const Name: tbtString; const Value: tbtString): TPSConstant; |
| 12923 | +begin |
| 12924 | + Result := AddConstant(Name, FindType('String') ); // STRING |
| 12925 | + Result.SetString(Value); |
| 12926 | +end; |
| 12927 | + |
| 12928 | +function TPSPascalCompiler.AddConstant(const Name: tbtString; const Value: tbtChar): TPSConstant; |
| 12929 | +begin |
| 12930 | + Result := AddConstant(Name, FindType('Char') ); // ANSICHAR |
| 12931 | + Result.SetChar(Value); |
| 12932 | +end; |
| 12933 | + |
| 12934 | +{$IFNDEF PS_NOWIDESTRING} |
| 12935 | +{$if defined(UNICODE) and not defined(PS_BTSTRINGNATIVE)} // WideChar == tbtChar |
| 12936 | +function TPSPascalCompiler.AddConstant(const Name: tbtString; const Value: WideChar): TPSConstant; |
| 12937 | +begin |
| 12938 | + Result := AddConstant(Name, FindType('WideChar') ); // WIDECHAR |
| 12939 | + Result.SetWideChar(Value); |
| 12940 | +end; |
| 12941 | +{$ifend} |
| 12942 | +function TPSPascalCompiler.AddConstant(const Name: tbtString; const Value: tbtWideString): TPSConstant; |
| 12943 | +begin |
| 12944 | + Result := AddConstant(Name, FindType('WideString') ); // WIDESTRING |
| 12945 | + Result.SetWideString(Value); |
| 12946 | +end; |
| 12947 | +{$IFDEF UNICODE} |
| 12948 | +function TPSPascalCompiler.AddConstant(const Name: tbtString; const Value: tbtUnicodeString): TPSConstant; |
| 12949 | +begin |
| 12950 | + Result := AddConstant(Name, FindType('UnicodeString') ); // UNICODESTRING |
| 12951 | + Result.SetUnicodeString(Value); |
| 12952 | +end; |
| 12953 | +{$ENDIF UNICODE} |
| 12954 | +{$ENDIF PS_NOWIDESTRING} |
| 12955 | + |
| 12956 | +function TPSPascalCompiler.AddConstant(const Name: tbtString; const Value: Extended): TPSConstant; |
| 12957 | +begin |
| 12958 | + Result := AddConstant(Name, FindType('Extended') ); // EXTENDED |
| 12959 | + Result.SetExtended(Value); |
| 12960 | +end; |
| 12961 | + |
12849 | 12962 | function TPSPascalCompiler.AddTypeCopy(const Name: tbtString; TypeNo: TPSType): TPSType;
|
12850 | 12963 | begin
|
12851 | 12964 | if FProcs = nil then
|
|
0 commit comments