Changes between Version 29 and Version 30 of IR2
- Timestamp:
- 04/28/21 14:18:17 (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
IR2
v29 v30 5 5 * CIVL-IR is a subset of CIVL-C. A CIVL-IR program is a CIVL-C program, and has the same semantics. 6 6 7 Questions 8 * how to allocate an array7 === Questions === 8 * How is an array allocated? An array variable `a` is declared with a decl such as `T a[];`, and then a statement such as `a=$new(T[n]);` will assign to a new arbitrary array value for an array of length `n` of elements of type `T`. For heap-allocation, a pointer is declared with a decl such as `T * p`, and a heap variable is also declared somewhere with a decl such as `$heap heap;` and then a statement such as `p = $alloc(&heap, n, T);`; it can be deallocated with `$free(p);`. 9 9 * how to initialize a variable (what are initial values?) 10 10 * how to go between sequences and arrays … … 145 145 {{{ 146 146 expr: 147 `$new`type-name /* returns a new arbitrary value of the given type */147 $new type-name /* returns a new arbitrary value of the given type */ 148 148 | 149 149
