Changes between Version 24 and Version 25 of IR


Ignore:
Timestamp:
11/22/15 20:32:54 (10 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IR

    v24 v25  
    5454==  Types ==
    5555
    56 **Do you need dependent types?**  I.e., can parameters to some of the types be arbitrary expressions, or do they have to be constants?
    57 
    58 **Do you need typedefs?**
    59 
    60 Question about types.  In the following, where in the state is the length of the array field stored?
    61 
    62 {{{
    63 #include <stdio.h>
    64 int n=10;
    65 int main() {
    66   struct S {int a[n];};
    67   struct S x1;
    68   n=20;
    69   struct S x2;
    70   printf("%ld, %ld\n", sizeof(x1), sizeof(x2));
    71   x2.a[10]=1; // error caught by CIVL
    72   fflush(stdout);
    73 }
    74 }}}
    75 
    76 
     56The types are:
     57
     58* `$dytype` : dynamic type: a value of this type represents a "dynamic type", a type which is created at runtime.  For example when the type name `int[n]` is evaluated, the result is a value of type `$dytype`.
    7759* `$bool` : boolean type, values are `$true` and `$false`
    7860* `$proc` : process type
     
    10284* `union(T1,...,Tn)` : similar to struct
    10385* `T[]` : array-of-T
    104 * **do we need the complete array type `T[e]`, which is a dependent type?**
    10586* Function<S1,...,Sn;T>
    10687 * function consuming S1,...,Sn and returning T.  T can be void.  The actual notation is the horrible C notation.
     
    10889 * `T*` : pointer-to-T, subtype of above
    10990
    110 When are two types equal?
    111 
    112 What are two types compatible?
    113 
    114 == Type names ==
    115 
    116 **Do we need another syntactic category for code that specifies a dynamic type**, for example
    117 * `int[n*m+3]`.
    118 
    119 This can be used in `sizeof`, ...
    120 
    121 **Do we need to clearly distinguish dynamic type names and static type names?**
     91Type names:
     92
     93A type name is a syntactic element that names a type, together with possibly more information that makes the type "complete".  All of the names listed above are type names, such as `int[]`, but so is `int[n*m]`.
     94
     95The expression `$dytypeof(typeName)` takes a type name and returns a value of type `$dytype` representing that type.
     96
     97The expression `$init_val(d)` takes a `$dytype` value `d` and returns the initial value for an object of type `d`.
     98
     99Example:
     100{{{
     101// type definitions
     102struct S { int a[];}
     103
     104// variable decls
     105int n;
     106$dytype _S;
     107struct S x1;
     108struct S x2;
     109
     110// statements (leaving out the chooses and whens for brevity)
     111n=10;
     112_S=$dytypeof(struct S { int a[n]; };
     113x1=$init_val(_S);
     114n=20;
     115x2=$init_val(_S);
     116}}}
     117
     118is semantically equivalent to the C code
     119
     120{{{
     121int n = 10;
     122struct S { int a[n]; };
     123struct S x1;
     124n=20;
     125struct S x2;
     126}}}
    122127
    123128
     
    150155
    151156== Expressions ==
     157
     158In the following list of expressions, `e`, `e0`, `e1`, etc., are expressions.  `T` is a type name.
    152159
    153160* literals
     
    165172 * `NULL` : value of type `void*`
    166173* variables
    167 * `$defined(e1)`
     174* `$dytypeof(T)` : an expression of type `$dytype`
     175* `$init_val(e)`, where `e1` is an expression of type `$dytype`
     176* `$defined(e)`
    168177* `e1+e2` : addition
    169178* `e1-e2` : subtraction
     
    185194* `$forall`, `$exists`
    186195* `e1.i`, some natural number i (tuple read)
    187 * `$initial_value(T; e1,...,en)`
    188  * e1,...,en are expressions of integer type
    189  * the type of this expression is T[e1]...[en]
    190  * array value with base type `T` and lengths e1,...,en
    191  * **do we need this for more types?**  E.g., structs of arrays of structs of arrays of ...?
    192 * `$typeof(...)`: what is this for?
    193196* `sizeof(T)` : T is a type name?
    194197* `e1&e2`, `e1|e2`, `e1^e2`, `~e1` : bit-wise operations: arguments are arrays of booleans