Advertisement
Guest User

Untitled

a guest
Jan 31st, 2016
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.53 KB | None | 0 0
  1. program whatwhat;
  2. {$mode objfpc}
  3. uses classes;
  4.  
  5. { objects }
  6. function whattype(t : tobject):string; overload; begin whattype := 'object:'+t.ClassName; end;
  7.  
  8. { ints }
  9. function whattype(i : byte    ):string; overload; begin whattype := 'int:byte';     end;
  10. function whattype(i : shortint):string; overload; begin whattype := 'int:short';    end;
  11. function whattype(i : smallint):string; overload; begin whattype := 'int:small';    end;
  12. function whattype(i : word    ):string; overload; begin whattype := 'int:word';     end;
  13. function whattype(i : longint ):string; overload; begin whattype := 'int:long';     end;
  14. function whattype(i : longword):string; overload; begin whattype := 'int:longword'; end;
  15. function whattype(i : int64   ):string; overload; begin whattype := 'int:64';       end;
  16. function whattype(i : qword   ):string; overload; begin whattype := 'int:qword';    end;
  17.  
  18. { floats }
  19. function whattype(f : real    ):string; overload; begin whattype := 'float:real';     end;
  20. function whattype(f : single  ):string; overload; begin whattype := 'float:single';   end;
  21. function whattype(f : double  ):string; overload; begin whattype := 'float:double';   end;
  22. function whattype(f : extended):string; overload; begin whattype := 'float:extended'; end;
  23. function whattype(f : comp    ):string; overload; begin whattype := 'float:comp';     end;
  24. function whattype(f : currency):string; overload; begin whattype := 'float:currency'; end;
  25.  
  26. { booleans }
  27. function whattype(f : boolean ):string; overload; begin whattype := 'bool:boolean';  end;
  28. function whattype(f : bytebool):string; overload; begin whattype := 'bool:byte'; end;
  29. function whattype(f : wordbool):string; overload; begin whattype := 'bool:word'; end;
  30. function whattype(f : longbool):string; overload; begin whattype := 'bool:long'; end;
  31.  
  32. { strings }
  33. function whattype(s : char  ):string; overload; begin whattype := 'string:char';   end;
  34. function whattype(s : string):string; overload; begin whattype := 'string:string'; end;
  35.  
  36. { pointers }
  37. function whattype(p : pchar  ):string; overload; begin whattype := 'pointer:pchar';   end;
  38. function whattype(p : pointer):string; overload; begin whattype := 'pointer:pointer'; end;
  39. type
  40.   tMyObject = class(tObject)
  41.   public
  42.      hello : integer;
  43.   end;
  44. var
  45.   b: byte;
  46.   bb : boolean;
  47.   c : tMyObject;
  48.   i : integer;
  49.   f : comp;
  50. begin
  51.   b := 1;
  52.   bb := false;
  53.   c := tMyObject.create;
  54.   i := 2;
  55.   f := 0.1;
  56.   writeln(whattype(b));
  57.   writeln(whattype(bb));
  58.   writeln(whattype(c));
  59.   writeln(whattype(i));
  60.   writeln(whattype(f));
  61. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement