Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
michele-nuzzi committed Feb 6, 2025
1 parent ef4c744 commit 6e0f200
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 291 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/ast/nodes/expr/functions/CallExpr.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SourceRange } from "../../../Source/SourceRange";
import { Identifier } from "../../common/Identifier";
import { HasSourceRange } from "../../HasSourceRange";
import { PebbleAstType } from "../../types/PebbleAstType";
import { PebbleExpr } from "../PebbleExpr";
Expand Down
48 changes: 23 additions & 25 deletions src/compiler/AstCompiler/AstCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export class AstCompiler extends DiagnosticEmitter
super( diagnostics );
}

readonly depGraph = new DependencyGraph();
readonly exportedSymbols = new Map<string, Source>();
// readonly depGraph = new DependencyGraph();
// readonly exportedSymbols = new Map<string, Source>();

async compileFile(
path: string,
Expand Down Expand Up @@ -115,11 +115,24 @@ export class AstCompiler extends DiagnosticEmitter

async compileSource( src: Source )
{
await this._typeCheck( src );
await this._checkCircularDependencies( src );

return this.diagnostics;
}

async checkCircularDependencies( src: Source | Path ): Promise<DiagnosticMessage[]>
{
if(!( src instanceof Source ))
{
src = src.toString();
src = mangleInternalPath( removeSingleDotDirsFromPath( src ) );
src = (await this.sourceFromInternalPath( src ))!;
if( !src ) return this.diagnostics;
}
await this._checkCircularDependencies( src );
return this.diagnostics;
}

/** MUST NOT be used as a "seen" log */
private readonly _sourceCache = new Map<string, Source>();
async sourceFromInternalPath(
Expand Down Expand Up @@ -154,24 +167,11 @@ export class AstCompiler extends DiagnosticEmitter
return this._sourceCache.get( internalPath );
}

async typeCheck( src: Source | Path ): Promise<DiagnosticMessage[]>
{
if(!( src instanceof Source ))
{
src = src.toString();
src = mangleInternalPath( removeSingleDotDirsFromPath( src ) );
src = (await this.sourceFromInternalPath( src ))!;
if( !src ) return this.diagnostics;
}
await this._typeCheck( src );
return this.diagnostics;
}

/**
*
* @returns `true` if there were no errors. `false` otherwise.
*/
private async _typeCheck(
private async _checkCircularDependencies(
source: Source | ResolveStackNode
): Promise<boolean>
{
Expand Down Expand Up @@ -254,13 +254,11 @@ export class AstCompiler extends DiagnosticEmitter

const imports = stmts.filter( isImportStmtLike );

const srcPath = src.internalPath;

const importPaths = this.importPathsFromStmts( imports, srcPath );

this.depGraph.addDependencies( srcPath, importPaths );
// const srcPath = src.internalPath;
// const importPaths = this.importPathsFromStmts( imports, srcPath );
// this.depGraph.addDependencies( srcPath, importPaths );

return await this.typeCheckDependencies(
return await this.checkCircularDependenciesDependencies(
imports,
resolveStack
);
Expand Down Expand Up @@ -290,7 +288,7 @@ export class AstCompiler extends DiagnosticEmitter
.filter( path => path !== "" );
}

async typeCheckDependencies(
async checkCircularDependenciesDependencies(
imports: ImportStmtLike[],
dependent: ResolveStackNode
): Promise<boolean>
Expand All @@ -306,7 +304,7 @@ export class AstCompiler extends DiagnosticEmitter
if( !src ) continue; // error already reported parsing import

const resolveStack = new ResolveStackNode( dependent, src );
if( !await this._typeCheck( resolveStack ) ) return false;
if( !await this._checkCircularDependencies( resolveStack ) ) return false;
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const complier = new AstCompiler(
);

test("type check", async () => {
const diagnostics = await complier.typeCheck("a.pebble");
const diagnostics = await complier.checkCircularDependencies("a.pebble");

expect( diagnostics.length )
// at least the 3 files in the cycle
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/path/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ export function resolveAsRootPath( toResolve: string, fromPath: string ): string
result = result === "." || result.endsWith( fromDirname.slice( 0, fromDirname.length - 1 ) ) ?
result + PATH_DELIMITER :
result;
result = result.startsWith("/") ? result : "/" + result;
// result = result.startsWith("/") ? result : "/" + result;

return result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,7 @@ export class Parser extends DiagnosticEmitter
const inner = this.joinPropertyCall(
startPos,
expr,
callee
callee as CallExpr
);
if( !inner ) return undefined;
call = new CallExpr(
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/pluts/API/V2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { POutputDatum } from "./Tx/POutputDatum";
import { PTxOut } from "./Tx/PTxOut";
import { PTxInInfo } from "./Tx/PTxInInfo";

export const V2 = Object.freeze({
export const V2: typeof V1 = Object.freeze({
...V1,

PScriptContext,
Expand All @@ -20,4 +20,4 @@ export const V2 = Object.freeze({
POutputDatum,
PTxInInfo,
PTxOut
} as const);
} as any);
10 changes: 4 additions & 6 deletions src/type_system/ts-pluts-conversion.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { PType } from "../PType";
import { PInt, PByteString, PString, PUnit, PBool, PList, PPair, PDelayed, PLam, PAlias, PStruct, PData, PAsData } from "../PTypes";
import { PBlsG1 } from "../PTypes/PBlsG1";
import { PBlsG2 } from "../PTypes/PBlsG2";
import { PBlsMlRes } from "../PTypes/PBlsMlRes";
import { PSop } from "../PTypes/PSoP/psop";
import { PAlias, PAsData, PBool, PByteString, PData, PDelayed, PInt, PLam, PList, PPair, PSop, PString, PStruct, PType, PUnit } from "../pluts";
import { PBlsG1 } from "../pluts/PTypes/PBlsG1";
import { PBlsG2 } from "../pluts/PTypes/PBlsG2";
import { PBlsMlRes } from "../pluts/PTypes/PBlsMlRes";
import { AliasT, GenericTermType, Methods, NonAliasTermType, PrimType, SopDefinition, StructDefinition, TermType } from "./types";

export type ToPType<T extends TermType> =
Expand Down
Loading

0 comments on commit 6e0f200

Please sign in to comment.