-
Notifications
You must be signed in to change notification settings - Fork 14
Description
schema.tlb
_ a:(## 6) b:(a . 2)?(## 32) = BitSelection;
tlbc -qv schema.tlb 2>&1 | tee schema.txt
1549 types defined, out of them 1548 built-in, 1 user-defined
built-in type #1: `##`, arity 1; prefixes {*}; size 0..32
type #1548: `BitSelection`, arity 0, 1 constructors
constructor `_`
_$_ a:(## 6) b:a.2?(## 32) = BitSelection;
begins with {*}
size 6..38 (any bits)
field `a`: ## 6 (used=1) (is_nat_subtype=1)
field `b`: _1.2?(## 32) (used=0) (is_nat_subtype=0)
type size 6..38 (any bits)
type begins with {*}
****************
5 constant expressions:
expr #1: 6
expr #2: ## 6
expr #3: 2
expr #4: 32
expr #5: ## 32reference behavior
tlbc -o schema-auto -n cu16::gen -z schema.tlbbool BitSelection::pack(vm::CellBuilder& cb, const BitSelection::Record& data) const {
return cb.store_ulong_rchk_bool(data.a, 6)
&& (!(data.a & 4) || cb.store_ulong_rchk_bool(data.b, 32));
}generat code
npx tlb -o schema-auto.ts schema.tlbincorrect behavior
export function storeBitSelection(bitSelection: BitSelection): (builder: Builder) => void {
return ((builder: Builder) => {
builder.storeUint(bitSelection.a, 6);
if ((bitSelection.b != undefined)) {
builder.storeUint(bitSelection.b, 32);
}
})
}expect behavior
export function storeBitSelection(bitSelection: BitSelection): (builder: Builder) => void {
return ((builder: Builder) => {
builder.storeUint(bitSelection.a, 6);
if (bitSelection.a & (1 << 2) && bitSelection.b != undefined) {
builder.storeUint(bitSelection.b, 32);
}
})
}Metadata
Metadata
Assignees
Labels
No labels