private void declareVariable(Variable var, LocalVariable localVar) {
            String name = var.getName();

            if (name == CONTEXT_PARAM_NAME) {
                mContextParam = new VariableRef(null, name);
                mContextParam.setVariable(var);
            }
            else if (name == SUB_PARAM_NAME) {
                mSubParam = new VariableRef(null, name);
                mSubParam.setVariable(var);
            }

            if (var.isField()) {
                if (mFields.get(name) != var) {
                    // Ensure field names are unique
                    int i = 0;
                    do {
                        name = var.getName() + '$' + i++;
                    } while (mFields.get(name) != null);

                    mFields.put(name, var);
                    var.setName(name);
                }
                mVariableMap.put(var, null);
            }
            else {
                if (localVar == null) {
                    TypeDesc desc = makeDesc(var);
                    localVar = mBuilder.createLocalVariable
                        (var.getName(), desc);
                }
                mVariableMap.put(var, localVar);
            }
        }