MCPcopy Create free account
hub / github.com/dynjs/dynjs / DynJS

Class DynJS

src/main/java/org/dynjs/runtime/DynJS.java:18–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16import java.util.Properties;
17
18public class DynJS {
19
20 public static final String VERSION;
21 public static final String VERSION_STRING;
22 private final JITCompiler jitCompiler;
23 private Config config;
24 private JSCompiler compiler;
25 private GlobalContext globalContext;
26
27 private ExecutionContext defaultExecutionContext;
28
29 public DynJS() {
30 this(new Config());
31 }
32
33 public DynJS(Config config) {
34 this( config, new DynObject() );
35 }
36
37 public DynJS(Config config, JSObject globalObject) {
38 this.config = config;
39 this.compiler = new JSCompiler(config);
40 this.jitCompiler = new JITCompiler();
41 this.globalContext = GlobalContext.newGlobalContext(this, globalObject);
42 this.defaultExecutionContext = ExecutionContext.createDefaultGlobalExecutionContext( this );
43 loadKernel();
44 }
45
46
47 private void loadKernel() {
48 // FIXME only works for non-IR atm
49 if (!Config.CompileMode.IR.equals(this.config.getCompileMode())) {
50 switch (this.config.getKernelMode()) {
51 case INTERNAL:
52 // Load pure-JS kernel
53 this.evaluate(getClass().getResourceAsStream("/dynjs/kernel.js"));
54 break;
55 case EXTERNAL:
56 try {
57 FileInputStream stream = new FileInputStream("src/main/resources/dynjs/kernel.js");
58 this.evaluate(stream);
59 } catch (FileNotFoundException e) {
60 throw new DynJSException(e);
61 }
62 break;
63 }
64 }
65 }
66
67 public GlobalContext getGlobalContext() {
68 return this.globalContext;
69 }
70
71 public Config getConfig() {
72 return this.config;
73 }
74
75 public JSCompiler getCompiler() {

Callers

nothing calls this directly

Calls 5

getPropertyMethod · 0.95
getClassLoaderMethod · 0.65
getPropertyMethod · 0.65
loadMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected