diff --git a/generated.ts b/generated.ts index c08c29e..6075926 100644 --- a/generated.ts +++ b/generated.ts @@ -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 = { diff --git a/tests/my.spec.ts b/tests/my.spec.ts index 50fa76b..be39c0c 100644 --- a/tests/my.spec.ts +++ b/tests/my.spec.ts @@ -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(); @@ -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) {