Skip to content
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

review2: fix: expression type cast source positions #2113

Merged
merged 4 commits into from
Jun 28, 2018

Conversation

pvojtechovsky
Copy link
Collaborator

fix of #2055

@pvojtechovsky pvojtechovsky force-pushed the fixExpressionPosition branch 2 times, most recently from 08f4671 to 4f1f16f Compare June 26, 2018 21:50
@pvojtechovsky pvojtechovsky changed the title WIP: test: Expression source position review2: fix: expression type cast source positions Jun 26, 2018
@@ -935,7 +936,10 @@ public boolean visit(BreakStatement breakStatement, BlockScope scope) {

@Override
public boolean visit(CastExpression castExpression, BlockScope scope) {
context.casts.add(this.references.buildTypeReference(castExpression.type, scope));
CastInfo ci = new CastInfo();
ci.nrOfBrackets = ((castExpression.bits >>> 21) & 0xF);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok this is a low level one ;) Could you explain the operation in a comment please?


@Test
public void testExpressions() throws Exception {
//contract: the expression parameter declared like `String arg[]`, `String[] arg` and `String []arg` has correct positions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be a cut/paste contract not related to what you test

@spoon-bot
Copy link
Collaborator

API changes: 1 (Detected by Revapi)

Old API: fr.inria.gforge.spoon:spoon-core:jar:6.3.0-20180627.174231-177 / New API: fr.inria.gforge.spoon:spoon-core:jar:6.3.0-SNAPSHOT

Method was added to an interface.
Old none
New method CoreFactory#createCompoundSourcePosition(CompilationUnit, int, int, int, int, .Array)
Breaking binary: non_breaking,

@monperrus
Copy link
Collaborator

do we really to need a new interface? or would it be ok to only add a new implementation class?

@pvojtechovsky
Copy link
Collaborator Author

New interface is consistent with other SourcePosition based interfaces. And yes, I will write a code which will check whether source position implements CompoundSourcePosition. It is not nice to ask if it implements CompoundSourcePositionImpl.

@monperrus
Copy link
Collaborator

monperrus commented Jun 27, 2018 via email

@pvojtechovsky
Copy link
Collaborator Author

I agree with you, but let's refactor all source position interfaces to keep whole SourcePosition model consistent.... but then it is a lot of changes :-}

@monperrus
Copy link
Collaborator

OK, so you would go with this one unmodified?

@pvojtechovsky
Copy link
Collaborator Author

OK, so you would go with this one unmodified?

yes, I prefer to keep one same pattern (iface + class) for all SourcePosition interfaces first. If we decide that this pattern is wrong in this case, then we should refactor it on all places where it occurs. I agree with this refactoring, but it should be different PR.

@monperrus
Copy link
Collaborator

rebase?

@pvojtechovsky
Copy link
Collaborator Author

rebase done

@@ -935,7 +936,11 @@ public boolean visit(BreakStatement breakStatement, BlockScope scope) {

@Override
public boolean visit(CastExpression castExpression, BlockScope scope) {
context.casts.add(this.references.buildTypeReference(castExpression.type, scope));
CastInfo ci = new CastInfo();
//the 8 bits from 21 to 28 represents number of enclosing brackets
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my information, because I'm curious ;) It's something you obtained by reverse engineering or there's a documentation somewhere with that info?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a documentation of these bits in source code of compiler ... and I needed some luck to found it ;-)

@monperrus monperrus merged commit 45c7017 into INRIA:master Jun 28, 2018
@surli
Copy link
Collaborator

surli commented Jun 28, 2018

LGTM

@pvojtechovsky pvojtechovsky deleted the fixExpressionPosition branch June 28, 2018 10:11
@surli surli mentioned this pull request Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants