diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-11-09 17:06:35 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-11-09 17:06:35 +0200 |
commit | 323e774380995c04ae705e29ae0e51d62246333d (patch) | |
tree | 83c18773c1efbfcdb7d3eef77d837880df21dc10 /build2/variable.cxx | |
parent | 3b0df49b8828921edfb7b764b0628fb164dab852 (diff) |
Add support for for-loop
The semantics is similar to the C++11 range-based for:
list = 1 2 3
for i: $list
print $i
Note that there is no scoping of any kind for the loop variable ('i' in
the above example).
See tests/loop/for.test for some examples/ideas.
In the future the plan is to also support more general while-loop as well
as break and continue.
Diffstat (limited to 'build2/variable.cxx')
-rw-r--r-- | build2/variable.cxx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/build2/variable.cxx b/build2/variable.cxx index 1bfd21c..1afa872 100644 --- a/build2/variable.cxx +++ b/build2/variable.cxx @@ -421,6 +421,7 @@ namespace build2 type_name, sizeof (bool), nullptr, // No base. + nullptr, // No element. nullptr, // No dtor (POD). nullptr, // No copy_ctor (POD). nullptr, // No copy_assign (POD). @@ -462,6 +463,7 @@ namespace build2 type_name, sizeof (uint64_t), nullptr, // No base. + nullptr, // No element. nullptr, // No dtor (POD). nullptr, // No copy_ctor (POD). nullptr, // No copy_assign (POD). @@ -538,6 +540,7 @@ namespace build2 type_name, sizeof (string), nullptr, // No base. + nullptr, // No element. &default_dtor<string>, &default_copy_ctor<string>, &default_copy_assign<string>, @@ -589,6 +592,7 @@ namespace build2 type_name, sizeof (path), nullptr, // No base. + nullptr, // No element. &default_dtor<path>, &default_copy_ctor<path>, &default_copy_assign<path>, @@ -632,7 +636,9 @@ namespace build2 { type_name, sizeof (dir_path), - &value_traits<path>::value_type, // Assume direct cast works for both. + &value_traits<path>::value_type, // Base (assuming direct cast works for + // both). + nullptr, // No element. &default_dtor<dir_path>, &default_copy_ctor<dir_path>, &default_copy_assign<dir_path>, @@ -678,7 +684,9 @@ namespace build2 { type_name, sizeof (abs_dir_path), - &value_traits<dir_path>::value_type, // Assume direct cast works for both. + &value_traits<dir_path>::value_type, // Base (assuming direct cast works + // for both). + nullptr, // No element. &default_dtor<abs_dir_path>, &default_copy_ctor<abs_dir_path>, &default_copy_assign<abs_dir_path>, @@ -716,6 +724,7 @@ namespace build2 type_name, sizeof (name), nullptr, // No base. + nullptr, // No element. &default_dtor<name>, &default_copy_ctor<name>, &default_copy_assign<name>, @@ -794,6 +803,7 @@ namespace build2 type_name, sizeof (name_pair), nullptr, // No base. + nullptr, // No element. &default_dtor<name_pair>, &default_copy_ctor<name_pair>, &default_copy_assign<name_pair>, @@ -930,6 +940,7 @@ namespace build2 type_name, sizeof (process_path), nullptr, // No base. + nullptr, // No element. &default_dtor<process_path>, &process_path_copy_ctor, &process_path_copy_assign, @@ -975,6 +986,7 @@ namespace build2 type_name, sizeof (target_triplet), nullptr, // No base. + nullptr, // No element. &default_dtor<target_triplet>, &default_copy_ctor<target_triplet>, &default_copy_assign<target_triplet>, |