Package wycc.lang

Examples of wycc.lang.NameID


    cases.add(new WyilFile.Case(body, Collections.EMPTY_LIST, Collections.EMPTY_LIST, attributes(expr)));
    WyilFile.FunctionOrMethodDeclaration lambda = new WyilFile.FunctionOrMethodDeclaration(
        modifiers, name, cfm, cases, attributes(expr));
    lambdas.add(lambda);
    Path.ID mid = context.file().module;
    NameID nid = new NameID(mid, name);

    // Finally, create the lambda
    int target = environment.allocate(tfm);
    codes.add(
        Codes.Lambda(cfm, target, operands, nid),
View Full Code Here


   * @param key
   * @return
   */
  private static Pair<Type.Function,NameID> choseToString(Type type) {
    Type.Function ft;
    NameID name;

    if (type == Type.T_BYTE) {
      ft = (Type.Function) Type.Function(Type.T_STRING, Type.T_VOID,
          Type.T_BYTE);
      name = new NameID(Trie.fromString("whiley/lang/Byte"),
          "toString");
    } else if (type == Type.T_CHAR) {
      ft = (Type.Function) Type.Function(Type.T_STRING, Type.T_VOID,
          Type.T_CHAR);
      name = new NameID(Trie.fromString("whiley/lang/Char"),
          "toString");
    } else {
      ft = (Type.Function) Type.Function(Type.T_STRING, Type.T_VOID,
          Type.T_ANY);
      name = new NameID(Trie.fromString("whiley/lang/Any"),
          "toString");
    }

    return new Pair<Type.Function,NameID>(ft,name);
  }
View Full Code Here

    }
    default:
    {
      String typeVariable = parseIdentifier();
      if(typeVariables.contains(typeVariable)) {
        return Nominal(new NameID(Trie.fromString("$"),
            typeVariable));
      } else {
        typeVariables = new HashSet<String>(typeVariables);
        typeVariables.add(typeVariable);
        match("<");
        Type t = parse(typeVariables);
        match(">");
        NameID label = new NameID(Trie.fromString("$"),
            typeVariable);
        return Recursive(label, t);
      }
    }
View Full Code Here

        return !fromSign && !toSign;
      case K_ANY:
        return fromSign && toSign;
      // === Leaf States First ===
      case K_NOMINAL: {
        NameID nid1 = (NameID) fromState.data;
        NameID nid2 = (NameID) toState.data;
        if(fromSign || toSign) {
          if(nid1.equals(nid2)) {
            return fromSign && toSign;
          } else {
            return !fromSign || !toSign;
View Full Code Here

        fn = "Difference";
        break;
      default:
        fn = ""; // deadcode
      }
      NameID nid = new NameID(WYCS_CORE_SET,fn);
      SemanticType.Tuple argType = SemanticType.Tuple(type, type);
      SemanticType.Function funType = SemanticType.Function(argType,
          type, ((SemanticType.Set)type).element());
      Code argument = Code.Nary(argType, Code.Op.TUPLE, new Code[] {
          lhs,rhs });
      return Code.FunCall(funType, argument, nid,
          attributes(e));
    }
    case LISTAPPEND: {
      NameID nid = new NameID(WYCS_CORE_LIST,"Append");
      SemanticType.Tuple argType = SemanticType.Tuple(type,type);
      SemanticType[] generics = bindGenerics(nid,argType,e);
      SemanticType.Function funType = SemanticType.Function(argType,
          type,generics);
      Code argument = Code.Nary(argType, Code.Op.TUPLE, new Code[] {
          lhs,rhs });
      return Code.FunCall(funType, argument, nid,
          attributes(e));
    }
    case RANGE: {
      NameID nid = new NameID(WYCS_CORE_LIST,"Range");
      SemanticType.Tuple argType = SemanticType.Tuple(SemanticType.Int,SemanticType.Int);
      SemanticType.Function funType = SemanticType.Function(argType,
          type);
      Code argument = Code.Nary(argType, Code.Op.TUPLE, new Code[] {
          lhs,rhs });
View Full Code Here

    SemanticType.EffectiveTuple element = (SemanticType.EffectiveTuple) type.element();
    Code first = generate(e.firstOperand, environment, context);
    Code second = generate(e.secondOperand, environment, context);
    Code third = generate(e.thirdOperand, environment, context);
    SemanticType argType;
    NameID nid;
    switch (e.op) {
    case UPDATE:
      nid = new NameID(WYCS_CORE_LIST, "ListUpdate");
      argType = SemanticType.Tuple(type,SemanticType.Int, element.tupleElement(1));
      break;
    case SUBLIST:
      nid = new NameID(WYCS_CORE_LIST, "Sublist");
      argType = SemanticType.Tuple(type,SemanticType.Int,SemanticType.Int);
      break;
    default:
      internalFailure("unknown ternary opcode encountered (" + e + ")",
          filename, e);
View Full Code Here

      SemanticType.Tuple argType = SemanticType.Tuple(type,
          element.tupleElement(0));
      SemanticType.Function funType = SemanticType.Function(argType,
          element.tupleElement(1),element.tupleElement(0),element.tupleElement(1));
      Code index = generate(e.index, environment, context);
      NameID nid = new NameID(WYCS_CORE_MAP, "IndexOf");
      Code argument = Code.Nary(argType, Code.Op.TUPLE, new Code[] {
          source, index });
      return Code.FunCall(funType, argument, nid,
          attributes(e));
    }
View Full Code Here

        try {
          WycsFile wf = getModule(id);
          if(wf == null) { continue; }
          T d = wf.declaration(name, type);
          if (d != null) {
            return new Pair<NameID, T>(new NameID(id, name), d);
          }
        } catch(SyntaxError e) {
          throw e;
        } catch (Exception e) {
          internalFailure(e.getMessage(), context.file().filename(),
View Full Code Here

      // int kind = input.read_uv();
      int pathIndex = input.read_uv();
      int nameIndex = input.read_uv();
      Path.ID id = pathPool[pathIndex];
      String name = stringPool[nameIndex];
      myNamePool[i] = new NameID(id, name);
    }

    namePool = myNamePool;
  }
View Full Code Here

TOP

Related Classes of wycc.lang.NameID

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.