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

컴포넌트 가져오기 및 재사용

이 섹션에서는 기존 WebAssembly 컴포넌트를 재사용하는 방법에 대한 언어별 가이드를 제공하며, 특히 adder 컴포넌트를 사용하여 calculator 컴포넌트를 완성하는 방법을 다룹니다.

adder 컴포넌트에는 다음과 같은 WIT 인터페이스가 있습니다.

package docs:adder@0.1.0;

interface add {
    add: func(x: u32, y: u32) -> u32;
}

world adder {
    export add;
}

calculator 컴포넌트에는 다음과 같은 인터페이스가 있습니다.

package docs:calculator@0.1.0;

interface calculate {
    enum op {
        add,
    }
    eval-expression: func(op: op, x: u32, y: u32) -> u32;
}

world calculator {
    export calculate;
    import docs:adder/add@0.1.0;
}

world app {
    import calculate;
}

언어

이 가이드는 다양한 언어로 구현되어 있습니다.


원문 © 2023 The Bytecode Alliance Contributors · WebAssembly Components Documentation · CC BY 4.0
Yeokja 한국어 번역·편집 · Anthropic 사의 claude-sonnet-5 모델을 활용하여 번역되었으며 학습을 모두 비허용한 상태로 작업하였습니다 · 이 번역은 원문을 수정한 문서이며 CC BY 4.0으로 제공합니다.