-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #680 from larsclausen/class-static-prop-assign
Handle assignment to static class properties in class methods
- Loading branch information
Showing
6 changed files
with
104 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Check that static class properties can be accessed for read and write in | ||
// class tasks. Check the property is shared across all instances and has the | ||
// same value for all instances. | ||
|
||
class C; | ||
static int i; | ||
task t; | ||
int x; | ||
x = i; | ||
i = x + 1; | ||
endtask | ||
endclass | ||
|
||
module test; | ||
|
||
C c1 = new; | ||
C c2 = new; | ||
C c3 = new; | ||
|
||
initial begin | ||
c1.t(); | ||
c2.t(); | ||
if (c1.i == 2 && c2.i == 2 && c3.i == 2) begin | ||
$display("PASSED"); | ||
end else begin | ||
$display("FAILED"); | ||
end | ||
end | ||
|
||
endmodule |
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,30 @@ | ||
// Check that static class properties can be accessed for read and write in | ||
// class tasks using `this`. Check the property is shared across all instances | ||
// and has the same value for all instances. | ||
|
||
class C; | ||
static int i; | ||
task t; | ||
int x; | ||
x = this.i; | ||
this.i = x + 1; | ||
endtask | ||
endclass | ||
|
||
module test; | ||
|
||
C c1 = new; | ||
C c2 = new; | ||
C c3 = new; | ||
|
||
initial begin | ||
c1.t(); | ||
c2.t(); | ||
if (c1.i == 2 && c2.i == 2 && c3.i == 2) begin | ||
$display("PASSED"); | ||
end else begin | ||
$display("FAILED"); | ||
end | ||
end | ||
|
||
endmodule |
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,31 @@ | ||
// Check that static class properties can be accessed for read and write on a | ||
// class object. Check the property is shared across all instances and has the | ||
// same value for all instances. | ||
|
||
class C; | ||
static int i; | ||
endclass | ||
|
||
module test; | ||
|
||
C c1 = new; | ||
C c2 = new; | ||
C c3 = new; | ||
|
||
task t(C c); | ||
int x; | ||
x = c.i; | ||
c.i = x + 1; | ||
endtask | ||
|
||
initial begin | ||
t(c1); | ||
t(c2); | ||
if (c1.i == 2 && c2.i == 2 && c3.i == 2) begin | ||
$display("PASSED"); | ||
end else begin | ||
$display("FAILED"); | ||
end | ||
end | ||
|
||
endmodule |
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