Exemplo n.º 1
0
  /** @see jaskell.compiler.JaskellVisitor#visit(QualifiedVariable) */
  public Object visit(QualifiedVariable a) {
    Module mod = null;
    Iterator it = a.getPath().iterator();
    while (it.hasNext()) {
      String mname = (String) it.next();
      if (mod != null) mod = (Module) mod.lookup(mname);
      else mod = (Module) Module.getToplevels().get(mname);
    }
    /* module found */
    if (mod != null) {
      Expression def = mod.lookup(a.getName());
      if (def == null) throw new CompilerException("Unknown variable " + a.getName());
      Type t = def.getType();
      if (t == null) t = (Type) def.visit(this);

      /* as it is the case for variable, we assume
       * that a defined symbol may be overloaded (only for primitive types)
       * so we return a type variable and defers choice of
       * symbol to a later stage
       */
      a.setType(t);
      return t;
    }
    throw new CompilerException("Unable to find module needed for variable " + a.getName());
  }
Exemplo n.º 2
0
 /* (non-Javadoc)
  * @see jaskell.compiler.JaskellVisitor#visit(jaskell.compiler.core.Module)
  */
 public Object visit(Module a) {
   try {
     return visit((Namespace) a);
   } catch (TypeError te) {
     if (te.getLineCol() == null) te.setLineCol(a.getTag("source"));
     log.severe("Type error at (" + te.getLineCol() + ") : " + te.getMessage());
     throw te;
   }
 }