Changes between Version 126 and Version 127 of IR2
- Timestamp:
- 06/10/21 08:54:25 (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
IR2
v126 v127 123 123 type-specifier: 124 124 ID type-args? /* type parameter or (possibly parameterized) typedef use */ 125 | '$int' /* mathematical integers */ 126 | '$bool' /* boolean type ($true and $false, unrelated to integers) */ 127 | '$char' /* character type (Unicode characters, unrelated to integers) */ 128 | '$real' /* mathematical reals */ 129 | '$float32' /* IEEE 32-bit floating-point numbers */ 130 | '$float64' /* IEEE 64-bit floating-point number */ 125 | '$int' size-spec /* mathematical integers */ 126 | '$bool' size-spec /* boolean type ($true and $false, unrelated to integers) */ 127 | '$char' size-spec /* character type (Unicode characters, unrelated to integers) */ 128 | '$real' size-spec /* mathematical reals */ 129 | '$float' size-spec /* IEEE floating-point numbers */ 131 130 | '$herbrand' '<' type-name '>' /* Herbrand type of non-Herbrand numeric type T */ 132 131 | '$proc' /* process type */ … … 142 141 | '$rel' type-args /* relation: set of n-tuples with specified component types */ 143 142 ; 144 type-qualifier : '$size' '(' constant-expr ')' /* size specification (in bytes) */ 143 size-spec: '<' expr '>' ; 145 144 declarator: '*'* direct-declarator ; 146 145 direct-declarator: … … 165 164 === Notes === 166 165 167 * Certain basic types can have a specified size---the number of bytes consumed by an object of that type. These basic types include '$bool', '$int', '$char', and '$real'. Two versions of the basic type with different sizes are in fact disjoint types. The basic type without a specified size has domain the union over all sizes of the size-qualified type. 166 * Certain basic types can have a specified size---the number of bytes consumed by an object of that type. These basic types include '$bool', '$int', '$char', and '$real'. Two versions of the basic type with different sizes are in fact disjoint types. The basic type without a specified size has domain the union over all sizes of the size-qualified type. TODO: require this or option? 168 167 * Sequences, sets, maps, relations, and `$mem` objects are immutable. An assignment using objects of this type creates a new copy of the object, just as with primitive types like `$int`. 169 168 * Arrays are similar to sequences. The main differences are as follows: … … 259 258 | expr type-args? '(' expression-list? ')' /* application of abstract function (and perhaps other functions?) */ 260 259 | '$typeof' '(' type-name ')' /* value type named by the extended type name */ 260 | 'sizeof' '(' (type-name | expr) ')' /* C's sizeof expression --- number of bytes */ 261 261 | '$fresh' '(' (expr | type-name) ')' /* returns a new arbitrary value of the given type */ 262 262 | '$new' '(' (expr | type-name) ')' /* returns a new arbitrary and undefined value of the given complete type */ … … 329 329 === Allowed Casts === 330 330 331 * between two types that are the same except for sizes of the basic types 331 332 * `$int` -> `$real` 332 * `$float32` -> `$real` 333 * `$float64` -> `$real` 333 * `$float` -> `$real` 334 334 * `T1*` -> `T2*`. How to check a cast is valid? What happens if it is not? If there are no exceptions, something must be returned. Perhaps undefined value. 335 335 * this is OK if one is a pointer to element 0 of an array, and the other is a pointer to the array … … 352 352 $system void $exit(); // terminate process immediately 353 353 $system $bool $terminated($proc p); // has the process terminated? 354 $ system int $choose_int($intn); // nondeterministic choice of int in 0..n-1354 $template <$int s> $system $int<s> $choose_int($int<s> n); // nondeterministic choice of int in 0..n-1 355 355 356 356 }}} … … 364 364 could be modeled as 365 365 {{{ 366 $int * p;367 $int (*p1)[]; // pointer to array of $int368 p1 = $alloc(&heap, $new( $int[10]));366 int * p; 367 int (*p1)[]; // pointer to array of int 368 p1 = $alloc(&heap, $new(int[10])); 369 369 p = &(*p1)[0]; 370 370 }}} … … 391 391 392 392 {{{ 393 $int $round($real x); // round to nearest integer 394 $int $floor($real x); // greatest integer less than or equal to 395 $int $ceil($real x); // least integer greater than or equal to 396 $float32 $round32($real x, $int mode); // round to float32 (see modes above) 397 $float64 $round64($real x, $int mode); // round to float64 (see modes above) 393 $template <$int s> $int<s> $round($real x); // round to nearest integer 394 $template <$int s> $int<s> $floor($real x); // greatest integer less than or equal to 395 $template <$int s> $int<s> $ceil($real x); // least integer greater than or equal to 396 $template <$int s> $float<s> $roundf($real x, $int mode); // round to float (see modes above) 398 397 $real $abs($real x); // absolute value on reals 399 $int $absi($int x); // absolute value on integers 400 $float32 $abs32($float32 x); // absolute value on $float32 398 $template <$int s> $int<s> $absi($int<s> x); // absolute value on integers 399 $template <$int s> $float<s> $absf($float<s> x); // absolute value on $float 400 ...left off here... 401 401 $float64 $abs64($float64 x); // absolute value on $float64 402 402 $real $pow($real x, $int n); // x to the n-th power. n>=0
