From 3d0e90eac8b77aa1c95e6648290d486942b3b75c Mon Sep 17 00:00:00 2001 From: Gusarich Date: Mon, 18 Nov 2024 11:30:59 +0300 Subject: [PATCH] feat: `sliceLast` -> `lastBits`, and make `computeDataSize` an extend function for both cell and slice --- src/imports/stdlib.ts | 28 ++++++++++++++-------------- stdlib/std/cells.tact | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/imports/stdlib.ts b/src/imports/stdlib.ts index 6266faca3..74dbc7196 100644 --- a/src/imports/stdlib.ts +++ b/src/imports/stdlib.ts @@ -177,20 +177,20 @@ files['std/cells.tact'] = 'IG11dGF0ZXMgbmF0aXZlIGxvYWRBZGRyZXNzKHNlbGY6IFNsaWNlKTogQWRkcmVzczsKCmFzbSBleHRlbmRzIG11dGF0ZXMgZnVuIHNraXBCaXRzKHNlbGY6IFNsaWNl' + 'LCBsOiBJbnQpIHsgU0RTS0lQRklSU1QgfQoKYXNtIGV4dGVuZHMgZnVuIGVuZFBhcnNlKHNlbGY6IFNsaWNlKSB7IEVORFMgfQoKYXNtIGV4dGVuZHMgZnVuIHNraXBM' + 'YXN0Qml0cyhzZWxmOiBTbGljZSwgbGVuOiBJbnQpOiBTbGljZSB7IFNEU0tJUExBU1QgfQoKYXNtIGV4dGVuZHMgZnVuIGZpcnN0Qml0cyhzZWxmOiBTbGljZSwgbGVu' + - 'OiBJbnQpOiBTbGljZSB7IFNEQ1VURklSU1QgfQoKYXNtIGV4dGVuZHMgZnVuIHNsaWNlTGFzdChzZWxmOiBTbGljZSwgbGVuOiBJbnQpOiBTbGljZSB7IFNEQ1VUTEFT' + - 'VCB9Cgphc20gZXh0ZW5kcyBmdW4gZGVwdGgoc2VsZjogU2xpY2UpOiBJbnQgeyBTREVQVEggfQoKLy8KLy8gU2xpY2Ugc2l6ZQovLwoKYXNtIGV4dGVuZHMgZnVuIHJl' + - 'ZnMoc2VsZjogU2xpY2UpOiBJbnQgeyBTUkVGUyB9Cgphc20gZXh0ZW5kcyB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XRDb25maWdQYXJhbShpZDogSW50KTogQ2VsbD8geyBDT05GSUdPUFRQQVJBTSB9Cg=='; files['std/context.tact'] = diff --git a/stdlib/std/cells.tact b/stdlib/std/cells.tact index dd0d5baf5..1b1f023a3 100644 --- a/stdlib/std/cells.tact +++ b/stdlib/std/cells.tact @@ -154,7 +154,7 @@ asm extends fun skipLastBits(self: Slice, len: Int): Slice { SDSKIPLAST } asm extends fun firstBits(self: Slice, len: Int): Slice { SDCUTFIRST } -asm extends fun sliceLast(self: Slice, len: Int): Slice { SDCUTLAST } +asm extends fun lastBits(self: Slice, len: Int): Slice { SDCUTLAST } asm extends fun depth(self: Slice): Int { SDEPTH } @@ -208,9 +208,9 @@ struct DataSize { refs: Int; } -asm fun computeDataSize(cell: Cell, maxCells: Int): DataSize { CDATASIZE TRIPLE } +asm extends fun computeDataSize(self: Cell, maxCells: Int): DataSize { CDATASIZE TRIPLE } -asm fun computeSliceDataSize(slice: Slice, maxCells: Int): DataSize { SDATASIZE TRIPLE } +asm extends fun computeDataSize(self: Slice, maxCells: Int): DataSize { SDATASIZE TRIPLE } asm extends fun depth(self: Cell): Int { CDEPTH }