-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure assignment expressions work correctly with tstrings
The node kinds that can hold a tstring has been expanded from just DT_NODE_FUNC to DT_NODE_OP1, DT_NODE_OP2, DT_NODE_OP3, DT_NODE_DEXPR. This is necessary in order to properly manage the life of tstrings. The dt_cg_store_var() function no longer frees the (possible) tstring associated with the assignment itself. Support has been added to handle tstrings when generating code for a ternary (?:) operator where the value are strings. Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com> Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
- Loading branch information
Showing
6 changed files
with
120 additions
and
16 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
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,29 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
/* | ||
* Ensure tstrings are handled correctly for non-void assignment expressoions. | ||
*/ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN { | ||
trace(z = strjoin((x = strjoin("abc", "def")), | ||
(y = strjoin("ABC", "DEF")))); | ||
trace(" "); | ||
trace(x); | ||
trace(" "); | ||
trace(y); | ||
trace(" "); | ||
trace(z); | ||
|
||
exit(0); | ||
} | ||
|
||
ERROR { | ||
exit(1); | ||
} |
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 @@ | ||
abcdefABCDEF abcdef ABCDEF abcdefABCDEF |
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,28 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
/* | ||
* Ensure tstrings are handled correctly for ternary (?:) expressoions. | ||
*/ | ||
|
||
#pragma D option quiet | ||
|
||
BEGIN { | ||
a = 1; | ||
b = 2; | ||
trace(a > b ? strjoin("abc", "def") : strjoin("ABC", "DEF")); | ||
trace(" "); | ||
trace(a < b ? strjoin("abc", "def") : strjoin("ABC", "DEF")); | ||
trace(" "); | ||
trace(a == b ? strjoin("abc", "def") : strjoin("ABC", "DEF")); | ||
|
||
exit(0); | ||
} | ||
|
||
ERROR { | ||
exit(1); | ||
} |
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 @@ | ||
ABCDEF abcdef ABCDEF |