/* Evaluates expressions as necessary
430446
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.
         */

        url = (String) ExpressionUtil.evalNotNull(
                "import", "url", url_, String.class, this, pageContext);
        if (url == null || url.equals("")) {
            throw new NullAttributeException("import", "url");
        }

        context = (String) ExpressionUtil.evalNotNull(
                "import", "context", context_, String.class, this, pageContext);
        charEncoding = (String) ExpressionUtil.evalNotNull(
                "import", "charEncoding", charEncoding_, String.class, this,
                pageContext);
    }
1228470
private boolean passesExpression(LoggingEvent event) {
    if (event != null) {
      if (expressionRule != null) {
        return (expressionRule.evaluate(event, null));
      }
    }
    return true;
  }
896307
protected String evaluateExpression(final String expression, final Map<String, ?> values) throws ExpressionEvaluationException {
        
        final Map<String, Object> context = new LinkedHashMap<String, Object>();
        context.putAll(values);
        
        // フォーマッターの追加
        context.computeIfAbsent("formatter", key -> new Formatter());
        
        final String value = expressionLanguage.evaluate(expression, context).toString();
        if(logger.isTraceEnabled()) {
            logger.trace("evaluate expression language: expression='{}' ===> value='{}'", expression, value);
        }
        
        return value;
    }
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);
        }
    }
1304852
@Override
	public Value evaluate(String line, Context ctxt) throws Exception
	{
		PExp expr = parseExpression(line, getDefaultName());
		Environment env = new ModuleEnvironment(assistantFactory, defaultModule);

		try
		{
			typeCheck(expr, env);
		} catch (VDMErrorsException e)
		{
			// We don't care... we just needed to type check it.
		}

		ctxt.threadState.init();

		try
		{
			return expr.apply(VdmRuntime.getExpressionEvaluator(), ctxt);
		} catch (Exception e)
		{
			throw e;
		}
	}
140174
def evaluate(expression):
    
    op_stack  = deque() # operator stack
    out_stack = deque() # output stack (values)
    tokens = parse(expression) # calls the function only once!
    for token in tokens:
        if numeric_value.match(token):
            out_stack.append(float(token))
        elif token == '(':
            op_stack.append(token)
        elif token == ')':
            while len(op_stack) > 0 and op_stack[-1] != '(':
                apply_operation(op_stack, out_stack)
            op_stack.pop() # Remove remaining '('
        else: # is_operator(token)
            while len(op_stack) > 0 and is_operator(op_stack[-1]) and higher_priority(op_stack[-1], token):
                apply_operation(op_stack, out_stack)
            op_stack.append(token)

    while len(op_stack) > 0:
        apply_operation(op_stack, out_stack)

    return out_stack[-1]
341099
@Override
    public Object visitComparisonExpression(ExcellentParser.ComparisonExpressionContext ctx) {
        Pair<Object, Object> args = Conversions.toSame(visit(ctx.expression(0)), visit(ctx.expression(1)), m_evalContext);
        int compared;

        if (args.getLeft() instanceof String) {
            // string comparison is case-insensitive
            compared = ((String) args.getLeft()).compareToIgnoreCase((String) args.getRight());
        }
        else {
            compared = ((Comparable) args.getLeft()).compareTo(args.getRight());
        }

        if (ctx.LTE() != null) {
            return compared <= 0;
        } else if (ctx.LT() != null) {
            return compared < 0;
        } else if (ctx.GTE() != null) {
            return compared >= 0;
        } else { // GT
            return compared > 0;
        }
    }
386506
public Object eval(String expression) {
    	expression = transform(expression);
    	Object result = calculate(expression);
        return result;
    }
643341
public Object evaluateExpression(String expression, EvaluationContext context) throws EvaluationError {
        return evaluateExpression(expression, context, EvaluationStrategy.COMPLETE);
    }
1278699
@Nonnull
  public static Value evalExpression(@Nonnull final String expression, @Nonnull final PreprocessorContext context) {
    try {
      final ExpressionTree tree = ExpressionParser.getInstance().parse(expression, context);
      return evalTree(tree, context);
    } catch (IOException unexpected) {
      throw context.makeException("[Expression]Wrong expression format detected [" + expression + ']', unexpected);
    }
  }
380892
function resolveExpression(expression) {
    // return empty string for undefined
    if (expression === undefined) {
        return "";
    }
    // return placeholder for promise
    if (isPromise(expression)) {
        // recursively resolve
        return "[promise]";
    }
    // return placeholder for function
    if (typeof expression === "function") {
        return "[function]";
    }
    // handle arrays
    if (Array.isArray(expression)) {
        var items = [];
        // resolve each item (might be promises as well)
        for (var _i = 0, expression_1 = expression; _i < expression_1.length; _i++) {
            var expressionItem = expression_1[_i];
            items.push(resolveExpression(expressionItem));
        }
        // join with newline
        return items.join("\n");
    }
    // return unmodified if got a string
    if (typeof expression === "string") {
        return expression;
    }
    // convert to string if got a number
    if (typeof expression === "number") {
        return expression.toString();
    }
    // return stringified value, handles circular references
    return flatted_1.stringify(expression, undefined, 2);
}
391836
function compileExpression(expression, extraFunctions /* optional */) {
    var functions = {
        abs: Math.abs,
        ceil: Math.ceil,
        floor: Math.floor,
        log: Math.log,
        max: Math.max,
        min: Math.min,
        random: Math.random,
        round: Math.round,
        sqrt: Math.sqrt,
    };
    if (extraFunctions) {
        for (var name in extraFunctions) {
            if (extraFunctions.hasOwnProperty(name)) {
                functions[name] = extraFunctions[name];
            }
        }
    }
    if (!compileExpression.parser) {
        // Building the original parser is the heaviest part. Do it
        // once and cache the result in our own function.
        compileExpression.parser = filtrexParser();
    }
    var tree = compileExpression.parser.parse(expression);

    var js = [];
    js.push('return ');
    function toJs(node) {
        if (Array.isArray(node)) {
            node.forEach(toJs);
        } else {
            js.push(node);
        }
    }
    tree.forEach(toJs);
    js.push(';');

    function unknown(funcName) {
        throw 'Unknown function: ' + funcName + '()';
    }

    function prop(obj, name) {
        return Object.prototype.hasOwnProperty.call(obj||{}, name) ? obj[name] : undefined;
    }

    var func = new Function('functions', 'data', 'unknown', 'prop', js.join(''));

    return function(data) {
        return func(functions, data, unknown, prop);
    };
}
853966
public Object evaluate(Object pContext,
                           VariableResolver pResolver,
                           Map functions,
                           String defaultPrefix,
                           Logger pLogger)
            throws ELException {
        Object value = mExpression.evaluate(pContext, pResolver, functions,
                defaultPrefix, pLogger);
        for (int i = 0; i < mOperators.size(); i++) {
            BinaryOperator operator = (BinaryOperator) mOperators.get(i);

            // For the And/Or operators, we need to coerce to a boolean
            // before testing if we shouldEvaluate
            if (operator.shouldCoerceToBoolean()) {
                value = Coercions.coerceToBoolean(value, pLogger);
            }

            if (operator.shouldEvaluate(value)) {
                Expression expression = (Expression) mExpressions.get(i);
                Object nextValue = expression.evaluate(pContext, pResolver,
                        functions, defaultPrefix,
                        pLogger);

                value = operator.apply(value, nextValue, pContext, pLogger);
            }
        }
        return value;
    }
581470
private void evaluateExpressions() throws JspException {
		String string = null;
		Boolean bool = null;
		if (getBase64Expr() != null
				&& (bool = EvalHelper.evalBoolean("base64", getBase64Expr(), this, pageContext)) != null) {
			setBase64(bool);
		}

		if (getAlignExpr() != null
				&& (string = EvalHelper.evalString("align", getAlignExpr(), this, pageContext)) != null) {
			setAlign(string);
		}

		if (getAltExpr() != null && (string = EvalHelper.evalString("alt", getAltExpr(), this, pageContext)) != null) {
			setAlt(string);
		}

		if (getBorderExpr() != null
				&& (string = EvalHelper.evalString("border", getBorderExpr(), this, pageContext)) != null) {
			setBorder(string);
		}

		if (getDirExpr() != null && (string = EvalHelper.evalString("dir", getDirExpr(), this, pageContext)) != null) {
			setDir(string);
		}

		if (getHeightExpr() != null
				&& (string = EvalHelper.evalString("height", getHeightExpr(), this, pageContext)) != null) {
			setHeight(string);
		}

		if (getHspaceExpr() != null
				&& (string = EvalHelper.evalString("hspace", getHspaceExpr(), this, pageContext)) != null) {
			setHspace(string);
		}

		if (getNameExpr() != null
				&& (string = EvalHelper.evalString("name", getNameExpr(), this, pageContext)) != null) {
			setName(string);
		}

		if (getIsmapExpr() != null
				&& (string = EvalHelper.evalString("ismap", getIsmapExpr(), this, pageContext)) != null) {
			setIsmap(string);
		}

		if (getLangExpr() != null
				&& (string = EvalHelper.evalString("lang", getLangExpr(), this, pageContext)) != null) {
			setLang(string);
		}

		if (getNameExpr() != null
				&& (string = EvalHelper.evalString("name", getNameExpr(), this, pageContext)) != null) {
			setName(string);
		}

		if (getOnclickExpr() != null
				&& (string = EvalHelper.evalString("onclick", getOnclickExpr(), this, pageContext)) != null) {
			setOnclick(string);
		}

		if (getOndblclickExpr() != null
				&& (string = EvalHelper.evalString("ondblclick", getOndblclickExpr(), this, pageContext)) != null) {
			setOndblclick(string);
		}

		if (getOnkeydownExpr() != null
				&& (string = EvalHelper.evalString("onkeydown", getOnkeydownExpr(), this, pageContext)) != null) {
			setOnkeydown(string);
		}

		if (getOnkeypressExpr() != null
				&& (string = EvalHelper.evalString("onkeypress", getOnkeypressExpr(), this, pageContext)) != null) {
			setOnkeypress(string);
		}

		if (getOnkeyupExpr() != null
				&& (string = EvalHelper.evalString("onkeyup", getOnkeyupExpr(), this, pageContext)) != null) {
			setOnkeyup(string);
		}

		if (getOnmousedownExpr() != null
				&& (string = EvalHelper.evalString("onmousedown", getOnmousedownExpr(), this, pageContext)) != null) {
			setOnmousedown(string);
		}

		if (getOnmousemoveExpr() != null
				&& (string = EvalHelper.evalString("onmousemove", getOnmousemoveExpr(), this, pageContext)) != null) {
			setOnmousemove(string);
		}

		if (getOnmouseoutExpr() != null
				&& (string = EvalHelper.evalString("onmouseout", getOnmouseoutExpr(), this, pageContext)) != null) {
			setOnmouseout(string);
		}

		if (getOnmouseoverExpr() != null
				&& (string = EvalHelper.evalString("onmouseover", getOnmouseoverExpr(), this, pageContext)) != null) {
			setOnmouseover(string);
		}

		if (getOnmouseupExpr() != null
				&& (string = EvalHelper.evalString("onmouseup", getOnmouseupExpr(), this, pageContext)) != null) {
			setOnmouseup(string);
		}

		if (getSrcExpr() != null && (string = EvalHelper.evalString("src", getSrcExpr(), this, pageContext)) != null) {
			setSrc(string);
		}

		if (getStyleExpr() != null
				&& (string = EvalHelper.evalString("style", getStyleExpr(), this, pageContext)) != null) {
			setStyle(string);
		}

		if (getStyleClassExpr() != null
				&& (string = EvalHelper.evalString("styleClass", getStyleClassExpr(), this, pageContext)) != null) {
			setStyleClass(string);
		}

		if (getStyleIdExpr() != null
				&& (string = EvalHelper.evalString("styleId", getStyleIdExpr(), this, pageContext)) != null) {
			setStyleId(string);
		}

		if (getTitleExpr() != null
				&& (string = EvalHelper.evalString("title", getTitleExpr(), this, pageContext)) != null) {
			setTitle(string);
		}

		if (getUsemapExpr() != null
				&& (string = EvalHelper.evalString("usemap", getUsemapExpr(), this, pageContext)) != null) {
			setUsemap(string);
		}

		if (getVspaceExpr() != null
				&& (string = EvalHelper.evalString("vspace", getVspaceExpr(), this, pageContext)) != null) {
			setVspace(string);
		}

		if (getWidthExpr() != null
				&& (string = EvalHelper.evalString("width", getWidthExpr(), this, pageContext)) != null) {
			setWidth(string);
		}
	}
404868
private void evaluateExpressions() throws JspException {
        if (dataSourceEL != null) {
            dataSource = ExpressionEvaluatorManager.evaluate
                    ("dataSource", dataSourceEL, Object.class, this, pageContext);
        }

        if (driverClassNameEL != null) {
            driverClassName = (String) ExpressionEvaluatorManager.evaluate
                    ("driver", driverClassNameEL, String.class, this, pageContext);
        }

        if (jdbcURLEL != null) {
            jdbcURL = (String) ExpressionEvaluatorManager.evaluate
                    ("url", jdbcURLEL, String.class, this, pageContext);
        }

        if (userNameEL != null) {
            userName = (String) ExpressionEvaluatorManager.evaluate
                    ("user", userNameEL, String.class, this, pageContext);
        }

        if (passwordEL != null) {
            password = (String) ExpressionEvaluatorManager.evaluate
                    ("password", passwordEL, String.class, this, pageContext);
        }
    }
894596
private BigInteger evalUnaryExpression(AstNode exprAst) {
    // only 'unary-operator cast-expression' production is allowed in #if-context

    AstNode operator = exprAst.getFirstChild();
    AstNode operand = operator.getNextSibling();
    AstNodeType operatorType = operator.getFirstChild().getType();

    if (operatorType.equals(CppPunctuator.PLUS)) {
      return evalToInt(operand);
    } else if (operatorType.equals(CppPunctuator.MINUS)) {
      return evalToInt(operand).negate();
    } else if (operatorType.equals(CppPunctuator.NOT)) {
      boolean result = !evalToBoolean(operand);
      return result ? BigInteger.ONE : BigInteger.ZERO;
    } else if (operatorType.equals(CppPunctuator.BW_NOT)) {
      //todo: need more information (signed/unsigned, data type length) to invert bits in all cases correct
      return evalToInt(operand).not().and(UINT64_MAX);
    } else {
      throw new EvaluationException("Unknown unary operator  '" + operatorType + "'");
    }
  }
631012
private void evaluateExpressions() throws JspException {

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

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