-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow
VAR_EXTERNAL
declarations (#1324)
* feat: allow `VAR_EXTERNAL` declarations Adds a new variable block type for VAR_EXTERNAL to the compiler. These blocks do not have any functionality for now and the compiler will emit a warning when such blocks are declared.
- Loading branch information
Showing
33 changed files
with
811 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
compiler/plc_diagnostics/src/diagnostics/error_codes/E106.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# VAR_EXTERNAL blocks have no effect | ||
|
||
Variables declared in a `VAR_EXTERNAL` block are currently ignored and the referenced globals will be used instead. | ||
|
||
Example: | ||
``` | ||
VAR_GLOBAL | ||
myArray : ARRAY [0..10] OF INT; | ||
myString: STRING; | ||
END_VAR | ||
FUNCTION main | ||
VAR_EXTERNAL CONSTANT | ||
myArray : ARRAY [0..10] OF INT; | ||
END_VAR | ||
myArray[5] := 42; | ||
myString := 'Hello, world!'; | ||
END_FUNCTION | ||
``` | ||
|
||
In this example, even though `arr` is declared as `VAR_EXTERNAL CONSTANT`, the `CONSTANT` constraint will be ignored and | ||
the global `myArray` will be mutated. The global `myString` can be read from and written to from within `main` even though it | ||
is not declared in a `VAR_EXTERNAL` block. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.