Repository navigation
Compute lazy lambda serialization #7870
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1453,8 +1453,24 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc) | |
|
|
||
| if (l1 && l2) | ||
| { | ||
| import core.stdc.string; | ||
| const(char)* getSerialization(FuncLiteralDeclaration fld) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't you return
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it's easier with strings, but the serialization field is is
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quoting a conversation with Walter here:
(we can even convert the C++ interfaces, but that's significantly more effort)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So how do we proceed here? That was my problem also: I may turn the field into a string, but what should I do regarding the header file?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about this: extern(C++) Dstring funLib(Dstring input);see full working example here showing using such API from C++ with the function defined in D. https://github.com/timotheecour/dtools/blob/master/tests/d01_dmd_string/ EDIT: see #7893
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @timotheecour #7893 is a good step in the right direction, we need to start using D strings in the compiler. That would be an effort separated from this. |
||
| { | ||
| import dmd.lambdacomp : SerializeVisitor; | ||
| auto serVisitor = new SerializeVisitor(sc); | ||
| fld.accept(serVisitor); | ||
| if (serVisitor.buf.offset == 0) | ||
| return "uncomparable"; | ||
| else | ||
| return serVisitor.buf.extractString(); | ||
| } | ||
|
|
||
| if (!l1.serialization) | ||
| l1.serialization = getSerialization(l1); | ||
| if (!l2.serialization) | ||
| l2.serialization = getSerialization(l2); | ||
|
|
||
| //printf("serialization1: %s\n", l1.serialization); | ||
| //printf("serialization2: %s\n", l2.serialization); | ||
| if (strcmp(l1.serialization, l2.serialization) == 0 && | ||
| strcmp(l1.serialization, "uncomparable") != 0) | ||
| { | ||
|
|
||
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.
Out of interest: why not
version= LOG? This is commonly used pattern in DRuntime.Uh oh!
There was an error while loading. Please reload this page.
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.
This is the pattern used in dmd from what I could obeserve :
https://github.com/dlang/dmd/blob/master/src/dmd/mtype.d#L61
https://github.com/dlang/dmd/blob/master/src/dmd/expression.d#L67
https://github.com/dlang/dmd/blob/master/src/dmd/expressionsem.d#L73
And the list could continue.