Package org.formulacompiler.compiler.internal.model

Examples of org.formulacompiler.compiler.internal.model.CellModel


      final ExpressionNodeForConstantValue constNode = (ExpressionNodeForConstantValue) _node;
      return constNode.value();
    }
    else if (_node instanceof ExpressionNodeForCellModel) {
      final ExpressionNodeForCellModel cellNode = (ExpressionNodeForCellModel) _node;
      final CellModel cell = cellNode.getCellModel();
      if (null == cell) {
        return null;
      }
      else if (!cell.isInput()) {
        if (null == cell.getExpression()) {
          return cell.getConstantValue();
        }
        else {
          return constantValueOf( cell.getExpression() );
        }
      }
    }
    return NOT_CONST;
  }
View Full Code Here


  protected final ExpressionNode expressionOf( ExpressionNode _node )
  {
    if (_node instanceof ExpressionNodeForCellModel) {
      final ExpressionNodeForCellModel cellNode = (ExpressionNodeForCellModel) _node;
      final CellModel cell = cellNode.getCellModel();
      if (null != cell && !cell.isInput() && null != cell.getExpression()) {
        return expressionOf( cell.getExpression() );
      }
    }
    return _node;
  }
View Full Code Here

    if (_expr == null) return null;

    ExpressionNode result = _expr;
    while (result instanceof ExpressionNodeForCellModel) {
      final ExpressionNodeForCellModel cellNode = (ExpressionNodeForCellModel) result;
      final CellModel cellModel = cellNode.getCellModel();
      if (!isInlineable( cellModel )) return result;
      result = cellModel.getExpression();
      if (null == result) {
        result = new ExpressionNodeForConstantValue( cellModel.getConstantValue(), cellModel.getDataType() );
      }
      else {
        cellModel.setExpression( null );
      }
    }
    inlineIntermediateResultsIntoArgsOf( result );
    return result;
  }
View Full Code Here

    if (_expr == null) {
      // nothing to do
    }
    else if (_expr instanceof ExpressionNodeForCellModel) {
      ExpressionNodeForCellModel cellNode = (ExpressionNodeForCellModel) _expr;
      CellModel cellModel = cellNode.getCellModel();
      if (null != cellModel) {
        reference( cellModel, _accessedBySubBand );
      }
    }
    else {
View Full Code Here

  private void addRefToEverythingReferencedBy( CallFrame _callChainToCall )
  {
    if (null == _callChainToCall) return;
    for (Object arg : _callChainToCall.getArgs()) {
      if (arg instanceof CellModel) {
        CellModel cell = (CellModel) arg;
        reference( cell, true );
      }
    }
    addRefToEverythingReferencedBy( _callChainToCall.getPrev() );
  }
View Full Code Here

  {
    final Spreadsheet ss = this.binding.getSpreadsheet();
    for (Entry<String, Spreadsheet.Range> nameDef : ss.getRangeNames().entrySet()) {
      final Spreadsheet.Range range = nameDef.getValue();
      if (range instanceof Spreadsheet.Cell) {
        final CellModel cellModel = getCellModel( (CellIndex) range );
        if (null != cellModel) {
          cellModel.setName( nameDef.getKey() );
        }
      }
    }
  }
View Full Code Here

        final Class[] types = method.getParameterTypes();
        for (int i = 0; i < args.length; i++) {
          final Object arg = args[ i ];
          final Class type = types[ i ];
          if (arg instanceof CellModel) {
            final CellModel argCell = (CellModel) arg;
            final ExpressionCompiler ex = expressionCompilerFor( type );
            ex.compileRef( argCell );
            ex.compileConversionTo( type );
          }
          else {
View Full Code Here


  @Override
  protected void compileBody() throws CompilerException
  {
    final CellModel cell = this.cellComputation.getCell();

    if (cell.isOutput()) {
      compileOutputGetter();
    }

    if (cell.isInput()) {
      if (shouldCache( cell )) {
        compileCacheBegin();
        compileInput( cell.getCallChainToCall() );
        compileCacheEnd();
      }
      else {
        compileInput( cell.getCallChainToCall() );
      }
    }
    else {
      final ExpressionNode cellExpr = cell.getExpression();
      final ExpressionCompiler ec = expressionCompiler();
      if (null != cellExpr) {
        if (shouldCache( cell )) {
          compileCacheBegin();
          compileExpression( cellExpr );
          compileCacheEnd();
        }
        else {
          compileExpression( cellExpr );
        }
      }
      else {
        final Object constantValue = cell.getConstantValue();
        ec.compileConst( constantValue );
      }
    }
  }
View Full Code Here

  {
    compileInputGetterCall( _callChainToCall );
    expressionCompiler().compileConversionFromResultOf( _callChainToCall.getMethod() );

    if (section().isComputationListenerEnabled()) {
      final CellModel cellModel = this.cellComputation.getCell();
      final Object source = cellModel.getSource();
      if (source instanceof CellAddress) {
        final CellAddress cellAddress = (CellAddress) source;
        final String name = cellModel.getName();
        expressionCompiler().compileLogging( cellAddress, name, true, cellModel.isOutput() );
      }
    }
  }
View Full Code Here

  }


  private final void compileOutputGetter() throws CompilerException
  {
    final CellModel cell = this.cellComputation.getCell();
    for (CallFrame callFrame : cell.getCallsToImplement()) {

      if (callFrame.getHead() != callFrame) throw new IllegalArgumentException();

      final Method method = callFrame.getMethod();
      if (0 == callFrame.getArgs().length) {
View Full Code Here

TOP

Related Classes of org.formulacompiler.compiler.internal.model.CellModel

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.