Skip to content

Commit

Permalink
remove child clone on change parent IR (this is either awesome or a b…
Browse files Browse the repository at this point in the history
…ig fuck up)
  • Loading branch information
michele-nuzzi committed Aug 17, 2024
1 parent 37fb867 commit f8d856c
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe("fee", () => {
});

expect( tx.body.fee ).toBeGreaterThanOrEqual( 174611 );
console.log( JSON.stringify( tx.toJson(), undefined, 2) )
// console.log( JSON.stringify( tx.toJson(), undefined, 2) )

});
})
18 changes: 9 additions & 9 deletions packages/onchain/src/IR/IRNodes/IRApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ export class IRApp
_parent = newParent;

// if has old parent
if( oldParent !== undefined && isIRParentTerm( oldParent ) )
{
// change reference to a clone for safety
_modifyChildFromTo(
oldParent,
this,
this.clone()
);
}
// if( oldParent !== undefined && isIRParentTerm( oldParent ) )
// {
// // change reference to a clone for safety
// _modifyChildFromTo(
// oldParent,
// this,
// this.clone()
// );
// }
},
enumerable: true,
configurable: false
Expand Down
18 changes: 9 additions & 9 deletions packages/onchain/src/IR/IRNodes/IRConst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ export class IRConst
_parent = newParent;

// if has old parent
if( oldParent !== undefined && isIRParentTerm( oldParent ) )
{
// change reference to a clone for safety
_modifyChildFromTo(
oldParent,
this,
this.clone()
);
}
// if( oldParent !== undefined && isIRParentTerm( oldParent ) )
// {
// // change reference to a clone for safety
// _modifyChildFromTo(
// oldParent,
// this,
// this.clone()
// );
// }
},
enumerable: true,
configurable: false
Expand Down
18 changes: 9 additions & 9 deletions packages/onchain/src/IR/IRNodes/IRDelayed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ export class IRDelayed
_parent = newParent;

// if has old parent
if( oldParent !== undefined && isIRParentTerm( oldParent ) )
{
// change reference to a clone for safety
_modifyChildFromTo(
oldParent,
this,
this.clone()
);
}
// if( oldParent !== undefined && isIRParentTerm( oldParent ) )
// {
// // change reference to a clone for safety
// _modifyChildFromTo(
// oldParent,
// this,
// this.clone()
// );
// }
},
enumerable: true,
configurable: false
Expand Down
18 changes: 9 additions & 9 deletions packages/onchain/src/IR/IRNodes/IRError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ export class IRError
_parent = newParent;

// if has old parent
if( oldParent !== undefined && isIRParentTerm( oldParent ) )
{
// change reference to a clone for safety
_modifyChildFromTo(
oldParent,
this,
this.clone()
);
}
// if( oldParent !== undefined && isIRParentTerm( oldParent ) )
// {
// // change reference to a clone for safety
// _modifyChildFromTo(
// oldParent,
// this,
// this.clone()
// );
// }
},
enumerable: true,
configurable: false
Expand Down
18 changes: 9 additions & 9 deletions packages/onchain/src/IR/IRNodes/IRForced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ export class IRForced
_parent = newParent;

// if has old parent
if( oldParent !== undefined && isIRParentTerm( oldParent ) )
{
// change reference to a clone for safety
_modifyChildFromTo(
oldParent,
this,
this.clone()
);
}
// if( oldParent !== undefined && isIRParentTerm( oldParent ) )
// {
// // change reference to a clone for safety
// _modifyChildFromTo(
// oldParent,
// this,
// this.clone()
// );
// }
},
enumerable: true,
configurable: false
Expand Down
18 changes: 9 additions & 9 deletions packages/onchain/src/IR/IRNodes/IRFunc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ export class IRFunc
_parent = newParent;

// if has old parent
if( oldParent !== undefined && isIRParentTerm( oldParent ) )
{
// change reference to a clone for safety
_modifyChildFromTo(
oldParent,
this,
this.clone()
);
}
// if( oldParent !== undefined && isIRParentTerm( oldParent ) )
// {
// // change reference to a clone for safety
// _modifyChildFromTo(
// oldParent,
// this,
// this.clone()
// );
// }
},
enumerable: true,
configurable: false
Expand Down
18 changes: 9 additions & 9 deletions packages/onchain/src/IR/IRNodes/IRHoisted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ export class IRHoisted
_parent = newParent;

// if has old parent
if( oldParent !== undefined && isIRParentTerm( oldParent ) )
{
// change reference to a clone for safety
_modifyChildFromTo(
oldParent,
this,
this.clone()
);
}
// if( oldParent !== undefined && isIRParentTerm( oldParent ) )
// {
// // change reference to a clone for safety
// _modifyChildFromTo(
// oldParent,
// this,
// this.clone()
// );
// }
},
enumerable: true,
configurable: false
Expand Down
18 changes: 9 additions & 9 deletions packages/onchain/src/IR/IRNodes/IRLetted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,15 @@ export class IRLetted
_parent = newParent;

// if has old parent
if( oldParent !== undefined && isIRParentTerm( oldParent ) )
{
// change reference to a clone for safety
_modifyChildFromTo(
oldParent,
this,
this.clone()
);
}
// if( oldParent !== undefined && isIRParentTerm( oldParent ) )
// {
// // change reference to a clone for safety
// _modifyChildFromTo(
// oldParent,
// this,
// this.clone()
// );
// }
},
enumerable: true,
configurable: false
Expand Down
18 changes: 9 additions & 9 deletions packages/onchain/src/IR/IRNodes/IRNative/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ export class IRNative
_parent = newParent;

// if has old parent
if( oldParent !== undefined && isIRParentTerm( oldParent ) )
{
// change reference to a clone for safety
_modifyChildFromTo(
oldParent,
this,
this.clone()
);
}
// if( oldParent !== undefined && isIRParentTerm( oldParent ) )
// {
// // change reference to a clone for safety
// _modifyChildFromTo(
// oldParent,
// this,
// this.clone()
// );
// }
},
enumerable: true,
configurable: false
Expand Down
18 changes: 9 additions & 9 deletions packages/onchain/src/IR/IRNodes/IRVar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ export class IRVar
_parent = newParent;

// if has old parent
if( oldParent !== undefined && isIRParentTerm( oldParent ) )
{
// change reference to a clone for safety
_modifyChildFromTo(
oldParent,
this,
this.clone()
);
}
// if( oldParent !== undefined && isIRParentTerm( oldParent ) )
// {
// // change reference to a clone for safety
// _modifyChildFromTo(
// oldParent,
// this,
// this.clone()
// );
// }
},
enumerable: true,
configurable: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const innerZ = new IRFunc( 1, // f
)
)
);
innerZ.hash;

const hoisted_z_comb = new IRHoisted(
new IRFunc( 1, // Z
Expand All @@ -35,6 +36,7 @@ const hoisted_z_comb = new IRHoisted(
)
)
);
hoisted_z_comb.hash;

const hoisted_matchList = new IRHoisted(
new IRFunc( 3,
Expand All @@ -60,6 +62,7 @@ const hoisted_matchList = new IRHoisted(
)
)
);
hoisted_matchList.hash;

const hoisted_lazyIfThenElse = new IRHoisted(
new IRFunc( 3, // condition, delayed_caseTrue, delayed_caseFalse
Expand All @@ -73,6 +76,7 @@ const hoisted_lazyIfThenElse = new IRHoisted(
)
)
);
hoisted_lazyIfThenElse.hash;

const hoisted_dropList = new IRHoisted(
new IRApp(
Expand Down Expand Up @@ -110,6 +114,7 @@ const hoisted_dropList = new IRHoisted(
)
)
);
hoisted_dropList.hash;

const hoisted_recursiveList = new IRHoisted(
new IRApp(
Expand Down Expand Up @@ -139,6 +144,7 @@ const hoisted_recursiveList = new IRHoisted(
)
)
);
hoisted_recursiveList.hash;

const hoisted_lazyOr = new IRHoisted(
new IRFunc( 2, // a, b
Expand All @@ -150,6 +156,7 @@ const hoisted_lazyOr = new IRHoisted(
)
)
);
hoisted_lazyOr.hash;

const hoisted_lazyAnd = new IRHoisted(
new IRFunc( 2, // a, b
Expand All @@ -161,6 +168,7 @@ const hoisted_lazyAnd = new IRHoisted(
)
)
);
hoisted_lazyAnd.hash;

const hoisted_foldr = new IRHoisted(
new IRFunc( 2, // reduceFunc, accmulator
Expand All @@ -186,6 +194,7 @@ const hoisted_foldr = new IRHoisted(
)
)
);
hoisted_foldr.hash;

export function nativeToIR( native: IRNative ): IRTerm
{
Expand Down
4 changes: 2 additions & 2 deletions packages/onchain/src/IR/utils/showIR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export function showIR( _ir: IRTerm )

lettedHashes.push( hash.slice() as IRHash );

getHoistedTerms( l.value.clone() ).forEach( ({ hoisted }) => addHoisted( hoisted ) );
getHoistedTerms( l.value ).forEach( ({ hoisted }) => addHoisted( hoisted ) );

Object.defineProperty(
letted, irHashToHex( hash ), {
Expand Down Expand Up @@ -262,7 +262,7 @@ export function prettyIR( _ir: IRTerm, _indent = 2 ) : PrettiedIR

lettedHashes.push( hash.slice() as IRHash );

getHoistedTerms( l.value.clone() ).forEach( ({ hoisted }) => addHoisted( hoisted ) );
getHoistedTerms( l.value ).forEach( ({ hoisted }) => addHoisted( hoisted ) );

const hashStr = irHashToHex( hash );
Object.defineProperty(
Expand Down
3 changes: 2 additions & 1 deletion packages/onchain/src/pluts/lib/builtins/_pflipIR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export const _pflipIR = new IRHoisted(
new IRVar( 1 ) // secondArg
)
)
);
);
_pflipIR.hash;
1 change: 1 addition & 0 deletions packages/onchain/src/pluts/lib/pmatch/getElemAtTerm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function getElemAtTerm( n: number ): TermFn<[ PList<PData> ], PData >

const term = new Term( lam( list(data), data ), _dbn => uplc );

uplc.hash;
defineReadOnlyProperty(
term, "$",
( lst: Term<PList<PData>>) =>
Expand Down
1 change: 1 addition & 0 deletions packages/onchain/src/pluts/lib/pmatch/matchNCtors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function matchNCtorsIdxs( _n: number, returnT: TermType ): Term<PType>

type ContinuationT = LamT<[PrimType.List, [PrimType.Data]], TermType>

body.hash;
const term = new Term(
fn([
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const hoisted_getFields = new IRHoisted(
)
)
);
hoisted_getFields.hash;

export const getFields = new Term<PLam<PData, PList<PData>>>(
lam( data, list( data ) ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const hoisted_getFields = new IRHoisted(
"hoisted_getFields"
)
);
hoisted_getFields.hash;

export function addPStructMethods<
SDef extends StructDefinition,
Expand Down

0 comments on commit f8d856c

Please sign in to comment.