Package org.formulacompiler.compiler.internal.expressions

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


public class LoggingVisitor extends AbstractComputationModelVisitor
{
  @Override
  protected boolean visitCell( final CellModel _cell ) throws CompilerException
  {
    final ExpressionNode expr = _cell.getExpression();
    if (expr != null) {
      final Object source = _cell.getSource();
      final String definedName = _cell.getName();
      final boolean input = _cell.isInput();
      final boolean output = _cell.isOutput();
View Full Code Here


  @Override
  protected void compileTraversal() throws CompilerException
  {
    final int colIdx = this.db.staticFoldedColumnIndex();
    if (colIdx < 0) {
      final ExpressionNode colIdxExpr = this.db.foldedColumnIndex();
      compileColumnSwitch( colIdxExpr );
    }
    else {
      compileFixedColumnTraversal( colIdx );
    }
View Full Code Here

  }


  private int compileRowTraversal( int _foldedCol, List<ExpressionNode> _elts, int _iElt ) throws CompilerException
  {
    final ExpressionNode elt = _elts.get( _iElt );
    if (elt instanceof ExpressionNodeForArrayReference) {
      compileRowTraversal( _foldedCol, elt.arguments(), 0 );
      return _iElt + 1;
    }
    else if (elt instanceof ExpressionNodeForSubSectionModel) {
      compileSubSectionTraversal( _foldedCol, (ExpressionNodeForSubSectionModel) elt );
      return _iElt + 1;
    }
    else {
      final GeneratorAdapter mv = mv();
      final int iFoldedElt = _iElt + _foldedCol;
      final ExpressionNode foldedElt = _elts.get( iFoldedElt );
      final Label noMatch = mv.newLabel();
      compileCallToMatcherAndBuildItInFirstPass( _elts, _iElt );
      compileSkipFoldIfNoMatch( noMatch );
      compileElementFold( foldedElt );
      mv.mark( noMatch );
View Full Code Here

  {
    final int nCols = this.tableDescriptor.numberOfColumns();
    final GeneratorAdapter mv = mv();
    try {
      for (int iCol = 0; iCol < nCols; iCol++) {
        final ExpressionNode elt = _elts.get( _iElt + iCol );
        letDict().let( this.colNames[ iCol ], this.colTypes[ iCol ], elt );
      }
      final Iterable<LetEntry> closure = closureOf( this.filterExpr );
      if (this.matcher == null) {
        this.matcher = new HelperCompilerForDatabaseMatch( section(), this.filterExpr, closure );
View Full Code Here

      {

        @Override
        protected void generateCase( int _key, Label _end ) throws CompilerException
        {
          final ExpressionNode val = vals.get( _key );
          valCompiler.compile( val );
          mv.visitInsn( valReturn );
        }

      } );
View Full Code Here

      return args.toArray( new ExpressionNode[ args.size() ] );
    }
    else if (_arrayRefNode instanceof ExpressionNodeForLetVar) {
      final ExpressionNodeForLetVar var = (ExpressionNodeForLetVar) _arrayRefNode;
      final Object res = letDict().lookup( var.varName() );
      final ExpressionNode val = (ExpressionNode) res;
      return arrayRefElements( _outerNode, val );
    }
    else {
      throw new CompilerException.UnsupportedExpression( "Array reference expected in "
          + _outerNode.describe() + "." );
View Full Code Here

  public final boolean compile() throws CompilerException
  {
    final Iterable<ExpressionNode> elts = firstVectorOf( apply.elements() );
    if (!elts.iterator().hasNext()) {
      final ExpressionNode whenEmpty = fold.isSpecialWhenEmpty() ? fold.whenEmpty() : fold.accuInit( 0 );
      expc.compile( whenEmpty );
      return true;
    }
    if (isChainable( fold ) && !ExpressionCompiler.isSubSectionIn( elts )) {
      final ExpressionNode initial = fold.mayReduce() ? elts.iterator().next() : fold.accuInit( 0 );
      expc.compile( initial );
      final String accName = fold.accuName( 0 );
      letDict.let( accName, fold.accuInit( 0 ).getDataType(), expc.TOP_OF_STACK );
      compileFoldOverLocalValues( elts, initial );
      letDict.unlet( accName );
View Full Code Here

  }

  static Iterable<ExpressionNode> firstVectorOf( Iterable<ExpressionNode> _elts )
  {
    Iterable<ExpressionNode> vec0 = _elts;
    ExpressionNode elt0;
    while ((elt0 = vec0.iterator().next()) instanceof ExpressionNodeForSubstitution
        || elt0 instanceof ExpressionNodeForArrayReference) {
      vec0 = elt0.arguments();
    }
    return vec0;
  }
View Full Code Here

        compileMatch( _node, 1 );
        return;
      }

      case 3: {
        final ExpressionNode typeArg = _node.arguments().get( 2 );
        if (typeArg instanceof ExpressionNodeForConstantValue) {
          final ExpressionNodeForConstantValue constTypeArg = (ExpressionNodeForConstantValue) typeArg;
          final Object typeVal = constTypeArg.value();
          if (typeVal instanceof Number) {
            compileMatch( _node, ((Number) typeVal).intValue() );
          }
          else if (typeVal instanceof Boolean) {
            compileMatch( _node, (Boolean) typeVal ? 1 : 0 );
          }
          else {
            compileMatch( _node, 1 );
          }
          return;
        }
        throw new InnerExpressionException( typeArg, new CompilerException.UnsupportedExpression(
            "The last argument to MATCH, the match type, must be constant, but is " + typeArg.describe() + "." ) );
      }

    }
    throw new CompilerException.UnsupportedExpression( "MATCH must have two or three arguments." );
  }
View Full Code Here

  private static final String[] TYPE_SUFFIXES = { "Descending", "Exact", "Ascending" };

  private void compileMatch( ExpressionNodeForFunction _node, int _type ) throws CompilerException
  {
    final ExpressionNode valNode = _node.argument( 0 );
    final ExpressionNodeForArrayReference arrayNode = (ExpressionNodeForArrayReference) _node.argument( 1 );
    if (valNode.getDataType() != arrayNode.getDataType()) {
      throw new CompilerException.UnsupportedExpression(
          "MATCH must have the same type of argument in the first and second slot." );
    }
    final int type = (_type > 0) ? +1 : (_type < 0) ? -1 : 0;

    final ExpressionCompilerForNumbers numCompiler = method().numericCompiler();
    final ExpressionCompiler valCompiler = method().expressionCompiler( valNode.getDataType() );
    final ArrayAccessorCompiler acc = section().getArrayAccessorForFullData( arrayNode );

    // return Runtime.fun_MATCH_xy( val, vals [, env] );
    final boolean needEnv = (valNode.getDataType() == DataType.STRING && type != 0);
    final String envDescriptor = needEnv ? ByteCodeEngineCompiler.ENV_DESC : "";
    valCompiler.compile( valNode );
    mv().loadThis();
    acc.compileCall( mv() );
    if (needEnv) {
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.