Changes between Version 20 and Version 21 of PIL
- Timestamp:
- 10/16/24 15:04:14 (19 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
PIL
v20 v21 316 316 == Objects 317 317 318 The function319 318 - `$obj $empty_obj($int size);` 320 returns the empty object spanning `size` bytes. Only values of a sized type can be written to an object. 319 * this function returns the empty object spanning `size` bytes. 320 Only values of a sized type can be written to an object. 321 - `void* $obj_base($obj* optr);` 322 * returns a pointer to byte 0 of the object. That pointer can be cast to different 323 pointer types in order to access the object. 321 324 322 325 An object is modified through a pointer into the object, for example: … … 325 328 typedef $size(8) $real double; 326 329 $obj o1 = $empty_obj(1000); 327 double* dp = (double*) &o1; // points to byte 0330 double* dp = (double*)$obj_base(&o1); // points to byte 0 328 331 *dp = 3.14; 329 332 *(dp+7) = 2.718; 330 int* ip = (int*) &o1;333 int* ip = (int*)dp; 331 334 *(ip+2) = 17; 332 335 }}} 333 The operations above place the double value 3.14 in o1at positions 0..7, the double value 2.718 at positions 28..35, and the integer value 17 at positions 8..11.336 The operations above place the double value 3.14 in `o1` at positions 0..7, the double value 2.718 at positions 28..35, and the integer value 17 at positions 8..11. 334 337 335 338 If a write to an object overlaps the interval of an existing value, the old value is removed. … … 343 346 * how to deal with "undefined" values? 344 347 * can there be nondeterministic expressions, i.e., expressions that evaluate to a set of values instead of one value? 348 * can there be nondeterministic statements, i.e., statements which result in multiple transitions 345 349 * how to implement C's malloc? 346 * what to return when something is wrong, e.g., $map_get$ when the specified key is not in the map (default value of type?) 347 348 Ideas on malloc: 349 350 Union of all types occurring in program: 351 {{{ 352 typedef union { 353 T1 t1; 354 T2 t2; 355 ... 356 } BigUnion; 357 }}} 358 359 A call to malloc returns a memory block: 360 - size (in bytes) (int) 361 - num_elements (int) 362 - sequence of tuples: 363 - offset (int) 364 - size (int) 365 - value (type `BigUnion`) 350
