mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 20:18:18 +00:00
fixes to opt-tool
This commit is contained in:
parent
719ea6a2a7
commit
6b9ce8638f
|
@ -74,27 +74,29 @@ export async function mergeModifiedFunction(code :string, funs : { code: string,
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function canCompileCode(inputFile : WorkspaceFile, code : string) {
|
async function canCompileCode(inputFile: WorkspaceFile, new_code: string) {
|
||||||
|
|
||||||
|
//
|
||||||
// move input file to a temp file
|
// move input file to a temp file
|
||||||
// move code to the inputFile.filename
|
// move code to the inputFile.filename
|
||||||
// invoke ninja in the build directory: ninja -b build
|
// invoke ninja in the build directory: ninja -b build
|
||||||
// move the temp file back to the original file
|
// move the temp file back to the original file
|
||||||
// return true iff it succeeded
|
// return true iff it succeeded
|
||||||
|
//
|
||||||
|
|
||||||
let tempFile = inputFile.filename + ".tmp";
|
let tempFile = inputFile.filename + ".tmp";
|
||||||
let original_content = inputFile.content;
|
let old_code = inputFile.content;
|
||||||
await workspace.writeText(tempFile, inputFile.content);
|
await workspace.writeText(tempFile, old_code);
|
||||||
await workspace.writeText(inputFile.filename, code);
|
await workspace.writeText(inputFile.filename, new_code);
|
||||||
let result = await host.exec(`cmd /k "C:\Program\ Files/Microsoft\ Visual\ Studio/2022/Enterprise/Common7/Tools/VsDevCmd.bat" -arch=x64 & ninja`, { cwd: "build" });
|
let result = await host.exec(`cmd /k "C:\Program\ Files/Microsoft\ Visual\ Studio/2022/Enterprise/Common7/Tools/VsDevCmd.bat" -arch=x64 & ninja`, { cwd: "build" });
|
||||||
|
await workspace.writeText(inputFile.filename, old_code);
|
||||||
// await fs.delete(tempFile);
|
if (result.exitCode == 0) {
|
||||||
if (result.exitCode !== 0) {
|
await workspace.writeText(tempFile, new_code);
|
||||||
await workspace.writeText(inputFile.filename, original_content);
|
return true;
|
||||||
|
}
|
||||||
console.log(result.stderr);
|
console.log(result.stderr);
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mergeCompileFunction(inputFile: WorkspaceFile, code: string, funs: { code: string, name: string }[], new_code_input: string) {
|
export async function mergeCompileFunction(inputFile: WorkspaceFile, code: string, funs: { code: string, name: string }[], new_code_input: string) {
|
||||||
|
@ -110,8 +112,10 @@ export async function mergeCompileFunction(inputFile : WorkspaceFile, code : str
|
||||||
|
|
||||||
if (!fun) {
|
if (!fun) {
|
||||||
console.log(`Function name '${name}' not found`);
|
console.log(`Function name '${name}' not found`);
|
||||||
|
console.log("Available functions: ");
|
||||||
for (const fun of funs)
|
for (const fun of funs)
|
||||||
console.log("'" + fun.name + "'");
|
console.log("'" + fun.name + "'");
|
||||||
|
console.log(new_code);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
console.log("Updated function: " + name);
|
console.log("Updated function: " + name);
|
||||||
|
|
|
@ -15,4 +15,4 @@ for (const fun of funs) {
|
||||||
new_code = await mergeCompileFunction(inputFile, new_code, funs, answer);
|
new_code = await mergeCompileFunction(inputFile, new_code, funs, answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
await workspace.writeText(inputFile.filename + "opt.cpp", new_code);
|
await workspace.writeText(inputFile.filename + ".opt.cpp", new_code);
|
||||||
|
|
Loading…
Reference in a new issue