2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								unit   Hak; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{$mode objfpc} {$H+} 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 20:31:11 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{$macro on} 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{$linklib hak} 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{$linklib c} 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-18 10:12:56 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{$linklib dl} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{$linklib gcc} 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{$if defined(HAK_LIB_QUADMATH_REQUIRED)} 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{$linklib quadmath} 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{$endif} 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								interface 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								uses   SysUtils; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								type 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 BitMask  =   longword ;   (* this must match hak_bitmask_t in hak.h *) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-11 16:39:16 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								( * const 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-06 12:16:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 TRAIT_LANG_ENABLE_EOL  =   ( BitMask( 1 )   shl   1 4 ) ;   * ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-11 16:39:16 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								type 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 Bchar  =   System. AnsiChar ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 PBchar  =   System. PAnsiChar ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{$if defined(HAK_WIDE_CHAR_SIZE_IS_4)} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 Uchar  =   System. UCS4Char ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 PUchar  =   System. PUCS4Char; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{$else} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 Uchar  =   System. WideChar ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 PUchar  =   System. PWideChar ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{$endif} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 TraitBit  =   (   (* this enum must follow hak_trait_t in hak.h *) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-06 12:16:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 LANG_ENABLE_EOL  =   ( BitMask( 1 )   shl   1 4 ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-11 16:39:16 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 Option  =   (   (* this enum must follow hak_option_t in hak.h *) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-11 16:39:16 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 TRAIT, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 LOG_MASK, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 LOG_MAXCAPA
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 IoCmd  =   (   (* this enum must follow hak_io_cmd_t in hak.h *) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 IO_OPEN, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 IO_CLOSE, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 IO_READ, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 IO_READ_BYTES, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 IO_WRITE, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 IO_WRITE_BYTES, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 IO_FLUSH
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 LocationB  =   record 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 line:   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 colm:   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 filp:   PBchar; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 LocationU  =   record 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 line:   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 colm:   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 filp:   PUchar; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 ErrorException  =   class( SysUtils. Exception) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 private 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 error_code:   integer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 error_file:   string ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 error_line:   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 error_colm:   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 public 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 constructor   Create( const   msg:   string ) ;   overload ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 constructor   Create( const   msg:   string ;   cod:   integer ;   const   fil:   string ;   lin:   System. SizeUint;   col:   System. SizeUint) ;   overload ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 property   Code:   integer   read   error_code; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 property   Line:   System. SizeUint  read   error_line; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 property   Column:   System. SizeUint  read   error_colm; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 property   FileName:   string   read   error_file; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{$ifndef HAK_CCI_BUF_LEN} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{$define HAK_CCI_BUF_LEN := 2048} 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-19 20:48:14 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{$endif} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:52:28 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								//{$packrecords c} 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 CciArgPtr  =   ^ CciArg; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 CciArg  =   record   (* this record must follow the public part of hak_io_cciarg_t in hak.h *) 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 name :   PUchar; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 handle:   pointer ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-19 17:09:31 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 byte_oriented:   integer ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 buf:   array [ 0 .. ( HAK_CCI_BUF_LEN  -   1 ) ]   of   Uchar; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 xlen:   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 includer:   CciArgPtr; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:52:28 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								//{$packrecords normal} 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 Interp  =   class 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 protected 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										 handle:   pointer ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 basefile:   string ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 public 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 constructor   Create( x:   integer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 destructor   Destroy( ) ;   override ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 procedure   Ignite( heapsize:   System. SizeUint) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										 procedure   AddBuiltinPrims( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-11 01:49:08 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 procedure   CompileFile( filename:   System. PAnsiChar ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 procedure   CompileText( text :   System. PAnsiChar ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 procedure   CompileText( text :   System. PAnsiChar ;   len:   System. SizeUint) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 procedure   CompileText( text :   PUchar) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 procedure   CompileText( text :   PUchar;   len:   System. SizeUint) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{$if defined(HAK_WIDE_CHAR_SIZE_IS_4)} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 procedure   CompileText( text :   PWideChar ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 procedure   CompileText( text :   PWideChar ;   len:   System. SizeUint) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{$endif} 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										 procedure   Execute( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 protected 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 function   FetchException( const   hdr:   string ) :   Exception; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:40:39 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 InterpExt  =   record 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 self:   Interp; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 InterpExtPtr  =   ^ InterpExt; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 IO  =   class 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 public 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 procedure   Open( ) ;   virtual ;   abstract ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 procedure   Close( ) ;   virtual ;   abstract ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 function   Read( ) :   System. SizeUint;   virtual ;   abstract ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-15 00:03:56 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 SynerrBPtr  =   ^ SynerrB; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 SynerrB  =   record 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 num:   integer ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-15 00:03:56 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 loc:   LocationB; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 ErrbinfPtr  =   ^ Errbinf; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 Errbinf  =   record 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 num:   integer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 msg:   array [ 0 .. 2 0 4 7 ]   of   Bchar; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-15 00:03:56 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 loc:   LocationB; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 ErruinfPtr  =   ^ Errbinf; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 Erruinf  =   record 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 num:   integer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 msg:   array [ 0 .. 2 0 4 7 ]   of   Uchar; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-15 00:03:56 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 loc:   LocationU; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 Errinf  =   Erruinf; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 ErrinfPtr  =   ErruinfPtr; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								(*----- external hak function -----*) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   hak_errnum_to_errbcstr( errnum:   integer ;   errbuf:   pointer ;   errbufsz:   System. SizeUint) :   pointer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   hak_errnum_is_synerr( errnum:   integer ) :   boolean ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   hak_openstd( xtnsize:   System. SizeUint;   errinf:   pointer ) :   pointer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								procedure   hak_close( handle:   pointer ) ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   hak_getxtn( handle:   pointer ) :   InterpExtPtr;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-11 16:39:16 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   hak_setoption( handle:   pointer ;   option:   Option;   value:   pointer ) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   hak_getoption( handle:   pointer ;   option:   Option;   value:   pointer ) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-11 16:39:16 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								procedure   hak_seterrnum( handle:   pointer ;   errnum:   integer ) ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   hak_geterrnum( handle:   pointer ) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-19 20:48:14 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								procedure   hak_seterrbmsg( handle:   pointer ;   errnum:   integer ;   errmsg:   PBchar) ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   hak_geterrbmsg( handle:   pointer ) :   PBchar;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								procedure   hak_geterrbinf( handle:   pointer ;   errinf:   pointer ) ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								procedure   hak_geterruinf( handle:   pointer ;   errinf:   pointer ) ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-19 20:48:14 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   hak_ignite( handle:   pointer ;   heapsize:   System. SizeUint) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   hak_addbuiltinprims( handle:   pointer ) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   hak_beginfeed( handle:   pointer ;   on_cnode:   pointer ) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   hak_feedbchars( handle:   pointer ;   data:   PBchar;   len:   System. SizeUint) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   hak_feeduchars( handle:   pointer ;   data:   PUchar;   len:   System. SizeUint) :   integer ;   cdecl ;   external ;   (* this is wrong in deed - hak_uchar_t may not been Uchar ..*) 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   hak_endfeed( handle:   pointer ) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   hak_attachccio( handle:   pointer ;   cci:   pointer ) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   hak_attachcciostdwithbcstr( handle:   pointer ;   cci:   PBchar) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								procedure   hak_detachccio( handle:   pointer ) ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   hak_attachudiostdwithbcstr( handle:   pointer ;   udi:   PBchar;   udo:   PBchar) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								procedure   hak_detachudio( handle:   pointer ) ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   hak_compile( handle:   pointer ;   cnode:   pointer ;   flags:   integer ) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   hak_execute( handle:   pointer ) :   pointer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								procedure   hak_abort( handle:   pointer )   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-15 00:03:56 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								procedure   hak_getsynerrb( handle:   pointer ;   synerr:   SynerrBPtr)   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   hak_syserrstrb( handle:   pointer ;   syserr_type:   integer ;   syserr_code:   integer ;   buf:   PBchar;   len:   System. SizeUint) :   integer ;   cdecl ;   external ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   hak_count_ucstr( ptr:   PUchar) :   System. SizeUint;   cdecl ;   external ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								(*----- end external hak function -----*) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								implementation 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								uses   Math,   Classes; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								type 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 NamedHandle  =   record 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 handle:   THandle; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 name :   System. RawByteString ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 NamedHandlePtr  =   ^ NamedHandle; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   PUCS4CharLength( p:   PUCS4Char) :   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 len:   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 len  : =   0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 while   p[ len]   < >   0   do   Inc( len) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 exit( len) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function   PUCS4CharToWideString( p:   PUCS4Char) :   System. WideString ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 len:   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 arr:   System. UCS4String; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 len  : =   PUCS4CharLength( p) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 ( *   len  +   1   for   SetLength  because  UCS4StringToWideString( )   skips  the  last  character  in   RTL. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    https: //gitlab.com/freepascal.org/fpc/source/-/blob/main/rtl/inc/ustrings.inc 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   function   UCS4StringToUnicodeString( const   s  :   UCS4String)   :   UnicodeString ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   var 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     i         :   SizeInt; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     reslen    :   SizeInt; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     reslen: = 0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     for   i: = 0   to   length( s) - 2   do 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								       Inc( reslen, 1 + ord( ( s[ i] > $ffff )   and   ( cardinal( s[ i] ) < = $10ffff ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     SetLength( result , reslen) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     UCS4Decode( s, pointer( result ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 * ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 SetLength( arr,   len  +   1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 Move( p^ ,   arr[ 0 ] ,   len  *   SizeOf( UCS4Char ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 exit( UCS4StringToWideString( arr) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								constructor   ErrorException. Create  ( const   msg:   string ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 inherited   Create( msg) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								constructor   ErrorException. Create  ( const   msg:   string ;   cod:   integer ;   const   fil:   string ;   lin:   System. SizeUint;   col:   System. SizeUint) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 inherited   Create( msg) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 self. error_code  : =   cod; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 self. error_file  : =   fil; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 self. error_line  : =   lin; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 self. error_colm  : =   col; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								constructor   Interp. Create  ( x:   integer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 h:   pointer ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 ei:   Errinf; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 ebi:   Errbinf; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-11 16:39:16 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 tb:   BitMask; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:40:39 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 ext:   InterpExtPtr; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 h  : =   hak_openstd( System. SizeOf( Interp) ,   @ ei) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 if   h  =   nil   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{$if defined(HAK_WIDE_CHAR_SIZE_IS_4)} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 raise   Exception. Create( System. UTF8Encode( PUCS4CharToWideString( ei. msg) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{$else} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 raise   Exception. Create( System. UTF8Encode( ei. msg) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{$endif} 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-11 16:39:16 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_getoption( h,   Option. TRAIT,   @ tb)   < =   - 1   then   tb  : =   0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:40:39 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-06 12:16:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 tb  : =   tb  or   BitMask( TraitBit. LANG_ENABLE_EOL) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_setoption( h,   Option. TRAIT,   @ tb)   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 hak_geterrbinf( h,   @ ebi) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 hak_close( h) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 raise   Exception. Create( ebi. msg) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:40:39 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 self. handle  : =   h; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:40:39 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 ext  : =   hak_getxtn( h) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:40:39 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 ext^ . self  : =   self; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								destructor   Interp. Destroy; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 if   self. handle  < >   nil   then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 hak_close( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										 self. handle  : =   nil ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 inherited ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   Interp. FetchException( const   hdr:   string ) :   Exception; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 ebi:   Errbinf; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-15 00:03:56 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 serr:   SynerrB; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 filp:   PBchar; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 xmsg:   string ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 hak_geterrbinf( self. handle,   @ ebi) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 if   hak_errnum_is_synerr( ebi. num)   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-15 00:03:56 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 hak_getsynerrb( self. handle,   @ serr) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 filp  : =   PBchar( '' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 if   serr. loc. filp  < >   nil   then   filp  : =   serr. loc. filp; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 exit( ErrorException. Create( string( ebi. msg) ,   ebi. num,   string( filp) ,   serr. loc. line,   serr. loc. colm) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 else   if   ebi. loc. line  >   0   then   begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 exit( ErrorException. Create( string( ebi. msg) ,   ebi. num,   string( ebi. loc. filp) ,   ebi. loc. line,   ebi. loc. colm) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 else   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 if   hdr  =   ''   then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 xmsg  : =   string( ebi. msg) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 xmsg  : =   SysUtils. Format( '%s - %s' ,   [ hdr,   string( ebi. msg) ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 exit( Exception. Create( xmsg) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								procedure   Interp. Ignite( heapsize:   System. SizeUint) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_ignite( self. handle,   heapsize)   < =   - 1   then 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 raise   self. FetchException( 'failed to ignite' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								procedure   Interp. AddBuiltinPrims( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_addbuiltinprims( self. handle)   < =   - 1   then 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 raise   self. FetchException( 'failed to add builtin primitives' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:40:39 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   handle_to_self( handle:   pointer ) :   Interp; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 ext:   InterpExtPtr; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 ext  : =   hak_getxtn( handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:40:39 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 exit( ext^ . self) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function   cci_handler( handle:   pointer ;   cmd:   IoCmd;   arg:   CciArgPtr) :   integer ;   cdecl ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 nf:   NamedHandlePtr; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 len:   System. LongInt ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-19 20:48:14 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 err:   System. Integer ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:40:39 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 name :   System. RawByteString ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 basedir:   System. RawByteString ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:40:39 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 self:   Interp; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 case   cmd  of 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 IO_OPEN:   begin 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:40:39 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 self  : =   handle_to_self( handle) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 if   arg^ . includer  =   nil   then   begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												 (* main stream *) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												 name   : =   self. basefile; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 else   begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												 (* included file *) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												 nf  : =   NamedHandlePtr( arg^ . includer^ . handle) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												 basedir  : =   SysUtils. ExtractFilePath( nf^ . name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 20:31:11 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												 name   : =   System. UTF8Encode( WideString( arg^ . name ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												 if   SysUtils. CompareStr( basedir,   '' )   < >   0   then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													 name   : =   SysUtils. ConcatPaths( [ basedir,   name ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 System. New( nf) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 if   nf  =   nil   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-19 20:48:14 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												 err  : =   SysUtils. GetLastOSError( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												 hak_seterrbmsg( handle,   hak_syserrstrb( handle,   0 ,   err,   nil ,   0 ) ,   PBchar( SysUtils. SysErrorMessage( err) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												 exit( - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 end ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 if   arg^ . includer  < >   nil   then   begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												 (* included file *) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												 nf^ . handle  : =   SysUtils. FileOpen( name ,   SysUtils. fmOpenRead) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												 if   nf^ . handle  =   System. THandle( - 1 )   then   begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													 err  : =   SysUtils. GetLastOSError( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													 hak_seterrbmsg( handle,   hak_syserrstrb( handle,   0 ,   err,   nil ,   0 ) ,   PBchar( SysUtils. SysErrorMessage( err) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													 System. Dispose( nf) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													 exit( - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 else   begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												 nf^ . handle  : =   THandle( - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 nf^ . name   : =   name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 arg^ . handle  : =   pointer( nf) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-19 17:09:31 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 arg^ . byte_oriented  : =   1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 IO_CLOSE:   begin 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 nf  : =   NamedHandlePtr( arg^ . handle) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 if   nf^ . handle  < >   System. THandle( - 1 )   then   SysUtils. FileClose( nf^ . handle) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 System. Dispose( nf) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 IO_READ_BYTES:   begin 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 nf  : =   NamedHandlePtr( arg^ . handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 len  : =   SysUtils. FileRead( nf^ . handle,   arg^ . buf,   System. SizeOf( arg^ . buf) ) ;   (* use SizeOf a Uchar buffer as it needs to fill it with bytes *) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 if   len  < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												 hak_seterrbmsg( handle,   hak_syserrstrb( handle,   0 ,   err,   nil ,   0 ) ,   PBchar( SysUtils. SysErrorMessage( err) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												 exit( - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 arg^ . xlen  : =   len; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 IO_FLUSH: 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 (* no effect on an input stream *) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 ( *   the  following  operations  are  prohibited  on  the  code  input  stream: 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:52:28 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 IO_READ: 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 IO_WRITE: 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 IO_WRITE_BYTES: 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 * ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 else   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 hak_seterrnum( handle,   9 9 9 ) ;   (* TODO: change error code *) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 exit( - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 exit( 0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-11 01:49:08 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								procedure   Interp. CompileFile( filename:   System. PAnsiChar ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 f:   System. THandle  =   - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 attached:   boolean   =   false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 feed_ongoing:   boolean   =   false ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-11 01:49:08 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 buf:   array [ 0 .. 1 0 2 3 ]   of   System. AnsiChar ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 len:   System. LongInt ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 excpt:   SysUtils. Exception; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								label 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 oops; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 f  : =   SysUtils. FileOpen( filename,   SysUtils. fmOpenRead) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:52:28 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   f  =   System. THandle( - 1 )   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   Exception. Create( 'failed to open '   +   filename  +   ' - '   +    SysUtils. SysErrorMessage( SysUtils. GetLastOSError( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 goto   oops; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 self. basefile  : =   filename; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_attachccio( self. handle,   @ cci_handler)   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to attach ccio handler' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 goto   oops; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 attached  : =   true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_beginfeed( self. handle,   nil )   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to begin feeding' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 goto   oops; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 feed_ongoing  : =   true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 while   true   do   begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 len  : =   SysUtils. FileRead( f,   buf,   System. SizeOf( buf) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 if   len  < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 excpt  : =   Exception. Create( 'failed to read '   +   filename  +   ' - '   +    SysUtils. SysErrorMessage( SysUtils. GetLastOSError( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 goto   oops; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 if   len  =   0   then   break; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 if   hak_feedbchars( self. handle,   buf,   len)   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 excpt  : =   self. FetchException( 'failed to feed text' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											 goto   oops; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_endfeed( self. handle)   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to end feeding' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 goto   oops; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 feed_ongoing  : =   false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 hak_detachccio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 self. basefile  : =   '' ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 SysUtils. FileClose( f) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 exit( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								oops: 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   feed_ongoing  then   hak_endfeed( self. handle) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 if   attached  then   hak_detachccio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:32:17 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 self. basefile  : =   '' ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-23 00:54:36 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   f  < >   System. THandle( - 1 )   then   SysUtils. FileClose( f) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 raise   excpt; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 00:57:30 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-11 01:49:08 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								procedure   Interp. CompileText( text :   System. PAnsiChar ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 15:52:28 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 self. CompileText( text ,   SysUtils. Strlen( text ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-11 01:49:08 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								procedure   Interp. CompileText( text :   System. PAnsiChar ;   len:   System. SizeUint) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 excpt:   Exception; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_attachcciostdwithbcstr( self. handle,   nil )   < =   - 1   then   begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to attach ccio handler' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 raise   excpt; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_beginfeed( self. handle,   nil )   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to begin feeding' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 hak_detachccio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 raise   excpt; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_feedbchars( self. handle,   text ,   len)   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to feed text' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 hak_endfeed( self. handle) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 hak_detachccio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 raise   excpt; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_endfeed( self. handle)   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to end feeding' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 hak_detachccio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 raise   excpt; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 hak_detachccio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{$if defined(HAK_WIDE_CHAR_SIZE_IS_4)} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								procedure   Interp. CompileText( text :   PWideChar ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 x:   UCS4String; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 x  : =   WideStringToUcs4String( text ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 self. CompileText( PUchar( x) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								procedure   Interp. CompileText( text :   PWideChar ;   len:   System. SizeUint) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 x_text:   PBchar; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 x_capa:   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 x_len:   System. SizeUint; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 x_capa  : =   len  *   4   +   1 ;   (* allocation sizing for the worst case *) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 System. GetMem( x_text,   x_capa) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 try 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 x_len  : =   System. UnicodeToUtf8( x_text,   x_capa,   text ,   len) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 self. CompileText( x_text,   x_len) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 finally 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 FreeMem( x_text) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{$endif} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								procedure   Interp. CompileText( text :   PUchar) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 (*self.CompileText(text, SysUtils.Strlen(text));*) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 self. CompileText( text ,   hak_count_ucstr( text ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-10-08 23:38:24 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								procedure   Interp. CompileText( text :   PUchar;   len:   System. SizeUint) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 excpt:   Exception; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_attachcciostdwithbcstr( self. handle,   nil )   < =   - 1   then   begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to attach ccio handler' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 raise   excpt; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_beginfeed( self. handle,   nil )   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to begin feeding' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 hak_detachccio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 raise   excpt; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_feeduchars( self. handle,   text ,   len)   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to feed text' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 hak_endfeed( self. handle) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 hak_detachccio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 raise   excpt; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_endfeed( self. handle)   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to end feeding' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 hak_detachccio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 raise   excpt; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 hak_detachccio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								procedure   Interp. Execute( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								var 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 excpt:   Exception; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_attachudiostdwithbcstr( self. handle,   nil ,   nil )   < =   - 1   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( 'failed to attach udio handlers' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 raise   excpt; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 if   hak_execute( self. handle)   =   nil   then   begin 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 excpt  : =   self. FetchException( '' ) ;   (* no header message used to make the error format the same as bin/hak *) 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 hak_detachudio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-10-20 01:02:23 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										 raise   excpt; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									 end ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 13:36:05 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-09-02 23:58:15 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 hak_detachudio( self. handle) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 14:57:46 +09:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end .   (* unit *)