Commit 0afc301
C++11 style Initializer lists (#838)
This lets you have constructs like
// pass a {} list as a triple, matrix, or struct
void func (point p);
func ({x, y, z});
// Assign {} to a struct if the types match up
struct vec2 { float x, y; };
vec2 v = {a,b};
// Compact 'return' notation, it knows to construct the return type
vec2 func (float a, float b)
{
return {a, b};
}
Along the way, a number of steps:
* Initialize struct array elements without going through a temporary.
* Refactor codegen of aassign into single method.
* Allow float <=> int conversions using "aassign" without going through a temporary.
* Allow initializer lists as return types.
* Allow initializer lists as function/constructor arguments.
* C++11 style initializer lists.
* Complete ASTcompound_initializer type check/binding.
* Remove ASTNode typecheck_initlist & typecheck_struct_initializers.
Everything now flows properly through ASTcompound_initializer.
* Adapt to recent function-overload changes.
Hide some implementation details that don't need to be public.
* Error on ambiguity of arguments using init-lists.
* Make warnings & errors involving initializer list arguments more obvious.1 parent db85b9a commit 0afc301
23 files changed
Lines changed: 1043 additions & 234 deletions
File tree
- src
- liboslcomp
- liboslexec
- testsuite
- array-aassign
- ref
- function-overloads
- ref
- initlist
- ref
- oslc-err-initlist-args
- ref
- oslc-err-initlist-return
- ref
- oslc-err-struct-ctr/ref
- oslc-err-struct-dup/ref
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
239 | | - | |
| 238 | + | |
| 239 | + | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| 275 | + | |
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
501 | 507 | | |
502 | 508 | | |
503 | 509 | | |
| |||
868 | 874 | | |
869 | 875 | | |
870 | 876 | | |
871 | | - | |
| 877 | + | |
| 878 | + | |
872 | 879 | | |
873 | 880 | | |
874 | 881 | | |
| |||
877 | 884 | | |
878 | 885 | | |
879 | 886 | | |
880 | | - | |
| 887 | + | |
881 | 888 | | |
882 | 889 | | |
883 | 890 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
| 303 | + | |
| 304 | + | |
304 | 305 | | |
305 | 306 | | |
306 | 307 | | |
| |||
346 | 347 | | |
347 | 348 | | |
348 | 349 | | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | 350 | | |
354 | 351 | | |
355 | 352 | | |
356 | 353 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | 354 | | |
364 | 355 | | |
365 | 356 | | |
366 | 357 | | |
367 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
368 | 367 | | |
369 | 368 | | |
370 | 369 | | |
| |||
707 | 706 | | |
708 | 707 | | |
709 | 708 | | |
710 | | - | |
| 709 | + | |
711 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
712 | 744 | | |
713 | 745 | | |
714 | 746 | | |
715 | 747 | | |
716 | 748 | | |
717 | 749 | | |
718 | 750 | | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
719 | 761 | | |
720 | 762 | | |
721 | 763 | | |
| |||
840 | 882 | | |
841 | 883 | | |
842 | 884 | | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | 885 | | |
864 | 886 | | |
865 | 887 | | |
| |||
0 commit comments