MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / run

Method run

src/main/java/wyc/Executor.java:64–94  ·  view source on GitHub ↗
(QualifiedName name, Type.Callable sig)

Source from the content-addressed store, hash-verified

62 }
63
64 public boolean run(QualifiedName name, Type.Callable sig) throws IOException {
65 //
66 ArrayList<WyilFile> deps = new ArrayList<>();
67 // Read target
68 deps.add(Compiler.readWyilFile(wyildir, this.target));
69 // Extract any dependencies from zips
70 for(File dep : whileypath) {
71 Compiler.extractDependencies(dep,deps);
72 }
73 // Try to run the given function or method
74 Interpreter interpreter = new Interpreter(System.out, deps);
75 // Add native methods
76 addStdNatives(interpreter);
77 // Sanity check target method exists
78 Decl.Callable lambda = interpreter.getCallable(name, sig);
79 if(lambda == null) {
80 System.err.println("method not found: " + name + ", " + sig);
81 return false;
82 } else {
83 // Create the initial stack
84 Interpreter.CallStack stack = interpreter.new CallStack();
85 try {
86 //
87 interpreter.execute(name, sig, stack);
88 return true;
89 } catch (Interpreter.RuntimeError e) {
90 e.printStackTrace();
91 return false;
92 }
93 }
94 }
95
96 private void addStdNatives(Interpreter interpreter) {
97 interpreter.bindNative(QualifiedName.fromString("std::io::print"), Executor::stdIoPrint);

Callers 1

mainMethod · 0.95

Calls 8

readWyilFileMethod · 0.95
extractDependenciesMethod · 0.95
addStdNativesMethod · 0.95
getCallableMethod · 0.95
executeMethod · 0.95
printlnMethod · 0.80
printStackTraceMethod · 0.80
addMethod · 0.65

Tested by

no test coverage detected