From 323e774380995c04ae705e29ae0e51d62246333d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 9 Nov 2017 17:06:35 +0200 Subject: 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. --- build2/variable.cxx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'build2/variable.cxx') 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, &default_copy_ctor, &default_copy_assign, @@ -589,6 +592,7 @@ namespace build2 type_name, sizeof (path), nullptr, // No base. + nullptr, // No element. &default_dtor, &default_copy_ctor, &default_copy_assign, @@ -632,7 +636,9 @@ namespace build2 { type_name, sizeof (dir_path), - &value_traits::value_type, // Assume direct cast works for both. + &value_traits::value_type, // Base (assuming direct cast works for + // both). + nullptr, // No element. &default_dtor, &default_copy_ctor, &default_copy_assign, @@ -678,7 +684,9 @@ namespace build2 { type_name, sizeof (abs_dir_path), - &value_traits::value_type, // Assume direct cast works for both. + &value_traits::value_type, // Base (assuming direct cast works + // for both). + nullptr, // No element. &default_dtor, &default_copy_ctor, &default_copy_assign, @@ -716,6 +724,7 @@ namespace build2 type_name, sizeof (name), nullptr, // No base. + nullptr, // No element. &default_dtor, &default_copy_ctor, &default_copy_assign, @@ -794,6 +803,7 @@ namespace build2 type_name, sizeof (name_pair), nullptr, // No base. + nullptr, // No element. &default_dtor, &default_copy_ctor, &default_copy_assign, @@ -930,6 +940,7 @@ namespace build2 type_name, sizeof (process_path), nullptr, // No base. + nullptr, // No element. &default_dtor, &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, &default_copy_ctor, &default_copy_assign, -- cgit v1.1