-
Notifications
You must be signed in to change notification settings - Fork 23
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
Q: how to find all the renamed attributes of a (AST processed) class in the gec compiler ? #70
Comments
This needs to be double-checked in the code, but if I recall correctly you have to look at |
Thanks. I also found this navigation: pwd: /gobo/tool/gec ../../library/tools/src/eiffel/compilation/et_feature_flattener.e ../../library/tools/src/eiffel/ast/feature/et_inherited_feature.e ../../library/tools/src/eiffel/ast/feature/et_parent_feature.e ../../library/tools/src/eiffel/ast/feature/et_feature.e Do you think this is good enough to scan all the renamed attribute (I don't care about methods)? |
I think it would work, except that ET_INHERITED_FEATURE objects are intermediate objects only used in the feature flattener. They are not kept in the AST objects. So with the former solution, you can call the code of gec up to Degree 4 included, and then write your own code (without having to modify any line of code in the Gobo library) to navigate through the resulting AST (ET_CLASS.queries.item(...).first_precursor). With the latter solution, you would probably have to modify the feature flattener class to intercept the ET_INHERITED_FEATURE objects on the fly when they are processed. Because they are thrown away after being processed. |
Which solution is easiest to implement in your estimate? (You know: "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies.") I want to take the simple way 🙂 |
Simplest way is the former solution: no need to modify Gobo's code, so no risk to break it. Just call the Gobo code from your code to generate the AST, and then traverse the AST (ET_CLASS, ET_FEATURE, precursors, ...) still from your code. |
Thanks. I will use |
Hi @ebezault I did a quick experiment using only two new methods:
Since https://github.com/joortcom/gobo/blob/eiffel_rename/tool/gedoc/Makefile
However in the test file BTW:
So what's going wrong? why some of the class / queries not visited? Can you help me to make this output Thanks. |
In particular: looks like it does not scan from the https://github.com/joortcom/gobo/blob/eiffel_rename/tool/gedoc/test/rename/app.ecf#L4 |
Before looking at the rename issue, I have a couple of remarks:
with:
|
For class
I can see that there are replications. It means that from 1 attribute Another solution could be to traverse This should compile with no CAT-call warnings with |
I tried this, the command runs fine without any error, but the executable |
Thanks, the navigation from
|
I've got the renamed fields path. Now, how do I get inherited (instead of self-declared) fields path? i.e.
|
Forcing the C compilation by calling |
OK, so you are not just interested in renamed attributes anymore, but in all inherited attributes! Perhaps you should combine the two implementations (traversing the parent clauses for the renamings, and the first and other precursors to detect those which are not renamed). If it has a precursor, it means that it is inherited. The reverse is not true as we could see in case of replication. Otherwise, in ET_CLASS.queries, the queries between 1 and `declared_count' are declared in the current class, and above they are inherited. But be careful, declared in the current class does not mean that they have been introduced in this class. It can also mean that they are inherited and redefined. |
I'm sorry that the solution is not as easy as it could be. This code has been written for the specific needs of |
I'm still interested in renamed attributes, but need to dig deeper: basically I want to detect renamed attributes that coming from the same origin (e.g. in the case of diamond problem). So:
I need to dig deeper:
and find out Sounds like I need to take this 1st approach:
I will give it a try. |
I just remembered that there is another data at your disposal (which you can use in combination with all the above):
|
what does "where the current feature was written" esp "written" mean? first time introduced? or last time (final)? |
Last time. "Written" means in which class file can I find its text. So if I have:
then feature And a more complicated example:
then |
Tried this, but it's not working for
My code is here: output is here: it worked for things like this one: but not for Will continue try the other method |
So we are unfortunately in the case where "the reverse is not true" (no precursor does not mean that it is not inherited). |
Looking at your code, I still recommend using:
instead of:
It's CAT-call free. |
This approach worked:
But now, I want to filter out non-direct super-sub-class relationship, i.e filter out:
So how to get a |
You get the direct super-classes with |
Is there a way to get rid of this: https://github.com/joortcom/gobo/blob/eiffel_rename/tool/gedoc/src/gedoc_field_rename_format.e#L124
|
|
You can also write:
which is probably better because it is possible to have two classes with the same name from different libraries. |
And how about compare: a |
I don't know if it can compile everything in EiffelVision2, but I have an application which uses some parts of it and I managed to compile and run it under Windows. I can see that you are under Linux (I guess). I never tried to compile an application using EiffelVision2 on this platform. |
FYI: I found a potential problem here: /Eiffel_23.09/examples/docking/simple
I'm manually checking the source code right now: This navigation verified the 2nd renamed path:
And the 1st un-renamed path is:
@ebezault while the updated attached if the generated file: inherited_fields.path.txt you can also run
to generate them yourself. |
It's probably time to try to implement the alternative implementation that I had suggested:
|
Can you let me know which part of EiffelVision2 you can build on Windows? I will give it a try with I have scanned all the Eiffel_23.09 dir, looks like all the diamonds reported are in EV_ library, so if |
If you want to compare the result of |
I want to build on the real code in Eiffel_23.09 distributed files. |
@ebezault Now, I want your opinion on this: Ultimately I want this functionality to be contributed back to the GOBO toolchain, but what's the best place to put it?
For me, I can do a prototype for option 2). For other options 1), 3), 4) probably you want do it since no one knows the interals of the GOBO compiler better than you. What do you think? |
You will have to let me a few days to think about it. I still did not have time to read your paper.
As for |
The essence of that paper is: ECMA Eiffel standard 8.16.2, and 8.6.16 are actually in conflict as demonstrated in this diamond field renaming example:
This is why SmartEiffel and GOBO implementations are different from ISE Eiffel: basically ISE did both 1) and 2) (which is wrong); while SmartEiffel and GOBO only did 1) (which is also wrong). (The correct implementation of 2) while honoring 1) is what have been proposed in the paper; and the ECMA Eiffel standard While both the current compiler implementation approaches are wrong, if I have to choose, I'd say ISE's implementation is more wrong: because it also defeats the original purpose of renaming to have separate features. I understand your goal to keep Regardless of the final outcome, a checker to detect the renamed fields in diamond inheritance and give warning messages to the programmers is always needed. |
Are we sure of that? There could be two attributes pointing to the same object. |
From this line:
you infer that:
But "same semantics" does not mean "identifical features", does it? |
and
This what Bertrand said "ambiguity": it's not made very precise in the ECMA standard what it supposed to mean. And in practice, SmartEiffel and GOBO completely ignored this rule; while ISE compiler implement it as reference identity. That's how ISE compiler implemented it, you can check and run the example code of |
This is what I get when compiled with ISE Eiffel:
Apparently the |
Ah? which version of ISE compiler you are using? on Windows? Linux? here is my result on Linux:
|
And regardless of 3 or 1 field, these last 2 lines of output are wrong in both GOBO and ISE compiler with respect to the programmer's intended application semantics. |
|
Are you using this Makefile: and
Let's try all the different platform and (non-)finalized mode. |
It's in finalized mode. I guess that you are in workbench (i.e. non-finalized mode). It's more likely to be the problem that the different of platform. |
I'm not using any Makefile. |
Let's try all the different platform and (non-)finalized mode. |
I get the same output as you in workbench mode under Windows. |
OK, I tried, (non-)finalized and finalized mode are different. This is an ISE compiler bug. |
So ISE Eiffel does not agree with itself between workbench and finalized mode! Interesting! |
But regardless of which finalized mode, these outputs are all wrong in both GOBO and ISE compiler. |
Even ISE Eiffel itself implemented two different field renaming semantics. |
BTW, @ebezault have you checked your @gobosoft.com email :-) |
Yes, but I still did not have time to review all your work. |
Now we can read my sentence as: I'd say ISE's workbench mode implementation is more wrong (than the finalized mode): because it also defeats the original purpose of renaming to have separate features. And it's been proven by their actual output behavior :-) |
Hi,
I want to find all the renamed attributes of a (AST processed) class in the gec compiler:
I have checked et_class.e
and found this navigation:
ET_CLASS.queries: ET_QUERY_LIST
ET_QUERY.is_attribute
but where to find if the attribute is a renamed one?
Thanks.
The text was updated successfully, but these errors were encountered: