Skip to content

Commit

Permalink
single cell reference
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyProgrammist committed Nov 15, 2023
1 parent 18b3159 commit 7d90aff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
9 changes: 6 additions & 3 deletions generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,19 @@ export function storeNFG(nFG: NFG): (builder: Builder) => void {
};
}
export type NFT = {

a: BitInteger;
};
export function loadNFT(slice: Slice): NFT {
let slice1 = slice.loadRef().beginParse();
return {

a: loadBitInteger(slice1)
};
}
export function storeNFT(nFT: NFT): (builder: Builder) => void {
return (builder: Builder) => {

let cell1 = beginCell();
storeBitInteger(nFT.a)(cell1);
builder.storeRef(cell1);
};
}
export type A = {
Expand Down
21 changes: 19 additions & 2 deletions tests/my.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,6 @@ describe('parsing into intermediate representation using grammar', () => {
handleField(element);
});

// cell22.storeRef(cell221);

insideStoreStatements.push(tExpressionStatement(tFunctionCall(tMemberExpression(tIdentifier(currentCell), tIdentifier('storeRef')), [tIdentifier(getCurrentSlice(slicePrefix, 'cell'))])))

slicePrefix.pop();
Expand Down Expand Up @@ -696,7 +694,26 @@ describe('parsing into intermediate representation using grammar', () => {
}

if (field.expr instanceof CellRefExpr) {
slicePrefix[slicePrefix.length - 1]++;
slicePrefix.push(0)

loadStatements.push(
tExpressionStatement(tDeclareVariable(tIdentifier(getCurrentSlice(slicePrefix, 'slice')),
tFunctionCall(tMemberExpression(
tFunctionCall(tMemberExpression(
tIdentifier(currentSlice), tIdentifier('loadRef')
), []),
tIdentifier('beginParse')
), []), )))


insideStoreStatements.push(tExpressionStatement(tDeclareVariable(tIdentifier(getCurrentSlice(slicePrefix, 'cell')), tFunctionCall(tIdentifier('beginCell'), []))))

handleField(new FieldNamedDef(field.name, field.expr.expr))

insideStoreStatements.push(tExpressionStatement(tFunctionCall(tMemberExpression(tIdentifier(currentCell), tIdentifier('storeRef')), [tIdentifier(getCurrentSlice(slicePrefix, 'cell'))])))

slicePrefix.pop();
}

if (field.expr instanceof CombinatorExpr) {
Expand Down

0 comments on commit 7d90aff

Please sign in to comment.