Package sizzle.types

Examples of sizzle.types.SizzleType


  }

  /** {@inheritDoc} */
  @Override
  public SizzleType visit(final Conjunction n, final SymbolTable argu) {
    final SizzleType lhs = n.f0.accept(this, argu);

    if (n.f1.present()) {
      final SizzleType rhs = n.f0.accept(this, argu);

      if (!rhs.compares(lhs))
        throw new TypeException("invalid type " + rhs + " for conjunction with " + lhs);

      return new SizzleBool();
    }

View Full Code Here


  }

  /** {@inheritDoc} */
  @Override
  public SizzleType visit(final Comparison n, final SymbolTable argu) {
    final SizzleType lhs = n.f0.accept(this, argu);

    if (n.f1.present()) {
      final SizzleType rhs = ((NodeSequence) n.f1.node).nodes.get(1).accept(this, argu);

      if (!rhs.compares(lhs))
        throw new TypeException("invalid type " + rhs + " for comparison with " + lhs);

      return new SizzleBool();
    }

View Full Code Here

  }

  /** {@inheritDoc} */
  @Override
  public SizzleType visit(final SimpleExpr n, final SymbolTable argu) {
    SizzleType type = n.f0.accept(this, argu);

    if (n.f1.present()) {
      for (final Node node : n.f1.nodes) {
        final SizzleType accept = ((NodeSequence) node).nodes.get(1).accept(this, argu);
        type = type.arithmetics(accept);
      }
    }

    return type;
View Full Code Here

  }

  /** {@inheritDoc} */
  @Override
  public SizzleType visit(final Term n, final SymbolTable argu) {
    final SizzleType accepts = n.f0.accept(this, argu);

    if (n.f1.present()) {
      SizzleScalar type;

      if (accepts instanceof SizzleFunction)
        type = (SizzleScalar) ((SizzleFunction) accepts).getType();
      else
        type = (SizzleScalar) accepts;

      for (final Node node : n.f1.nodes) {
        final SizzleType accept = ((NodeSequence) node).nodes.get(1).accept(this, argu);

        type = type.arithmetics(accept);
      }

      return type;
View Full Code Here

    if (n.f1.present()) {
      for (final Node node : n.f1.nodes) {
        final NodeChoice nodeChoice = (NodeChoice) node;
        switch (nodeChoice.which) {
        case 0: // member
          final SizzleType soperand = n.f0.accept(this, argu);

          if (!(soperand instanceof SizzleTuple))
            throw new TypeException("invalid operand type " + soperand + " for member selection");

          // final SizzleType selector = ((Selector)
          // nodeChoice.choice).accept(this, argu);

          return ((SizzleTuple) soperand).getMember(((Selector) nodeChoice.choice).f1.f0.tokenImage);
        case 1: // index
          final SizzleType ioperand = n.f0.accept(this, argu);

          final SizzleType index = ((Index) nodeChoice.choice).accept(this, argu);

          if (ioperand instanceof SizzleArray) {
            if (!(index instanceof SizzleInt))
              throw new TypeException("invalid operand type " + index + " for indexing into array");
View Full Code Here

    final List<String> tables = new ArrayList<String>();
    for (final Entry<String, TableDescription> entry : this.tables.entrySet()) {
      final String id = entry.getKey();
      final TableDescription description = entry.getValue();
      final String parameters = description.getParameters() == null ? "" : description.getParameters().get(0);
      final SizzleType type = description.getType();

      final StringBuilder src = new StringBuilder();
      for (final Class<?> c : argu.getAggregators(description.getAggregator(), type))
        src.append(", new " + c.getCanonicalName() + "(" + parameters + ")");
View Full Code Here

    return null;
  }

  @Override
  public String visit(final VarDecl n, final SymbolTable argu) {
    final SizzleType type = argu.get(n.f0.f0.tokenImage);

    if (n.f2.present()) {
      argu.setId(n.f0.f0.tokenImage);
      n.f2.node.accept(this, argu);
      argu.setId(null);
    }

    if (type instanceof SizzleTable)
      return null;

    final StringTemplate st = this.stg.getInstanceOf("VarDecl");

    st.setAttribute("id", n.f0.f0.tokenImage);

    // TODO: make templates for types
    st.setAttribute("type", type.toJavaType());

    if (n.f3.present()) {
      final NodeChoice nodeChoice = (NodeChoice) n.f3.node;

      switch (nodeChoice.which) {
      case 0: // initializer
        SizzleType t;
        try {
          t = this.typechecker.visit((Expression) ((NodeSequence) nodeChoice.choice).elementAt(1), argu.cloneNonLocals());
        } catch (final IOException e) {
          throw new RuntimeException(e.getClass().getSimpleName() + " caught", e);
        }
View Full Code Here

  @Override
  public String visit(final Index n, final SymbolTable argu) {
    final StringTemplate st = this.stg.getInstanceOf("Index");

    try {
      final SizzleType t = this.typechecker.visit(argu.getOperand(), argu.cloneNonLocals());
      if (t instanceof SizzleMap)
        st.setAttribute("map", true);
      else if (t instanceof SizzleArray)
        st.setAttribute("map", false);
    } catch (final IOException e) {
View Full Code Here

      switch (nodeChoice.which) {
      case 0: // pair list
        st.setAttribute("pairlist", nodeChoice.choice.accept(this, argu));
        break;
      case 1: // expression list
        final SizzleType t;
        try {
          t = this.typechecker.visit((ExprList) nodeChoice.choice, argu.cloneNonLocals());
        } catch (final IOException e) {
          throw new RuntimeException(e.getClass().getSimpleName() + " caught", e);
        }

        st.setAttribute("type", t.toJavaType());
        st.setAttribute("exprlist", nodeChoice.choice.accept(this, argu));
        break;
      default:
        throw new RuntimeException("unexpected choice " + nodeChoice.which + " is " + nodeChoice.choice.getClass());
      }
View Full Code Here

TOP

Related Classes of sizzle.types.SizzleType

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.