Examples of VariableExpression


Examples of org.codehaus.groovy.ast.expr.VariableExpression

                }
                addError("Error: annotation " + MY_TYPE_NAME + " can only be used within a Script body.", expr);
                return expr;
            }
        } else if (insideScriptBody && expr instanceof VariableExpression && currentClosure != null) {
            VariableExpression ve = (VariableExpression) expr;
            if (ve.getName().equals(variableName)) {
                // we may only check the variable name because the Groovy compiler
                // already fails if a variable with the same name already exists in the scope.
                // this means that a closure cannot shadow a class variable
                ve.setAccessedVariable(fieldNode);
                final VariableScope variableScope = currentClosure.getVariableScope();
                final Iterator<Variable> iterator = variableScope.getReferencedLocalVariablesIterator();
                while (iterator.hasNext()) {
                    Variable next = iterator.next();
                    if (next.getName().equals(variableName)) iterator.remove();
View Full Code Here

Examples of org.codehaus.groovy.ast.expr.VariableExpression

        // let's make the constructor
        BlockStatement block = new BlockStatement();
        // this block does not get a source position, because we don't
        // want this synthetic constructor to show up in corbertura reports
        VariableExpression outer = new VariableExpression("_outerInstance");
        outer.setSourcePosition(expression);
        block.getVariableScope().putReferencedLocalVariable(outer);
        VariableExpression thisObject = new VariableExpression("_thisObject");
        thisObject.setSourcePosition(expression);
        block.getVariableScope().putReferencedLocalVariable(thisObject);
        TupleExpression conArgs = new TupleExpression(outer, thisObject);
        block.addStatement(
                new ExpressionStatement(
                        new ConstructorCallExpression(
                                ClassNode.SUPER,
                                conArgs)));

        // let's assign all the parameter fields from the outer context
        for (Parameter param : localVariableParams) {
            String paramName = param.getName();
            ClassNode type = param.getType();
            if (true) {
                VariableExpression initialValue = new VariableExpression(paramName);
                initialValue.setAccessedVariable(param);
                initialValue.setUseReferenceDirectly(true);
                ClassNode realType = type;
                type = ClassHelper.makeReference();
                param.setType(ClassHelper.makeReference());
                FieldNode paramField = answer.addField(paramName, ACC_PRIVATE | ACC_SYNTHETIC, type, initialValue);
                paramField.setOriginType(ClassHelper.getWrapper(param.getOriginType()));
View Full Code Here

Examples of org.codehaus.groovy.ast.expr.VariableExpression

    private void checkFinalFieldAccess(Expression expression) {
        if (!(expression instanceof VariableExpression) && !(expression instanceof PropertyExpression)) return;
        Variable v = null;
        if (expression instanceof VariableExpression) {
            VariableExpression ve = (VariableExpression) expression;
            v = ve.getAccessedVariable();
        } else {
          PropertyExpression propExp = ((PropertyExpression) expression);
          Expression objectExpression = propExp.getObjectExpression();
          if(objectExpression instanceof VariableExpression) {
            VariableExpression varExp = (VariableExpression) objectExpression;
            if(varExp.isThisExpression()) {
              v = currentClass.getDeclaredField(propExp.getPropertyAsString());
            }
          }
        }
        if (v instanceof FieldNode) {
View Full Code Here

Examples of org.datanucleus.query.expression.VariableExpression

                }
            }
            else if (expr.getLeft() instanceof VariableExpression)
            {
                // "{varExpr}.field[.field[.field]]"
                VariableExpression varExpr = (VariableExpression)expr.getLeft();
                processVariableExpression(varExpr);
                SQLExpression varSqlExpr = stack.pop();
                if (varSqlExpr instanceof UnboundExpression)
                {
                    // Bind as CROSS JOIN for now
                    processUnboundExpression((UnboundExpression)varSqlExpr);
                    varSqlExpr = stack.pop();
                }

                Class varType = clr.classForName(varSqlExpr.getJavaTypeMapping().getType());
                if (varSqlExpr.getSQLStatement() == stmt.getParentStatement())
                {
                    // Use parent mapper to get the mapping for this field since it has the table
                    SQLTableMapping sqlMapping =
                        parentMapper.getSQLTableMappingForPrimaryExpression(stmt, null, expr, Boolean.FALSE);
                    if (sqlMapping == null)
                    {
                        throw new NucleusException("PrimaryExpression " + expr.getId() + " is not yet supported");
                    }
                    // TODO Cater for the table required to join to not being the primary table of the outer query
                    // This should check on
                    // getDatastoreAdapter().supportsOption(RDBMSAdapter.ACCESS_PARENTQUERY_IN_SUBQUERY))

                    sqlExpr = exprFactory.newExpression(varSqlExpr.getSQLStatement(),
                        sqlMapping.table, sqlMapping.mapping);
                    stack.push(sqlExpr);
                    return sqlExpr;
                }

                SQLTableMapping varTblMapping = getSQLTableMappingForAlias(varExpr.getId());
                if (varTblMapping == null)
                {
                    throw new NucleusUserException("Variable " + varExpr.getId() + " is not yet bound, so cannot get field " + expr.getId());
                }
                if (varTblMapping.cmd == null)
                {
                    throw new NucleusUserException("Variable " + varExpr.getId() + " of type " + varType.getName() + " cannot evaluate " + expr.getId());
                }

                SQLTableMapping sqlMapping =
                    getSQLTableMappingForPrimaryExpression(varSqlExpr.getSQLStatement(), varExpr.getId(),
                        expr, Boolean.FALSE);

                sqlExpr = exprFactory.newExpression(sqlMapping.table.getSQLStatement(), sqlMapping.table,
                    sqlMapping.mapping);
                stack.push(sqlExpr);
View Full Code Here

Examples of org.datanucleus.query.expression.VariableExpression

            {
                value = QueryUtils.getValueForParameterExpression(parameterValues, (ParameterExpression)primExpr.getLeft());
            }
            else if (primExpr.getLeft() instanceof VariableExpression)
            {
                VariableExpression varExpr = (VariableExpression)primExpr.getLeft();
                try
                {
                    value = getValueForVariableExpression(varExpr);
                }
                catch (VariableNotSetException vnse)
                {
                    // We don't know the possible values here!
                    NucleusLogger.QUERY.error("Attempt to access variable " + varExpr.getId() + " as part of primaryExpression " + primExpr);
                    return new InMemoryFailure();
                }
            }
            else
            {
View Full Code Here

Examples of org.datanucleus.query.expression.VariableExpression

                return "?" + paramExpr.getPosition();
            }
        }
        else if (expr instanceof VariableExpression)
        {
            VariableExpression varExpr = (VariableExpression)expr;
            return varExpr.getId();
        }
        else if (expr instanceof InvokeExpression)
        {
            InvokeExpression invExpr = (InvokeExpression)expr;
            StringBuffer str = new StringBuffer();
            if (invExpr.getLeft() != null)
            {
                str.append(JDOQLQueryHelper.getJDOQLForExpression(invExpr.getLeft())).append(".");
            }
            str.append(invExpr.getOperation());
            str.append("(");
            List<Expression> args = invExpr.getArguments();
            if (args != null)
            {
                Iterator<Expression> iter = args.iterator();
                while (iter.hasNext())
                {
                    str.append(JDOQLQueryHelper.getJDOQLForExpression(iter.next()));
                    if (iter.hasNext())
                    {
                        str.append(",");
                    }
                }
            }
            str.append(")");
            return str.toString();
        }
        else if (expr instanceof Literal)
        {
            Literal litExpr = (Literal)expr;
            Object value = litExpr.getLiteral();
            if (value instanceof String || value instanceof Character)
            {
                return "'" + value.toString() + "'";
            }
            else if (value instanceof Boolean)
            {
                return ((Boolean)value ? "TRUE" : "FALSE");
            }
            else
            {
                if (litExpr.getLiteral() == null)
                {
                    return "null";
                }
                else
                {
                    return litExpr.getLiteral().toString();
                }
            }
        }
        else if (expr instanceof VariableExpression)
        {
            VariableExpression varExpr = (VariableExpression)expr;
            return varExpr.getId();
        }
        else
        {
            throw new UnsupportedOperationException("Dont currently support " + expr.getClass().getName() + " in JDOQLHelper");
        }
View Full Code Here

Examples of org.datanucleus.query.expression.VariableExpression

                SubqueryImpl sub = subqueryIter.next();
                org.datanucleus.query.expression.Expression subExpr = sub.getQueryExpression();
                if (subExpr instanceof SubqueryExpression)
                {
                    SubqueryExpression subqueryExpr = (SubqueryExpression) sub.getQueryExpression();
                    VariableExpression subqueryVar = (VariableExpression) subqueryExpr.getRight();
                    CriteriaQueryImpl<T> subDelegate = (CriteriaQueryImpl<T>) sub.getDelegate();
                    QueryCompilation subCompilation = subDelegate.getCompilation(mmgr, clr, compilation.getSymbolTable());
                    subCompilation.setQueryLanguage("JPQL");
                    compilation.addSubqueryCompilation(subqueryVar.getId(), subCompilation);
                }
                else if (subExpr instanceof VariableExpression)
                {
                    VariableExpression subVarExpr = (VariableExpression)subExpr;
                    CriteriaQueryImpl<T> subDelegate = (CriteriaQueryImpl<T>) sub.getDelegate();
                    QueryCompilation subCompilation = subDelegate.getCompilation(mmgr, clr, compilation.getSymbolTable());
                    subCompilation.setQueryLanguage("JPQL");
                    compilation.addSubqueryCompilation(subVarExpr.getId(), subCompilation);
                }
            }
        }

        return compilation;
View Full Code Here

Examples of org.datanucleus.query.expression.VariableExpression

      } else {
        throw newUnsupportedQueryMethodException(invokeExpr);
      }
    } else if (expr instanceof VariableExpression) {
      // We don't support variables
      VariableExpression varExpr = (VariableExpression) expr;
      throw new NucleusFatalUserException(
          "Unexpected expression type while parsing query. Variables not supported by GAE (" + varExpr.getId() + ")");
    } else {
      throw new UnsupportedDatastoreFeatureException(
          "Unexpected expression type while parsing query: "+ expr.getClass().getName());
    }
  }
View Full Code Here

Examples of org.lilystudio.smarty4j.expression.VariableExpression

    if (!Character.isJavaIdentifierStart(line.charAt(start))) {
      words[wordSize] = getOperation('$');
      return start;
    }
    start = findIdentifier(line, start, end, words, wordSize);
    VariableExpression variable = new VariableExpression(
        (String) words[wordSize]);
    loop: while (start < end) {
      char c = line.charAt(start);
      switch (c) {
      case '[': {
        words[wordSize] = null;
        int pos = findExpression(line, start + 1, end, words, wordSize, ']');
        Object o = words[wordSize];
        if (o == null) {
          break loop;
        }
        start = pos;
        variable.add(new ListExtended((IExpression) o));
        continue;
      }
      case '.': {
        if (type != STRING) {
          c = line.charAt(start + 1);
          IExpression exp;
          if (c == '`') {
            words[wordSize] = null;
            int pos = findExpression(line, start + 2, end, words, wordSize, '`');
            Object o = words[wordSize];
            if (o == null) {
              break loop;
            }
            start = pos;
            exp = (IExpression) words[wordSize];
          } else if (!Character.isJavaIdentifierStart(c)) {
            break loop;
          } else {
            start = findIdentifier(line, start + 1, end, words, wordSize);
            exp = new StringExpression((String) words[wordSize]);
          }
          variable.add(new MapExtended(exp));
          continue;
        }
      }
      default:
        break loop;
View Full Code Here

Examples of org.thymeleaf.standard.expression.VariableExpression

         * Only asterisk syntax (selection variable expressions) are allowed here.
         */
       
        if (useSelectionAsRoot) {

            VariableExpression boundObjectValue =
                    (VariableExpression) processingContext.getLocalVariable(SpringContextVariableNames.SPRING_BOUND_OBJECT_EXPRESSION);
            if (boundObjectValue == null) {
                // Try the deprecated name, to avoid legacy issues
                boundObjectValue =
                        (VariableExpression) processingContext.getLocalVariable(SpringContextVariableNames.SPRING_FORM_COMMAND_VALUE);
            }

            final String boundObjectExpression =
                    (boundObjectValue == null? null : boundObjectValue.getExpression());

            if (GLOBAL_EXPRESSION.equals(expression)) {
                // Should return null if no object previously bound: nothing to apply 'global' on!
                if (boundObjectExpression == null) {
                    return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.