Program: 72325
Project: 72325
Buggy source:
/** 
 * Create a new parameter if it does not already exist. The options argument can specify a "type", a "description", "visibility", and/or a "value". If a type is given, set the type as specified. Otherwise, leave the type unspecified so that it will be inferred from the value. If a description is given, then create, append to, or modify the DocAttribute named "documentation" contained by this actor to include documentation of this output. If a value is given, then set the default value of the parameter if it does not already have a value.
 * @param name The name of the parameter.
 * @param options The options, or null to accept the defaults.
 * @return The previous value of this parameter, if it has one, andnull otherwise.
 * @exception IllegalActionException If no name is given.
 * @exception NameDuplicationException If the name is a reserved word, or if an attributealready exists with the name and is not a parameter.
 */
public Token parameter(String name,Map<String,Object> options) throws IllegalActionException, NameDuplicationException {
  if (name == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  Attribute parameter=getAttribute(name);
  if (parameter == null) {
    parameter=new Parameter(this,name);
  }
 else {
    if (parameter == script) {
      throw new NameDuplicationException(this,"String_Node_Str" + name);
    }
 else     if (!(parameter instanceof Parameter)) {
      throw new NameDuplicationException(this,"String_Node_Str" + name);
    }
  }
  Token result=null;
  if (options != null) {
    Type ptType=null;
    Object type=options.get("String_Node_Str");
    if (type instanceof String) {
      ptType=_typeAccessorToPtolemy((String)type,parameter);
    }
 else     if (type != null) {
      throw new IllegalActionException(this,"String_Node_Str" + type);
    }
    if (ptType != null) {
      ((Parameter)parameter).setTypeEquals(ptType);
    }
    _setOptionsForSelect(parameter,options);
    Object value=options.get("String_Node_Str");
    if (value != null && !parameter.isOverridden()) {
      Object token;
      try {
        token=((Invocable)_engine).invokeFunction("String_Node_Str",value);
      }
 catch (      Exception e) {
        throw new IllegalActionException(this,e,"String_Node_Str" + value);
      }
      if (token instanceof Token) {
        ((Parameter)parameter).setToken((Token)token);
      }
 else {
        throw new IllegalActionException(this,"String_Node_Str" + value);
      }
      parameter.setDerivedLevel(1);
    }
    if (parameter.isOverridden()) {
      result=((Parameter)parameter).getToken();
    }
    Object visibility=options.get("String_Node_Str");
    if (visibility instanceof String) {
      String generic=((String)visibility).trim().toLowerCase();
switch (generic) {
case "String_Node_Str":
        if (parameter instanceof Variable) {
          ((Variable)parameter).setVisibility(Settable.NONE);
        }
      break;
case "String_Node_Str":
    if (parameter instanceof Variable) {
      ((Variable)parameter).setVisibility(Settable.EXPERT);
    }
  break;
case "String_Node_Str":
if (parameter instanceof Variable) {
  ((Variable)parameter).setVisibility(Settable.NOT_EDITABLE);
}
break;
default :
if (parameter instanceof Variable) {
((Variable)parameter).setVisibility(Settable.FULL);
}
}
}
Object description=options.get("String_Node_Str");
if (description != null) {
_setPortDescription(parameter,description.toString());
}
}
if (_proxies.get(parameter) == null) {
PortOrParameterProxy proxy=new PortOrParameterProxy(parameter);
_proxies.put(parameter,proxy);
_proxiesByName.put(parameter.getName(),proxy);
}
return result;
}

Fixed version (ground truth):
/** 
 * Create a new parameter if it does not already exist. The options argument can specify a "type", a "description", "visibility", and/or a "value". If a type is given, set the type as specified. Otherwise, leave the type unspecified so that it will be inferred from the value. If a description is given, then create, append to, or modify the DocAttribute named "documentation" contained by this actor to include documentation of this output. If a value is given, then set the default value of the parameter if it does not already have a value.
 * @param name The name of the parameter.
 * @param options The options, or null to accept the defaults.
 * @return The previous value of this parameter, if it has one, andnull otherwise.
 * @exception IllegalActionException If no name is given.
 * @exception NameDuplicationException If the name is a reserved word, or if an attributealready exists with the name and is not a parameter.
 */
public Token parameter(String name,Map<String,Object> options) throws IllegalActionException, NameDuplicationException {
  if (name == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  Attribute parameter=getAttribute(name);
  if (parameter == null) {
    parameter=new Parameter(this,name);
  }
 else {
    if (parameter == script) {
      throw new NameDuplicationException(this,"String_Node_Str" + name);
    }
 else     if (!(parameter instanceof Parameter)) {
      throw new NameDuplicationException(this,"String_Node_Str" + name);
    }
  }
  Token result=null;
  if (options != null) {
    Type ptType=null;
    Object type=options.get("String_Node_Str");
    if (type instanceof String) {
      ptType=_typeAccessorToPtolemy((String)type,parameter);
    }
 else     if (type != null) {
      throw new IllegalActionException(this,"String_Node_Str" + type);
    }
    if (ptType != null) {
      ((Parameter)parameter).setTypeEquals(ptType);
    }
    _setOptionsForSelect(parameter,options);
    Object value=options.get("String_Node_Str");
    if (value != null && !parameter.isOverridden() && parameter.getDerivedLevel() == Integer.MAX_VALUE) {
      Object token;
      try {
        token=((Invocable)_engine).invokeFunction("String_Node_Str",value);
      }
 catch (      Exception e) {
        throw new IllegalActionException(this,e,"String_Node_Str" + value);
      }
      if (token instanceof Token) {
        ((Parameter)parameter).setToken((Token)token);
      }
 else {
        throw new IllegalActionException(this,"String_Node_Str" + value);
      }
      parameter.setDerivedLevel(1);
    }
    if (parameter.isOverridden()) {
      result=((Parameter)parameter).getToken();
    }
    Object visibility=options.get("String_Node_Str");
    if (visibility instanceof String) {
      String generic=((String)visibility).trim().toLowerCase();
switch (generic) {
case "String_Node_Str":
        if (parameter instanceof Variable) {
          ((Variable)parameter).setVisibility(Settable.NONE);
        }
      break;
case "String_Node_Str":
    if (parameter instanceof Variable) {
      ((Variable)parameter).setVisibility(Settable.EXPERT);
    }
  break;
case "String_Node_Str":
if (parameter instanceof Variable) {
  ((Variable)parameter).setVisibility(Settable.NOT_EDITABLE);
}
break;
default :
if (parameter instanceof Variable) {
((Variable)parameter).setVisibility(Settable.FULL);
}
}
}
Object description=options.get("String_Node_Str");
if (description != null) {
_setPortDescription(parameter,description.toString());
}
}
if (_proxies.get(parameter) == null) {
PortOrParameterProxy proxy=new PortOrParameterProxy(parameter);
_proxies.put(parameter,proxy);
_proxiesByName.put(parameter.getName(),proxy);
}
return result;
}