@@ -74,6 +74,25 @@ int InitPtrToInt(const Init* ptr) {
74
74
return val.getValue ();
75
75
}
76
76
77
+ bool InitPtrToBool (const Init* ptr) {
78
+ bool ret = false ;
79
+ const DefInit& val = dynamic_cast <const DefInit&>(*ptr);
80
+ const std::string& str = val.getAsString ();
81
+
82
+ if (str == " true" ) {
83
+ ret = true ;
84
+ }
85
+ else if (str == " false" ) {
86
+ ret = false ;
87
+ }
88
+ else {
89
+ throw " Incorrect boolean value: '" + str +
90
+ " ': must be either 'true' or 'false'" ;
91
+ }
92
+
93
+ return ret;
94
+ }
95
+
77
96
const std::string& InitPtrToString (const Init* ptr) {
78
97
const StringInit& val = dynamic_cast <const StringInit&>(*ptr);
79
98
return val.getValue ();
@@ -95,13 +114,7 @@ const std::string GetOperatorName(const DagInit& D) {
95
114
96
115
// / CheckBooleanConstant - Check that the provided value is a boolean constant.
97
116
void CheckBooleanConstant (const Init* I) {
98
- const DefInit& val = dynamic_cast <const DefInit&>(*I);
99
- const std::string& str = val.getAsString ();
100
-
101
- if (str != " true" && str != " false" ) {
102
- throw " Incorrect boolean value: '" + str +
103
- " ': must be either 'true' or 'false'" ;
104
- }
117
+ InitPtrToBool (I);
105
118
}
106
119
107
120
// CheckNumberOfArguments - Ensure that the number of args in d is
@@ -935,8 +948,22 @@ class CollectToolProperties : public HandlerTable<CollectToolPropertiesHandler>
935
948
}
936
949
937
950
void onJoin (const DagInit& d) {
938
- CheckNumberOfArguments (d, 0 );
939
- toolDesc_.setJoin ();
951
+ bool isReallyJoin = false ;
952
+
953
+ if (d.getNumArgs () == 0 ) {
954
+ isReallyJoin = true ;
955
+ }
956
+ else {
957
+ Init* I = d.getArg (0 );
958
+ isReallyJoin = InitPtrToBool (I);
959
+ }
960
+
961
+ // Is this *really* a join tool? We allow (join false) for generating two
962
+ // tool descriptions from a single generic one.
963
+ // TOFIX: come up with a cleaner solution.
964
+ if (isReallyJoin) {
965
+ toolDesc_.setJoin ();
966
+ }
940
967
}
941
968
942
969
void onOutLanguage (const DagInit& d) {
0 commit comments