Skip to content

pastojs: Fixed arithmetic for simple integer types

Dmytro Bogatskyy requested to merge BDmytro/fpc-source:main into main

Summary

Fixed arithmetic for simple integer types

What is the behavior after applying this patch?

  1. replaced rtl.lw() function (longword fix function) with "value >>> 0" operation
  2. fixed "not" operation for byte, word, shortint, smallint types
  3. added integer overflow "emulation" for byte, word, shortint, smallint, longword, longint types for arithmetic operations
  4. fixed integer type resolve for arithmetic operations for byte, word, shortint, smallint types and mixed expressions For example: byte + byte should be resolved to longint, currently it is byte
  5. fixed assignment of different integer types For example: a : byte := b : Integer; => "a = b & 255"
  6. different optimizations that taking into account parent expression and applies integer overflow "emulation" only when needed.

Relevant logs and/or screenshots

MathTest.pas This simple test shows expressions that resolved/calculated incorrectly in the current version and fixed by this patch.

Merge request reports