Package org.formulacompiler.compiler.internal.expressions

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


    // We need the type info to properly treat by-example criteria contained in strings.
    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 );
    }
    else {
      TypeAnnotator.annotateExpr( this.folded );
      final DataType foldedType = this.folded.getDataType();
      apply = new ExpressionNodeForFoldDatabase( this.fold, New.array( testedType, foldedType ), this.colPrefix(),
          filter, 1, null, null, vectorsToMatrix( tested, makeVertical( this.folded ) ) );
    }

    return filterBuilder.encloseFoldInLets( apply );
View Full Code Here



  private DataType annotate( CellModel _cell ) throws CompilerException
  {
    if (_cell == null) return DataType.NULL;
    final DataType type = _cell.getDataType();
    if (null != type) {
      return type;
    }
    else {
      final Object cst = _cell.getConstantValue();
View Full Code Here

  {
    if (null == _expr) {
      return DataType.NULL;
    }
    else {
      final DataType type = _expr.getDataType();
      if (null != type) {
        return type;
      }
      else {
        final DataType inferredDataType = dispatch( _expr );
        final DataType declaredDataType = _expr.getDeclaredDataType();
        if (declaredDataType != null) {
          if (inferredDataType != null && inferredDataType != declaredDataType) {
            throw new CompilerException.DataTypeError( "The declared type " + declaredDataType
                + " of expression " + _expr + " does not match its inferred type " + inferredDataType + "." );
          }
View Full Code Here

    }
  }

  private DataType typeOf( Iterable<ExpressionNode> _exprs )
  {
    DataType type = DataType.NULL;
    for (ExpressionNode arg : _exprs) {
      if (null != arg) {
        DataType argType = arg.getDataType();
        switch (argType) {
          case NUMERIC:
            return argType;
          case STRING:
            type = argType;
View Full Code Here

  }


  private DataType typeOf( ExpressionNodeForLet _expr ) throws CompilerException
  {
    final DataType valType = annotate( _expr.value() );
    letDict().let( _expr.varName(), valType, null );
    try {
      return annotate( _expr.in() );
    }
    finally {
View Full Code Here

    return annotate( exp );
  }

  private DataType commonTypeOf( ExpressionNode _parent, ExpressionNode... _args ) throws CompilerException
  {
    DataType refType = null;
    ExpressionNode refExpr = null;
    for (ExpressionNode arg : _args) {
      final DataType type = arg.getDataType();
      if (type != null) {
        refType = type;
        refExpr = arg;
        break;
      }
    }
    if (refType == null) {
      throw new CompilerException.DataTypeError( "Cannot determine type of expression " + _parent
          + " because its argument(s) are untyped." );
    }
    for (ExpressionNode arg : _args) {
      final DataType type = arg.getDataType();
      if (type != null) {
        if (refType != type) {
          throw new CompilerException.DataTypeError( "Arguments of expression " + _parent
              + " must have the same type."
              + "\nExpression " + arg + " has type " + type + "."
View Full Code Here

    if (null == _node) {
      mv().visitInsn( Opcodes.ACONST_NULL );
      return;
    }

    final DataType nodeType = _node.getDataType();

    if (null == nodeType) {
      throw new CompilerException.UnsupportedDataType( "Internal error: Data type not set on node "
          + _node.describe() + "." );
    }
View Full Code Here

  @Override
  protected void compileBody() throws CompilerException
  {
    assert ChainedFoldCompiler.isChainable( fold ) && !fold.isSpecialWhenEmpty();
    final ExpressionNode initNode = fold.accuInit( 0 );
    final DataType initType = initNode.getDataType();
    final Iterable<ExpressionNode> elts = apply.elements();
    final ExpressionNode initialElt = fold.mayReduceAndRearrange() ? firstLocalElementIn( elts ) : null;
    final ExpressionNode initial = (null != initialElt) ? initialElt : initNode;

    expressionCompiler().compile( initial );
View Full Code Here

  @Override
  protected void compileBody() throws CompilerException
  {
    final GeneratorAdapter mv = mv();
    final DataType eltDataType = this.arrayNode.getDataType();
    final ExpressionCompiler eltCompiler = expressionCompiler( eltDataType );
    final Type eltType = eltCompiler.type();
    final String initName = methodName() + "$init";
    final String initDesc = "Z";
View Full Code Here

    final int nAccus = fold.accuCount();
    accuTypes = new Type[ nAccus ];
    accuVars = new int[ nAccus ];
    for (int i = 0; i < nAccus; i++) {
      final ExpressionNode initNode = fold.accuInit( i );
      final DataType initType = initNode.getDataType();
      final Type accuType = section().engineCompiler().typeCompiler( initType ).type();
      final int accuVar = newLocal( accuType.getSize() );
      accuTypes[ i ] = accuType;
      accuVars[ i ] = accuVar;
      expressionCompiler().compile( initNode );
View Full Code Here

TOP

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

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.