Esempio n. 1
0
 public void visit(AbsVarDecl acceptor) {
   // Lokalna spremenljivka.
   // Parametre obdelamo pri AbsFunDecl.
   // Komponente obdelamo pri AbsRecType.
   Frame frame = frms.peek();
   SemType type = TypeResolver.getType(acceptor.name);
   int offset = frame.addVariable(type.size());
   Access access = new Access(frame.level, offset);
   setAccess(acceptor, access);
   acceptor.type.accept(this);
 }
Esempio n. 2
0
 public void visit(AbsRecType acceptor) {
   int offset = 0;
   for (AbsDecl decl : acceptor.comps.decls) {
     AbsVarDecl varDecl = (AbsVarDecl) decl;
     Access varAccess = new Access(-1, offset);
     setAccess(varDecl, varAccess);
     SemType type = TypeResolver.getType(varDecl.name);
     offset += type.size();
     varDecl.type.accept(this);
   }
 }
Esempio n. 3
0
  public static int compare(Typing a, Typing b, IHierarchy h) {
    int r = 0;
    for (Local v : a.map.keySet()) {
      Type ta = a.get(v), tb = b.get(v);

      int cmp;
      if (TypeResolver.typesEqual(ta, tb)) cmp = 0;
      if (h.ancestor(ta, tb)) cmp = 1;
      else if (h.ancestor(tb, ta)) cmp = -1;
      else return -2;

      if ((cmp == 1 && r == -1) || (cmp == -1 && r == 1)) return 2;
      if (r == 0) r = cmp;
    }
    return r;
  }