Changes between Version 76 and Version 77 of IR2


Ignore:
Timestamp:
05/06/21 10:42:59 (5 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IR2

    v76 v77  
    8282* 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.
    8383* 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.
    8585* 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.
    8686* An abstract function represents a new uninterpreted pure function.
     
    123123  | '$char'  /* character type (Unicode characters, unrelated to integers) */
    124124  | '$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 */
    126127  | '$herbrand' '<' type-name '>'  /* Herbrand type of non-Herbrand numeric type T */
    127128  | '$proc'  /* process type */
     
    146147type-name: ... /* same as declarator but without the ID */
    147148type-args: '<' type-name (',' type-name)* '>';
    148 parameter-type-list: type-specifier declarator (type-specifier declarator)* ;
     149parameter-type-list: type-specifier declarator (',' type-specifier declarator)* ;
    149150
    150151}}}
     
    163164
    164165== Statements ==
     166
     167An 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.
    165168
    166169{{{
     
    193196{{{
    194197expr:
    195   | ID
    196   | lvalue
     198  | ID  /* variable or function identifier */
    197199  | '$true'
    198200  | '$false'
     
    218220  | '!' expr  /* logical not */
    219221  | expr '<' expr  /* less than */
    220   | expr '<=" expr  /* less than or equal to */
     222  | expr '<=' expr  /* less than or equal to */
    221223  | expr '[' expr ']'  /* array element access */
    222224  | expr '.' ID  /* field access */
     
    237239}}}
    238240
     241* For float types, which rounding mode is used?
     242* Comparisons likes `==` and `<` return a `$bool` (not an int, like C)
     243
    239244
    240245== Standard CIVL Library ==
    241246
    242 === `civlc.cvh` ===
     247=== `math.cvh` ===
    243248
    244249Work in progress...
     250
     251Rounding modes:
     252* 0 = to nearest
     253* 1 = upward
     254* 2 = downward
     255* 3 = toward zero.
    245256
    246257{{{
    247258$int $round($real x); // round to nearest integer
    248259$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, ...
    273271
    274272=== `mem.cvh` ===