@author Bob McWhirter
| 15 | * @author Bob McWhirter |
| 16 | */ |
| 17 | public class Compiler { |
| 18 | |
| 19 | private final Config config; |
| 20 | private CompilationContext compilationContext; |
| 21 | |
| 22 | private Reader source; |
| 23 | private boolean shouldClose; |
| 24 | private String fileName; |
| 25 | |
| 26 | private boolean forceStrict; |
| 27 | |
| 28 | public Compiler() { |
| 29 | this.config = new Config(); |
| 30 | } |
| 31 | |
| 32 | public Compiler(Config config) { |
| 33 | this.config = config; |
| 34 | } |
| 35 | |
| 36 | public Compiler withContext(ExecutionContext context) { |
| 37 | this.compilationContext = context; |
| 38 | return this; |
| 39 | } |
| 40 | |
| 41 | public Compiler forceStrict() { |
| 42 | return forceStrict(true); |
| 43 | } |
| 44 | |
| 45 | public Compiler forceStrict(boolean forceStrict) { |
| 46 | this.forceStrict = forceStrict; |
| 47 | return this; |
| 48 | } |
| 49 | |
| 50 | public Compiler withSource(String source) { |
| 51 | this.source = new StringReader(source); |
| 52 | this.shouldClose = true; |
| 53 | return this; |
| 54 | } |
| 55 | |
| 56 | public Compiler withSource(Reader source) { |
| 57 | this.source = source; |
| 58 | this.shouldClose = false; |
| 59 | return this; |
| 60 | } |
| 61 | |
| 62 | public Compiler withSource(File source) throws FileNotFoundException { |
| 63 | this.source = new FileReader(source); |
| 64 | this.shouldClose = true; |
| 65 | this.fileName = source.getName(); |
| 66 | return this; |
| 67 | } |
| 68 | |
| 69 | public Compiler withFileName(String fileName) { |
| 70 | this.fileName = fileName; |
| 71 | return this; |
| 72 | } |
| 73 | |
| 74 | public JSProgram compile() { |
nothing calls this directly
no outgoing calls
no test coverage detected