Skip to content

Commit

Permalink
Bump up version to 0.1.30
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaprieto committed Feb 22, 2023
1 parent 235dc29 commit 0ccbc45
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 167 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "juvix-mode",
"version": "0.1.29",
"version": "0.1.30",
"license": "GPL-3.0",
"description": "Juvix Mode for VSCode",
"displayName": "Juvix",
Expand Down Expand Up @@ -590,9 +590,9 @@
},
"juvix-mode.vampirBinName": {
"type": "string",
"default": "vampir",
"default": "vamp-ir",
"scope": "machine-overridable",
"description": "Name of the executable of VampIR. (e.g. vampir)"
"description": "Name of the executable of VampIR. (e.g. vamp-ir)"
},
"juvix-mode.vampirBinPath": {
"type": "string",
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export class JuvixConfig {
}

// geb settings
readonly vampirBinaryName = new VsCodeSetting('juvix-mode.vampirName', {
serializer: serializerWithDefault('vampir'),
readonly vampirBinaryName = new VsCodeSetting('juvix-mode.vampirBinName', {
serializer: serializerWithDefault('vamp-ir'),
});
readonly vampirBinaryPath = new VsCodeSetting('juvix-mode.vampirBinPath', {
serializer: serializerWithDefault(''),
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as judoc from './judoc';
import * as dev from './dev';
import * as check from './check';
import * as formatter from './formatter';
import * as vampir from './vampir/commands';
import * as vampir from './vampir/tasks';

export async function activate(context: vscode.ExtensionContext) {
debugChannel.clear();
Expand Down
161 changes: 0 additions & 161 deletions src/vampir/commands.ts

This file was deleted.

169 changes: 169 additions & 0 deletions src/vampir/tasks.ts
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']
);
}
1 change: 1 addition & 0 deletions test/range.pir
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
vamp-ir compile -u params.pp -s tests/range.pir -o circuit.plonk
vamp-ir prove -u params.pp -c circuit.plonk -o proof.plonk
vamp-ir verify -u params.pp -c circuit.plonk -p proof.plonk

*/

pub x;
Expand Down
1 change: 1 addition & 0 deletions test/vampir.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "x": "90" }

0 comments on commit 0ccbc45

Please sign in to comment.