Package org.formulacompiler.compiler.internal.expressions

Examples of org.formulacompiler.compiler.internal.expressions.ExpressionNode


  }

  @Override
  public ExpressionNode getExpression() throws SpreadsheetException
  {
    final ExpressionNode own = super.getExpression();
    if (null != own) {
      return own;
    }
    else {
      final int colOffset = getColumnIndex() - this.baseExpression.getColumnIndex();
      final int rowOffset = getRow().getRowIndex() - this.baseExpression.getRow().getRowIndex();
      final ExpressionNode exp = this.baseExpression.getExpression().clone( colOffset, rowOffset );
      setExpression( exp );
      return exp;
    }
  }
View Full Code Here



  @Override
  protected boolean visitCell( CellModel _cell ) throws CompilerException
  {
    final ExpressionNode expr = _cell.getExpression();
    if (null != expr) {
      _cell.setExpression( this.rewriter.rewrite( this.model, expr ) );
      // Re-establish invariant: everything within a typed cell is fully typed.
      if (null != _cell.getDataType())
        TypeAnnotator.annotateExpr( _cell.getExpression() );
View Full Code Here

    }
    else {
      newFold = fold;
    }

    final ExpressionNode result;
    result = node().cloneWithoutArguments();
    result.addArgument( newFold );
    addDynamicArgsToPartialFold( result, dynArgs );
    return result;
  }
View Full Code Here

    final ExpressionNodeForArrayReference tested = makeVertical( this.tested );
    TypeAnnotator.annotateExpr( tested );

    final FilterBuilder filterBuilder = new FilterBuilder();
    final DataType testedType = tested.getDataType();
    final ExpressionNode filter = filterBuilder.buildFilterByExample( 0, this.test, testedType );

    final ExpressionNodeForFoldDatabase apply;
    if (this.folded == null) {
      apply = new ExpressionNodeForFoldDatabase( this.fold, New.array( testedType ), this.colPrefix(), filter, 0,
          null, null, tested );
View Full Code Here

            cellModel.getDataType() );
      }
      return cellModel;
    }

    final ExpressionNode expression = cellModel.getExpression();
    if (null != expression) {
      final TypedResult constResult = EvalShadow.evaluate( expression, type() );
      if (constResult instanceof ExpressionNode) {

        // Do not need to clone leaf node.
View Full Code Here


  protected final ExpressionNode rewrite( ExpressionNode _expr, boolean[] _haveRewritten ) throws CompilerException
  {
    assert this.model != null;
    ExpressionNode result = _expr;
    try {
      if (result instanceof ExpressionNodeForFunction) {
        result = rewriteFun( (ExpressionNodeForFunction) result, _haveRewritten );
      }
    }
View Full Code Here

    }
    else {
      final List<ExpressionNode> args = _expr.arguments();
      final boolean[] argRewritten = new boolean[] { false };
      for (int iArg = 0; iArg < args.size(); iArg++) {
        final ExpressionNode arg = args.get( iArg );
        argRewritten[ 0 ] = false;
        final ExpressionNode rewritten = rewrite( arg, argRewritten );
        if (rewritten != arg) {
          args.set( iArg, rewritten );
        }
        if (argRewritten[ 0 ]) _haveRewritten[ 0 ] = true;
      }
View Full Code Here

  private ExpressionNode rewriteFun( ExpressionNodeForFunction _fun, boolean[] _haveRewritten )
      throws CompilerException
  {
    ExpressionNodeForFunction curr = _fun;
    ExpressionNode rewritten = rewriteFunOnce( curr );
    while (rewritten != curr && rewritten instanceof ExpressionNodeForFunction) {
      curr = (ExpressionNodeForFunction) rewritten;
      rewritten = rewriteFunOnce( curr );
    }
    // The next line assumes function node rewrites are never in-place.
View Full Code Here

        return rewriteAggIf( _fun, this.generatedRules.fold_sum() );
      case COUNTIF:
        return rewriteAggIf( _fun, fold_count() );

      case ISNONTEXT: {
        final ExpressionNode arg = _fun.argument( 0 );
        TypeAnnotator.annotateExpr( arg );
        return DataType.STRING != arg.getDataType() ? TRUE : FALSE;
      }
      case ISNUMBER: {
        final ExpressionNode arg = _fun.argument( 0 );
        TypeAnnotator.annotateExpr( arg );
        return DataType.NUMERIC == arg.getDataType() ? TRUE : FALSE;
      }
      case ISTEXT: {
        final ExpressionNode arg = _fun.argument( 0 );
        TypeAnnotator.annotateExpr( arg );
        return DataType.STRING == arg.getDataType() ? TRUE : FALSE;
      }
      case VALUE: {
        final ExpressionNode arg = _fun.argument( 0 );
        TypeAnnotator.annotateExpr( arg );
        if (DataType.NUMERIC == arg.getDataType()) {
          return arg;
        }
        break;
      }
      case N: {
        final ExpressionNode arg = _fun.argument( 0 );
        TypeAnnotator.annotateExpr( arg );
        if (DataType.NUMERIC == arg.getDataType()) {
          return arg;
        }
        else {
          return ZERO;
        }
      }
      case T: {
        final ExpressionNode arg = _fun.argument( 0 );
        TypeAnnotator.annotateExpr( arg );
        if (DataType.STRING == arg.getDataType()) {
          return arg;
        }
        else {
          return EMPTY_STRING;
        }
      }
      case TEXT: {
        final ExpressionNode arg = _fun.argument( 0 );
        TypeAnnotator.annotateExpr( arg );
        if (DataType.STRING == arg.getDataType()) {
          return arg;
        }
        break;
      }
View Full Code Here

    {
      final int len = _critCols.length;
      final Collection<ExpressionNode> result = New.list( len );
      for (int iCrit = 0; iCrit < len; iCrit++) {
        final int iCol = _critCols[ iCrit ];
        final ExpressionNode criterion = _critIterator.next();
        final ExpressionNode colFilter = (iCol == FREE_FORM) ? buildFreeFormFilter( criterion, _firstRow )
            : buildFilterByExample( iCol, criterion, _colTypes[ iCol ] );
        if (null != colFilter) {
          result.add( colFilter );
        }
      }
View Full Code Here

TOP

Related Classes of org.formulacompiler.compiler.internal.expressions.ExpressionNode

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.