Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ขอบเขตชนิด

ออปโคดของ Wasm บางตัว เช่น local.set มีอาร์กิวเมนต์แบบหลายรูปแบบ (polymorphic) ผู้ใช้สามารถกำหนดเงื่อนไขเพิ่มเติมให้กับการแมตช์ตำแหน่งโพรบดังกล่าวตามชนิดได้ด้วยขอบเขตชนิด (type bound)

ในตอนนี้ วิธีนี้ยังช่วยเลี่ยงความจำเป็นในการทำ polymorphism ใน Whamm โดยผู้ใช้ต้องสร้างโพรบแบบขอบเขตชนิดหนึ่งตัวต่อชนิดที่เป็นไปได้แต่ละชนิด

ตัวอย่างการใช้ขอบเขตชนิดมีดังนี้:

wasm:opcode:call(arg0: i32):before {
    report unshared var all_arg0s: map<i32, i32>;
    all_arg0s[arg0]++;
}