Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program whatwhat;
- {$mode objfpc}
- uses classes;
- { objects }
- function whattype(t : tobject):string; overload; begin whattype := 'object:'+t.ClassName; end;
- { ints }
- function whattype(i : byte ):string; overload; begin whattype := 'int:byte'; end;
- function whattype(i : shortint):string; overload; begin whattype := 'int:short'; end;
- function whattype(i : smallint):string; overload; begin whattype := 'int:small'; end;
- function whattype(i : word ):string; overload; begin whattype := 'int:word'; end;
- function whattype(i : longint ):string; overload; begin whattype := 'int:long'; end;
- function whattype(i : longword):string; overload; begin whattype := 'int:longword'; end;
- function whattype(i : int64 ):string; overload; begin whattype := 'int:64'; end;
- function whattype(i : qword ):string; overload; begin whattype := 'int:qword'; end;
- { floats }
- function whattype(f : real ):string; overload; begin whattype := 'float:real'; end;
- function whattype(f : single ):string; overload; begin whattype := 'float:single'; end;
- function whattype(f : double ):string; overload; begin whattype := 'float:double'; end;
- function whattype(f : extended):string; overload; begin whattype := 'float:extended'; end;
- function whattype(f : comp ):string; overload; begin whattype := 'float:comp'; end;
- function whattype(f : currency):string; overload; begin whattype := 'float:currency'; end;
- { booleans }
- function whattype(f : boolean ):string; overload; begin whattype := 'bool:boolean'; end;
- function whattype(f : bytebool):string; overload; begin whattype := 'bool:byte'; end;
- function whattype(f : wordbool):string; overload; begin whattype := 'bool:word'; end;
- function whattype(f : longbool):string; overload; begin whattype := 'bool:long'; end;
- { strings }
- function whattype(s : char ):string; overload; begin whattype := 'string:char'; end;
- function whattype(s : string):string; overload; begin whattype := 'string:string'; end;
- { pointers }
- function whattype(p : pchar ):string; overload; begin whattype := 'pointer:pchar'; end;
- function whattype(p : pointer):string; overload; begin whattype := 'pointer:pointer'; end;
- type
- tMyObject = class(tObject)
- public
- hello : integer;
- end;
- var
- b: byte;
- bb : boolean;
- c : tMyObject;
- i : integer;
- f : comp;
- begin
- b := 1;
- bb := false;
- c := tMyObject.create;
- i := 2;
- f := 0.1;
- writeln(whattype(b));
- writeln(whattype(bb));
- writeln(whattype(c));
- writeln(whattype(i));
- writeln(whattype(f));
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement