diff --git a/compiler/forget/src/HIR/HIRBuilder.ts b/compiler/forget/src/HIR/HIRBuilder.ts index 94126ff410..818ad5f185 100644 --- a/compiler/forget/src/HIR/HIRBuilder.ts +++ b/compiler/forget/src/HIR/HIRBuilder.ts @@ -21,6 +21,7 @@ import { GotoVariant, HIR, Identifier, + IdentifierId, Instruction, makeBlockId, makeInstructionId, @@ -86,7 +87,7 @@ export default class HIRBuilder { parentFunction: NodePath; errors: CompilerError = new CompilerError(); - get nextIdentifierId() { + get nextIdentifierId(): IdentifierId { return this.#env.nextIdentifierId; } @@ -127,7 +128,7 @@ export default class HIRBuilder { /** * Push a statement or expression onto the current block */ - push(instruction: Instruction) { + push(instruction: Instruction): void { this.#current.instructions.push(instruction); } @@ -272,7 +273,7 @@ export default class HIRBuilder { /** * Terminate the current block w the given terminal, and start a new block */ - terminate(terminal: Terminal, nextBlockKind: BlockKind) { + terminate(terminal: Terminal, nextBlockKind: BlockKind): void { const { id: blockId, kind, instructions } = this.#current; this.#completed.set(blockId, { kind, @@ -290,7 +291,7 @@ export default class HIRBuilder { * Terminate the current block w the given terminal, and set the previously * reserved block as the new current block */ - terminateWithContinuation(terminal: Terminal, continuation: WipBlock) { + terminateWithContinuation(terminal: Terminal, continuation: WipBlock): void { const { id: blockId, kind, instructions } = this.#current; this.#completed.set(blockId, { kind: kind, @@ -315,7 +316,7 @@ export default class HIRBuilder { /** * Save a previously reserved block as completed */ - complete(block: WipBlock, terminal: Terminal) { + complete(block: WipBlock, terminal: Terminal): void { const { id: blockId, kind, instructions } = block; this.#completed.set(blockId, { kind, @@ -536,7 +537,7 @@ export function removeUnreachableFallthroughs(func: HIR): void { export function reversePostorderBlocks(func: HIR): void { const visited: Set = new Set(); const postorder: Array = []; - function visit(blockId: BlockId) { + function visit(blockId: BlockId): void { if (visited.has(blockId)) { return; } @@ -634,7 +635,7 @@ export function reversePostorderBlocks(func: HIR): void { func.blocks = blocks; } -export function markInstructionIds(func: HIR) { +export function markInstructionIds(func: HIR): void { let id = 0; const visited = new Set(); for (const [_, block] of func.blocks) { @@ -650,12 +651,12 @@ export function markInstructionIds(func: HIR) { } } -export function markPredecessors(func: HIR) { +export function markPredecessors(func: HIR): void { for (const [, block] of func.blocks) { block.preds.clear(); } const visited: Set = new Set(); - function visit(blockId: BlockId, prevBlock: BasicBlock | null) { + function visit(blockId: BlockId, prevBlock: BasicBlock | null): void { const block = func.blocks.get(blockId)!; if (prevBlock) { block.preds.add(prevBlock.id); diff --git a/compiler/forget/src/HIR/PrintHIR.ts b/compiler/forget/src/HIR/PrintHIR.ts index d3146be577..8e8da1e6c4 100644 --- a/compiler/forget/src/HIR/PrintHIR.ts +++ b/compiler/forget/src/HIR/PrintHIR.ts @@ -42,7 +42,7 @@ export function printFunction(fn: HIRFunction): string { export function printHIR(ir: HIR, options: Options | null = null): string { let output = []; let indent = " ".repeat(options?.indent ?? 0); - const push = (text: string, indent: string = " ") => { + const push = (text: string, indent: string = " "): void => { output.push(`${indent}${text}`); }; for (const [blockId, block] of ir.blocks) { diff --git a/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts b/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts index 89b3d9ab76..33ff1c90a8 100644 --- a/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts +++ b/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts @@ -416,7 +416,7 @@ function codegenDependency( return object; } -function withLoc TNode>( +function withLoc t.Node>( fn: T ): ( loc: SourceLocation | null | undefined, @@ -430,8 +430,7 @@ function withLoc TNode>( if (loc != null && loc != GeneratedSource) { node.loc = loc; } - // @ts-ignore - return node; + return node as ReturnType; }; } @@ -439,9 +438,9 @@ const createBinaryExpression = withLoc(t.binaryExpression); const createCallExpression = withLoc(t.callExpression); const createExpressionStatement = withLoc(t.expressionStatement); const createFunctionDeclaration = withLoc(t.functionDeclaration); -const createLabelledStatement = withLoc(t.labeledStatement); +const _createLabelledStatement = withLoc(t.labeledStatement); const createVariableDeclaration = withLoc(t.variableDeclaration); -const createWhileStatement = withLoc(t.whileStatement); +const _createWhileStatement = withLoc(t.whileStatement); const createTaggedTemplateExpression = withLoc(t.taggedTemplateExpression); const createLogicalExpression = withLoc(t.logicalExpression); const createSequenceExpression = withLoc(t.sequenceExpression); diff --git a/compiler/forget/src/ReactiveScopes/visitors.ts b/compiler/forget/src/ReactiveScopes/visitors.ts index d6a493d05c..6a5a5d8f3f 100644 --- a/compiler/forget/src/ReactiveScopes/visitors.ts +++ b/compiler/forget/src/ReactiveScopes/visitors.ts @@ -30,9 +30,9 @@ export function visitReactiveFunction( } export class ReactiveFunctionVisitor { - visitID(id: InstructionId, state: TState): void {} - visitLValue(id: InstructionId, lvalue: LValue, state: TState): void {} - visitPlace(id: InstructionId, place: Place, state: TState): void {} + visitID(_id: InstructionId, _state: TState): void {} + visitLValue(_id: InstructionId, _lvalue: LValue, _state: TState): void {} + visitPlace(_id: InstructionId, _place: Place, _state: TState): void {} visitValue(id: InstructionId, value: ReactiveValue, state: TState): void { this.traverseValue(id, value, state); diff --git a/compiler/forget/src/SSA/EnterSSA.ts b/compiler/forget/src/SSA/EnterSSA.ts index f573134391..89a2ce8b67 100644 --- a/compiler/forget/src/SSA/EnterSSA.ts +++ b/compiler/forget/src/SSA/EnterSSA.ts @@ -157,14 +157,14 @@ class SSABuilder { return newId; } - fixIncompletePhis(block: BasicBlock) { + fixIncompletePhis(block: BasicBlock): void { const state = this.#states.get(block)!; for (const phi of state.incompletePhis) { this.addPhi(block, phi.oldId, phi.newId); } } - startBlock(block: BasicBlock) { + startBlock(block: BasicBlock): void { this.#current = block; this.#states.set(block, { defs: new Map(), @@ -172,7 +172,7 @@ class SSABuilder { }); } - print() { + print(): void { const text: string[] = []; for (const [block, state] of this.#states) { text.push(`bb${block.id}:`); @@ -194,7 +194,7 @@ class SSABuilder { } } -export default function enterSSA(func: HIRFunction) { +export default function enterSSA(func: HIRFunction): void { const visitedBlocks: Set = new Set(); const builder = new SSABuilder(func.env, func.body.blocks); for (const [blockId, block] of func.body.blocks) {