Execute a Constant expression at a given point in the function or
method body

@param expr
--- The expression to execute
@param frame
--- The current stack frame
@return
199211
private RValue executeConst(Expr.Constant expr, CallStack frame) {
		Value v = expr.getValue();
		switch (v.getOpcode()) {
		case ITEM_null:
			return RValue.Null;
		case ITEM_bool: {
			Value.Bool b = (Value.Bool) v;
			if (b.get()) {
				return RValue.True;
			} else {
				return RValue.False;
			}
		}
		case ITEM_byte: {
			Value.Byte b = (Value.Byte) v;
			return semantics.Byte(b.get());
		}
		case ITEM_int: {
			Value.Int i = (Value.Int) v;
			return semantics.Int(i.get());
		}
		case ITEM_utf8: {
			Value.UTF8 s = (Value.UTF8) v;
			byte[] bytes = s.get();
			RValue[] elements = new RValue[bytes.length];
			for (int i = 0; i != elements.length; ++i) {
				// FIXME: something tells me this is wrong for signed byte
				// values?
				elements[i] = semantics.Int(BigInteger.valueOf(bytes[i]));
			}
			return semantics.Array(elements);
		}
		default:
			throw new RuntimeException("unknown value encountered (" + expr + ")");
		}
	}
855703
private boolean executeQuantifier(int index, Expr.Quantifier expr, CallStack frame) {
		Tuple<Decl.Variable> vars = expr.getParameters();
		if (index == vars.size()) {
			// This is the base case where we evaluate the condition itself.
			RValue.Bool r = executeExpression(BOOL_T, expr.getOperand(), frame);
			boolean q = (expr instanceof Expr.UniversalQuantifier);
			// If this evaluates to true, then we will continue executing the
			// quantifier.
			return r.boolValue() == q;
		} else {
			Decl.Variable var = vars.get(index);
			RValue.Array range = executeExpression(ARRAY_T, var.getInitialiser(), frame);
			RValue[] elements = range.getElements();
			for (int i = 0; i != elements.length; ++i) {
				frame.putLocal(var.getName(), elements[i]);
				boolean r = executeQuantifier(index + 1, expr, frame);
				if (!r) {
					// early termination
					return r;
				}
			}
			return true;
		}
	}
1106378
function statementExpr(lastClause) {
      
      return function(ascent) {
   
         // kick off the evaluation by passing through to the last clause
         var exprMatch = lastClause(ascent);
                                                     
         return exprMatch === true ? head(ascent) : exprMatch;
      };
   }
959379
function(expr) {
      var obj = this._apply("anything"),
          state = this.bt.current_state();

      this.bt.inject(obj);
      expr.call(this);
      this._apply("end");

      this.bt.restore(state);
      return obj;
    }
726458
@Override
    public List<AbstractExpression> bindingToIndexedExpression(AbstractExpression expr) {
        if (m_originalValue == null || ! m_originalValue.equals(expr)) {
            return null;
        }
        // This parameter's value was matched, so return this as one bound parameter.
        List<AbstractExpression> result = new ArrayList<AbstractExpression>();
        result.add(this);
        return result;
    }
42588
@Override
    public GroovyExpression apply(GroovyExpression expr, OptimizationContext context) {

        FunctionCallExpression exprAsFunction = (FunctionCallExpression)expr;
        GroovyExpression result = exprAsFunction.getCaller();

        List<GroovyExpression> nonExtractableArguments = new ArrayList<>();
        for(GroovyExpression argument : exprAsFunction.getArguments()) {

            if (GremlinQueryOptimizer.isExtractable(argument)) {
                //Set the caller of the deepest expression in the call hierarchy
                //of the argument to point to the current result.
                //For example, if result is "g.V()" and the updatedArgument is "has('x').has('y')",
                //updatedArgument would be a tree like this:
                //
                //                  has('y')
                //                 /
                //                / caller
                //              |/_
                //           has('x')
                //             /
                //            / caller
                //          |/_
                //        (null)
                //
                //We would set the caller of has('x') to be g.V(), so result would become g.V().has('x').has('y').
                //
                // Note: This operation is currently done by making a copy of the argument tree.  That should
                // be changed.
                result = GremlinQueryOptimizer.copyWithNewLeafNode(
                        (AbstractFunctionExpression) argument, result);
            } else {
                logger_.warn("Found non-extractable argument '{}' in the 'and' expression '{}'",argument.toString(), expr.toString());
                nonExtractableArguments.add(argument);
            }
        }

        if (!nonExtractableArguments.isEmpty()) {
            //add a final 'and' call with the arguments that could not be extracted
            result =  factory.generateLogicalExpression(result, "and", nonExtractableArguments);
        }
        return result;
    }
1309438
protected Expression visitExpression(Expression expr) {
        if (expr == null) {
            return null;
        }

        Expression newExpr = (Expression)expr.accept(this);
        if (expr != newExpr) {
            Type newType = newExpr.getType();

            if (newType == null || !newType.equals(expr.getType())) {
                Iterator<Expression.Conversion> it =
                    expr.getConversionChain().iterator();
                while (it.hasNext()) {
                    Expression.Conversion conv = it.next();
                    newExpr.convertTo
                        (conv.getToType(), conv.isCastPreferred());
                }
            }
        }
        return newExpr;
    }
1208683
public static Object execExpr(ExprResolver exprResolver, String expression) {

        try {
            // 返回输出的内容
            return exprResolver.executeExpr(expression);

        } catch (Exception e) {

            // 输出日志
            if (logger.isDebugEnabled()) {
                logger.debug("Can't resolving expression: " + expression, e);
            }
        }

        return null;
    }
1250565
private AbstractExpression parseExpressionNode(VoltXMLElement exprNode) {
        String elementName = exprNode.name.toLowerCase();

        XMLElementExpressionParser parser = m_exprParsers.get(elementName);
        if (parser == null) {
            throw new PlanningErrorException("Unsupported expression node '" + elementName + "'");
        }
        AbstractExpression retval = parser.parse(this, exprNode);
        assert("asterisk".equals(elementName) || retval != null);
        return retval;
    }
560241
public Expr call(String method, Expr argument1) {
      return new Expr(
        expr + "." + method + "(" + argument1.toSwiftCode() + ")",
        false,
        containsThrow || argument1.containsThrow,
        false);
    }
144611
public static ExprBoolean toExprBoolean(Expression expr, Position start, Position end) {
	if (expr instanceof Literal) {
	    Boolean b = ((Literal) expr).getBoolean(null);
	    if (b != null) {
		return expr.getFactory().createLitBoolean(!b.booleanValue(), start, end);
	    }
	}
	return new OpNegate(expr, start, end);
    }
891600
private Status executeVariableDeclaration(Decl.Variable stmt, CallStack frame) {
		// We only need to do something if this has an initialiser
		if(stmt.hasInitialiser()) {
			RValue value = executeExpression(ANY_T, stmt.getInitialiser(), frame);
			frame.putLocal(stmt.getName(),value);
		}
		return Status.NEXT;
	}
258992
public static Expression<?> toExpression(Object o) {
        if (o instanceof Expression) {
            return (Expression<?>) o;
        } else {
            return ConstantImpl.create(o);
        }
    }
1134921
public static ExprDouble toExprDouble(Expression expr) {
	if (expr instanceof ExprDouble) return (ExprDouble) expr;
	if (expr instanceof Literal) {
	    Double dbl = ((Literal) expr).getDouble(null);
	    if (dbl != null) return expr.getFactory().createLitDouble(dbl.doubleValue(), expr.getStart(), expr.getEnd());
	}
	return new CastDouble(expr);
    }
1160518
@SuppressWarnings("unchecked")
	public Expr translateExpression(WyilFile.Expr expr, Integer selector, LocalEnvironment environment) {
		Expr result;
		try {
			switch (expr.getOpcode()) {
			case WyilFile.EXPR_constant:
				result = translateConstant((WyilFile.Expr.Constant) expr, environment);
				break;
			case WyilFile.EXPR_cast:
				result = translateConvert((WyilFile.Expr.Cast) expr, environment);
				break;
			case WyilFile.EXPR_recordaccess:
			case WyilFile.EXPR_recordborrow:
				result = translateFieldLoad((WyilFile.Expr.RecordAccess) expr, environment);
				break;
			case WyilFile.EXPR_indirectinvoke:
				result = translateIndirectInvoke((WyilFile.Expr.IndirectInvoke) expr, environment);
				break;
			case WyilFile.EXPR_invoke:
				result = translateInvoke((WyilFile.Expr.Invoke) expr, selector, environment);
				break;
			case WyilFile.DECL_lambda:
				result = translateLambda((WyilFile.Decl.Lambda) expr, environment);
				break;
			case WyilFile.EXPR_lambdaaccess:
				result = translateLambda((WyilFile.Expr.LambdaAccess) expr, environment);
				break;
			case WyilFile.EXPR_logicalexistential:
			case WyilFile.EXPR_logicaluniversal:
				result = translateQuantifier((WyilFile.Expr.Quantifier) expr, environment);
				break;
			case WyilFile.EXPR_variablemove:
			case WyilFile.EXPR_variablecopy:
				result = translateVariableAccess((WyilFile.Expr.VariableAccess) expr, environment);
				break;
			case WyilFile.EXPR_staticvariable:
				result = translateStaticVariableAccess((WyilFile.Expr.StaticVariableAccess) expr, environment);
				break;
			case WyilFile.EXPR_logicalnot:
				result = translateNotOperator((WyilFile.Expr.LogicalNot) expr, environment);
				break;
			case WyilFile.EXPR_integernegation:
				result = translateArithmeticNegation((WyilFile.Expr.IntegerNegation) expr, environment);
				break;
			case WyilFile.EXPR_integeraddition:
			case WyilFile.EXPR_integersubtraction:
			case WyilFile.EXPR_integermultiplication:
			case WyilFile.EXPR_integerdivision:
			case WyilFile.EXPR_integerremainder:
			case WyilFile.EXPR_equal:
			case WyilFile.EXPR_notequal:
			case WyilFile.EXPR_integerlessthan:
			case WyilFile.EXPR_integerlessequal:
			case WyilFile.EXPR_integergreaterthan:
			case WyilFile.EXPR_integergreaterequal:
			case WyilFile.EXPR_logiaclimplication:
			case WyilFile.EXPR_logicaliff:
				result = translateBinaryOperator((WyilFile.Expr.BinaryOperator) expr, environment);
				break;
			case WyilFile.EXPR_logicaland:
			case WyilFile.EXPR_logicalor:
				result = translateNaryOperator((WyilFile.Expr.NaryOperator) expr, environment);
				break;
			case WyilFile.EXPR_is:
				result = translateIs((WyilFile.Expr.Is) expr, environment);
				break;
			case WyilFile.EXPR_arrayaccess:
			case WyilFile.EXPR_arrayborrow:
				result = translateArrayIndex((WyilFile.Expr.ArrayAccess) expr, environment);
				break;
			case WyilFile.EXPR_arrayinitialiser:
				result = translateArrayInitialiser((WyilFile.Expr.ArrayInitialiser) expr, environment);
				break;
			case WyilFile.EXPR_arraygenerator:
				result = translateArrayGenerator((WyilFile.Expr.ArrayGenerator) expr, environment);
				break;
			case WyilFile.EXPR_recordinitialiser:
				result = translateRecordInitialiser((WyilFile.Expr.RecordInitialiser) expr, environment);
				break;
			case WyilFile.EXPR_arraylength:
				result = translateArrayLength((WyilFile.Expr.ArrayLength) expr, environment);
				break;
			case WyilFile.EXPR_dereference:
				result = translateDereference((WyilFile.Expr.Dereference) expr, environment);
				break;
			case WyilFile.EXPR_bitwiseshr:
			case WyilFile.EXPR_bitwiseshl:
			case WyilFile.EXPR_bitwiseand:
			case WyilFile.EXPR_bitwiseor:
			case WyilFile.EXPR_bitwisexor:
			case WyilFile.EXPR_bitwisenot:
			case WyilFile.EXPR_new:
				result = translateAsUnknown(expr, environment);
				break;
			default:
				throw new RuntimeException("Deadcode reached (" + expr.getClass().getName() + ")");
			}
		} catch (SyntacticException e) {
			throw e;
		} catch (Throwable e) {
			throw new SyntacticException(e.getMessage(), ((WyilFile) expr.getHeap()).getEntry(), expr, e);
		}
		return allocate(result, expr.getParent(WyilFile.Attribute.Span.class));
	}
1155190
@Nullable
    public static Predicate allOf(Collection<Predicate> exprs) {
        Predicate rv = null;
        for (Predicate b : exprs) {
            if (b != null) {
                rv = rv == null ? b : ExpressionUtils.and(rv,b);
            }
        }
        return rv;
    }
72314
public static DataExpr parseDataExpr(String expr) {
    try {
      return (DataExpr) parse(expr);
    } catch (ClassCastException e) {
      throw new IllegalArgumentException("invalid data expression: " + expr, e);
    }
  }