mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 16:39:24 +01:00 
			
		
		
		
	+ support for bitsizeof() function
+ some small tests for it git-svn-id: trunk@4590 -
This commit is contained in:
		
							parent
							
								
									056eb5b012
								
							
						
					
					
						commit
						cd5b9245f9
					
				@ -68,6 +68,7 @@ const
 | 
				
			|||||||
   in_get_caller_frame  = 58;
 | 
					   in_get_caller_frame  = 58;
 | 
				
			||||||
   in_pack_x_y_z        = 59;
 | 
					   in_pack_x_y_z        = 59;
 | 
				
			||||||
   in_unpack_x_y_z      = 60;
 | 
					   in_unpack_x_y_z      = 60;
 | 
				
			||||||
 | 
					   in_bitsizeof_x       = 61;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{ Internal constant functions }
 | 
					{ Internal constant functions }
 | 
				
			||||||
   in_const_sqr        = 100;
 | 
					   in_const_sqr        = 100;
 | 
				
			||||||
 | 
				
			|||||||
@ -470,7 +470,8 @@ implementation
 | 
				
			|||||||
               end;
 | 
					               end;
 | 
				
			||||||
            end;
 | 
					            end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          in_sizeof_x :
 | 
					          in_sizeof_x,
 | 
				
			||||||
 | 
					          in_bitsizeof_x :
 | 
				
			||||||
            begin
 | 
					            begin
 | 
				
			||||||
              consume(_LKLAMMER);
 | 
					              consume(_LKLAMMER);
 | 
				
			||||||
              in_args:=true;
 | 
					              in_args:=true;
 | 
				
			||||||
@ -484,10 +485,26 @@ implementation
 | 
				
			|||||||
                  is_array_of_const(p1.resulttype.def) or
 | 
					                  is_array_of_const(p1.resulttype.def) or
 | 
				
			||||||
                  is_open_string(p1.resulttype.def)
 | 
					                  is_open_string(p1.resulttype.def)
 | 
				
			||||||
                 ) then
 | 
					                 ) then
 | 
				
			||||||
               statement_syssym:=geninlinenode(in_sizeof_x,false,p1)
 | 
					                begin
 | 
				
			||||||
 | 
					                  statement_syssym:=geninlinenode(in_sizeof_x,false,p1);
 | 
				
			||||||
 | 
					                  { no packed bit support for these things }
 | 
				
			||||||
 | 
					                  if (l = in_bitsizeof_x) then
 | 
				
			||||||
 | 
					                    statement_syssym:=caddnode.create(muln,statement_syssym,cordconstnode.create(8,sinttype,true));
 | 
				
			||||||
 | 
					                end
 | 
				
			||||||
              else
 | 
					              else
 | 
				
			||||||
               begin
 | 
					               begin
 | 
				
			||||||
                 statement_syssym:=cordconstnode.create(p1.resulttype.def.size,sinttype,true);
 | 
					                 if (l = in_sizeof_x) or
 | 
				
			||||||
 | 
					                    (not((p1.nodetype = vecn) and
 | 
				
			||||||
 | 
					                         is_packed_array(tvecnode(p1).left.resulttype.def)) and
 | 
				
			||||||
 | 
					                     not((p1.nodetype = subscriptn) and
 | 
				
			||||||
 | 
					                         is_packed_record_or_object(tsubscriptnode(p1).left.resulttype.def))) then
 | 
				
			||||||
 | 
					                   begin
 | 
				
			||||||
 | 
					                     statement_syssym:=cordconstnode.create(p1.resulttype.def.size,sinttype,true);
 | 
				
			||||||
 | 
					                     if (l = in_bitsizeof_x) then
 | 
				
			||||||
 | 
					                       statement_syssym:=caddnode.create(muln,statement_syssym,cordconstnode.create(8,sinttype,true));
 | 
				
			||||||
 | 
					                   end
 | 
				
			||||||
 | 
					                 else
 | 
				
			||||||
 | 
					                   statement_syssym:=cordconstnode.create(p1.resulttype.def.packedbitsize,sinttype,true);
 | 
				
			||||||
                 { p1 not needed !}
 | 
					                 { p1 not needed !}
 | 
				
			||||||
                 p1.destroy;
 | 
					                 p1.destroy;
 | 
				
			||||||
               end;
 | 
					               end;
 | 
				
			||||||
 | 
				
			|||||||
@ -69,6 +69,7 @@ const
 | 
				
			|||||||
   fpc_in_get_caller_frame  = 58;
 | 
					   fpc_in_get_caller_frame  = 58;
 | 
				
			||||||
   fpc_in_pack_x_y_z        = 59;
 | 
					   fpc_in_pack_x_y_z        = 59;
 | 
				
			||||||
   fpc_in_unpack_x_y_z      = 60;
 | 
					   fpc_in_unpack_x_y_z      = 60;
 | 
				
			||||||
 | 
					   fpc_in_bitsizeof_x       = 61;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{ Internal constant functions }
 | 
					{ Internal constant functions }
 | 
				
			||||||
   fpc_in_const_sqr        = 100;
 | 
					   fpc_in_const_sqr        = 100;
 | 
				
			||||||
 | 
				
			|||||||
@ -17,12 +17,18 @@ type
 | 
				
			|||||||
var
 | 
					var
 | 
				
			||||||
   unone    : array[3..24] of char;
 | 
					   unone    : array[3..24] of char;
 | 
				
			||||||
   pacone   : packed array[1..4] of char;
 | 
					   pacone   : packed array[1..4] of char;
 | 
				
			||||||
 | 
					   pacy     : array[1..4] of char;
 | 
				
			||||||
   untwo    : array[4..8] of colourtype;
 | 
					   untwo    : array[4..8] of colourtype;
 | 
				
			||||||
   pactwo   : packed array[6..7] of colourtype;
 | 
					   pactwo   : packed array[6..7] of colourtype;
 | 
				
			||||||
   i        : integer;
 | 
					   i        : integer;
 | 
				
			||||||
   colour   : colourtype;
 | 
					   colour   : colourtype;
 | 
				
			||||||
 | 
					   s: string;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
   pacone:='ABCD';
 | 
					   pacone:='ABCD';
 | 
				
			||||||
 | 
					   pacy:=pacone;
 | 
				
			||||||
 | 
					   if pacy <> 'ABCD' then
 | 
				
			||||||
 | 
					     halt(1);
 | 
				
			||||||
 | 
					   s := pacone;
 | 
				
			||||||
   unpack(pacone,unone,5);
 | 
					   unpack(pacone,unone,5);
 | 
				
			||||||
   if (unone[3] <> #0) or
 | 
					   if (unone[3] <> #0) or
 | 
				
			||||||
      (unone[4] <> #0) or
 | 
					      (unone[4] <> #0) or
 | 
				
			||||||
 | 
				
			|||||||
@ -16,6 +16,10 @@ type
 | 
				
			|||||||
var
 | 
					var
 | 
				
			||||||
  km: GPCKeymap;
 | 
					  km: GPCKeymap;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
 | 
					  if bitsizeof(km[1]) <> 1 then
 | 
				
			||||||
 | 
					    halt(1);
 | 
				
			||||||
 | 
					  if bitsizeof(FPCKeyMap(km)[0]) <> 8 then
 | 
				
			||||||
 | 
					    halt(2);
 | 
				
			||||||
  fillchar(km,sizeof(km),0);
 | 
					  fillchar(km,sizeof(km),0);
 | 
				
			||||||
  km[56] := true;
 | 
					  km[56] := true;
 | 
				
			||||||
  if (FPCKeyMap(km)[0] <> 0) or
 | 
					  if (FPCKeyMap(km)[0] <> 0) or
 | 
				
			||||||
@ -42,5 +46,7 @@ begin
 | 
				
			|||||||
      writeln('error');
 | 
					      writeln('error');
 | 
				
			||||||
      halt(1);
 | 
					      halt(1);
 | 
				
			||||||
    end;
 | 
					    end;
 | 
				
			||||||
 | 
					  writeln('ok');
 | 
				
			||||||
end.
 | 
					end.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user