Skip to content

Commit

Permalink
asm_compile gotos
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephAbbey committed Jun 24, 2023
1 parent eef3c55 commit 477160f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion design/demos/asm/add.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ r1 <- 0b0000

loop:
leds <- r0 + btns
wincr 3
wincri 3
leds <- btns and r1
wincr 1
goto loop
31 changes: 19 additions & 12 deletions scratch-vhdl-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ export function activate(context: vscode.ExtensionContext) {
output = output.replace(
/ --> ([a-zA-Z]:[\\\/](?:[^\\\/<>:"|?*\s]+[\\\/])*(?:[^\\\/<>:"|?*\s]+\.asm)):\x1b\[0m\x1b\[90m(\d+):(\d+)/g,
(_, file, line, column) =>
` --> ${file}:<button class="a" onclick="window.goto('${file}',${
line - 1
},${column - 1})">${line}:${column}</button>`
` --> ${file}:<button class="a" onclick="window.goto('${file.replace(
/\\/g,
'\\\\'
)}',${line - 1},${column - 1})">${line}:${column}</button>`
);

output = output.replace(
/ --> ([a-zA-Z]:[\\\/](?:[^\\\/<>:"|?*\s]+[\\\/])*(?:[^\\\/<>:"|?*\s]+\.asm)):\x1b\[0m\x1b\[90m(\d+):(\d+)/g,
(_, file, line, column) =>
` --> ${file}:<button class="a" onclick="window.goto('${file}',${
line - 1
},${column - 1})">${line}:${column}</button>`
` --> ${file}:<button class="a" onclick="window.goto('${file.replace(
/\\/g,
'\\\\'
)}',${line - 1},${column - 1})">${line}:${column}</button>`
);
output = output.replace(
/\x1b\[90m/g,
Expand Down Expand Up @@ -95,22 +97,27 @@ export function activate(context: vscode.ExtensionContext) {
case 'goto': {
const a = message.text.split(',');
const f = a[0];
const b = message.text.split(' ');
const b = a[1].split(' ');
const l = parseInt(b[0]);
const c = parseInt(b[1]);

const doc = await vscode.workspace.openTextDocument(
vscode.Uri.parse(f)
const e = await vscode.window.showTextDocument(
await vscode.workspace.openTextDocument(vscode.Uri.file(f)),
{
preview: true,
viewColumn: editor.viewColumn,
}
);
const e = await vscode.window.showTextDocument(doc);

e.revealRange(
new vscode.Range(
new vscode.Position(l, c),
new vscode.Position(l, c)
)
);
e.selection = new vscode.Selection(l, 0, l, 999);
e.selection = new vscode.Selection(
new vscode.Position(l, c),
new vscode.Position(l, c)
);
break;
}
}
Expand Down

0 comments on commit 477160f

Please sign in to comment.