A lazy wrapper around {@link #eval}.

<p>Useful for {@code {let ...}} and {@code {param ...}} commands where the expression may be
defined before being used.
356149
private SoyValueProvider lazyEval(final ExprNode expr, final SoyNode node) {
    return new SoyAbstractCachingValueProvider() {
      @Override
      protected SoyValue compute() {
        return eval(expr, node);
      }

      @Override
      public RenderResult status() {
        return RenderResult.done();
      }
    };
  }
1289121
public Object eval(
        Reader in, NameSpace nameSpace, String sourceFileInfo
            /*, CallStack callstack */ )
        throws EvalError
    {
        Object retVal = null;
        Interpreter.debug("eval: nameSpace = ", nameSpace);

        /*
            Create non-interactive local interpreter for this namespace
            with source from the input stream and out/err same as
            this interpreter.
        */
        Interpreter localInterpreter = new Interpreter(
            in, getOut(), getErr(), false, nameSpace, this, sourceFileInfo  );
        CallStack callstack = new CallStack( nameSpace );

        SimpleNode node = null;
        boolean eof = false;
        while( !eof )
        {
            try
            {
                eof = localInterpreter.readLine();
                if (localInterpreter.get_jjtree().nodeArity() > 0)
                {
                    node = (SimpleNode)localInterpreter.get_jjtree().rootNode();
                    // nodes remember from where they were sourced
                    node.setSourceFile( sourceFileInfo );

                    if ( TRACE )
                        println( "// " +node.getText() );

                    retVal = node.eval( callstack, localInterpreter );

                    // sanity check during development
                    if ( callstack.depth() > 1 )
                        throw new InterpreterError(
                            "Callstack growing: "+callstack);

                    if ( retVal instanceof ReturnControl ) {
                        retVal = ((ReturnControl)retVal).value;
                        break; // non-interactive, return control now
                    }
                }
            } catch(ParseException e) {
                if ( DEBUG.get() )
                    // show extra "expecting..." info
                    error( e.getMessage(DEBUG.get()) );

                // add the source file info and throw again
                e.setErrorSourceFile( sourceFileInfo );
                throw e;
            } catch ( InterpreterError e ) {
                throw new EvalError(
                    "Sourced file: "+sourceFileInfo+" internal Error: "
                    + e.getMessage(), node, callstack, e);
            } catch ( TargetError e ) {
                // failsafe, set the Line as the origin of the error.
                if ( e.getNode()==null )
                    e.setNode( node );
                e.reThrow("Sourced file: "+sourceFileInfo);
            } catch ( EvalError e) {
                if ( DEBUG.get())
                    e.printStackTrace();
                // failsafe, set the Line as the origin of the error.
                if ( e.getNode()==null )
                    e.setNode( node );
                e.reThrow( "Sourced file: "+sourceFileInfo );
            } catch ( Exception e) {
                if ( DEBUG.get())
                    e.printStackTrace();
                throw new EvalError(
                    "Sourced file: "+sourceFileInfo+" unknown error: "
                    + e.getMessage(), node, callstack, e);
            } finally {
                localInterpreter.get_jjtree().reset();

                // reinit the callstack
                if ( callstack.depth() > 1 ) {
                    callstack.clear();
                    callstack.push( nameSpace );
                }
            }
        }
        return Primitive.unwrap( retVal );
    }
1316695
public ExecutionContext createEvalExecutionContext(JSProgram eval, boolean direct) {
        // 10.4.2 (with caller)
        //System.err.println( "CREATE EVAL EXEC CONTEXT" );
        ExecutionContext context = null;

        Object evalThisBinding = null;
        LexicalEnvironment evalLexEnv = null;
        LexicalEnvironment evalVarEnv = null;

        if (!direct) {
            evalThisBinding = getGlobalContext().getObject();
            evalLexEnv = LexicalEnvironment.newGlobalEnvironment(getGlobalContext().getObject());
            evalVarEnv = LexicalEnvironment.newGlobalEnvironment(getGlobalContext().getObject());
        } else {
            evalThisBinding = this.thisBinding;
            evalLexEnv = this.getLexicalEnvironment();
            evalVarEnv = this.getVariableEnvironment();
        }

        if (eval.isStrict()) {
            LexicalEnvironment strictVarEnv = LexicalEnvironment.newDeclarativeEnvironment(this.getLexicalEnvironment());
            evalLexEnv = strictVarEnv;
            evalVarEnv = strictVarEnv;
        }

        context = new ExecutionContext(this.runtime, this, evalLexEnv, evalVarEnv, evalThisBinding, eval.isStrict());
        context.source = eval.getSource();
        context.fileName = eval.getFileName();
        //System.err.println( context.fileName + " >> " + context.source );
        context.performFunctionDeclarationBindings(eval, true);
        context.performVariableDeclarationBindings(eval, true);
        return context;
    }
1060748
private void evaluateExpressions() throws JspException {
        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        if (begin_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                    "begin", begin_, Integer.class, this, pageContext);
            if (r == null) {
                throw new NullAttributeException("forEach", "begin");
            }
            begin = ((Integer) r).intValue();
            validateBegin();
        }

        if (end_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                    "end", end_, Integer.class, this, pageContext);
            if (r == null) {
                throw new NullAttributeException("forEach", "end");
            }
            end = ((Integer) r).intValue();
            validateEnd();
        }

        if (step_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                    "step", step_, Integer.class, this, pageContext);
            if (r == null) {
                throw new NullAttributeException("forEach", "step");
            }
            step = ((Integer) r).intValue();
            validateStep();
        }

        if (items_ != null) {
            rawItems = ExpressionEvaluatorManager.evaluate(
                    "items", items_, Object.class, this, pageContext);
            // use an empty list to indicate "no iteration", if relevant
            if (rawItems == null) {
                rawItems = new ArrayList();
            }
        }
    }
289205
public static AbstractExpression evaluateExpression(AbstractExpression expr) {
        if (expr == null) {
            return null;
        }

        // Evaluate children first
        expr.setLeft(evaluateExpression(expr.getLeft()));
        expr.setRight(evaluateExpression(expr.getRight()));

        // Evaluate self
        if (ExpressionType.CONJUNCTION_AND == expr.getExpressionType()) {
            if (ExpressionType.VALUE_CONSTANT == expr.getLeft().getExpressionType()) {
                if (ConstantValueExpression.isBooleanTrue(expr.getLeft())) {
                    return expr.getRight();
                } else {
                    return expr.getLeft();
                }
            }
            if (ExpressionType.VALUE_CONSTANT == expr.getRight().getExpressionType()) {
                if (ConstantValueExpression.isBooleanTrue(expr.getRight())) {
                    return expr.getLeft();
                } else {
                    return expr.getRight();
                }
            }
        } else if (ExpressionType.CONJUNCTION_OR == expr.getExpressionType()) {
            if (ExpressionType.VALUE_CONSTANT == expr.getLeft().getExpressionType()) {
                if (ConstantValueExpression.isBooleanTrue(expr.getLeft())) {
                    return expr.getLeft();
                } else {
                    return expr.getRight();
                }
            }
            if (ExpressionType.VALUE_CONSTANT == expr.getRight().getExpressionType()) {
                if (ConstantValueExpression.isBooleanTrue(expr.getRight())) {
                    return expr.getRight();
                } else {
                    return expr.getLeft();
                }
            }
        } else if (ExpressionType.OPERATOR_NOT == expr.getExpressionType()) {
            AbstractExpression leftExpr = expr.getLeft();
            // function expressions can also return boolean. So the left child expression
            // can be expression which are not constant value expressions, so don't
            // evaluate every left child expr as constant value expression
            if ((VoltType.BOOLEAN == leftExpr.getValueType()) &&
                    (leftExpr instanceof ConstantValueExpression)) {
                if (ConstantValueExpression.isBooleanTrue(leftExpr)) {
                    return ConstantValueExpression.getFalse();
                } else {
                    return ConstantValueExpression.getTrue();
                }
            } else if (ExpressionType.OPERATOR_NOT == leftExpr.getExpressionType()) {
                return leftExpr.getLeft();
            } else if (ExpressionType.CONJUNCTION_OR == leftExpr.getExpressionType()) {
                // NOT (.. OR .. OR ..) => NOT(..) AND NOT(..) AND NOT(..)
                AbstractExpression l = new OperatorExpression(ExpressionType.OPERATOR_NOT, leftExpr.getLeft(), null);
                AbstractExpression r = new OperatorExpression(ExpressionType.OPERATOR_NOT, leftExpr.getRight(), null);
                leftExpr = new OperatorExpression(ExpressionType.CONJUNCTION_AND, l, r);
                return evaluateExpression(leftExpr);
            }
            // NOT (expr1 AND expr2) => (NOT expr1) || (NOT expr2)
            // The above case is probably not interesting to do for short circuit purpose
        }
        return expr;
    }
358463
private RLSupplier<Value> evaluate() {
		/* check if is there something to evaluate */
        if (stackRPN.empty()) {
            return () -> new StringValue("");
        }

		/* clean answer stack */
        stackAnswer.clear();

		/* get the clone of the RPN stack for further evaluating */
        @SuppressWarnings("unchecked")
        Stack stackRPN = (Stack) this.stackRPN.clone();

		/* evaluating the RPN expression */
        while (!stackRPN.empty()) {
            Object token = stackRPN.pop();
            if (token instanceof Value) {
                stackAnswer.push( (RLSupplier) ()->token );
            } else if (token instanceof Operator) {
                int arity = ((Operator) token).getArity();
                if ( arity == 2 ) {
                    RLSupplier a = (RLSupplier) stackAnswer.pop();
                    RLSupplier b = (RLSupplier) stackAnswer.pop();
                    stackAnswer.push( ((Operator) token).getEval(a,b));
                } else { // assume 1
                    RLSupplier a = (RLSupplier) stackAnswer.pop();
                    stackAnswer.push( ((Operator) token).getEval(a,null));
                }
            } else if (token instanceof VarPath) {
                VarPath vp = (VarPath) token;
                stackAnswer.push( vp.getEval() );
            } else if (token instanceof FuncOperand) {
                FuncOperand func = (FuncOperand) token;
                RLSupplier<Value> args[] = new RLSupplier[func.getArity()];
                for (int i = 0; i < args.length; i++) {
                    args[args.length-i-1] = ((RLSupplier<Value>)stackAnswer.pop());
                }
                stackAnswer.push(func.getEval(args));
            }
        }

        if (stackAnswer.size() > 1) {
            throw new QParseException("Some operator is missing");
        }

        return (RLSupplier<Value>) stackAnswer.pop();
    }
657734
private void evaluateExpressions() throws JspException {
        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        // 'value' attribute (mandatory)
        value = (Date) ExpressionEvaluatorManager.evaluate(
                "value", value_, Date.class, this, pageContext);

        // 'type' attribute
        if (type_ != null) {
            type = (String) ExpressionEvaluatorManager.evaluate(
                    "type", type_, String.class, this, pageContext);
        }

        // 'dateStyle' attribute
        if (dateStyle_ != null) {
            dateStyle = (String) ExpressionEvaluatorManager.evaluate(
                    "dateStyle", dateStyle_, String.class, this, pageContext);
        }

        // 'timeStyle' attribute
        if (timeStyle_ != null) {
            timeStyle = (String) ExpressionEvaluatorManager.evaluate(
                    "timeStyle", timeStyle_, String.class, this, pageContext);
        }

        // 'pattern' attribute
        if (pattern_ != null) {
            pattern = (String) ExpressionEvaluatorManager.evaluate(
                    "pattern", pattern_, String.class, this, pageContext);
        }

        // 'timeZone' attribute
        if (timeZone_ != null) {
            timeZone = ExpressionEvaluatorManager.evaluate(
                    "timeZone", timeZone_, Object.class, this, pageContext);
        }
    }
154368
public Object eval( String statements, NameSpace nameSpace )
        throws EvalError
    {
        String s = ( statements.endsWith(";") ? statements : statements+";" );
        return eval(
            new StringReader(s), nameSpace,
            "inline evaluation of: ``"+ showEvalString(s)+"''" );
    }
861026
public Object execEval(String arg) {
		try {
			return scriptEngine.eval("eval(" + arg + ")");
		} catch (ScriptException e) {
			throw new BundlingProcessException("Error while evaluating a script", e);
		}
	}
76547
@Override
  public Object eval(final byte[] script, final List<byte[]> keys, final List<byte[]> args) {
    return eval(script, toByteArray(keys.size()), getParamsWithBinary(keys, args));
  }
477956
private void evaluateExpressions() throws JspException {
        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        if (escapeXml_ != null) {
            Boolean b = (Boolean) ExpressionUtil.evalNotNull(
                    "out",
                    "escapeXml",
                    escapeXml_,
                    Boolean.class,
                    this,
                    pageContext);
            if (b == null) {
                escapeXml = false;
            } else {
                escapeXml = b.booleanValue();
            }
        }
    }
361708
public Object eval(Node node, Context ctx) {
        Object evalResult = null;
        if(node instanceof AstRoot){
            Object ret = null;
            Iterator<Node> it = node.iterator();
            while(it.hasNext()){
                Node n = it.next();
                ret = eval(n, ctx);
            }
            evalResult = ret;
        }else if(node instanceof Block){
            //{...}
            Context ctx1 = ctx.createChild();
            Iterator<Node> it = node.iterator();
            while(it.hasNext()){
                Node n = it.next();
                eval(n,ctx1);
            }
        }else if(node instanceof DoLoop){
            //do while(...) ...;
            Context ctx1 = ctx.createChild();
            do{
                try{
                    eval(((DoLoop) node).getBody(), ctx);
                }catch (LoopContinueException e){

                }catch (LoopBreakException e){
                    break;
                }
            }while (condition(((DoLoop) node).getCondition(),ctx1));
        }else if(node instanceof WhileLoop){
            //while(...){...}
            Context ctx1 = ctx.createChild();
            while(condition(((WhileLoop) node).getCondition(),ctx1)){
                try{
                    eval(((WhileLoop) node).getBody(), ctx1);
                }catch (LoopContinueException e){

                }catch (LoopBreakException e){
                    break;
                }
            }
        }else if(node instanceof ForInLoop){
            //for(x in y){...}
            Context ctx1 = ctx.createChild();
            Object o = get(((ForInLoop) node).getIteratedObject(),ctx);
            if(o instanceof Map){
                for(String s:((Map<String,Object>) o).keySet()){
                    AstNode it = ((ForInLoop) node).getIterator();
                    if(it instanceof VariableDeclaration){
                        String name = ((Name)((VariableDeclaration) it).getVariables().get(0).getTarget()).getIdentifier();
                        ctx1.getVariables().put(name, s);
                    }
                    try{
                        eval(((ForInLoop) node).getBody(),ctx1);
                    }catch (LoopContinueException e){

                    }catch (LoopBreakException e){
                        break;
                    }
                }
            }else if(o instanceof List){
                for(double i=0.0D;i<((List<Object>) o).size();i++){
                    AstNode it = ((ForInLoop) node).getIterator();
                    if(it instanceof VariableDeclaration){
                        String name = ((Name)((VariableDeclaration) it).getVariables().get(0).getTarget()).getIdentifier();
                        ctx1.getVariables().put(name,i);
                    }
                    try{
                        eval(((ForInLoop) node).getBody(),ctx1);
                    }catch (LoopContinueException e){

                    }catch (LoopBreakException e){
                        break;
                    }
                }
            }
        }else if(node instanceof ForLoop){
            //for(...;...;...){...}
            Context ctx1 = ctx.createChild();
            for(eval(((ForLoop) node).getInitializer(),ctx1);
                condition(((ForLoop) node).getCondition(),ctx1);
                eval(((ForLoop) node).getIncrement(),ctx1)){
                try{
                    eval(((ForLoop) node).getBody(), ctx1);
                }catch (LoopContinueException e){

                }catch (LoopBreakException e){
                    break;
                }
            }
        }else if(node instanceof NewExpression){
            //new ...;

        }else if(node instanceof IfStatement){
            //if(...){...}
            boolean c = condition(((IfStatement) node).getCondition(),ctx);
            if(c){
                eval(((IfStatement) node).getThenPart(), ctx.createChild());
            }else{
                if(((IfStatement) node).getElsePart()!=null){
                    eval(((IfStatement) node).getElsePart(),ctx.createChild());
                }
            }
        }else if(node instanceof SwitchStatement){
            //switch(...)
            Object o = get(((SwitchStatement) node).getExpression(), ctx);
            for(SwitchCase sc:((SwitchStatement) node).getCases()){
                boolean b = false;
                if(sc.isDefault()){
                    b = true;
                }else{
                    Object o2 = get(sc.getExpression(),ctx);
                    if(Objects.equals(o,o2)){
                        b = true;
                    }
                }
                if(b){
                    try{
                        for(AstNode s: sc.getStatements()){
                            eval(s, ctx);
                        }
                    }catch (LoopContinueException e){
                    }catch (LoopBreakException e){
                        break;
                    }
                }
            }
        }else if(node instanceof WithStatement){
            //with(...){...}

        }else if(node instanceof VariableDeclaration){
            //var ...
            for(VariableInitializer vi:((VariableDeclaration) node).getVariables()){
                String name = ((Name)vi.getTarget()).getIdentifier();
                ctx.getVariables().put(name,get(vi.getInitializer(), ctx));
            }
        }else if(node instanceof TryStatement){
            //try{...}catch(..){...}finally{...}
            try{
                Context ctx1 = ctx.createChild();
                eval(((TryStatement) node).getTryBlock(),ctx1);
            }catch (ScriptException e){
                for(CatchClause cc:((TryStatement) node).getCatchClauses()){
                    Context ctx1 = ctx.createChild();
                    ctx1.getVariables().put(cc.getVarName().getIdentifier(),e.getData());
                    if(cc.getCatchCondition()==null || condition(cc.getCatchCondition(), ctx1)){
                        eval(cc.getBody(),ctx1);
                    }
                }
            }finally {
                eval(((TryStatement) node).getFinallyBlock(),ctx);
            }
        }else if(node instanceof ThrowStatement){
            //throw ...;
            throw new ScriptException(get(((ThrowStatement) node).getExpression(),ctx));
        }else if(node instanceof ReturnStatement){
            //return ...;
            throw new FunctionReturnException(get(((ReturnStatement) node).getReturnValue(),ctx));
        }else if(node instanceof BreakStatement){
            //break;
            throw new LoopBreakException();
        }else if(node instanceof ContinueStatement){
            //continue;
            throw new LoopContinueException();
        }else if(node instanceof Scope && !(node instanceof FunctionNode)){
            //{...}
            Context ctx1 = ctx.createChild();
            for(AstNode n:((Scope) node).getStatements()){
                eval(n,ctx1);
            }
        }else{
            evalResult = get((AstNode)node,ctx);
        }
        return evalResult;
    }
293488
public Object eval( CallStack callstack, Interpreter interpreter) throws EvalError {
        if ( null != types )
            return types;

        types = new Class[countTypes()];
        if ( isUntyped() )
            types[0] = UNTYPED;
        else for ( int i=0; i< countTypes(); i++ )
            types[i] = ((BSHType) jjtGetChild(i)).getType( callstack, interpreter );

        return types;
    }

    public Class<?>[] getTypes() {
        return this.types;
    }
}
642590
private void evaluateExpressions() throws JspException {

        // 'basename' attribute (mandatory)
        basename = (String) ExpressionEvaluatorManager.evaluate(
                "basename", basename_, String.class, this, pageContext);

        // 'prefix' attribute (optional)
        if (prefix_ != null) {
            prefix = (String) ExpressionEvaluatorManager.evaluate(
                    "prefix", prefix_, String.class, this, pageContext);
        }
    }
1128696
final public ThenExpressionBuilder<T> ifExp() {
    return new ThenExpressionBuilder<T>(new ExpressionHandler<ThenBuilder<T>>() {
      public ThenBuilder<T> handleExpression(final Expression e) {
        return new ThenBuilder<T>(e, new IfStatementHandler<T>() {
          public T handleStatement(IfStatement ifStatement) {
            return statementHandler().handleStatement(ifStatement);
          }
        }, builder);
      }
    });
  }
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();
    }
  }
268240
def do_eval(self, inputs, ctx):
        """"""
        return cwltool.expression.do_eval(
            self.expr, inputs, self.req, None, None, {}, context=ctx)