OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from compiler.ast import Const | 5 from compiler.ast import Const |
6 from compiler.ast import Dict | 6 from compiler.ast import Dict |
7 from compiler.ast import Discard | 7 from compiler.ast import Discard |
8 from compiler.ast import List | 8 from compiler.ast import List |
9 from compiler.ast import Module | 9 from compiler.ast import Module |
10 from compiler.ast import Node | 10 from compiler.ast import Node |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 # Make a copy of the variables dict so that it won't influence anything | 1066 # Make a copy of the variables dict so that it won't influence anything |
1067 # outside of its own scope. | 1067 # outside of its own scope. |
1068 ProcessVariablesAndConditionsInDict(item, phase, variables, build_file) | 1068 ProcessVariablesAndConditionsInDict(item, phase, variables, build_file) |
1069 elif isinstance(item, list): | 1069 elif isinstance(item, list): |
1070 ProcessVariablesAndConditionsInList(item, phase, variables, build_file) | 1070 ProcessVariablesAndConditionsInList(item, phase, variables, build_file) |
1071 elif isinstance(item, str): | 1071 elif isinstance(item, str): |
1072 expanded = ExpandVariables(item, phase, variables, build_file) | 1072 expanded = ExpandVariables(item, phase, variables, build_file) |
1073 if isinstance(expanded, str) or isinstance(expanded, int): | 1073 if isinstance(expanded, str) or isinstance(expanded, int): |
1074 the_list[index] = expanded | 1074 the_list[index] = expanded |
1075 elif isinstance(expanded, list): | 1075 elif isinstance(expanded, list): |
1076 del the_list[index] | 1076 the_list[index:index+1] = expanded |
1077 for expanded_item in expanded: | 1077 index += len(expanded) |
1078 the_list.insert(index, expanded_item) | |
1079 index = index + 1 | |
1080 | 1078 |
1081 # index now identifies the next item to examine. Continue right now | 1079 # index now identifies the next item to examine. Continue right now |
1082 # without falling into the index increment below. | 1080 # without falling into the index increment below. |
1083 continue | 1081 continue |
1084 else: | 1082 else: |
1085 raise ValueError, \ | 1083 raise ValueError, \ |
1086 'Variable expansion in this context permits strings and ' + \ | 1084 'Variable expansion in this context permits strings and ' + \ |
1087 'lists only, found ' + expanded.__class__.__name__ + ' at ' + \ | 1085 'lists only, found ' + expanded.__class__.__name__ + ' at ' + \ |
1088 index | 1086 index |
1089 elif not isinstance(item, int): | 1087 elif not isinstance(item, int): |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2478 ValidateRunAsInTarget(target, target_dict, build_file) | 2476 ValidateRunAsInTarget(target, target_dict, build_file) |
2479 ValidateActionsInTarget(target, target_dict, build_file) | 2477 ValidateActionsInTarget(target, target_dict, build_file) |
2480 | 2478 |
2481 # Generators might not expect ints. Turn them into strs. | 2479 # Generators might not expect ints. Turn them into strs. |
2482 TurnIntIntoStrInDict(data) | 2480 TurnIntIntoStrInDict(data) |
2483 | 2481 |
2484 # TODO(mark): Return |data| for now because the generator needs a list of | 2482 # TODO(mark): Return |data| for now because the generator needs a list of |
2485 # build files that came in. In the future, maybe it should just accept | 2483 # build files that came in. In the future, maybe it should just accept |
2486 # a list, and not the whole data dict. | 2484 # a list, and not the whole data dict. |
2487 return [flat_list, targets, data] | 2485 return [flat_list, targets, data] |
OLD | NEW |