Skip to content

Commit

Permalink
refactor: move errors.ts (#1316)
Browse files Browse the repository at this point in the history
  • Loading branch information
verytactical authored Jan 14, 2025
1 parent ffb448e commit 4b2a80d
Show file tree
Hide file tree
Showing 41 changed files with 47 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/abi/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
writeString,
} from "../generator/writers/writeConstant";
import { writeExpression } from "../generator/writers/writeExpression";
import { throwCompilationError } from "../errors";
import { throwCompilationError } from "../error/errors";
import { getErrorId } from "../types/resolveErrors";
import { AbiFunction } from "./AbiFunction";
import { sha256_sync } from "@ton/crypto";
Expand Down
2 changes: 1 addition & 1 deletion src/abi/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TypeRef } from "../types/types";
import { WriterContext } from "../generator/Writer";
import { ops } from "../generator/writers/ops";
import { writeExpression } from "../generator/writers/writeExpression";
import { throwCompilationError } from "../errors";
import { throwCompilationError } from "../error/errors";
import { getType } from "../types/resolveDescriptors";
import { AbiFunction } from "./AbiFunction";
import { AstExpression } from "../grammar/ast";
Expand Down
2 changes: 1 addition & 1 deletion src/abi/struct.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ops } from "../generator/writers/ops";
import { writeExpression } from "../generator/writers/writeExpression";
import { throwCompilationError } from "../errors";
import { throwCompilationError } from "../error/errors";
import { getType } from "../types/resolveDescriptors";
import { AbiFunction } from "./AbiFunction";

Expand Down
2 changes: 1 addition & 1 deletion src/bindings/typescript/serializers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ABITypeRef } from "@ton/core";
import { Writer } from "../../utils/Writer";
import { throwInternalCompilerError } from "../../errors";
import { throwInternalCompilerError } from "../../error/errors";

const primitiveTypes = [
"int",
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/typescript/writeStruct.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ABIType, ABITypeRef } from "@ton/core";
import { serializers } from "./serializers";
import { AllocationCell, AllocationOperation } from "../../storage/operation";
import { throwInternalCompilerError } from "../../errors";
import { throwInternalCompilerError } from "../../error/errors";
import { Writer } from "../../utils/Writer";

export const maxTupleSize = 15;
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/writeTypescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
writeTupleSerializer,
} from "./typescript/writeStruct";
import { AllocationCell } from "../storage/operation";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";
import { topologicalSort } from "../utils/utils";
import {
allocate,
Expand Down
2 changes: 1 addition & 1 deletion src/constEval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
isLiteral,
AstLiteral,
} from "./grammar/ast";
import { TactConstEvalError, throwInternalCompilerError } from "./errors";
import { TactConstEvalError, throwInternalCompilerError } from "./error/errors";
import { AstUtil } from "./optimizer/util";
import { ExpressionTransformer } from "./optimizer/types";
import { StandardOptimizer } from "./optimizer/standardOptimizer";
Expand Down
2 changes: 1 addition & 1 deletion src/error/display-to-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Render error message to JSON for tests
*/

import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "./errors";
import { SrcInfo } from "../grammar";
import { srcInfoEqual } from "../grammar/src-info";
import { ErrorDisplay } from "./display";
Expand Down
2 changes: 1 addition & 1 deletion src/error/display-to-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { ErrorDisplay } from "./display";
import { locationStr } from "../errors";
import { locationStr } from "./errors";

export const displayToString: ErrorDisplay<string> = {
text: (text) => text,
Expand Down
4 changes: 2 additions & 2 deletions src/errors.ts → src/error/errors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "path";
import { cwd } from "process";
import { AstFuncId, AstId, AstTypeId } from "./grammar/ast";
import { SrcInfo } from "./grammar";
import { AstFuncId, AstId, AstTypeId } from "../grammar/ast";
import { SrcInfo } from "../grammar";

export class TactError extends Error {
readonly loc?: SrcInfo;
Expand Down
2 changes: 1 addition & 1 deletion src/generator/writers/writeExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
TactConstEvalError,
throwCompilationError,
throwInternalCompilerError,
} from "../../errors";
} from "../../error/errors";
import { getExpType } from "../../types/resolveExpression";
import {
getStaticConstant,
Expand Down
2 changes: 1 addition & 1 deletion src/generator/writers/writeFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { cast } from "./cast";
import { resolveFuncTupleType } from "./resolveFuncTupleType";
import { ops } from "./ops";
import { freshIdentifier } from "./freshIdentifier";
import { idTextErr, throwInternalCompilerError } from "../../errors";
import { idTextErr, throwInternalCompilerError } from "../../error/errors";
import { ppAsmShuffle } from "../../prettyPrinter";

export function writeCastedExpression(
Expand Down
2 changes: 1 addition & 1 deletion src/generator/writers/writeSerialization.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { contractErrors } from "../../abi/errors";
import { throwInternalCompilerError } from "../../errors";
import { throwInternalCompilerError } from "../../error/errors";
import { dummySrcInfo, ItemOrigin } from "../../grammar";
import { AllocationCell, AllocationOperation } from "../../storage/operation";
import { StorageAllocation } from "../../storage/StorageAllocation";
Expand Down
2 changes: 1 addition & 1 deletion src/grammar/ast.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address, Cell, Slice } from "@ton/core";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";
import { dummySrcInfo, SrcInfo } from "./src-info";

export type AstModule = {
Expand Down
2 changes: 1 addition & 1 deletion src/grammar/clone.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AstNode, FactoryAst } from "./ast";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";

export function cloneNode<T extends AstNode>(
src: T,
Expand Down
2 changes: 1 addition & 1 deletion src/grammar/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
AstStatementDestruct,
} from "./ast";
import { AstRenamer } from "./rename";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";
import JSONbig from "json-bigint";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/grammar/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
AstAsmInstruction,
} from "./ast";
import { createHash } from "crypto";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";
import JSONbig from "json-bigint";

export type AstHash = string;
Expand Down
5 changes: 4 additions & 1 deletion src/grammar/next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import * as $ from "@tonstudio/parser-runtime";
import * as A from "../ast";
import * as G from "./grammar";
import type { $ast } from "./grammar";
import { TactCompilationError, throwInternalCompilerError } from "../../errors";
import {
TactCompilationError,
throwInternalCompilerError,
} from "../../error/errors";
import { SyntaxErrors, syntaxErrorSchema } from "../parser-error";
import { AstSchema, getAstSchema } from "../ast-typed";
import { getSrcInfo, ItemOrigin } from "../src-info";
Expand Down
2 changes: 1 addition & 1 deletion src/grammar/prev/grammar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Node, IterationNode, NonterminalNode } from "ohm-js";
import tactGrammar from "./grammar.ohm-bundle";
import { throwInternalCompilerError } from "../../errors";
import { throwInternalCompilerError } from "../../error/errors";
import {
AstAugmentedAssignOperation,
AstConstantAttribute,
Expand Down
2 changes: 1 addition & 1 deletion src/grammar/prev/parser-error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MatchResult } from "ohm-js";
import { ErrorDisplay } from "../../error/display";
import { TactCompilationError } from "../../errors";
import { TactCompilationError } from "../../error/errors";
import { syntaxErrorSchema } from "../parser-error";
import { ItemOrigin, SrcInfo } from "../src-info";
import { getSrcInfoFromOhm } from "./src-info";
Expand Down
2 changes: 1 addition & 1 deletion src/grammar/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
AstContractAttribute,
AstNode,
} from "./ast";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";

/**
* Provides utilities to sort lists of AST nodes.
Expand Down
2 changes: 1 addition & 1 deletion src/grammar/src-info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";

export type ItemOrigin = "stdlib" | "user";

Expand Down
2 changes: 1 addition & 1 deletion src/grammar/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
AstTypeDecl,
AstAsmFunctionDef,
} from "./ast";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";
import { CompilerContext, createContextStore } from "../context";
import { ItemOrigin } from "./src-info";
import { Parser } from "./grammar";
Expand Down
2 changes: 1 addition & 1 deletion src/imports/resolveImports.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ItemOrigin, Parser } from "../grammar";
import { VirtualFileSystem } from "../vfs/VirtualFileSystem";
import { throwCompilationError } from "../errors";
import { throwCompilationError } from "../error/errors";
import { resolveLibrary } from "./resolveLibrary";

export function resolveImports(args: {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export {
TactInternalCompilerError,
TactConstEvalError,
TactErrorCollection,
} from "./errors";
} from "./error/errors";
export {
optionsSchema,
projectSchema,
Expand Down
2 changes: 1 addition & 1 deletion src/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
idTextErr,
throwConstEvalError,
throwInternalCompilerError,
} from "./errors";
} from "./error/errors";
import {
AstAddress,
AstBinaryOperation,
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export { createVirtualFileSystem } from "./vfs/createVirtualFileSystem";
export * from "./browser";
export * from "./verify";
export * from "./logger";
export * from "./errors";
export * from "./error/errors";
2 changes: 1 addition & 1 deletion src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ConfigProject, Config, parseConfig } from "./config/parseConfig";
import { createNodeFileSystem } from "./vfs/createNodeFileSystem";
import { build } from "./pipeline/build";
import { LogLevel, Logger } from "./logger";
import { TactErrorCollection } from "./errors";
import { TactErrorCollection } from "./error/errors";

type AdditionalCliOptions = {
mode?: ConfigProject["mode"];
Expand Down
2 changes: 1 addition & 1 deletion src/optimizer/test/partial-eval.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AssociativeRule3 } from "../associative";
import { evalBinaryOp, evalUnaryOp } from "../../interpreter";
import { getParser } from "../../grammar";
import { defaultParser } from "../../grammar/grammar";
import { throwInternalCompilerError } from "../../errors";
import { throwInternalCompilerError } from "../../error/errors";

const MAX: string =
"115792089237316195423570985008687907853269984665640564039457584007913129639935";
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { compile } from "./compile";
import { precompile } from "./precompile";
import { getCompilerVersion } from "./version";
import { FactoryAst, getAstFactory, idText } from "../grammar/ast";
import { TactErrorCollection } from "../errors";
import { TactErrorCollection } from "../error/errors";
import { getParser, Parser } from "../grammar";
import { defaultParser } from "../grammar/grammar";

Expand Down
2 changes: 1 addition & 1 deletion src/storage/allocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
AllocationOperation,
AllocationOperationType,
} from "./operation";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";

const ALLOCATOR_RESERVE_BIT = 1;
const ALLOCATOR_RESERVE_REF = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/storage/resolveAllocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AllocationOperation } from "./operation";
import { allocate, getAllocationOperationFromField } from "./allocator";
import { createABITypeRefFromTypeRef } from "../types/resolveABITypeRef";
import { funcInitIdOf } from "../generator/writers/id";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";
import { idText } from "../grammar/ast";

const store = createContextStore<StorageAllocation>();
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveABITypeRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
idTextErr,
throwCompilationError,
throwInternalCompilerError,
} from "../errors";
} from "../error/errors";
import { TypeRef } from "./types";
import { CompilerContext } from "../context";
import { getType } from "./resolveDescriptors";
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveDescriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
idTextErr,
throwCompilationError,
throwInternalCompilerError,
} from "../errors";
} from "../error/errors";
import { CompilerContext, createContextStore, Store } from "../context";
import {
ConstantDescription,
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CompilerContext, createContextStore } from "../context";
import { AstNode, FactoryAst, isRequire } from "../grammar/ast";
import { traverse } from "../grammar/iterators";
import { evalConstantExpression } from "../constEval";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";
import {
getAllStaticFunctions,
getAllTypes,
Expand Down
4 changes: 2 additions & 2 deletions src/types/resolveExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
AstCommentValue,
AstStructValue,
} from "../grammar/ast";
import { idTextErr, throwCompilationError } from "../errors";
import { idTextErr, throwCompilationError } from "../error/errors";
import { CompilerContext, createContextStore } from "../context";
import {
getAllTypes,
Expand All @@ -37,7 +37,7 @@ import { StatementContext } from "./resolveStatements";
import { MapFunctions } from "../abi/map";
import { GlobalFunctions } from "../abi/global";
import { isAssignable, moreGeneralType } from "./subtyping";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";
import { StructFunctions } from "../abi/struct";
import { prettyPrint } from "../prettyPrinter";

Expand Down
4 changes: 2 additions & 2 deletions src/types/resolveSignatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import {
idTextErr,
throwConstEvalError,
throwInternalCompilerError,
} from "../errors";
} from "../error/errors";
import { getType, getAllTypes } from "./resolveDescriptors";
import {
BinaryReceiverSelector,
CommentReceiverSelector,
ReceiverDescription,
TypeDescription,
} from "./types";
import { throwCompilationError } from "../errors";
import { throwCompilationError } from "../error/errors";
import { AstNumber, AstReceiver, FactoryAst } from "../grammar/ast";
import { commentPseudoOpcode } from "../generator/writers/writeRouter";
import { sha256_sync } from "@ton/crypto";
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveStatements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
throwCompilationError,
throwConstEvalError,
throwInternalCompilerError,
} from "../errors";
} from "../error/errors";
import {
getAllStaticFunctions,
getStaticConstant,
Expand Down
2 changes: 1 addition & 1 deletion src/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ABIField } from "@ton/core";
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";
import {
AstConstantDef,
AstFunctionDef,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tricks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const match = <const I extends any[]>(
}) as MV<Flat<I>, never>;
};

import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";

/**
* Convert union to intersection. See https://stackoverflow.com/q/50374908
Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { throwInternalCompilerError } from "../errors";
import { throwInternalCompilerError } from "../error/errors";

export function topologicalSort<T>(src: T[], references: (src: T) => T[]) {
const result: T[] = [];
Expand Down

0 comments on commit 4b2a80d

Please sign in to comment.