aboutsummaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorUri Shaked2020-04-16 23:52:43 +0300
committerUri Shaked2020-04-16 23:52:43 +0300
commitc2745db7c3ebcc5b4b3ab56b910324a0b1d430cb (patch)
treedf2a73b0bbe056b34307119549061761ce06c9af /benchmark
parentchore: release 0.8.0 (diff)
downloadavr8js-c2745db7c3ebcc5b4b3ab56b910324a0b1d430cb.tar.gz
avr8js-c2745db7c3ebcc5b4b3ab56b910324a0b1d430cb.tar.bz2
avr8js-c2745db7c3ebcc5b4b3ab56b910324a0b1d430cb.zip
fix(benchmark): update to work with latest code
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/convert-instructions.ts26
1 files changed, 14 insertions, 12 deletions
diff --git a/benchmark/convert-instructions.ts b/benchmark/convert-instructions.ts
index 67a3f1f..9ddd058 100644
--- a/benchmark/convert-instructions.ts
+++ b/benchmark/convert-instructions.ts
@@ -1,14 +1,14 @@
import * as fs from 'fs';
import * as prettier from 'prettier';
+import prettierOptions from '../prettier.config';
-const input = fs.readFileSync('src/instruction.ts', { encoding: 'utf-8' });
+const input = fs.readFileSync('src/cpu/instruction.ts', { encoding: 'utf-8' });
let fnName = '';
let fnBody = '';
-let openingBrace = false;
let currentInstruction = '';
let pattern = '';
let output = `
-import { ICPU } from '../src/cpu';
+import { ICPU } from '../src/cpu/cpu';
function isTwoWordInstruction(opcode: number) {
return (
@@ -22,22 +22,22 @@ function isTwoWordInstruction(opcode: number) {
(opcode & 0xfe0e) === 0x940c
);
}
+
+/* eslint-disable @typescript-eslint/no-unused-vars */
`;
const patternToFn: Array<[string, string]> = [];
for (const line of input.split('\n')) {
- if (line.startsWith(' /* ')) {
+ if (line.startsWith(' /* ') && line.includes(', ')) {
currentInstruction = line
.trim()
.split(',')[0]
.split(' ')[1];
fnBody = '';
- openingBrace = false;
pattern = line.split(',')[1].split('*')[0];
console.log(currentInstruction);
- fnName = 'inst' + currentInstruction.replace(/[\(\)]/g, '');
+ fnName = 'inst' + currentInstruction.replace(/[()]/g, '');
patternToFn.push([pattern.trim(), fnName]);
- }
- if (line.startsWith(' }')) {
+ } else if (line.startsWith(' }')) {
output += `
export function ${fnName}(cpu: ICPU, opcode: number) {
/*${pattern}*/
@@ -49,10 +49,8 @@ for (const line of input.split('\n')) {
}
`;
currentInstruction = '';
- } else if (currentInstruction && openingBrace) {
+ } else if (currentInstruction) {
fnBody += line;
- } else if (currentInstruction && !openingBrace) {
- openingBrace = line.includes('{');
}
}
@@ -74,7 +72,11 @@ export function executeInstruction(idx: number, cpu: ICPU, opcode: number) {
}
}`;
-const formattedOutput = prettier.format(output, { singleQuote: true, parser: 'babel' });
+const formattedOutput = prettier.format(output, {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ ...(prettierOptions as any),
+ parser: 'babel'
+});
fs.writeFileSync('benchmark/instruction-fn.ts', formattedOutput, {
encoding: 'utf-8'
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.