Package xtc.type

Examples of xtc.type.Type


        // pass the value through to existing variant types.
        for (Production p : m.productions) {
          if (AST.isDynamicNode(p.type) &&
              AST.isGenericNode(p.type) &&
              ! analyzer.setsValue(p.choice, false)) {
            final Type t = gtyper.type(p, false);
            if (! t.isError()) setType(p, t);
          }
        }

        // Pull.
        isPushMode = false;
View Full Code Here


    pushPull(m);

    // Process any remaining generic productions.
    for (Production p : m.productions) {
      if (AST.isDynamicNode(p.type) && AST.isGenericNode(p.type)) {
        Type t = gtyper.type(p, true);

        if (! t.isError()) {
          setType(p, t);
          productions.add(p);
        }
      }
    }
View Full Code Here

    dispatch(p.choice);

    // Update the production's type in pull mode by unifying the
    // alternatives' types.
    if (! isPushMode) {
      Type    result   = Wildcard.TYPE;
      boolean seenWild = false; // Flag for having seen a wildcard.
      boolean seenPoly = false; // Flag for having seen a polymorphic variant.

      loop: for (Type t : types) {
        switch (t.tag()) {
        case ERROR:
          result = ErrorT.TYPE;
          break loop;

        case WILDCARD:
          seenWild = true;
          if (seenPoly) {
            runtime.error("production requires polymorphic variant", p);
            runtime.errConsole().loc(p).
              pln(": error: but has alternatives without static type").flush();
            result = ErrorT.TYPE;
            break loop;
          }
          break;

        case VARIANT:
          if (seenPoly) {
            result = merge(result.toVariant(), t.toVariant(), p);
            if (result.isError()) break loop;

          } else if (result.isWildcard()) {
            result = t;

          } else if (! result.equals(t)) {
            if (isGeneric) {
              runtime.error("variant '" + result.toVariant().getName() + "' " +
                            "overlaps with '" + t.toVariant().getName() + "'",p);
              result = ErrorT.TYPE;
              break loop;

            } else if (seenWild) {
              runtime.error("production requires polymorphic variant", p);
              runtime.errConsole().loc(p).
                pln(": error: but has alternatives without static type").flush();
              result = ErrorT.TYPE;
              break loop;

            } else {
              VariantT v = result.toVariant();
              result     = merge(ast.toVariant(p.qName.name, true), v, p);
              if (result.isError()) break loop;
              result     = merge(result.toVariant(), t.toVariant(), p);
              if (result.isError()) break loop;
              seenPoly   = true;
            }
          }
          break;

        default:
          throw new AssertionError("Unrecognized type " + t);
        }
      }

      // If we have a meaningful result, update the production's type.
      if (! result.isWildcard()) {
        setType(p, result);

        final Type r = result.resolve();
        if (r.isVariant() && ! r.toVariant().isPolymorphic()) {
          // Push the production's variant type.
          productions.add(p);
        }
      }
    }
View Full Code Here

      }

      // Update the element type.
      if ((null != element) && ! element.isError()) {
        for (Binding b : bindings) {
          Type t = analyzer.type(b.element);
          if (AST.isList(t)) t = AST.getArgument(t);

          Type u = ast.unify(element, t, true);
          if (u.isError()) {
            runtime.error("unable to determine consistent list element type", s);
            runtime.errConsole().loc(s).p(": error: 1st type is '");
            ast.print(element, runtime.errConsole(), false, true, null);
            runtime.errConsole().pln("'");
            runtime.errConsole().loc(s).p(": error: 2nd type is '");
View Full Code Here

TOP

Related Classes of xtc.type.Type

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.