1 package polyglot.ext.jl; 2 3 import java.io.Reader ; 4 import java.util.ArrayList ; 5 import java.util.List ; 6 7 import polyglot.ast.NodeFactory; 8 import polyglot.ext.jl.ast.NodeFactory_c; 9 import polyglot.ext.jl.parse.Grm; 10 import polyglot.ext.jl.parse.Lexer_c; 11 import polyglot.ext.jl.types.TypeSystem_c; 12 import polyglot.frontend.*; 13 import polyglot.types.*; 14 import polyglot.util.ErrorQueue; 15 import polyglot.util.InternalCompilerError; 16 import polyglot.visit.*; 17 18 54 public class ExtensionInfo extends polyglot.frontend.AbstractExtensionInfo { 55 protected void initTypeSystem() { 56 try { 57 LoadedClassResolver lr; 58 lr = new SourceClassResolver(compiler, this, getOptions().constructFullClasspath(), 59 compiler.loader(), true); 60 ts.initialize(lr, this); 61 } 62 catch (SemanticException e) { 63 throw new InternalCompilerError( 64 "Unable to initialize type system: " + e.getMessage()); 65 } 66 } 67 68 public String defaultFileExtension() { 69 return "jl"; 70 } 71 72 public String compilerName() { 73 return "jlc"; 74 } 75 76 public polyglot.main.Version version() { 77 return new Version(); 78 } 79 80 81 protected TypeSystem createTypeSystem() { 82 return new TypeSystem_c(); 83 } 84 85 86 protected NodeFactory createNodeFactory() { 87 return new NodeFactory_c(); 88 } 89 90 public JobExt jobExt() { 91 return null; 92 } 93 94 public Parser parser(Reader reader, FileSource source, ErrorQueue eq) { 95 polyglot.lex.Lexer lexer = new Lexer_c(reader, source.name(), eq); 96 polyglot.parse.BaseParser parser = new Grm(lexer, ts, nf, eq); 97 98 return new CupParser(parser, source, eq); 99 } 100 101 public List passes(Job job) { 102 ArrayList l = new ArrayList (15); 103 104 l.add(new ParserPass(Pass.PARSE, compiler, job)); 105 l.add(new VisitorPass(Pass.BUILD_TYPES, job, new TypeBuilder(job, ts, nf))); 106 l.add(new GlobalBarrierPass(Pass.BUILD_TYPES_ALL, job)); 107 l.add(new VisitorPass(Pass.CLEAN_SUPER, job, 108 new AmbiguityRemover(job, ts, nf, AmbiguityRemover.SUPER))); 109 l.add(new BarrierPass(Pass.CLEAN_SUPER_ALL, job)); 110 l.add(new VisitorPass(Pass.CLEAN_SIGS, job, 111 new AmbiguityRemover(job, ts, nf, AmbiguityRemover.SIGNATURES))); 112 l.add(new VisitorPass(Pass.ADD_MEMBERS, job, new AddMemberVisitor(job, ts, nf))); 113 l.add(new GlobalBarrierPass(Pass.ADD_MEMBERS_ALL, job)); 114 l.add(new VisitorPass(Pass.DISAM, job, new 115 AmbiguityRemover(job, ts, nf, AmbiguityRemover.ALL))); 116 l.add(new BarrierPass(Pass.DISAM_ALL, job)); 117 l.add(new VisitorPass(Pass.TYPE_CHECK, job, new TypeChecker(job, ts, nf))); 118 l.add(new VisitorPass(Pass.REACH_CHECK, job, new ReachChecker(job, ts, nf))); 119 l.add(new VisitorPass(Pass.EXC_CHECK, job, new ExceptionChecker(job, ts, nf))); 120 l.add(new VisitorPass(Pass.EXIT_CHECK, job, new ExitChecker(job, ts, nf))); 121 l.add(new VisitorPass(Pass.INIT_CHECK, job, new InitChecker(job, ts, nf))); 122 l.add(new VisitorPass(Pass.CONSTRUCTOR_CHECK, job, new ConstructorCallChecker(job, ts, nf))); 123 l.add(new VisitorPass(Pass.FWD_REF_CHECK, job, new FwdReferenceChecker(job, ts, nf))); 124 l.add(new EmptyPass(Pass.PRE_OUTPUT_ALL)); 125 126 if (compiler.serializeClassInfo()) { 127 l.add(new VisitorPass(Pass.SERIALIZE, 128 job, new ClassSerializer(ts, nf, 129 job.source().lastModified(), 130 compiler.errorQueue(), 131 version()))); 132 } 133 134 l.add(new OutputPass(Pass.OUTPUT, job, 135 new Translator(job, ts, nf, targetFactory()))); 136 137 return l; 138 } 139 140 static { Topics t = new Topics(); } 141 } 142 | Popular Tags |