You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/1.4/language.md
+26-4Lines changed: 26 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2318,8 +2318,8 @@ The *object declarations* are any number of declarations of objects, session
2318
2318
variables, saved variables, methods, or other `#if` statements, but not
2319
2319
parameters, `is` statements, or `in each` statements . When the conditional is
2320
2320
`true` (or if it's the else branch of a false conditional), the object
2321
-
declarations are treated as if they had appeared without any surrounding *#if*.
2322
-
So the two following declarations are equivalent:
2321
+
declarations are treated as if they had appeared without any surrounding `#if`.
2322
+
Thus, the two following snippets are equivalent:
2323
2323
2324
2324
```
2325
2325
#if (true) {
@@ -2329,12 +2329,34 @@ So the two following declarations are equivalent:
2329
2329
}
2330
2330
```
2331
2331
2332
-
is equivalent to
2333
-
2334
2332
```
2335
2333
register R size 4;
2336
2334
```
2337
2335
2336
+
As a special exception, an `#if` statement that appears on top level is allowed
2337
+
to contain any type of statement, as long as the condition doesn't reference
2338
+
any identifiers other than `dml_1_2`, `true` and `false`. This is often useful
2339
+
while migrating the devices of a system from DML 1.2 to DML 1.4,
2340
+
as it allows conditional definitions of templates in common code used from both DML 1.2 and DML 1.4. For example, let's say an existing template `reset_to_seven`
2341
+
is used in DML 1.2 code to set the reset value of a field to 7 in DML 1.2.
2342
+
The parameters that control reset values have changed from DML 1.2 to DML 1.4,
2343
+
and one way to handle this is to provide separate template definitions
2344
+
depending on whether the device uses DML 1.2 or DML 1.4:
2345
+
```
2346
+
#if (dml_1_2) {
2347
+
template seven is field {
2348
+
param hard_reset_value = 7;
2349
+
param soft_reset_value = 7;
2350
+
}
2351
+
} #else {
2352
+
template seven is field {
2353
+
param init_val = 7;
2354
+
}
2355
+
}
2356
+
```
2357
+
Later, when all related devices have been ported to DML 1.4,
2358
+
the `dml_1_2` clause can be removed.
2359
+
2338
2360
## In Each Declarations
2339
2361
2340
2362
In Each declarations are a convenient mechanism to apply a
0 commit comments