Exemple #1
0
 @Override
 public boolean sameStructureAs(SemType type) {
   if (type.actualType() instanceof SemRecType) {
     SemRecType recordType = (SemRecType) (type.actualType());
     if (this.getNumComps() != recordType.getNumComps()) return false;
     for (int i = 0; i < getNumComps(); i++)
       if (!this.getCompType(i).sameStructureAs(recordType.getCompType(i))) return false;
     return true;
   } else return false;
 }
 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);
 }
 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);
   }
 }