-
Notifications
You must be signed in to change notification settings - Fork 113
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
Compiletime rgb()
evaluation
#2115
base: master
Are you sure you want to change the base?
Conversation
rgb()
evaluationrgb()
evaluation
} | ||
|
||
// TODO: There is a difference between passing null and not passing a fourth arg at all | ||
if (a is null) { |
Check notice
Code scanning / InspectCode
'if' statement can be rewritten as '?:' expression Note
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.
The huge ternary is less readable, so no.
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.
Yea I think this is a notice we should turn off
rgb()
is supposed to be considered a constant when its args are constant, as shown in the included unit test which passes in BYOND.To facilitate this,
rgb()
handling has been moved to the compiler and theDMExpression
now implementsTryAsConstant()
.As a bonus, the peephole optimizer will attempt to evaluate it at compiletime whenever
Rgb
's argtype isFromStack
and its argcount matches a precedingPushNFloats
count. That means we'll compiletime eval something likergb(255,255,255)
but notrgb(255,255,255, space=foo())
.