Detect the constant function changing the state

        Recursively visit the calls
        Returns:
            list: {'vuln', 'filename,'contract','func','#varsWritten'}
966008
def _detect(self):
        
        results = []
        for c in self.contracts:
            for f in c.functions:
                if f.contract != c:
                    continue
                if f.view or f.pure:
                    if f.contains_assembly:
                        attr = 'view' if f.view else 'pure'
                        info = '{}.{} ({}) is declared {} but contains assembly code\n'
                        info = info.format(f.contract.name, f.name, f.source_mapping_str, attr)
                        json = self.generate_json_result(info)
                        self.add_function_to_json(f, json)
                        json['elements'].append({'type': 'info',
                                                 'contains_assembly' : True})
                        results.append(json)

                    variables_written = f.all_state_variables_written()
                    if variables_written:
                        attr = 'view' if f.view else 'pure'
                        info = '{}.{} ({}) is declared {} but changes state variables:\n'
                        info = info.format(f.contract.name, f.name, f.source_mapping_str, attr)
                        for variable_written in variables_written:
                            info += '\t- {}.{}\n'.format(variable_written.contract.name,
                                                         variable_written.name)


                        json = self.generate_json_result(info)
                        self.add_function_to_json(f, json)
                        self.add_variables_to_json(variables_written, json)
                        json['elements'].append({'type': 'info',
                                                  'contains_assembly' : False})
                        results.append(json)

        return results
1147267
def differing_functions_with_consts(self):
        
        different_funcs = []
        for (func_a, func_b) in self.function_matches:
            if not self.functions_probably_identical(func_a, func_b, check_consts=True):
                different_funcs.append((func_a, func_b))
        return different_funcs
53739
def _detect(self):
        
        results = []
        for c in self.contracts:
            unindexed_params = self.detect_erc20_unindexed_event_params(c)
            if unindexed_params:
                info = "{} ({}) does not mark important ERC20 parameters as 'indexed':\n"
                info = info.format(c.name, c.source_mapping_str)
                for (event, parameter) in unindexed_params:
                    info += "\t-{} ({}) does not index parameter '{}'\n".format(event.name, event.source_mapping_str, parameter.name)

                # Add the events to the JSON (note: we do not add the params/vars as they have no source mapping).
                json = self.generate_json_result(info)
                self.add_functions_to_json([event for event, _ in unindexed_params], json)
                results.append(json)

        return results
732138
def get_constantvalue(self):
          # noqa

        buff = self.get_attribute("ConstantValue")
        if buff is None:
            return None

        with unpack(buff) as up:
            (cval_ref, ) = up.unpack_struct(_H)

        return cval_ref
1155887
function unwrapSync (x) {
  if (!x || (typeof x !== 'object' && typeof x !== 'function')) {
    return x
  }

  const then = x.then
  if (typeof then !== 'function') return x

  let state = constants.PENDING
  let value
  const unwrapValue = y => {
    if (state === constants.PENDING) {
      state = constants.RESOLVED
      value = y
    }
  }
  const unwrapReason = r => {
    if (state === constants.PENDING) {
      state = constants.REJECTED
      value = r
    }
  }
  then.call(x, unwrapValue, unwrapReason)

  if (state === constants.PENDING) {
    state = constants.ASYNC
    throw new UnwrapError(x)
  }

  if (state === constants.RESOLVED) {
    return unwrapSync(value)
  }

  // state === REJECTED
  throw value
}
594647
def _detect(self):
        
        results = []
        for c in self.slither.contracts_derived:
            unusedVars = self.detect_unused(c)
            if unusedVars:
                info = ''
                for var in unusedVars:
                    info += "{}.{} ({}) is never used in {}\n".format(var.contract.name,
                                                                      var.name,
                                                                      var.source_mapping_str,
                                                                      c.name)


                json = self.generate_json_result(info)
                self.add_variables_to_json(unusedVars, json)
                results.append(json)

        return results
307708
def detect_arbitrary_send(self, contract):
        
        ret = []
        for f in [f for f in contract.functions if f.contract == contract]:
            nodes = self.arbitrary_send(f)
            if nodes:
                ret.append((f, nodes))
        return ret
581915
def constants(self):
        

        for i in range(1, len(self.consts)):
            t, _v = self.consts[i]
            if t:
                yield (i, t, self.deref_const(i))
787302
def _detect(self):
        
        results = []
        for c in self.contracts:
            functions = self.detect_suicidal(c)
            for func in functions:

                txt = "{}.{} ({}) allows anyone to destruct the contract\n"
                info = txt.format(func.contract.name,
                                  func.name,
                                  func.source_mapping_str)

                json = self.generate_json_result(info)
                self.add_function_to_json(func, json)
                results.append(json)

        return results
774355
def literals():
        '''
        '''
        def fget(self):
            if self.variants:
                return map(lambda x: x.literal,
                           self.variants)
            else:
                return None
 
        return locals()
145295
def _ensureAtomicity(fn):
    """"""
    @ensureScoopStartedProperly
    def wrapper(*args, **kwargs):
        """setConst(**kwargs)
        Set a constant that will be shared to every workers.
        This call blocks until the constant has propagated to at least one
        worker.

        :param \*\*kwargs: One or more combination(s) key=value. Key being the
            variable name and value the object to share.

        :returns: None.

        Usage: setConst(name=value)
        """
        # Note that the docstring is the one of setConst.
        # This is because of the documentation framework (sphinx) limitations.

        from . import _control

        # Enforce retrieval of currently awaiting constants
        _control.execQueue.socket.pumpInfoSocket()

        for key, value in kwargs.items():
            # Object name existence check
            if key in itertools.chain(*(elem.keys() for elem in elements.values())):
                raise TypeError("This constant already exists: {0}.".format(key))

        # Retry element propagation until it is returned
        while all(key in elements.get(scoop.worker, []) for key in kwargs.keys()) is not True:
            scoop.logger.debug("Sending global variables {0}...".format(
                list(kwargs.keys())
            ))
            # Call the function
            fn(*args, **kwargs)

            # Enforce retrieval of currently awaiting constants
            _control.execQueue.socket.pumpInfoSocket()

            # TODO: Make previous blocking instead of sleep
            time.sleep(0.1)

        # Atomicity check
        elementNames = list(itertools.chain(*(elem.keys() for elem in elements.values())))
        if len(elementNames) != len(set(elementNames)):
            raise TypeError("This constant already exists: {0}.".format(key))

    return wrapper
120705
def detect_dangerous_timestamp(self, contract):
        
        ret = []
        for f in [f for f in contract.functions if f.contract == contract]:
            nodes = self.timestamp(f)
            if nodes:
                ret.append((f, nodes))
        return ret
237063
function getConstantViolationsBefore(binding, path, functions) {
  var violations = binding.constantViolations.slice();
  violations.unshift(binding.path);
  return violations.filter(function (violation) {
    violation = violation.resolve();
    var status = violation._guessExecutionStatusRelativeTo(path);
    if (functions && status === "function") functions.push(violation);
    return status === "before";
  });
}
1004567
def trace(f):
    
    @functools.wraps(f)
    def decorator(*args, **kwargs):
        print 'Calling ' + f.func_name + ' in ' + str(args[0])
        return f(*args, **kwargs)
    return decorator
906133
def get_current_args(caller_level = 0, func = None, argNames = None):
    
    if argNames is None:
        argNames = getargnames(getargspecs(func))
    if func is None:
        func = get_current_function(caller_level+1)
    if isinstance(func, property):
        func = func.fget if func.fset is None else func.fset
    stck = inspect.stack()
    lcs = stck[1+caller_level][0].f_locals
    return tuple([lcs[t] for t in argNames])
1248312
def constants(opts = {})
      opts = SymbolHash[:included => true].update(opts)
      consts = children.select {|o| o.is_a? ConstantObject }
      consts + (opts[:included] ? included_constants : [])
    end
182471
def get_functarguments(func):
    
    argspec = inspect.getargspec(func)
    if argspec.defaults is not None:
        args = argspec.args[:-len(argspec.defaults)]
        kwargs = dict(
            zip(argspec.args[-len(argspec.defaults):], argspec.defaults))
    else:
        args = argspec.args
        kwargs = {}
    if args and args[0] == 'self':
        args.pop(0)
    func.__named__ = []
    arguments = []
    shared = get_shared(func)
    for arg in args:
        if has_shared(arg, shared) is not False:
            continue
        if has_argument(arg, func.__cls__) is not False:
            continue
        arguments.append(([arg], {}, ))
        func.__named__.append(arg)
    for key, val in kwargs.items():
        if has_shared(key, shared) is not False:
            continue
        if has_argument(key, func.__cls__) is not False:
            continue
        if isinstance(val, dict):
            flags = [val.pop('lflag', '--%s' % key)]
            short = val.pop('flag', None)
            dest = val.get('dest', key).replace('-', '_')
            if short:
                flags.insert(0, short)
        else:
            flags = ['--%s' % key]
            val = dict(default=val)
            dest = key.replace('-', '_')
        func.__named__.append(dest)
        arguments.append((flags, val, ))
    return arguments