Changes between Version 76 and Version 77 of IR2
- Timestamp:
- 05/06/21 10:42:59 (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
IR2
v76 v77 82 82 * A typedef can be used to define parameterized types. The type parameters are listed between angular brackets preceding the typedef. When the identifier is later used, it must be used with angular brackets and actual type names to replace the type parameters. 83 83 * A declaration declares a variable to have either an object type or a function type. (An object type is any type that is not a function type.) 84 * The optional type-param-list in a declaration may be applied to declaration of function type only. It declares a "generic" function. When the function is called (or spawned), the call must include the angular brackets with a list of type names that replace the type parameters used in the declaration or definition of the function.84 * The optional type-param-list in a declaration may be applied only to a declaration of function type. It declares a "generic" function. When the function is called (or spawned), the call must include the angular brackets with a list of type names that replace the type parameters used in the declaration or definition of the function. 85 85 * A variable of function type represents either an abstract or a system function. The declaration of such a variable must use either the qualifier `$abstract_f` or `$system_f`. Moreover, those two qualifiers can only be used in a declaration of function type. 86 86 * An abstract function represents a new uninterpreted pure function. … … 123 123 | '$char' /* character type (Unicode characters, unrelated to integers) */ 124 124 | '$real' /* mathematical reals */ 125 | '$float' '<' INT ',' INT '>' /* IEEE floating-point numbers e=significand bits, f=exponent bits */ 125 | '$float32' /* IEEE 32-bit floating-point numbers */ 126 | '$float64' /* IEEE 64-bit floating-point number */ 126 127 | '$herbrand' '<' type-name '>' /* Herbrand type of non-Herbrand numeric type T */ 127 128 | '$proc' /* process type */ … … 146 147 type-name: ... /* same as declarator but without the ID */ 147 148 type-args: '<' type-name (',' type-name)* '>'; 148 parameter-type-list: type-specifier declarator ( type-specifier declarator)* ;149 parameter-type-list: type-specifier declarator (',' type-specifier declarator)* ; 149 150 150 151 }}} … … 163 164 164 165 == Statements == 166 167 An lvalue is an expression that represents an object, as in C. It is either a variable, an array element expression, a struct or union field expression, or dereference expression. 165 168 166 169 {{{ … … 193 196 {{{ 194 197 expr: 195 | ID 196 | lvalue 198 | ID /* variable or function identifier */ 197 199 | '$true' 198 200 | '$false' … … 218 220 | '!' expr /* logical not */ 219 221 | expr '<' expr /* less than */ 220 | expr '<= "expr /* less than or equal to */222 | expr '<=' expr /* less than or equal to */ 221 223 | expr '[' expr ']' /* array element access */ 222 224 | expr '.' ID /* field access */ … … 237 239 }}} 238 240 241 * For float types, which rounding mode is used? 242 * Comparisons likes `==` and `<` return a `$bool` (not an int, like C) 243 239 244 240 245 == Standard CIVL Library == 241 246 242 === ` civlc.cvh` ===247 === `math.cvh` === 243 248 244 249 Work in progress... 250 251 Rounding modes: 252 * 0 = to nearest 253 * 1 = upward 254 * 2 = downward 255 * 3 = toward zero. 245 256 246 257 {{{ 247 258 $int $round($real x); // round to nearest integer 248 259 $int $floor($real x); // greatest integer less than or equal to 249 $int ceil($real x); // least integer greater than or equal to 250 $float<e,f> $roundf($real x, $int e, $int f); // PROBLEM this is not a parameterized type 251 252 }}} 253 254 255 * `round(e,t)`: returns value in numerical type `t` that is "closest" to the given value `e` 256 * add argument for rounding mode? 257 * exception if out of range? 258 * `floor(e)` : given a real or floating number, returns the greatest `Integer` less than or equal to it. 259 * `ceil(e)` : given a real or floating number, returns the least `Integer` greater than or equal to it. 260 * `abs(e)`: given any numeric expression e, returns the absolute value; result is same type as `e`. 261 * `pow(e,n)`: power operator 262 * given any numeric expression e and expression `n` of any integral type, returns e to the n-th power. 263 * `n` must evaluate to a nonnegative integer. 264 * `herbrand(e)`: "Herbrandize" a numeric value. 265 * given a numeric value of type `T`, returns the value as type `Herbrand[T]`, a trivial symbolic expression consisting of a single node. 266 * `eval(e)` : evaluate a Herbrand expression 267 * given a value of type `Herbrand[T]`, returns the value of type `T` obtained by evaluating all the delayed operations 268 * exceptions may be thrown if evaluating any of the delayed operations results in an exception 269 270 {{{ 271 272 }}} 260 $int $ceil($real x); // least integer greater than or equal to 261 $float32 $round32($real x, $int mode); // round to float32 (see modes above) 262 $float64 $round64($real x, $int mode); // round to float64 (see modes above) 263 <T> T $abs(T x); // absolute value (T must be a numeric type) 264 <T> T $pow(T x, $int n); // x to the n-th power. T must be a numeric type; n>=0. 265 <T> T $eval($herbrand<T> x); // returns value of type T obtained by evaluating all the delayed operations 266 <T> $herbrand<T> $herbrandize(T x); // trivial symbolic expression consisting of a single node 267 268 }}} 269 270 * Is it OK to have parameterized functions that only work for certain T? Would it better to expand for each numeric type? E.g., absi, abs, abs32, abs64, ... 273 271 274 272 === `mem.cvh` ===
