roterdam / crystalsaf

Automatically exported from code.google.com/p/crystalsaf
0 stars 0 forks source link

Non-final variables exception #23

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Getting the following exception:

java.lang.IllegalArgumentException: Non-final variables must be declared 
locally: float v[pos: 1][id:3][pc: 0-13]
    at edu.cmu.cs.crystal.tac.model.SourceVariable.<init>(SourceVariable.java:58)
    at edu.cmu.cs.crystal.tac.eclipse.EclipseTAC.getVariable(EclipseTAC.java:456)
    at edu.cmu.cs.crystal.tac.eclipse.EclipseTAC.sourceVariable(EclipseTAC.java:237)
    at edu.cmu.cs.crystal.tac.eclipse.EclipseTACInstructionFactory.create(EclipseTACInstructionFactory.java:504)
    at edu.cmu.cs.crystal.tac.eclipse.EclipseTAC$NewInstructionVisitor.visit(EclipseTAC.java:900)
    at org.eclipse.jdt.core.dom.SimpleName.accept0(SimpleName.java:148)
    at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
    at edu.cmu.cs.crystal.tac.eclipse.EclipseTAC.createInstruction(EclipseTAC.java:504)
    at edu.cmu.cs.crystal.tac.eclipse.EclipseTAC.instruction(EclipseTAC.java:201)

When analyzing the attached code.

I'm not yet sure which part is causing the problem. Narrowing that down on 
Monday.

Kevin, can you scan this and see if anything jumps out at you as being 
unexpected for TAC?

Original issue reported on code.google.com by ciera.christopher on 12 Nov 2010 at 8:38

Attachments:

GoogleCodeExporter commented 9 years ago
Narrowed it down to the method. The problem comes when analyzing 
TimeOptionHandler.handleOptions(String, SVGConverter). I presume it's something 
about that anonymous inner class? All non-final variables appear to be locally 
declared to me. v is local, and c is final.

        public void handleOption(String optionValue, final SVGConverter c) {
            try {
                ClockParser p = new ClockParser(false);
                p.setClockHandler(new ClockHandler() {
                    public void clockValue(float v) {
                        handleOption(v, c);
                    }
                });
                p.parse(optionValue);
            } catch (ParseException e) {
                throw new IllegalArgumentException();
            }
        }

Original comment by ciera.christopher on 12 Nov 2010 at 9:24

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
aken problem to following:

The problem is local variables (in example, the float v). When creating a new 
source variable, we have to determine whether the variable is local. The last 
parameter determines this.

This line however is incorrect (in EclipseTAC, getVariable(IBinding), line 456):

result = new SourceVariable(vb.getName(), vb, method.equals(declaredIn));

The last param is meant to determine whether we have a local. However, 
declaredIn is clockValue, and method is handleOption.

Not sure how to fix this. I considered changing method to a stack of methods, 
but it doesn't seem that the visitor walks the entire thing right away. It 
looks like instead, the  TAC are created on demand. In which case, I need to 
find an alternate way of determining whether the variable is a locally declared 
variable.

Original comment by ciera.christopher on 16 Nov 2010 at 6:11