tags:

views:

33

answers:

1

If I am getting an error on a function that a variable opcode may not have been initialized, should this be done inside this method or in the beginning of the class.

private void compileDo() {
        int endLabel, endLabelLoc, topLabel, opcode;
        accept("do");
        accept("(");
        compileExpr();
        accept(")");
        topLabel = cs.getPos();
        endLabelLoc = cs.emit(opcode, topLabel); 
        compileStatement();

    }

Any help would be most appreciated.

+1  A: 

something like this:

int  opcode = 0;

opcode is a local variable and hence, you should initialize within the function.

aJ