Closed GoogleCodeExporter closed 9 years ago
Try using getSourceVariable() and see if that works. (You'll have to get the
binding
from the declaration.)
getVariable() is not really meant to be used in this way: it returns the
variable
representing the result of evaluating the given (expression) node. A
declaration has
no result and is not an expression, hence getVariable() doesn't work. (We may
be
able to make it work, or at least document it more clearly. getVariable()
doesn't
just take an Expression AST node because it works for some things that are not
expressions according to the Eclipse AST, notably array stuffs I believe.)
The correct way to extend getVariable() to work with declarations is probably
to add
two lines into EclipseTAC.variable:
TACInstruction result = instruction(astNode);
if(result != null) {
if(result instanceof ResultfulInstruction)
return ((ResultfulInstruction<?>) result).getResultVariable();
if(result instanceof SourceVariableDeclaration)
return ((SourceVariableDeclaration) result).getDeclaredVariable();
throw ...
}
Original comment by kevin.bi...@gmail.com
on 9 Jun 2009 at 3:54
Using getSourceVariable fixed the problem. Thanks! I'll add documentation to
getVariable for now.
Original comment by ciera.christopher
on 9 Jun 2009 at 4:36
Original issue reported on code.google.com by
ciera.christopher
on 9 Jun 2009 at 1:43