diff --git a/Source/uPSCompiler.pas b/Source/uPSCompiler.pas index 5d6f921..9880307 100644 --- a/Source/uPSCompiler.pas +++ b/Source/uPSCompiler.pas @@ -6184,7 +6184,7 @@ function TPSPascalCompiler.ProcessSub(BlockInfo: TPSBlockInfo): Boolean; {$IFNDEF PS_NOIDISPATCH}or ((u.BaseType = btVariant) or (u.BaseType = btNotificationVariant)){$ENDIF} or (u.BaseType = btExtClass) then exit; if FParser.CurrTokenId = CSTI_OpenBlock then begin - if (u.BaseType = btString) or (u.BaseType = btWideString) then + if (u.BaseType = btString) {$IFNDEF PS_NOWIDESTRING} or (u.BaseType = btWideString) {$ENDIF} then begin FParser.Next; tmp := Calc(CSTI_CloseBlock); @@ -6205,9 +6205,11 @@ function TPSPascalCompiler.ProcessSub(BlockInfo: TPSBlockInfo): Boolean; FParser.Next; if FParser.CurrTokenId = CSTI_Assignment then begin + {$IFNDEF PS_NOWIDESTRING} if u.BaseType = btWideString then l := FindProc('WSTRSET') else + {$ENDIF} l := FindProc('STRSET'); if l = -1 then begin @@ -6250,7 +6252,8 @@ function TPSPascalCompiler.ProcessSub(BlockInfo: TPSBlockInfo): Boolean; x := nil; exit; end; - if (GetTypeNo(BlockInfo, Tmp).BaseType <> btChar) and (GetTypeno(BlockInfo, Tmp).BaseType <> btWideChar) then + if (GetTypeNo(BlockInfo, Tmp).BaseType <> btChar) + {$IFNDEF PS_NOWIDESTRING} and (GetTypeno(BlockInfo, Tmp).BaseType <> btWideChar) {$ENDIF} then begin x.Free; x := nil; @@ -6265,10 +6268,12 @@ function TPSPascalCompiler.ProcessSub(BlockInfo: TPSBlockInfo): Boolean; if not Param.ExpectedType.Used then asm int 3; end; {$ENDIF} end else begin + {$IFNDEF PS_NOWIDESTRING} if u.BaseType = btWideString then l := FindProc('WSTRGET') else - l := FindProc('STRGET'); + {$ENDIF} + l := FindProc('STRGET'); if l = -1 then begin MakeError('', ecUnknownIdentifier, 'StrGet'); @@ -6278,9 +6283,11 @@ function TPSPascalCompiler.ProcessSub(BlockInfo: TPSBlockInfo): Boolean; exit; end; tmp3 := TPSValueProcNo.Create; + {$IFNDEF PS_NOWIDESTRING} if u.BaseType = btWideString then tmp3.ResultType := FindBaseType(btWideChar) else + {$ENDIF} tmp3.ResultType := FindBaseType(btChar); tmp3.ProcNo := L; tmp3.SetParserPos(FParser); @@ -12081,7 +12088,11 @@ procedure TPSPascalCompiler.DefineStandardProcedures; var p: TPSRegProc; begin + {$IFNDEF PS_NOINT64} AddFunction('function inttostr(i: Int64): string;'); + {$ELSE} + AddFunction('function inttostr(i: Integer): string;'); + {$ENDIF} AddFunction('function strtoint(s: string): Longint;'); AddFunction('function strtointdef(s: string; def: Longint): Longint;'); AddFunction('function copy(s: string; ifrom, icount: Longint): string;'); @@ -12107,8 +12118,10 @@ begin end; AddFunction('Function StrGet(var S : String; I : Integer) : Char;'); AddFunction('procedure StrSet(c : Char; I : Integer; var s : String);'); + {$IFNDEF PS_NOWIDESTRING} AddFunction('Function WStrGet(var S : WideString; I : Integer) : WideChar;'); AddFunction('procedure WStrSet(c : WideChar; I : Integer; var s : WideString);'); + {$ENDIF} AddFunction('Function StrGet2(S : String; I : Integer) : Char;'); AddFunction('Function AnsiUppercase(s : string) : string;'); AddFunction('Function AnsiLowercase(s : string) : string;'); @@ -12129,8 +12142,13 @@ begin aType:=FindBaseType(btS32); //Integer end; end; + {$IFNDEF PS_NOINT64} AddFunction('function Low: Int64;').Decl.AddParam.OrgName:='x'; AddFunction('function High: Int64;').Decl.AddParam.OrgName:='x'; + {$ELSE} + AddFunction('function Low: Integer;').Decl.AddParam.OrgName:='x'; + AddFunction('function High: Integer;').Decl.AddParam.OrgName:='x'; + {$ENDIF} with AddFunction('procedure Dec;').Decl do begin with AddParam do begin diff --git a/Source/uPSRuntime.pas b/Source/uPSRuntime.pas index ace5057..d528d7f 100644 --- a/Source/uPSRuntime.pas +++ b/Source/uPSRuntime.pas @@ -8109,7 +8109,7 @@ var Tmp: TObject; begin case Longint(p.Ext1) of - 0: Stack.SetString(-1, IntToStr(Stack.GetInt64(-2))); // inttostr + 0: Stack.SetString(-1, IntToStr(Stack.{$IFNDEF PS_NOINT64}GetInt64{$ELSE}GetInt{$ENDIF}(-2))); // inttostr 1: Stack.SetInt(-1, SysUtils.StrToInt(Stack.GetString(-2))); // strtoint 2: Stack.SetInt(-1, StrToIntDef(Stack.GetString(-2), Stack.GetInt(-3))); // strtointdef 3: Stack.SetInt(-1, Pos(Stack.GetString(-2), Stack.GetString(-3)));// pos @@ -8248,6 +8248,7 @@ begin else Stack.SetInt(-1, Temp.aType.RealSize) end; +{$IFNDEF PS_NOWIDESTRING} 42: // WStrGet begin temp := NewTPSVariantIFC(Stack[Stack.Count -2], True); @@ -8282,6 +8283,7 @@ begin end; tbtWidestring(temp.Dta^)[i] := WideChar(Stack.GetInt(-1)); end; +{$ENDIF} else begin Result := False; @@ -8357,11 +8359,13 @@ begin begin Stack.SetInt(-1,length(tbtstring(arr.Dta^))); Result:=true; +{$IFNDEF PS_NOWIDESTRING} end else if arr.aType.BaseType=btWideString then begin Stack.SetInt(-1,length(tbtWidestring(arr.Dta^))); Result:=true; +{$ENDIF} end; end; @@ -8381,11 +8385,13 @@ begin begin SetLength(tbtstring(arr.Dta^),STack.GetInt(-2)); Result:=true; +{$IFNDEF PS_NOWIDESTRING} end else if arr.aType.BaseType=btWideString then begin SetLength(tbtwidestring(arr.Dta^),STack.GetInt(-2)); Result:=true; +{$ENDIF} end; end; @@ -8398,13 +8404,13 @@ begin case arr.aType.BaseType of btArray : Stack.SetInt(-1,0); btStaticArray: Stack.SetInt(-1,TPSTypeRec_StaticArray(arr.aType).StartOffset); - btString : Stack.SetInt64(-1,1); - btU8 : Stack.SetInt64(-1,Low(Byte)); //Byte: 0 - btS8 : Stack.SetInt64(-1,Low(ShortInt)); //ShortInt: -128 - btU16 : Stack.SetInt64(-1,Low(Word)); //Word: 0 - btS16 : Stack.SetInt64(-1,Low(SmallInt)); //SmallInt: -32768 - btU32 : Stack.SetInt64(-1,Low(Cardinal)); //Cardinal/LongWord: 0 - btS32 : Stack.SetInt64(-1,Low(Integer)); //Integer/LongInt: -2147483648 + btString : Stack.SetInt(-1,1); + btU8 : Stack.SetInt(-1,Low(Byte)); //Byte: 0 + btS8 : Stack.SetInt(-1,Low(ShortInt)); //ShortInt: -128 + btU16 : Stack.SetInt(-1,Low(Word)); //Word: 0 + btS16 : Stack.SetInt(-1,Low(SmallInt)); //SmallInt: -32768 + btU32 : Stack.SetInt(-1,Low(Cardinal)); //Cardinal/LongWord: 0 + btS32 : Stack.SetInt(-1,Low(Integer)); //Integer/LongInt: -2147483648 else Result:=false; end; end; @@ -8536,8 +8542,10 @@ begin {$ENDIF} RegisterFunctionName('SIZEOF', DefProc, Pointer(41), nil); + {$IFNDEF PS_NOWIDESTRING} RegisterFunctionName('WSTRGET', DefProc, Pointer(42), nil); RegisterFunctionName('WSTRSET', DefProc, Pointer(43), nil); + {$ENDIF} RegisterInterfaceLibraryRuntime(Self); end; @@ -12429,7 +12437,7 @@ begin (DispParam.rgvarg[i].pvarVal)^ := Par[High(Par)-i]; *) Move(Par[High(Par)-i],Pointer(DispParam.rgvarg[i].pvarVal)^, - Sizeof(OleVariant)); + Sizeof({$IFDEF DELPHI4UP}OleVariant{$ELSE}Variant{$ENDIF})); end; end;