Skip to content

Commit

Permalink
refactor: move contexts out of root (#1320)
Browse files Browse the repository at this point in the history
- compiler context
- logger
  • Loading branch information
verytactical authored Jan 14, 2025
1 parent aba33c1 commit 2a16308
Show file tree
Hide file tree
Showing 37 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion scripts/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FuncCompilationResult, funcCompile } from "../src/func/funcCompile";
import path from "path";
import { glob } from "glob";
import { verify } from "../src/verify";
import { Logger } from "../src/logger";
import { Logger } from "../src/context/logger";
import { __DANGER__disableVersionNumber } from "../src/pipeline/version";

// Read cases
Expand Down
2 changes: 1 addition & 1 deletion src/abi/AbiFunction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AstExpression } from "../grammar/ast";
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { WriterContext } from "../generator/Writer";
import { TypeRef } from "../types/types";
import { SrcInfo } from "../grammar";
Expand Down
2 changes: 1 addition & 1 deletion src/abi/map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { SrcInfo } from "../grammar";
import { TypeRef } from "../types/types";
import { WriterContext } from "../generator/Writer";
Expand Down
2 changes: 1 addition & 1 deletion src/browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Config, verifyConfig } from "./config/parseConfig";
import { ILogger } from "./logger";
import { ILogger } from "./context/logger";
import { build } from "./pipeline/build";
import { createVirtualFileSystem } from "./vfs/createVirtualFileSystem";

Expand Down
2 changes: 1 addition & 1 deletion src/config/features.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerContext, createContextStore } from "../context";
import { CompilerContext, createContextStore } from "../context/context";

const featureStore = createContextStore<boolean | null | string>();

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/func/funcCompile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from "fs";
import path from "path";
import { Logger } from "../logger";
import { Logger } from "../context/logger";
import { funcCompile } from "./funcCompile";
import files from "../imports/stdlib";

Expand Down
2 changes: 1 addition & 1 deletion src/func/funcCompile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ILogger } from "../logger";
import { ILogger } from "../context/logger";

// Wasm Imports
// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down
2 changes: 1 addition & 1 deletion src/generator/Writer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { escapeUnicodeControlCodes, trimIndent } from "../utils/text";
import { topologicalSort } from "../utils/utils";
import { Writer } from "../utils/Writer";
Expand Down
2 changes: 1 addition & 1 deletion src/generator/createABI.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ABIGetter, ABIReceiver, ABIType, ContractABI } from "@ton/core";
import { contractErrors } from "../abi/errors";
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { idText } from "../grammar/ast";
import { getSupportedInterfaces } from "../types/getSupportedInterfaces";
import { createABITypeRefFromTypeRef } from "../types/resolveABITypeRef";
Expand Down
2 changes: 1 addition & 1 deletion src/generator/writeProgram.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { getAllocation, getSortedTypes } from "../storage/resolveAllocation";
import {
getAllStaticFunctions,
Expand Down
2 changes: 1 addition & 1 deletion src/generator/writeReport.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContractABI } from "@ton/core";
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { PackageFileFormat } from "../packaging/fileFormat";
import { getType } from "../types/resolveDescriptors";
import { Writer } from "../utils/Writer";
Expand Down
2 changes: 1 addition & 1 deletion src/generator/writers/resolveFuncType.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { resolveDescriptors } from "../../types/resolveDescriptors";
import { WriterContext } from "../Writer";
import { resolveFuncType } from "./resolveFuncType";
import { openContext } from "../../grammar/store";
import { CompilerContext } from "../../context";
import { CompilerContext } from "../../context/context";
import { getParser } from "../../grammar";
import { defaultParser } from "../../grammar/grammar";

Expand Down
2 changes: 1 addition & 1 deletion src/generator/writers/writeExpression.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { WriterContext } from "../Writer";
import { writeExpression } from "./writeExpression";
import { openContext } from "../../grammar/store";
import { resolveStatements } from "../../types/resolveStatements";
import { CompilerContext } from "../../context";
import { CompilerContext } from "../../context/context";
import { getParser } from "../../grammar";
import { getAstFactory } from "../../grammar/ast";
import { defaultParser } from "../../grammar/grammar";
Expand Down
2 changes: 1 addition & 1 deletion src/generator/writers/writeSerialization.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerContext } from "../../context";
import { CompilerContext } from "../../context/context";
import {
getAllocation,
resolveAllocations,
Expand Down
2 changes: 1 addition & 1 deletion src/grammar/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
AstAsmFunctionDef,
} from "./ast";
import { throwInternalCompilerError } from "../error/errors";
import { CompilerContext, createContextStore } from "../context";
import { CompilerContext, createContextStore } from "../context/context";
import { ItemOrigin } from "./src-info";
import { Parser } from "./grammar";

Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export { createVirtualFileSystem } from "./vfs/createVirtualFileSystem";

export * from "./browser";
export * from "./verify";
export * from "./logger";
export * from "./context/logger";
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 @@ -3,7 +3,7 @@ import fs from "fs";
import { ConfigProject, Config, parseConfig } from "./config/parseConfig";
import { createNodeFileSystem } from "./vfs/createNodeFileSystem";
import { build } from "./pipeline/build";
import { LogLevel, Logger } from "./logger";
import { LogLevel, Logger } from "./context/logger";
import { TactErrorCollection } from "./error/errors";

type AdditionalCliOptions = {
Expand Down
2 changes: 1 addition & 1 deletion src/optimizer/constEval.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import {
AstBinaryOperation,
AstExpression,
Expand Down
2 changes: 1 addition & 1 deletion src/optimizer/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Address, beginCell, BitString, Cell, toNano } from "@ton/core";
import { paddedBufferToBits } from "@ton/core/dist/boc/utils/paddedBits";
import * as crc32 from "crc-32";
import { evalConstantExpression } from "./constEval";
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import {
TactCompilationError,
TactConstEvalError,
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 @@ -7,7 +7,7 @@ import {
} from "../../grammar/ast";
import { AstUtil, getAstUtil } from "../util";
import { getOptimizer } from "../constEval";
import { CompilerContext } from "../../context";
import { CompilerContext } from "../../context/context";
import { ExpressionTransformer, Rule } from "../types";
import { AssociativeRule3 } from "../associative";
import { evalBinaryOp, evalUnaryOp } from "../interpreter";
Expand Down
4 changes: 2 additions & 2 deletions src/pipeline/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { decompileAll } from "@tact-lang/opcode";
import { writeTypescript } from "../bindings/writeTypescript";
import { featureEnable } from "../config/features";
import { ConfigProject } from "../config/parseConfig";
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { funcCompile } from "../func/funcCompile";
import { writeReport } from "../generator/writeReport";
import { getRawAST } from "../grammar/store";
import files from "../imports/stdlib";
import { ILogger, Logger } from "../logger";
import { ILogger, Logger } from "../context/logger";
import { PackageFileFormat } from "../packaging/fileFormat";
import { packageCode } from "../packaging/packageCode";
import { createABITypeRefFromTypeRef } from "../types/resolveABITypeRef";
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline/compile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { createABI } from "../generator/createABI";
import { writeProgram } from "../generator/writeProgram";

Expand Down
2 changes: 1 addition & 1 deletion src/pipeline/precompile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { resolveDescriptors } from "../types/resolveDescriptors";
import { resolveAllocations } from "../storage/resolveAllocation";
import { openContext } from "../grammar/store";
Expand Down
2 changes: 1 addition & 1 deletion src/storage/resolveAllocation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { resolveDescriptors } from "../types/resolveDescriptors";
import { getAllocations, resolveAllocations } from "./resolveAllocation";
import { openContext } from "../grammar/store";
import { resolveStatements } from "../types/resolveStatements";
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { resolveSignatures } from "../types/resolveSignatures";
import path from "path";
import { getParser } from "../grammar";
Expand Down
2 changes: 1 addition & 1 deletion src/storage/resolveAllocation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerContext, createContextStore } from "../context";
import { CompilerContext, createContextStore } from "../context/context";
import { getType, toBounced, getAllTypes } from "../types/resolveDescriptors";
import { TypeDescription } from "../types/types";
import { topologicalSort } from "../utils/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/types/getSupportedInterfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { enabledDebug } from "../config/features";
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { TypeDescription } from "./types";

export function getSupportedInterfaces(
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveABITypeRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
throwInternalCompilerError,
} from "../error/errors";
import { TypeRef } from "./types";
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { getType } from "./resolveDescriptors";
import { SrcInfo } from "../grammar";

Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveDescriptors.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import {
getAllStaticFunctions,
getAllTypes,
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveDescriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
throwCompilationError,
throwInternalCompilerError,
} from "../error/errors";
import { CompilerContext, createContextStore, Store } from "../context";
import { CompilerContext, createContextStore, Store } from "../context/context";
import {
ConstantDescription,
FieldDescription,
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveErrors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sha256_sync } from "@ton/crypto";
import { CompilerContext, createContextStore } from "../context";
import { CompilerContext, createContextStore } from "../context/context";
import { AstNode, FactoryAst, isRequire } from "../grammar/ast";
import { traverse } from "../grammar/iterators";
import { evalConstantExpression } from "../optimizer/constEval";
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
AstStructValue,
} from "../grammar/ast";
import { idTextErr, throwCompilationError } from "../error/errors";
import { CompilerContext, createContextStore } from "../context";
import { CompilerContext, createContextStore } from "../context/context";
import {
getAllTypes,
getStaticConstant,
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveSignatures.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as changeCase from "change-case";
import { ABIField, beginCell } from "@ton/core";
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { idToHex } from "../utils/idToHex";
import {
idTextErr,
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveStatements.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { resolveDescriptors } from "./resolveDescriptors";
import { loadCases } from "../utils/loadCases";
import { openContext } from "../grammar/store";
import { resolveStatements } from "./resolveStatements";
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import { featureEnable } from "../config/features";
import { getParser } from "../grammar";
import { getAstFactory } from "../grammar/ast";
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveStatements.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompilerContext } from "../context";
import { CompilerContext } from "../context/context";
import {
AstCondition,
AstStatement,
Expand Down
2 changes: 1 addition & 1 deletion src/verify.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import normalize from "path-normalize";
import { Cell } from "@ton/core";
import { Config, Options } from "./config/parseConfig";
import { ILogger, Logger } from "./logger";
import { ILogger, Logger } from "./context/logger";
import { PackageFileFormat, run } from "./main";
import { fileFormat } from "./packaging/fileFormat";
import { getCompilerVersion } from "./pipeline/version";
Expand Down

0 comments on commit 2a16308

Please sign in to comment.