Working subroutine of eval
354396
private Object evalInternal(
    Selector sel,
    MatchSpaceKey bind,
    EvalCache cache,
    Object contextValue,
    boolean permissive)
    throws BadMessageFormatMatchingException
  {
    if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.entry(cclass, "evalInternal", new Object[] { sel, bind, cache, contextValue, new Boolean(permissive) });
    
    Object theReturn = null;
    // If sel is a literal, its value is simply the literal's value
    if (sel instanceof Literal)
    {
      if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
        tc.debug(cclass, "Selector is a literal");         
      theReturn = ((Literal) sel).getValue();
      if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
        tc.exit(cclass, "evalInternal", theReturn);  
      return theReturn;
    }

    // If sel is an Identifier, we let the MatchSpaceKey evaluate it.  The MatchSpaceKey is
    // given explicit type information unless the evaluation mode is permissive, in which
    // case the value is retrieved regardless and the permissive casts are applied.

    if (sel instanceof Identifier)
    {
      if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
        tc.debug(cclass, "Selector is an Identifier");        
      Identifier id = (Identifier) sel;
      if (permissive && id.getType() != Selector.UNKNOWN)
      {
        // Result may require permissive mode casts.  First, get the value, whatever it
        // is.
        boolean returnList = true;
        if(id.getType() == Selector.BOOLEAN)
          returnList = false;
        Object idVal = 
          bind.getIdentifierValue(id,
                                  true,
                                  contextValue, 
                                  returnList); // true means return a nodelist
        if (idVal == null)
        {
          if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
            tc.exit(cclass, "evalInternal", null);            
          return null;
        }
        // Perform permissive casts
        switch (id.getType())
        {
          case Selector.NUMERIC :
            if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
              tc.debug(cclass, "Selector type is numeric");               
            if (idVal instanceof Number) // was NumericValue
            {
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", idVal);                
              return idVal;
            }
            else
            {
              if(idVal instanceof ArrayList)
              {
                theReturn = castToNumberList((ArrayList)idVal);
              }
              else
                theReturn = castToNumber(idVal);
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", theReturn);
              return theReturn;
            }
          case Selector.STRING :
            if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
              tc.debug(cclass, "Selector type is string");              
            if (idVal instanceof String)
            {
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", idVal);                
              return idVal;
            }
            else
            {
              if(idVal instanceof ArrayList)
              {
                theReturn = castToStringList((ArrayList)idVal);
              }
              else
                theReturn = idVal.toString();
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", theReturn);
              return theReturn;
            }            
          case Selector.BOOLEAN :
            if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
              tc.debug(cclass, "Selector type is boolean");              
            if (idVal instanceof Boolean) // was BooleanValue
            {
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", idVal);                
              return idVal;
            }
            else
            {
              theReturn = castToBoolean(idVal);
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", theReturn);            
              return theReturn;              
            }
          default :
            if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
              tc.debug(cclass, "Selector type is default");              
            // Normally, permissive mode evaluation would not apply to TOPIC and OBJECT
            // Identifiers.  But, in any case, there are no valid casts to those types.
            if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
              tc.exit(cclass, "evalInternal", null);              
            return null;
        }
      }
      else
      {
        // not permissive, or the type is UNKNOWN so no permissive mode casts apply
        boolean returnList = true;
        if(id.getType() == Selector.BOOLEAN)
          returnList = false;
        theReturn = 
          bind.getIdentifierValue(id,
                                  false,
                                  contextValue, 
                                  returnList); // true means return a nodelist
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);         
        return theReturn;
      }
    }

    // Otherwise, it's an Operator
    Operator op = (Operator) sel;
    if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
      tc.debug(cclass, "Selector is an operator");  
    // Evaluate the operands to obtain the values needed to evaluate the operator
    Object val0 = eval(op.getOperands()[0], bind, cache, contextValue, permissive); // was false
    Object val1 =
      (op.getOperands().length == 1)
        ? null
        : eval(op.getOperands()[1], bind, cache, contextValue, permissive); // was false

    // Evaluate according to the operator
    switch (op.getOp())
    {
      case Selector.NOT :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is NOT");         
        if (val0 instanceof Boolean) 
        {
          theReturn = not((Boolean) val0);
          if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
            tc.exit(cclass, "evalInternal", theReturn);         
          return theReturn;          
        }
        else
          if (permissive && val0 != null)
          {
            theReturn = not(castToBoolean(val0));
            if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
              tc.exit(cclass, "evalInternal", theReturn);         
            return theReturn;            
          }
          else
          {
            if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
              tc.exit(cclass, "evalInternal", null);              
            return null; 
          }
      case Selector.NEG :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is NEG");         
        if (!(val0 instanceof Number)) // was NumericValue
          if (permissive && val0 != null)
          {
            val0 = castToNumber(val0);
            if (val0 == null)
            {
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", null);               
              return null;
            }
          }
          else
          {
            if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
              tc.exit(cclass, "evalInternal", null);             
            return null;
          }
        // val0 is now definitely a Number
        return neg((Number)val0);
      case Selector.ISNULL :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type ISNULL");
        theReturn = Boolean.valueOf(val0 == null);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);         
        return theReturn;         
      case Selector.LIKE :
      case Selector.TOPIC_LIKE:
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is LIKE");        
        if (!(val0 instanceof String))
          if (permissive && val0 != null)
            val0 = val0.toString();
          else
          {
            if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
              tc.exit(cclass, "evalInternal", null);              
            return null;
          }
        // val0 is a String
        theReturn = Boolean.valueOf(((LikeOperatorImpl) op)
            .getInternalPattern().match((String) val0));
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);           
        return theReturn;
      case Selector.NE :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is NE");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, false);
        else
          theReturn = not(compare(val0, val1, false, permissive));
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);           
        return theReturn;        
      case Selector.EQ :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is EQ");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, true);
        else        
          theReturn = compare(val0, val1, false, permissive);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn); 
        return theReturn;
      case Selector.GT :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is GT");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, true);
        else              
          theReturn = compare(val1, val0, true, permissive);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn); 
        return theReturn;        
      case Selector.LT :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is LT");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, true);
        else              
          theReturn = compare(val0, val1, true, permissive);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn); 
        return theReturn;         
      case Selector.GE :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is GE");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, false);
        else              
          theReturn = not(compare(val0, val1, true, permissive));
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn); 
        return theReturn;          
      case Selector.LE :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is LE");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, false);
        else              
          theReturn = not(compare(val1, val0, true, permissive));
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn); 
        return theReturn;          
      case Selector.PLUS :
      case Selector.MINUS :
      case Selector.TIMES :
      case Selector.DIV :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is ARITHMETIC");          
        theReturn = promoteAndEvaluate(op.getOp(), val0, val1, permissive);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);         
        return theReturn;
      case Selector.AND :
      case Selector.OR :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is ANDOR");          
        if (!(val0 instanceof Boolean)) // was BooleanValue
          if (permissive && val0 != null)
            val0 = castToBoolean(val0);
        if (!(val1 instanceof Boolean)) // was BooleanValue
          if (permissive && val1 != null)
            val1 = castToBoolean(val1);
        if (op.getOp() == Operator.AND)
          theReturn = and((Boolean) val0, (Boolean) val1);
        else
          theReturn = or((Boolean) val0, (Boolean) val1);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);         
        return theReturn;        
      default :
        // Should not occur
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is DEFAULT");          
        throw new IllegalStateException();
    }
  }
985764
def _eval_args(args):
    """"""
    res = []
    for arg in args:
        if not isinstance(arg, tuple):
            res.append(arg)
        elif is_callable_type(arg[0]):
            callable_args = _eval_args(arg[1:])
            if len(arg) == 2:
                res.append(Callable[[], callable_args[0]])
            elif arg[1] is Ellipsis:
                res.append(Callable[..., callable_args[1]])
            else:
                res.append(Callable[list(callable_args[:-1]), callable_args[-1]])
        else:
            res.append(type(arg[0]).__getitem__(arg[0], _eval_args(arg[1:])))
    return tuple(res)
185579
public Object eval( String statements ) throws EvalError {
        Interpreter.debug("eval(String): ", statements);
        return eval(statements, globalNameSpace);
    }
48362
def evaluate(node, indent)
      # Check if this is a substructure of a control block and remove the last
      # end evaluation if it is
      if node[@value] =~ Settings::END_REMOVAL
        @template.pop if @template[-1] == [:eval, 'end']
      end

      # Check for explicit end node
      if node[@value] =~ Settings::END_EXPLICIT
        Logger.error :compile, @template, :explicit_end, node
      end

      # Evaluate the current expression
      buffer_eval node[@value]

      # If the node has children, evaluate each one of them
      node[@children].each do |child|
        root child, indent + @settings[:indent]
      end if node[@children]

      # Check if the node is actually a block expression
      buffer_eval 'end' if node[@value] =~ Settings::END_INSERTION
    end
12345
def eval_py(self, _globals, _locals):
        
        try:
            params = eval(self.script, _globals, _locals)
        except NameError as e:
            raise Exception(
                'Failed to evaluate parameters: {}'
                .format(str(e))
            )
        except ResolutionError as e:
            raise Exception('GetOutput: {}'.format(str(e)))

        return params
745561
function evalList(scope, list) {
  const length = list.length;
  const result = [];
  for (let i = 0; i < length; i++) {
    result[i] = list[i].evaluate(scope);
  }
  return result;
}
894902
function __eval(__source, __global, load) {
    // Hijack System.register to set declare function
    System.__curRegister = System.register;
    System.register = function(name, deps, declare) {
      // store the registered declaration as load.declare
      load.declare = typeof name == 'string' ? declare : deps;
    }
    eval('var __moduleName = "' + (load.name || '').replace('"', '\"') + '"; (function() { ' + __source + ' \n }).call(__global);');

    System.register = System.__curRegister;
    delete System.__curRegister;
  }
1020099
def evaluate_expression(expression, vars):
    ''''''
    try:
        v = eval(expression, globals(), vars)
    except NameError:
        return None
    except ZeroDivisionError:
        return None
    return v
175104
def run_evaluate(self) -> None:
        
        result = None
        self.eval_error = False
        if self._needs_evaluation:
            result = self._schema.value.evaluate(self._evaluation_context)

        self.eval_error = result is None
        if self.eval_error:
            return

        # Only set the value if it conforms to the field type
        if not self._schema.is_type_of(result):
            try:
                result = self._schema.type_object(result)
            except Exception as err:
                logging.debug('{} in casting {} to {} for field {}. Error: {}'.format(
                    type(err).__name__, result, self._schema.type,
                    self._schema.fully_qualified_name, err))
                self.eval_error = True
                return

        try:
            result = self._schema.sanitize_object(result)
        except Exception as err:
            logging.debug('{} in sanitizing {} of type {} for field {}. Error: {}'.format(
                type(err).__name__, result, self._schema.type, self._schema.fully_qualified_name,
                err))
            self.eval_error = True
            return

        self.value = result
1032206
static function evalConstant ($exp, &$valid = null)
  {
    $exp = trim ($exp);
    if ($exp !== '') {
      $valid = true;
      if ($exp[0] == '"' || $exp[0] == "'") return substr ($exp, 1, -1);
      if (is_numeric ($exp)) {
        return ctype_digit ($exp) ? intval ($exp) : floatVal ($exp);
      }
      if (defined ($exp))
        return constant ($exp);
    }
    $valid = false;
    return null;
  }
983623
static function run ($_code)
  {
    if (ctype_space ($_code[0]))
      $_code = ltrim ($_code);
    if (substr ($_code, 0, 5) == '<?php')
      return eval (substr ($_code, 5));
    return eval ($_code);
  }
1259170
function eval$if(params) {
  var script = params.$if
              ? params.$then
              : typeof params.$else == 'undefined' ? null : params.$else;
  return isScript(script)
          ? new this.js.Script(script)
          : script;
}
196053
def eval(self):
        
        Expr.ignore = False
        result = self.try_eval()
        Expr.ignore = True

        return result
1216900
def _evaluate(expression, defines):
    
    #interpolated = _interpolate(s, defines)
    try:
        defined = {'defined': (lambda v: v in defines)}
        return_value = eval(expression, defined, defines)
    except Exception, ex:
        message = str(ex)
        if message.startswith("name '") and message.endswith("' is not defined"):
            # A common error (at least this is presumed:) is to have
            #   defined(FOO)   instead of   defined('FOO')
            # We should give a little insight into what might be wrong.
            # message == "name 'FOO' is not defined"
            #    -->  variable_name == "FOO"
            variable_name = message[len("name '"):-len("' is not defined")]
            if expression.find("defined(%s)" % variable_name) > -1:
                # "defined(FOO)" in expr instead of "defined('FOO')"
                message += ''' (perhaps you want `defined('%s')` instead of `defined(%s)`)''' % (variable_name, variable_name)
        elif message.startswith("invalid syntax"):
            message = "invalid syntax: `%s`" % expression
        raise PreprocessorError(message, defines['__FILE__'], defines['__LINE__'])

    logger.debug("evaluate %r -> %s (defines=%r)", expression, return_value, defines)
    return return_value
268240
def do_eval(self, inputs, ctx):
        """"""
        return cwltool.expression.do_eval(
            self.expr, inputs, self.req, None, None, {}, context=ctx)
580752
def shell_eval(opts={})
      should_escape = opts[:escape] != false
      command = yield(should_escape ? shell.escape(path) : path)
      run command, :escape => should_escape
    end
310273
def eval_string(stri):
    ''
    tokens = shlex.split(stri)

    return run_write_read(['plash', 'eval'], '\n'.join(tokens).encode()).decode()