Package com.caucho.quercus.expr

Examples of com.caucho.quercus.expr.Expr


      if (env.isInitializedClass(map.getKey()))
        continue;
     
      for (StaticField field : map.getValue()) {
        Value val;
        Expr expr = field._expr;

        //php/096f
        if (expr instanceof ClassConstExpr)
          val = ((ClassConstExpr) expr).eval(env);
        else
          val = expr.eval(env);

        String fullName = _className + "::" + field._name;
       
        env.setGlobalValue(fullName, val);
      }
View Full Code Here


  /**
   * Finds the matching constant
   */
  public final Value getConstant(Env env, String name)
  {
    Expr expr = _constMap.get(name);

    if (expr != null)
      return expr.eval(env);

    throw new QuercusRuntimeException(L.l("{0}::{1} is an unknown constant",
                                        getName(), name));
  }
View Full Code Here

      return null;
  }
 
  private static void addInterpreted(Env env, ArrayValue result, int i)
  {
    Expr expr = env.peekCall(i);

    if (expr instanceof CallExpr) {
      CallExpr callExpr = (CallExpr) expr;

      String functionName = callExpr.getName();
      if ("debug_backtrace".equals(functionName))
        return;
       
      ArrayValue call = new ArrayValueImpl();
      result.put(call);
     
      if (callExpr.getFileName() != null) {
        call.put(FILE,
                 env.createString(callExpr.getFileName()));
        call.put(LINE,
                 LongValue.create(callExpr.getLine()));
      }

      call.put(FUNCTION,
               env.createString(callExpr.getName()));

      // Create "args" argument value array

      // evaluating args a second time is problematic, affecting mediawiki
      // php/180q
      //ArrayValueImpl args = evalArgsArray(env, callExpr);

      ArrayValueImpl args = new ArrayValueImpl(env.peekArgs(i));
     
      call.put(ARGS, args);
    }
    else if (expr instanceof ObjectMethodExpr) {
      ObjectMethodExpr callExpr = (ObjectMethodExpr) expr;

      ArrayValue call = new ArrayValueImpl();
      result.put(call);
     
      if (callExpr.getFileName() != null) {
        call.put(FILE,
                 env.createString(callExpr.getFileName()));
        call.put(LINE,
                 LongValue.create(callExpr.getLine()));
      }

      call.put(FUNCTION,
               env.createString(callExpr.getName()));

      call.put(CLASS,
               env.createString(env.peekCallThis(i).getClassName()));

      call.put(TYPE, env.createString("->"));

      call.put(ARGS, new ArrayValueImpl());
    }
    else if (expr instanceof FunIncludeExpr) {
      ArrayValue call = new ArrayValueImpl();
      result.put(call);
     
      if (expr.getFileName() != null) {
        call.put(FILE, env.createString(expr.getFileName()));
        call.put(LINE, LongValue.create(expr.getLine()));
      }

      call.put(FUNCTION, env.createString("include"));
    }
    else if (expr instanceof FunIncludeOnceExpr) {
      boolean isRequire = ((FunIncludeOnceExpr) expr).isRequire();
     
      ArrayValue call = new ArrayValueImpl();
      result.put(call);
     
      if (expr.getFileName() != null) {
        call.put(FILE, env.createString(expr.getFileName()));
        call.put(LINE, LongValue.create(expr.getLine()));
      }
   
      String name;
     
      if (isRequire)
View Full Code Here

    for (; i < _marshalArgs.length; i++) {
      Marshal marshal = _marshalArgs[i];

      if (i < args.length && args[i] != null) {
        Expr arg = args[i];

        int argCost = marshal.getMarshalingCost(arg);

        cost = Math.max(argCost + cost, cost);
      }
View Full Code Here

   
    getStaticFields(env, array, _cls);
   
    HashMap<StringValue, ClassField> fieldMap = _cls.getClassFields();
    for (Map.Entry<StringValue, ClassField> entry : fieldMap.entrySet()) {
      Expr initExpr = entry.getValue().getInitValue();
     
      array.put(entry.getKey(), initExpr.eval(env));
    }
   
    return array;
  }
View Full Code Here

    ArrayValue varArray = new ArrayValueImpl();

    for (ClassField field : cl.getClassFields().values()) {
      if (field.isPublic()) {
        StringValue name = field.getName();
        Expr initValue = field.getInitValue();
       
        Value value = initValue.eval(env);

        varArray.append(name, value);
      }
    }
View Full Code Here

    Location location = _location;

    if (location != null)
      return location;

    Expr call = peekCall(0);

    if (call != null)
      return call.getLocation();

    return Location.UNKNOWN;
  }
View Full Code Here

   * Returns the current function.
   */
  public String getFunctionLocation()
  {
    // XXX: need to work with compiled code, too
    Expr call = peekCall(0);

    if (call != null)
      return call.getFunctionLocation();
    else
      return "";
  }
View Full Code Here

    }

    for (int i = args.length; i < _args.length; i++) {
      Arg arg = _args[i];

      Expr defaultExpr = arg.getDefault();

      if (defaultExpr == null)
        return env.error("expected default expression");
      else if (arg.isReference())
        map.put(arg.getName(),
                new EnvVarImpl(defaultExpr.evalVar(env).toVar()));
      else {
        map.put(arg.getName(),
                new EnvVarImpl(defaultExpr.eval(env).copy().toVar()));
      }
    }

    Map<StringValue,EnvVar> oldMap = env.pushEnv(map);
    Value []oldArgs = env.setFunctionArgs(values); // php/0476
View Full Code Here

    }

    for (int i = args.length; i < _args.length; i++) {
      Arg arg = _args[i];

      Expr defaultExpr = arg.getDefault();

      if (defaultExpr == null)
        return env.error("expected default expression");
      else if (arg.isReference())
        map.put(
          arg.getName(), new EnvVarImpl(defaultExpr.evalVar(env).toVar()));
      else {
        map.put(
          arg.getName(), new EnvVarImpl(defaultExpr.eval(env).toLocalVar()));
      }
    }

    Map<StringValue,EnvVar> oldMap = env.pushEnv(map);
    Value []oldArgs = env.setFunctionArgs(args);
View Full Code Here

TOP

Related Classes of com.caucho.quercus.expr.Expr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.