Changes between Version 90 and Version 91 of IR2


Ignore:
Timestamp:
05/12/21 15:57:02 (5 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IR2

    v90 v91  
    231231  | expr '?' expr ':' expr  /* if-then-else expression */
    232232  | '$length' '(' expr ')'  /* length of array */
    233   | '$defined' '(' expr ')'  /* does evaluation of expr result in a well-defined value? */
     233  | '$summable' '(' expr ',' expr ')'  /* is pointer addition p+i defined? */
     234  | '$subtractable' '(' expr ',' 'expr ')'  /* is pointer subtraction p-q defined? */
     235  | '$castable' '(' expr ',' type-name ')'  /* can expr be cast to type T? */
     236  | '$defined' '(' lvalue ')'  /* has the specified memory location been assigned? */
    234237  | '$valid '(' expr ')'  /* does a pointer point to a memory location capable of holding a value of its base type? */
    235238  ;
     
    241244=== Notes ===
    242245
    243 * For float types, which rounding mode is used?  Round-to-nearest?
    244 * Comparisons likes `==` and `<` return a `$bool` (not an int, like C)
    245 * explanation of `$defined`: a bit is associated to each memory location.  Memory locations are created by declaring variables and allocation.   Every variable initially holds an undefined value.   Memory locations become defined by assigning to them defined values.
     246* For operations on float types the rounding mode used is round-to-nearest.
     247* Comparisons likes `==` and `<` return a `$bool` (not an int, like C).
     248* Every object holds a value of its declared type, always.   There is no notion of "trap representation", as in C.
     249* For every operation, there is a way to determine if performing that operation is safe.
     250  * `a/b`: `b!=0`
     251  * `p+i` (pointer arithmetic): `$summable(p, i)`
     252  * `a[i]`: `0<=i && i<$length(a)`
     253  * `p-q` (pointer subtraction): `$subtractable(p,q)`
     254  * `(T)e` (cast): `$castable(e, T)`
     255  * `*p`: `$valid(p)`
     256* The result of an unsafe operation is unspecified, but will result in some value of the appropriate type.
     257* Explanation of `$defined`: a bit is associated to each object.  We say an object is "defined" if the bit is true, else it is undefined.  An object is initially undefined.  It becomes defined by assignment.
     258Memory locations are created by declaring variables and allocation.   Every variable initially holds an undefined value.   Memory locations become defined by assigning to them defined values.
    246259  * Question: should an assignment of an undefined value to a variable make that variable defined, or not?
    247260  * Constants are defined values.  This includes integer and real constants, and `NULL`.