-
-
Notifications
You must be signed in to change notification settings - Fork 265
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
Continue with DValue refactoring and fix issue #1327 #1562
Conversation
kinke
commented
Jun 15, 2016
- Introduce a DRValue base class to be able to discriminate between DLValues and DRValues (e.g., function parameters).
- Let DValue::getRVal() return each DValue's value as DRValue. This allows to convert a DLValue to a DRValue while retaining the D type, something we've previously lost when returning the low-level rvalue directly.
- Let the DtoR/LVal() helpers be the only way to convert a DValue to a low-level value.
The 2nd commit demonstrates what I was aiming for with that DValue refactoring, but it's only a beginning, there are surely more issues of this kind. #1327 is fixed with this at least. |
The 3rd commit fixes #1433. |
Could you add some tests for these fixes? |
Yeah I'll add some tests. They should probably go upstream. |
I'm not perfectly happy with |
* Introduce a DRValue base class to be able to discriminate between DLValues and DRValues (e.g., function parameters). * Let DValue::getRVal() return each DValue's value as DRValue. This allows to convert a DLValue to a DRValue, a snapshot of the lvalue's current state, while retaining the D type, something we've previously lost when returning the low-level rvalue directly. * Let the DtoR/LVal() helpers be the only way to convert a DValue to a low-level value.
Any concerns or has noone found the time to review this yet? |
I haven't reviewed this in detail, but I have no concerns :) |
|
||
// base class for d-values | ||
/// Associates an immutable low-level value with an immutable D type. |
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.
Nitpick: "immutable" is a bit misleading imho (in any other context, "immutable D type" would refer to the immutable
keyword – maybe An immutable pair of LLVM value and associated D type.
?
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.
Very well, done.
class DImValue : public DValue { | ||
/// Represents an immediate D value via a low-level rvalue. | ||
/// Suited for primitive low-level types like pointers (incl. class references), | ||
/// integral and floating-point types. |
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 tried to elaborate a bit here, but my understanding of 'immediate' is pretty vague too. ;)
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.
Thanks – I think pretty much all there even is to understand is that it is a D rvalue represented by a straight LLVM value, and without any special further properties (e.g. being null, etc).
lgtm (modulo tests still running, of course) |
Fixes issue ldc-developers#1327 by loading immediately from lvalues resulting from left- and right-hand sides.
/// Represents an immediate D value (simple rvalue with no special properties | ||
/// like being a compile-time constant) via a low-level rvalue. | ||
/// Restricted to primitive types such as pointers (incl. class references), | ||
/// integral and floating-point types. |
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've incorporated your latest comment here.
The tests were green and I've only touched some comments. Merging eagerly. dmd-testsuite test will follow soon. |
git bisect tells me that this PR (specifically commit a3adb40) is causing a unittest failure in Weka's codebase. |
I found the bugged code. It looks like a bug in Weka's code to me. Need to discuss with the author. |
Found the problem: #1617 |