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
@@ -2321,8 +2321,8 @@ The *object declarations* are any number of declarations of objects, session
2321
2321
variables, saved variables, methods, or other `#if` statements, but not
2322
2322
parameters, `is` statements, or `in each` statements . When the conditional is
2323
2323
`true` (or if it's the else branch of a false conditional), the object
2324
-
declarations are treated as if they had appeared without any surrounding *#if*.
2325
-
So the two following declarations are equivalent:
2324
+
declarations are treated as if they had appeared without any surrounding `#if`.
2325
+
Thus, the two following snippets are equivalent:
2326
2326
2327
2327
```
2328
2328
#if (true) {
@@ -2332,12 +2332,34 @@ So the two following declarations are equivalent:
2332
2332
}
2333
2333
```
2334
2334
2335
-
is equivalent to
2336
-
2337
2335
```
2338
2336
register R size 4;
2339
2337
```
2340
2338
2339
+
As a special exception, an `#if` statement that appears on top level is allowed
2340
+
to contain any type of statement, as long as the condition doesn't reference
2341
+
any identifiers other than `dml_1_2`, `true` and `false`. This is often useful
2342
+
while migrating the devices of a system from DML 1.2 to DML 1.4,
2343
+
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`
2344
+
is used in DML 1.2 code to set the reset value of a field to 7 in DML 1.2.
2345
+
The parameters that control reset values have changed from DML 1.2 to DML 1.4,
2346
+
and one way to handle this is to provide separate template definitions
2347
+
depending on whether the device uses DML 1.2 or DML 1.4:
2348
+
```
2349
+
#if (dml_1_2) {
2350
+
template seven is field {
2351
+
param hard_reset_value = 7;
2352
+
param soft_reset_value = 7;
2353
+
}
2354
+
} #else {
2355
+
template seven is field {
2356
+
param init_val = 7;
2357
+
}
2358
+
}
2359
+
```
2360
+
Later, when all related devices have been ported to DML 1.4,
2361
+
the `dml_1_2` clause can be removed.
2362
+
2341
2363
## In Each Declarations
2342
2364
2343
2365
In Each declarations are a convenient mechanism to apply a
0 commit comments