m_errors.check();  m_ast.traverse(new Node.Switch() { public void onSuper(SuperNd sn) { m_errors.warn (sn, "super is no longer necessary and deprecated, " + "please remove"); } });  m_errors.check();
    public void emit(Root root) {	m_root = root;        for (Iterator it = m_root.getObjectTypes().iterator();	     it.hasNext(); ) {            m_symbols.addEmitted((ObjectType) it.next());        }        if (root.getObjectType("global.String") == null) {            loadResource("com/arsdigita/persistence/proto/pdl/global.pdl");        }        m_ast.traverse(new Node.Switch() {                public void onObjectType(ObjectTypeNd ot) {                    if (ot.hasReturns()) {                        m_errors.warn(ot, "returns clause is deprecated");                    }                    m_symbols.define(ot);                }            });	m_errors.check();        m_ast.traverse(new Node.Switch() {                public void onType(TypeNd t) {                    m_symbols.resolve(t);                }            });	m_errors.check();        m_symbols.sort();	m_errors.check();        m_symbols.emit();	m_ast.traverse(new Node.Switch() {		public void onAssociation(AssociationNd assn) {		    if (assn.getProperties().size() == 0) {			return;		    }		    ObjectType ot = new ObjectType			(Model.getInstance			 (assn.getFile().getModel().getName()),			 linkName(assn.getRoleOne(), assn.getRoleTwo()), null);		    m_symbols.addEmitted(ot);		}	    });        m_ast.traverse(new Node.Switch() {                private Role define(ObjectType type, PropertyNd prop) {                    String name = prop.getName().getName();                    if (type.hasProperty(name)) {                        m_errors.fatal(prop, "duplicate property: " + name);                        return null;                    }                    Role result =                        new Role(prop.getName().getName(),                                 m_symbols.getEmitted                                 (m_symbols.lookup(prop.getType())),                                 prop.isComponent(),                                 prop.isCollection(),                                 prop.isNullable());                    type.addProperty(result);                    if (prop.isImmediate()) {                        type.addImmediateProperty(result);                    }                    m_properties.put(prop, result);                    return result;                }                public void onProperty(PropertyNd prop) {                    ObjectType type =                        m_symbols.getEmitted((ObjectTypeNd) prop.getParent());                    Role role = define(type, prop);                    /* if the property is a composite, the other end is a                     * needs to be set up for cascading deletes to work                     */                    if (prop.isComposite()) {                        String rev = "~" + prop.getName().getName() + ":" +                            type.getQualifiedName().replace('.', '$');                        Role reverse = new Role(rev, type, true, true, true);                        role.getType().addProperty(reverse);                        role.setReverse(reverse);                    }                }                public void onAssociation(AssociationNd assn) {		    PropertyNd one = assn.getRoleOne();		    PropertyNd two = assn.getRoleTwo();		    Collection props = assn.getProperties();		    ObjectType oneot =			m_symbols.getEmitted(m_symbols.lookup(one.getType()));		    ObjectType twoot =			m_symbols.getEmitted(m_symbols.lookup(two.getType()));		    if (props.size() > 0) {			Role rone = new Role(one.getName().getName(), oneot,					     one.isComponent(), false, false);			Role rtwo = new Role(two.getName().getName(), twoot,					     two.isComponent(), false, false);			ObjectType ot = m_symbols.getEmitted(linkName(assn));			ot.addProperty(rone);			Role revOne = new Role("~" + rone.getName(), ot,					       true, true, true);			rone.getType().addProperty(revOne);			rone.setReverse(revOne);			ot.addProperty(rtwo);			Role revTwo = new Role("~" + rtwo.getName(), ot,					       true, true, true);			rtwo.getType().addProperty(revTwo);			rtwo.setReverse(revTwo);			for (Iterator it = props.iterator(); it.hasNext(); ) {			    PropertyNd prop = (PropertyNd) it.next();			    define(ot, prop);			}			Link l = new Link(rone.getName(), rtwo, rone,					  one.isCollection(),					  one.isNullable());			m_links.add(l);			twoot.addProperty(l);			l = new Link(rtwo.getName(), rone, rtwo,				     two.isCollection(), two.isNullable());			oneot.addProperty(l);			m_links.add(l);		    } else {			Role rone = define(oneot, two);			Role rtwo = define(twoot, one);			if (rone != null && rtwo != null) {			    rone.setReverse(rtwo);			}		    }                }            }, new Node.IncludeFilter(new Node.Field[] {                AST.FILES, FileNd.OBJECT_TYPES, ObjectTypeNd.PROPERTIES,                FileNd.ASSOCIATIONS            }));        m_errors.check();        for (Iterator it = m_symbols.getObjectTypes().iterator();             it.hasNext(); ) {            ObjectTypeNd ot = (ObjectTypeNd) it.next();            m_root.addObjectType(m_symbols.getEmitted(ot));        }        m_ast.traverse(new Node.Switch() {                public void onObjectType(ObjectTypeNd otn) {                    m_root.addObjectMap                        (new ObjectMap(m_symbols.getEmitted(otn)));                }		public void onAssociation(AssociationNd assn) {		    ObjectType ot = m_symbols.getEmitted(linkName(assn));		    if (ot != null) {			m_root.addObjectType(ot);			m_root.addObjectMap(new ObjectMap(ot));		    }		}            });        emitDDL();        m_errors.check();        emitMapping();        m_errors.check();        emitEvents();        m_errors.check();        emitDataOperations();        m_errors.check();	m_ast.traverse(new Node.Switch() {		public void onObjectType(ObjectTypeNd nd) {		    ObjectType ot = m_symbols.getEmitted(nd);		    JavaClassNd jcn = nd.getJavaClass();		    JavaClassNd acn = nd.getAdapterClass();		    if (jcn == null || acn == null) {			return;		    }		    Class javaClass;		    try {			javaClass = Class.forName(jcn.getName());		    } catch (ClassNotFoundException e) {			m_errors.fatal(jcn, e.getMessage());			return;		    }		    ot.setJavaClass(javaClass);		    try {			Class adapterClass = Class.forName(acn.getName());			Adapter ad = (Adapter) adapterClass.newInstance();			Adapter.addAdapter(javaClass, ad);		    } catch (IllegalAccessException e) {			m_errors.fatal(acn, e.getMessage());		    } catch (ClassNotFoundException e) {			m_errors.fatal(acn, e.getMessage());		    } catch (InstantiationException e) {			m_errors.fatal(acn, e.getMessage());		    }		}	    });	m_errors.check();        m_ast.traverse(new Node.Switch() {            public void onProperty(PropertyNd pnd) {                Node n = pnd.getMapping();                if (!(n instanceof ColumnNd)) {                    return;                }                ObjectType ot = m_symbols.getEmitted(pnd.getType());                Column col = lookup((ColumnNd)n);                if (col.getType() == Integer.MIN_VALUE) {                    Adapter ad = Adapter.getAdapter(ot.getJavaClass());                    col.setType(ad.defaultJDBCType());                }            }        });	propogateTypes();    }