public void compile() {
		errs.clear();
		
		int n = 0;
		int max = links.getHighestDep();
		//System.out.println("* MAX "+max);
		while (n<=max) {
			ArrayList<Import> imps = links.getLinksWithDepsOf(n);
			//System.out.println("* N "+n);
			//System.out.println("* IMPS "+imps);
			if (imps.isEmpty()) {
				n++;
			} else {
				for (Import imp : (ArrayList<Import>) imps.clone()) {
					SourcePackage compPkg = new SourcePackage();
					
					if (imp.pkg!=null) {
						compPkg.addContents(imp.pkg);
						compPkg.setName(imp.pkg.getName());

						HashSet<String> has = new HashSet<>();
						has.add(imp.name);

						for (Import imp2 : imps) {
							if (imp2!=imp) {
								if (imp2.pkg!=null) {
									if (!has.contains(imp2.name)) {
										compPkg.addContents(imp2.pkg);
										has.add(imp2.name);
									}
								}
							}
						}

						addNeeded(compPkg,compPkg,has);

						compPkg.addContents(platform.pkgs.get("core"));

						errs.addAll(SourceCompiler.compile(compPkg));
					}
					
					//System.out.println("* COMP "+imp);
					imp.compiled = true;
					n = 0;
				}
			}
		}
		
		outputPackage.setName(inputPackage.getName());
		for (Import imp : links.getAllLinks()) {
			outputPackage.addContents(imp.pkg);
		}
		outputPackage.addContents(platform.pkgs.get("core"));
	}