Skip to content

Commit

Permalink
Define ShiftLeftExpression and ShiftRightExpression evaluation for in…
Browse files Browse the repository at this point in the history
…teger types
  • Loading branch information
scrabsha committed Sep 3, 2024
1 parent 8b51cc1 commit e6146b8
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions src/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,23 @@ The :t:`evaluation` of a :t:`shift left expression` proceeds as follows:
The :t:`right operand` is evaluated.

#. :dp:`fls_f0p70y92k14f`
``core::ops::Shl::shl(left_operand, right_operand)`` is invoked.
If the type of the left :t:`[operand]` is any :t:`[unsigned integer type]`
and the type of the right :t:`[operand]` is any :t:`[integer type]`, then
the :t:`[shift left expression]` evaluates to the left logical shift of the
value of the left :t:`[operand]` by the value of the right :t:`[operand]`. If
the right operand is negative, then the operation results in an
:t:`arithmetic overflow`.

#. :dp:`fls_lLoagximIxMO`
If the type of the left :t:`[operand]` is any :t:`[signed integer type]` and
the type of the right :t:`[operand]` is any :t:`[integer type]`, then the
:t:`[shift left expression]` evaluates to the left arithmetic shift of the
value of the left :t:`[operand]` by the value of the right :t:`[operand]`. If
the right operand is negative, then the operation results in an
:t:`arithmetic overflow`.

#. :dp:`fls_8QGbl2SBU3R0`
Otherwise, ``core::ops::Shl::shl(left_operand, right_operand)`` is invoked.

:dp:`fls_303r0u6ug215`
The :t:`evaluation` of a :t:`shift right expression` proceeds as follows:
Expand All @@ -1730,8 +1746,24 @@ The :t:`evaluation` of a :t:`shift right expression` proceeds as follows:
#. :dp:`fls_gurl2ve58drz`
The :t:`right operand` is evaluated.

#. :dp:`fls_r02OGonXp93A`
If the type of the left :t:`[operand]` is any :t:`[unsigned integer type]`
and the type of the right :t:`[operand]` is any :t:`[integer type]`, then
the :t:`[shift right expression]` evaluates to the right logical shift of the
left :t:`[operand]` by the value of the right :t:`[operand]`. If the right
operand is negative, then the operation results in an
:t:`arithmetic overflow`.

#. :dp:`fls_rGv3cUKV1qpc`
If the type of the left :t:`[operand]` is any :t:`[signed integer type]` and
the type of the right :t:`[operand]` is any :t:`[integer type]`, then the
:t:`[shift right expression]` evaluates to the right arithmetic shift of the
left :t:`[operand]` by the value of the right :t:`[operand]`. If the right
operand is negative, then the operation results in an
:t:`arithmetic overflow`.

#. :dp:`fls_xkyj83mcb9d5`
``core::ops::Shr::shr(left_operand, right_operand)`` is invoked.
Otherwise, ``core::ops::Shr::shr(left_operand, right_operand)`` is invoked.

.. rubric:: Examples

Expand Down Expand Up @@ -5099,9 +5131,10 @@ Arithmetic Overflow
-------------------

:dp:`fls_oFIRXBPXu6Zv`
An :t:`arithmetic overflow` occurs when an :t:`arithmetic expression` or a
:t:`negation expression` computes a :t:`value` of a :t:`scalar type` that lies
outside of the range of valid :t:`[value]s` for the :t:`scalar type`.
An :t:`arithmetic overflow` occurs when an :t:`arithmetic expression`, a
:t:`negation expression` or a :t:`bit expression` computes a :t:`value` of a
:t:`scalar type` that lies outside of the range of valid :t:`[value]s` for the
:t:`scalar type`.

.. rubric:: Dynamic Semantics

Expand Down

0 comments on commit e6146b8

Please sign in to comment.