-
Notifications
You must be signed in to change notification settings - Fork 137
Adds PreIncrement & PreDecrement opcodes; fixes comparison operators
#2666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ike709
wants to merge
4
commits into
OpenDreamProject:master
Choose a base branch
from
ike709:preop_time
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,59 @@ | ||
| /proc/comparison_reference_proc_a() | ||
| return | ||
|
|
||
| /proc/comparison_reference_proc_b() | ||
| return | ||
|
|
||
| /proc/assert_left_preserving_comparisons(label, left, right) | ||
| var/result = left < right | ||
| if (result != left) | ||
| CRASH("[label] < expected the left operand, got [result]") | ||
|
|
||
| result = left <= right | ||
| if (result != left) | ||
| CRASH("[label] <= expected the left operand, got [result]") | ||
|
|
||
| result = left > right | ||
| if (result != left) | ||
| CRASH("[label] > expected the left operand, got [result]") | ||
|
|
||
| result = left >= right | ||
| if (result != left) | ||
| CRASH("[label] >= expected the left operand, got [result]") | ||
|
|
||
| /proc/RunTest() | ||
| var/datum/datum_a = new | ||
| var/datum/datum_b = new | ||
| var/list/list_a = list(1) | ||
| var/list/list_b = list(1) | ||
| var/typepath_a = /datum | ||
| var/typepath_b = /atom | ||
| var/procpath_a = /proc/comparison_reference_proc_a | ||
| var/procpath_b = /proc/comparison_reference_proc_b | ||
| var/icon_a = icon() | ||
| var/icon_b = icon() | ||
| var/sound_a = sound() | ||
| var/sound_b = sound() | ||
| var/file_a = file("comparison_probe_a.tmp") | ||
| var/file_b = file("comparison_probe_b.tmp") | ||
|
|
||
| var/list/reference_names = list("datum", "list", "typepath", "procpath", "icon", "sound", "file") | ||
| var/list/reference_values = list(datum_a, list_a, typepath_a, procpath_a, icon_a, sound_a, file_a) | ||
| var/list/left_names = reference_names + list("num", "text", "null") | ||
| var/list/left_values = reference_values + list(1, "abc", null) | ||
|
|
||
| for (var/left_index in 1 to left_values.len) | ||
| for (var/right_index in 1 to reference_values.len) | ||
| assert_left_preserving_comparisons( | ||
| "[left_names[left_index]]_[reference_names[right_index]]", | ||
| left_values[left_index], | ||
| reference_values[right_index] | ||
| ) | ||
|
|
||
| assert_left_preserving_comparisons("distinct datums", datum_a, datum_b) | ||
| assert_left_preserving_comparisons("distinct lists", list_a, list_b) | ||
| assert_left_preserving_comparisons("distinct typepaths", typepath_a, typepath_b) | ||
| assert_left_preserving_comparisons("distinct proc paths", procpath_a, procpath_b) | ||
| assert_left_preserving_comparisons("distinct icons", icon_a, icon_b) | ||
| assert_left_preserving_comparisons("distinct sounds", sound_a, sound_b) | ||
| assert_left_preserving_comparisons("distinct files", file_a, file_b) |
This file contains hidden or 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,9 @@ | ||
| /proc/RunTest() | ||
| var/text_value = "bad" | ||
| ASSERT(--text_value == -1) | ||
|
|
||
| var/list/list_values = list("a","b","c") | ||
| ASSERT(--list_values[1] == -1) | ||
|
|
||
| var/null_value = null | ||
| ASSERT(--null_value == -1) |
This file contains hidden or 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,9 @@ | ||
| /proc/RunTest() | ||
| var/text_value = "bad" | ||
| ASSERT(++text_value == 1) | ||
|
|
||
| var/list/list_values = list("a","b","c") | ||
| ASSERT(++list_values[1] == 1) | ||
|
|
||
| var/null_value = null | ||
| ASSERT(++null_value == 1) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the maintainability issue this creates. BYOND doesn't make this sort of "reference type" distinction, would it be more accurate to say this applies to anything that isn't a number, null, or string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably? I'd need to find time this weekend for further testing.