-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
235dc29
commit 0ccbc45
Showing
7 changed files
with
177 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
/*--------------------------------------------------------- | ||
* Copyright (C) Microsoft Corporation. All rights reserved. | ||
*--------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
import * as vscode from 'vscode'; | ||
import { debugChannel } from '../utils/debug'; | ||
import { JuvixConfig } from '../config'; | ||
|
||
export const TASK_TYPE = 'VampIR'; | ||
|
||
export async function activate(context: vscode.ExtensionContext) { | ||
if (vscode.workspace.workspaceFolders === undefined) { | ||
const msg = 'VampIR extension requires at least one workspace open.\n'; | ||
vscode.window.showErrorMessage(msg); | ||
debugChannel.error(msg); | ||
return; | ||
} | ||
|
||
const provider = new VampIRProvider(); | ||
const vampIRTasks: Promise<vscode.Task[]> = provider.provideTasks(); | ||
context.subscriptions.push( | ||
vscode.tasks.registerTaskProvider(TASK_TYPE, provider) | ||
); | ||
|
||
vampIRTasks | ||
.then(tasks => { | ||
for (const task of tasks) { | ||
const cmdName = task.name; | ||
const qualifiedCmdName = 'juvix-mode.vampir-' + cmdName; | ||
const cmd = vscode.commands.registerTextEditorCommand( | ||
qualifiedCmdName, | ||
() => { | ||
const ex = vscode.tasks.executeTask(task); | ||
ex.then((v: vscode.TaskExecution) => { | ||
debugChannel.info('Task "' + cmdName + '" executed'); | ||
v.terminate(); | ||
return true; | ||
}); | ||
debugChannel.info('VampIR Task "' + cmdName + '" executed'); | ||
return false; | ||
} | ||
); | ||
context.subscriptions.push(cmd); | ||
debugChannel.info('[!] VampIR "' + cmdName + '" command registered'); | ||
} | ||
}) | ||
.catch(err => { | ||
debugChannel.error('VampIR Task provider error: ' + err); | ||
}); | ||
} | ||
|
||
export interface VampIRDefinition extends vscode.TaskDefinition { | ||
command?: string; | ||
args?: string[]; | ||
} | ||
|
||
export class VampIRProvider implements vscode.TaskProvider { | ||
async provideTasks(): Promise<vscode.Task[]> { | ||
const config = new JuvixConfig(); | ||
|
||
const defs = [ | ||
{ | ||
command: 'setup', | ||
args: ['--unchecked', '-o', 'params.pp'], | ||
group: vscode.TaskGroup.Build, | ||
reveal: vscode.TaskRevealKind.Always, | ||
}, | ||
{ | ||
command: 'compile', | ||
args: [ | ||
'-u', | ||
'params.pp', | ||
'--unchecked', | ||
'-s', | ||
'${file}', | ||
'-o', | ||
'${file}.plonk', | ||
], | ||
group: vscode.TaskGroup.Build, | ||
reveal: vscode.TaskRevealKind.Always, | ||
}, | ||
{ | ||
// prove -u params.pp --unchecked -c range.plonk -o range.proof | ||
command: 'prove', | ||
args: [ | ||
'-u', | ||
'params.pp', | ||
'--unchecked', | ||
'-c', | ||
'${file}.plonk', | ||
'-o', | ||
'${file}.proof', | ||
], | ||
group: vscode.TaskGroup.Build, | ||
reveal: vscode.TaskRevealKind.Always, | ||
}, | ||
{ | ||
//vamp-ir verify -u params.pp --unchecked -c range.plonk -p range.proof | ||
command: 'verify', | ||
args: [ | ||
'-u', | ||
'params.pp', | ||
'--unchecked', | ||
'-c', | ||
'${file}.plonk', | ||
'-p', | ||
'${file}.proof', | ||
], | ||
group: vscode.TaskGroup.Build, | ||
reveal: vscode.TaskRevealKind.Always, | ||
}, | ||
]; | ||
|
||
const tasks: vscode.Task[] = []; | ||
|
||
for (const def of defs) { | ||
const vscodeTask = await VampIR( | ||
{ type: TASK_TYPE, command: def.command }, // definition | ||
def.command, // name | ||
[def.command].concat(def.args ?? []) // args | ||
); | ||
vscodeTask.group = def.group; | ||
vscodeTask.problemMatchers = ['$rusterror']; | ||
vscodeTask.presentationOptions = { | ||
reveal: def.reveal, | ||
showReuseMessage: false, | ||
panel: vscode.TaskPanelKind.Shared, | ||
focus: false, | ||
echo: false, | ||
clear: true, | ||
}; | ||
vscodeTask.runOptions = { | ||
reevaluateOnRerun: true, | ||
}; | ||
tasks.push(vscodeTask); | ||
} | ||
return tasks; | ||
} | ||
|
||
async resolveTask(task: any): Promise<vscode.Task | undefined> { | ||
const definition = task.definition as VampIRDefinition; | ||
if (definition.type === TASK_TYPE && definition.command) { | ||
const args = [definition.command].concat(definition.args ?? []); | ||
return await VampIR(definition, task.name, args); | ||
} | ||
debugChannel.warn('resolveTask: fail to resolve', task); | ||
return undefined; | ||
} | ||
} | ||
|
||
export async function VampIR( | ||
definition: VampIRDefinition, | ||
name: string, | ||
args: string[] | ||
): Promise<vscode.Task> { | ||
let input = args.join(' ').trim(); | ||
const config = new JuvixConfig(); | ||
const VampirExec = config.getVampirExec(); | ||
let exec = new vscode.ShellExecution(VampirExec + ` ${input}`); | ||
return new vscode.Task( | ||
definition, | ||
vscode.TaskScope.Global, | ||
name, | ||
TASK_TYPE, | ||
exec, | ||
['$juvixerror'] | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "x": "90" } |