Package wycc.util

Examples of wycc.util.ResolveError


        }
        importCache.put(key, matches);
      }
      return matches;
    } catch(Exception e) {
      throw new ResolveError(e.getMessage(),e);
    }
  }
View Full Code Here


          // 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);
        }
      }
    }

    return new Pair<NameID, Nominal.FunctionOrMethod>(candidateID,
View Full Code Here

            // ok, we have found the name in question. But, is it
            // visible?
            if (isNameVisible(nid, context)) {
              return nid;
            } else {
              throw new ResolveError(nid + " is not visible");
            }
          }
        }
      }
    }

    throw new ResolveError("name not found: " + name);
  }
View Full Code Here

      NameID nid = new NameID(mid, name);
      if (builder.isName(nid)) {
        if (isNameVisible(nid, context)) {
          return nid;
        } else {
          throw new ResolveError(nid + " is not visible");
        }
      }
    } else {
      String name = names.get(names.size() - 1);
      String module = names.get(names.size() - 2);
      Path.ID pkg = Trie.ROOT;
      for (int i = 0; i != names.size() - 2; ++i) {
        pkg = pkg.append(names.get(i));
      }
      Path.ID mid = pkg.append(module);
      NameID nid = new NameID(mid, name);
      if (builder.isName(nid)) {
        if (isNameVisible(nid, context)) {
          return nid;
        } else {
          throw new ResolveError(nid + " is not visible");
        }
      }
    }

    String name = null;
    for (String n : names) {
      if (name != null) {
        name = name + "." + n;
      } else {
        name = n;
      }
    }
    throw new ResolveError("name not found: " + name);
  }
View Full Code Here

      for (Path.ID mid : builder.imports(filter)) {
        return mid;
      }
    }

    throw new ResolveError("module not found: " + name);
  }
View Full Code Here

          return myIndex;
        }
        Type.Set ts = (Type.Set) t;
        return append(ts.element(), states);
      } else {
        throw new ResolveError("type not found: " + key);
      }
    }

    // following is needed to terminate any recursion
    roots.put(key, states.size());
View Full Code Here

      throws IOException, ResolveError {
    Constant result = constantCache.get(key);
    if (result != null) {
      return result;
    } else if (visited.contains(key)) {
      throw new ResolveError("cyclic constant definition encountered ("
          + key + " -> " + key + ")");
    } else {
      visited.add(key);
    }

    WhileyFile wf = builder.getSourceFile(key.module());

    if (wf != null) {
      WhileyFile.Declaration decl = wf.declaration(key.name());
      if (decl instanceof WhileyFile.Constant) {
        WhileyFile.Constant cd = (WhileyFile.Constant) decl;
        if (cd.resolvedValue == null) {
          cd.constant = propagate(cd.constant, new Environment(), cd);
          cd.resolvedValue = resolveAsConstant(cd.constant, cd,
              visited);
        }
        result = cd.resolvedValue;
      } else {
        throw new ResolveError("unable to find constant " + key);
      }
    } else {
      WyilFile module = builder.getModule(key.module());
      WyilFile.ConstantDeclaration cd = module.constant(key.name());
      if (cd != null) {
        result = cd.constant();
      } else {
        throw new ResolveError("unable to find constant " + key);
      }
    }

    constantCache.put(key, result);
View Full Code Here

        if (td != null) {
          r = td.type();
        }
      }
      if (r == null) {
        throw new ResolveError("unable to locate " + nid);
      }
      return expandOneLevel(r);
    } else if (type instanceof Type.Leaf || type instanceof Type.Reference
        || type instanceof Type.Tuple || type instanceof Type.Set
        || type instanceof Type.List || type instanceof Type.Map
View Full Code Here

        return null;
      }
    }

    // FIXME: better error message?
    throw new ResolveError("name not found: " + nid);
  }
View Full Code Here

              context, e);
        }
      }
    }

    throw new ResolveError("cannot resolve name as function: " + name);
  }
View Full Code Here

TOP

Related Classes of wycc.util.ResolveError

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.