wasmdef.pas 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. unit wasmdef;
  2. {$i fpcdefs.inc}
  3. interface
  4. uses
  5. symtype, symdef, symconst, constexp
  6. ,defutil;
  7. { returns whether a def always resides in memory,
  8. rather than in wasm local variables...) }
  9. function wasmAlwayInMem(def: tdef): boolean;
  10. function get_para_push_size(def: tdef): tdef;
  11. implementation
  12. function get_para_push_size(def: tdef): tdef;
  13. begin
  14. result:=def;
  15. if def.typ=orddef then
  16. case torddef(def).ordtype of
  17. u8bit,uchar:
  18. if torddef(def).high>127 then
  19. result:=s8inttype;
  20. u16bit:
  21. begin
  22. if torddef(def).high>32767 then
  23. result:=s16inttype;
  24. end
  25. else
  26. ;
  27. end;
  28. end;
  29. function wasmAlwayInMem(def: tdef): boolean;
  30. begin
  31. case def.typ of
  32. arraydef,
  33. filedef,
  34. recorddef,
  35. objectdef,
  36. stringdef:
  37. result:=true;
  38. else
  39. result:=false;
  40. end;
  41. end;
  42. end.