void uncaughtType(Type t, Position pos) throws SemanticException { SemanticException e = new SemanticException( codeType + " cannot throw a \"" + t + "\"; the exception must either be caught or declared to be thrown.", pos); Map<String, Object> map = CollectionFactory.newHashMap(); map.put(CodedErrorInfo.ERROR_CODE_KEY, CodedErrorInfo.ERROR_CODE_SURROUND_THROW); map.put("TYPE", t.toString()); e.setAttributes(map); throw e; }
/** * Run all jobs in the work list (and any children they have) to completion. This method returns * <code>true</code> if all jobs were successfully completed. If all jobs were successfully * completed, then the worklist will be empty. * * <p>The scheduling of <code>Job</code>s uses two methods to maintain scheduling invariants: * <code>selectJobFromWorklist</code> selects a <code>SourceJob</code> from <code>worklist</code> * (a list of jobs that still need to be processed); <code>enforceInvariants</code> is called * before a pass is performed on a <code>SourceJob</code> and is responsible for ensuring all * dependencies are satisfied before the pass proceeds, i.e. enforcing any scheduling invariants. */ public boolean runToCompletion() { boolean okay = true; while (okay && !worklist.isEmpty()) { SourceJob job = selectJobFromWorklist(); if (Report.should_report(Report.frontend, 1)) { Report.report(1, "Running job " + job); } okay &= runAllPasses(job); if (job.completed()) { // the job has finished. Let's remove it from the map so it // can be garbage collected, and free up the AST. jobs.put(job.source(), COMPLETED_JOB); if (Report.should_report(Report.frontend, 1)) { Report.report(1, "Completed job " + job); } } else { // the job is not yet completed (although, it really // should be...) if (Report.should_report(Report.frontend, 1)) { Report.report(1, "Failed to complete job " + job); } worklist.add(job); } } if (Report.should_report(Report.frontend, 1)) Report.report(1, "Finished all passes -- " + (okay ? "okay" : "failed")); return okay; }
/** * Add a new <code>SourceJob</code> for the <code>Source source</code>, with AST <code>ast</code>. * A new job will be created if needed. If the <code>Source source</code> has already been * processed, and its job discarded to release resources, then <code>null</code> will be returned. */ public SourceJob addJob(Source source, Node ast) { Object o = jobs.get(source); SourceJob job = null; if (o == COMPLETED_JOB) { // the job has already been completed. // We don't need to add a job return null; } else if (o == null) { // No appropriate job yet exists, we will create one. job = this.createSourceJob(source, ast); // record the job in the map and the worklist. jobs.put(source, job); worklist.addLast(job); if (Report.should_report(Report.frontend, 3)) { Report.report(3, "Adding job for " + source + " at the " + "request of job " + currentJob); } } else { job = (SourceJob) o; } // if the current source job caused this job to load, record the // dependency. if (currentJob instanceof SourceJob) { ((SourceJob) currentJob).addDependency(source); } return job; }
JLCInfo getJLCInfo(String typeSystemKey) { // Check if already set. JLCInfo jlc = (JLCInfo) jlcInfoCache.get(typeSystemKey); if (jlc != null) { return jlc; } jlc = new JLCInfo(); jlcInfoCache.put(typeSystemKey, jlc); try { int mask = 0; for (int i = 0; i < fields.length; i++) { if (fields[i].name().equals("jlc$SourceLastModified$" + typeSystemKey)) { jlc.sourceLastModified = fields[i].getLong(); mask |= 1; } else if (fields[i].name().equals("jlc$CompilerVersion$" + typeSystemKey)) { jlc.compilerVersion = fields[i].getString(); mask |= 2; } else if (fields[i].name().equals("jlc$ClassType$" + typeSystemKey)) { // there is encoded class type information. StringBuffer encodedClassTypeInfo = new StringBuffer(fields[i].getString()); // check to see if there are more fields. int seeking = 1; boolean found; do { found = false; String suffix = ("$" + seeking); String seekingFieldName = "jlc$ClassType$" + typeSystemKey + suffix; for (int j = 0; j < fields.length; j++) { if (fields[j].name().equals(seekingFieldName)) { encodedClassTypeInfo.append(fields[j].getString()); found = true; seeking++; break; } } } while (found); jlc.encodedClassType = encodedClassTypeInfo.toString(); mask |= 4; } } if (mask != 7) { // Not all the information is there. Reset to default. jlc.sourceLastModified = 0; jlc.compilerVersion = null; jlc.encodedClassType = null; } } catch (SemanticException e) { jlc.sourceLastModified = 0; jlc.compilerVersion = null; jlc.encodedClassType = null; } return jlc; }
/** Initialize the <code>passes</code> field and the <code>passMap</code> field. */ protected void init() { passes = new ArrayList(getPasses()); passMap = new HashMap(); for (int i = 0; i < passes.size(); i++) { Pass pass = (Pass) passes.get(i); passMap.put(pass.id(), new Integer(i)); } }