Skip to content

Commit 42e7014

Browse files
committed
light formatting updates
1 parent a2f23bd commit 42e7014

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

packages/playground/evaluate/utils.ts

+33-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { readdirSync, readFileSync, writeFileSync } from "node:fs";
33
import { Biome, Distribution } from "@biomejs/js-api";
44
import { config, createResultFilePath, errorFilePath, finalResultPath, formatterErrorFilePath, resultsDirectory, resumeMode, shouldTakeABreath, startFilePath } from "./config";
55
import { VirtualTypeScriptEnvironment } from "@typescript/vfs";
6-
import ts from "typescript";
76
import { inspect } from "node:util";
87
import { join } from "node:path";
98

@@ -70,8 +69,38 @@ const extractAddress = (line: string) => {
7069
}
7170

7271
const sortMemoryLines = (memoryLines: string) => memoryLines.split('\n')
73-
.sort((a, b) => extractAddress(a) - extractAddress(b))
74-
.join('\n');
72+
.sort((a, b) => extractAddress(a) - extractAddress(b))
73+
.join('\n');
74+
75+
const sortSections = (data: string) => {
76+
// find the lines between `\tmemory: {` and `\t{`
77+
const memoryLines = data.match(/\tmemory: {\r?\n(.*?)\r?\n\t}/s);
78+
if (memoryLines) {
79+
const old = memoryLines[1];
80+
if (old.indexOf(`"111111111`) !== -1) {
81+
writeFileSync(errorFilePath, data, "utf-8");
82+
throw new Error(`found an invalid memory address!`);
83+
}
84+
const sorted = sortMemoryLines(old);
85+
data = data.replace(old, sorted)
86+
}
87+
88+
const L1CacheLines = data.match(/\tL1Cache: {\r?\n(.*?)\r?\n\t}/s);
89+
if (L1CacheLines) {
90+
const old = L1CacheLines[1];
91+
const sorted = sortMemoryLines(old);
92+
data = data.replace(old, sorted)
93+
}
94+
95+
const activeLocalsLines = data.match(/\tactiveLocals: {\r?\n(.*?)\r?\n\t}/s);
96+
if (activeLocalsLines) {
97+
const old = activeLocalsLines[1];
98+
const sorted = old.split('\n').sort().join('\n');
99+
data = data.replace(old, sorted)
100+
}
101+
102+
return data;
103+
}
75104

76105
export const fsWorker = {
77106
writeFile: (
@@ -95,16 +124,7 @@ export const fsWorker = {
95124
}
96125

97126
if (kind === 'ts') {
98-
// find the lines between `\tmemory: {` and `\t{`
99-
const start = data.indexOf('\tmemory: {');
100-
const end = data.indexOf('\t}', start);
101-
const memoryLines = data.substring(start, end);
102-
const sortedMemoryLines = sortMemoryLines(memoryLines);
103-
data = data.replace(memoryLines, sortedMemoryLines);
104-
if (memoryLines.indexOf(`"111111111`) !== -1) {
105-
writeFileSync(errorFilePath, data, "utf-8");
106-
throw new Error(`found an invalid memory address!`);
107-
}
127+
data = sortSections(data);
108128
}
109129

110130
writeFileSync(filePath, data, "utf-8");

tsconfig.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@
2828
"exclude": [
2929
//
3030
//
31-
// "packages/playground/doom/*",
31+
"packages/playground/doom/*",
3232
"packages/playground/add/*",
3333
"packages/playground/conway-stateless/*", // this can always be off because the file has no dependencies
3434
"packages/playground/conway-stateful/*", // this can always be off because the file has no dependencies
3535
"packages/playground/evaluate/results/result-*",
36-
"packages/playground/evaluate/stats",
37-
"packages/playground/evaluate/results/bootstrap*",
36+
"packages/playground/evaluate/stats/*",
3837
"packages/playground/evaluate/start.ts",
3938
"packages/playground/evaluate/restart/*",
4039
//

0 commit comments

Comments
 (0)