def safe_eval(str, **vars)
      return str if str.is_a?(Integer)

      # dentaku 2 doesn't support hex
      str = str.gsub(/0x[0-9a-zA-Z]+/) { |c| c.to_i(16) }
      Dentaku::Calculator.new.store(vars).evaluate(str)
    end
def safe_eval(str, **vars)
      return str if str.is_a?(Integer)

      # dentaku 2 doesn't support hex
      str = str.gsub(/0x[0-9a-zA-Z]+/) { |c| c.to_i(16) }
      Dentaku::Calculator.new.store(vars).evaluate(str)
    end
Evaluate string safely.

 @param [String] str
   String to be evaluated.
 @param [{Symbol => Integer}] vars
   Predefined variables

 @return [Integer]
   Result.

 @example
   Util.safe_eval('heap + 0x10 * pp', heap: 0xde00, pp: 8)
   #=> 56960 # 0xde80