Package wycc.lang

Examples of wycc.lang.NameID


      // 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


        case WyilFileWriter.CONSTANT_Function :
        case WyilFileWriter.CONSTANT_Method : {
          int typeIndex = input.read_uv();
          int nameIndex = input.read_uv();
          Type.FunctionOrMethod t = (Type.FunctionOrMethod) typePool[typeIndex];
          NameID name = namePool[nameIndex];
          constant = Constant.V_LAMBDA(name, t);
          break;
        }
        default:
          throw new RuntimeException(
View Full Code Here

      case Code.OPCODE_invokemdv: {
        if (!(type instanceof Type.FunctionOrMethod)) {
          throw new RuntimeException("expected function or method type");
        }
        int nameIdx = readRest(wideRest);;
        NameID nid = namePool[nameIdx];
        return Codes.Invoke((Type.FunctionOrMethod) type, Codes.NULL_REG,
            operands, nid);
      }
    }
    throw new RuntimeException("unknown opcode encountered (" + opcode
View Full Code Here

    case Code.OPCODE_invokemd: {
      if(!(type instanceof Type.FunctionOrMethod)) {
        throw new RuntimeException("expected function or method type");
      }
      int nameIdx = readRest(wideRest);
      NameID nid = namePool[nameIdx];
      return Codes.Invoke((Type.FunctionOrMethod) type, target, operands,
          nid);
    }
    case Code.OPCODE_lambdafn:
    case Code.OPCODE_lambdamd: {
      if(!(type instanceof Type.FunctionOrMethod)) {
        throw new RuntimeException("expected function or method type");
      }
      // Lambda's are the only instances of NULLABLENARYASSIGN's
      for(int i=0;i!=operands.length;++i) {
        operands[i] -= 1;
      }
      int nameIdx = readRest(wideRest);
      NameID nid = namePool[nameIdx];
      return Codes.Lambda((Type.FunctionOrMethod) type, target, operands,
          nid);
    }
    case Code.OPCODE_newmap: {
      if (!(type instanceof Type.Map)) {
View Full Code Here

   * @param cd
   *            Constant declaration to check.
   * @throws IOException
   */
  public void propagate(WhileyFile.Constant cd) throws IOException, ResolveError {
    NameID nid = new NameID(cd.file().module, cd.name());
    cd.resolvedValue = resolveAsConstant(nid);
  }
View Full Code Here

      for (String n : expr.qualification) {
        qualifications.add(n);
      }
    }
    qualifications.add(expr.name);
    NameID name = resolveAsName(qualifications, context);

    // third, lookup the appropriate function or method based on the name
    // and given parameter types.
    Nominal.FunctionOrMethod funType = resolveAsFunctionOrMethod(name,
        paramTypes, context);
View Full Code Here

        qualifications.add(n);
      }
    }
    qualifications.add(expr.name);
    try {
      NameID name = resolveAsName(qualifications, context);
      // Second, determine the value of the constant.
      expr.value = resolveAsConstant(name);
      return expr;
    } catch (ResolveError e) {
      syntaxError(errorMessage(UNKNOWN_VARIABLE), context, expr);
View Full Code Here

          // the given name exists, in which case any matching names
          // are automatically imported.
          filter = filter.parent().append(name);
        }
        for (Path.ID mid : builder.imports(filter)) {
          NameID nid = new NameID(mid, name);
          addCandidateFunctionsAndMethods(nid, parameters,
              candidates, context);
        }
      }
    }
View Full Code Here

    } else {
      rawParameters = null;
      target = null;
    }

    NameID candidateID = null;
    Nominal.FunctionOrMethod candidateType = null;
    for (Pair<NameID, Nominal.FunctionOrMethod> p : candidates) {
      Nominal.FunctionOrMethod nft = p.second();
      Type.FunctionOrMethod ft = nft.raw();
      if (parameters == null || paramSubtypes(ft, target)) {
        // this is now a genuine candidate
        if (candidateType == null
            || paramStrictSubtypes(candidateType.raw(), ft)) {
          candidateType = nft;
          candidateID = p.first();
        } else if (!paramStrictSubtypes(ft, candidateType.raw())) {
          // this is an ambiguous error
          String msg = name + parameterString(parameters)
              + " is ambiguous";
          // FIXME: should report all ambiguous matches here
          msg += "\n\tfound: " + candidateID + " : "
              + candidateType.nominal();
          msg += "\n\tfound: " + p.first() + " : "
              + p.second().nominal();
          throw new ResolveError(msg);
        }
      }
    }

    if (candidateType == null) {
      // second, didn't find matching message so generate error message
      String msg = "no match for " + name + parameterString(parameters);

      for (Pair<NameID, Nominal.FunctionOrMethod> p : candidates) {
        msg += "\n\tfound: " + p.first() + " : " + p.second().nominal();
      }

      throw new ResolveError(msg);
    } else {
      // now check protection modifier
      WhileyFile wf = builder.getSourceFile(candidateID.module());
      if (wf != null) {
        if (wf != context.file()) {
          for (WhileyFile.FunctionOrMethod d : wf.declarations(
              WhileyFile.FunctionOrMethod.class,
              candidateID.name())) {
            if (d.parameters.equals(candidateType.params())) {
              if (!d.hasModifier(Modifier.PUBLIC)
                  && !d.hasModifier(Modifier.PROTECTED)) {
                String msg = candidateID.module() + "." + name
                    + parameterString(parameters)
                    + " is not visible";
                throw new ResolveError(msg);
              }
            }
          }
        }
      } else {
        WyilFile m = builder.getModule(candidateID.module());
        WyilFile.FunctionOrMethodDeclaration d = m.functionOrMethod(
            candidateID.name(), candidateType.raw());
        if (!d.hasModifier(Modifier.PUBLIC)
            && !d.hasModifier(Modifier.PROTECTED)) {
          String msg = candidateID.module() + "." + name
              + parameterString(parameters) + " is not visible";
          throw new ResolveError(msg);
        }
      }
    }
View Full Code Here

          // the given name exists, in which case any matching names
          // are automatically imported.
          filter = filter.parent().append(name);
        }
        for (Path.ID mid : builder.imports(filter)) {
          NameID nid = new NameID(mid, name);
          if (builder.isName(nid)) {
            // ok, we have found the name in question. But, is it
            // visible?
            if (isNameVisible(nid, context)) {
              return nid;
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.