mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 15:59:28 +01:00 
			
		
		
		
	in the system unit for easier debugging)
  * disabled a bunch more feature flags by default for the JVM target
  * incorporate modified version of inc/systemh.inc (split into two parts:
    jsystemh_types.inc and jsystemh.inc, because some of the types are
    required for the declaration of the shortstring/ansistring/set/...
    classes, which in turn are required for the routine declarations) and
    inc/system.inc (as jsystem.inc)
   o moved some routines around from old to new locations based on where
     they appear in the common files
   o added a number of defines that allow skipping more common implementations
     in case a platform-specific one is already available
  * all base classes (AnsistringClass etc) are now descendants of
    JLObject rather than TObject, because their declaration is now parsed
    before TObject is known (and there's no need for them to inherit from
    TObject)
  * incorporate modified version of inc/system.inc
  * use the common version of generic.inc, currh.inc, gencurr.inc and
    genmath.inc (with small modification to those files)
  + addition of quite a bit of system unit functionality (halt, runerror,
    random, round, str() for integer types, abs, odd, endian swapping helpers,
    bit scanning, trigonometric functions, ln, exp, ...)
   o round()/trunc() for comp-types has been renamed trunc_comp() on the
     JVM target because their JVM signature conflicts with trunc(currency)
   o the unsigned versions of swapendian() and other endian helpers are not
     available on the JVM target because of JVM signature conflicts
git-svn-id: branches/jvmbackend@18746 -
		
	
			
		
			
				
	
	
		
			115 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			115 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
{
 | 
						|
    This file is part of the Free Pascal run time library.
 | 
						|
    Copyright (c) 2011 by Jonas Maebe,
 | 
						|
    members of the Free Pascal development team.
 | 
						|
 | 
						|
    This file implements Java math routines
 | 
						|
 | 
						|
    See the file COPYING.FPC, included in this distribution,
 | 
						|
    for details about the copyright.
 | 
						|
 | 
						|
    This program is distributed in the hope that it will be useful,
 | 
						|
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 | 
						|
 | 
						|
 **********************************************************************}
 | 
						|
 | 
						|
{$define FPC_SYSTEM_HAS_ARCTAN}
 | 
						|
function fpc_arctan_real(d : ValReal) : ValReal;compilerproc;{$ifdef MATHINLINE}inline;{$endif}
 | 
						|
  begin
 | 
						|
    result:=JLMath.atan(d);
 | 
						|
  end;
 | 
						|
 | 
						|
 | 
						|
{$define FPC_SYSTEM_HAS_COS}
 | 
						|
function fpc_cos_real(d : ValReal) : ValReal;compilerproc;{$ifdef MATHINLINE}inline;{$endif}
 | 
						|
  begin
 | 
						|
    result:=JLMath.cos(d);
 | 
						|
  end;
 | 
						|
 | 
						|
 | 
						|
{$define FPC_SYSTEM_HAS_EXP}
 | 
						|
function fpc_exp_real(d : ValReal) : ValReal;compilerproc;{$ifdef MATHINLINE}inline;{$endif}
 | 
						|
  begin
 | 
						|
    result:=JLMath.exp(d);
 | 
						|
  end;
 | 
						|
 | 
						|
 | 
						|
{$define FPC_SYSTEM_HAS_INT}
 | 
						|
function fpc_int_real(d : ValReal) : ValReal;compilerproc;{$ifdef MATHINLINE}inline;{$endif}
 | 
						|
  begin
 | 
						|
    if d>=0 then
 | 
						|
      result:=JLMath.floor(d)
 | 
						|
    else
 | 
						|
      result:=JLMath.ceil(d);
 | 
						|
  end;
 | 
						|
 | 
						|
 | 
						|
{$define FPC_SYSTEM_HAS_LN}
 | 
						|
function fpc_ln_real(d : ValReal) : ValReal;compilerproc;{$ifdef MATHINLINE}inline;{$endif}
 | 
						|
  begin
 | 
						|
    result:=JLMath.log(d);
 | 
						|
  end;
 | 
						|
 | 
						|
 | 
						|
{$define FPC_SYSTEM_HAS_SIN}
 | 
						|
function fpc_sin_real(d : ValReal) : ValReal;compilerproc;{$ifdef MATHINLINE}inline;{$endif}
 | 
						|
  begin
 | 
						|
    result:=JLMath.sin(d);
 | 
						|
  end;
 | 
						|
 | 
						|
{$define FPC_SYSTEM_HAS_SQR}
 | 
						|
{ handled in the code generator }
 | 
						|
function fpc_sqr_real(d : ValReal) : ValReal;compilerproc;{$ifdef MATHINLINE}inline;{$endif}
 | 
						|
  begin
 | 
						|
    HandleError(219);
 | 
						|
  end;
 | 
						|
 | 
						|
 | 
						|
{$define FPC_SYSTEM_HAS_SQRT}
 | 
						|
function fpc_sqrt_real(d : ValReal) : ValReal;compilerproc;
 | 
						|
  begin
 | 
						|
    result:=JLMath.sqrt(d);
 | 
						|
  end;
 | 
						|
 | 
						|
{$define FPC_SYSTEM_HAS_TRUNC}
 | 
						|
{ handled in the code generator }
 | 
						|
function fpc_trunc_real(d : ValReal) : int64;compilerproc;
 | 
						|
  begin
 | 
						|
    HandleError(219);
 | 
						|
  end;
 | 
						|
 | 
						|
 | 
						|
{$define FPC_SYSTEM_HAS_REAL2DOUBLE}
 | 
						|
function real2double(r : real48) : double;
 | 
						|
  var
 | 
						|
     res : jlong;
 | 
						|
     exponent : word;
 | 
						|
  begin
 | 
						|
     { check for zero }
 | 
						|
     if r[0]=0 then
 | 
						|
       begin
 | 
						|
         real2double:=0.0;
 | 
						|
         exit;
 | 
						|
       end;
 | 
						|
 | 
						|
     { copy mantissa }
 | 
						|
     res:=(r[1] shl 5) shl 8;
 | 
						|
     res:=res or (((r[1] shr 3) or (r[2] shl 5)) shl 16);
 | 
						|
     res:=res or (((r[2] shr 3) or (r[3] shl 5)) shl 24);
 | 
						|
     res:=res or (((r[3] shr 3) or (r[4] shl 5)) shl 32);
 | 
						|
     res:=res or (((r[4] shr 3) or (r[5] and $7f) shl 5) shl 40);
 | 
						|
     res:=res or (((r[5] and $7f) shr 3) shl 48);
 | 
						|
 | 
						|
     { copy exponent }
 | 
						|
     { correct exponent: }
 | 
						|
     exponent:=(word(r[0])+(1023-129));
 | 
						|
     res:=res or (((exponent and $f) shl 4) shl 48);
 | 
						|
     res:=res or ((exponent shr 4) shl 56);
 | 
						|
 | 
						|
     { set sign }
 | 
						|
     res:=res or (r[5] and $80) shl 56;
 | 
						|
     real2double:=JLDouble.longBitsToDouble(res);
 | 
						|
  end;
 | 
						|
 |