'Add the given variable to this file
@see JSObject.addVariable'

def addVariable(self, name, value=None, metadata=None):

    assert (value is not None), 'no    value    given'
    v = self.variables.get(name, None)
    if (v is None):
        log.info('VAR:    %s    on    line    %d,    type:%r    (class    %r)', name, value.line, value.type, type(value))
        self.variables[name] = v = value
    elif (value.type and (not v.type)):
        log.debug('existing    VAR:%s,    setting    type:    %r', name, value.type)
        v.type = value.type
    if metadata:
        if (v.metadata is None):
            v.metadata = metadata
        else:
            v.metadata.update(metadata)
    return v
