From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../global_objects/webassembly/compile/index.html | 83 ++++++++++ .../webassembly/compileerror/index.html | 114 ++++++++++++++ .../webassembly/compilestreaming/index.html | 79 ++++++++++ .../global_objects/webassembly/global/index.html | 116 ++++++++++++++ .../webassembly/global/prototype/index.html | 69 +++++++++ .../global_objects/webassembly/index.html | 100 ++++++++++++ .../global_objects/webassembly/instance/index.html | 74 +++++++++ .../webassembly/instantiate/index.html | 168 +++++++++++++++++++++ .../webassembly/instantiatestreaming/index.html | 83 ++++++++++ .../webassembly/linkerror/index.html | 113 ++++++++++++++ .../global_objects/webassembly/memory/index.html | 112 ++++++++++++++ .../global_objects/webassembly/module/index.html | 83 ++++++++++ .../webassembly/runtimeerror/index.html | 111 ++++++++++++++ .../global_objects/webassembly/table/index.html | 130 ++++++++++++++++ .../global_objects/webassembly/validate/index.html | 75 +++++++++ 15 files changed, 1510 insertions(+) create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/compile/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/compileerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/global/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/global/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/instance/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/instantiate/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/linkerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/memory/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/module/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/table/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/validate/index.html (limited to 'files/ko/web/javascript/reference/global_objects/webassembly') diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/compile/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/compile/index.html new file mode 100644 index 0000000000..eb7dd71f5f --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/compile/index.html @@ -0,0 +1,83 @@ +--- +title: WebAssembly.compile() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/compile +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/compile +--- +
{{JSRef}}
+ +

WebAssembly.compile()함수는 WebAssembly 바이너리 코드에서 {{jsxref ( "WebAssembly.Module")}}을 컴파일합니다. 이 함수는 모듈을 인스턴스화하기 전에 컴파일해야하는 경우에 유용합니다. 그렇지 않으면 {{jsxref ( "WebAssembly.instantiate ()")}} 함수를 사용해야합니다.

+ +

Syntax

+ +
Promise<WebAssembly.Module> WebAssembly.compile(bufferSource);
+ +

Parameters

+ +
+
bufferSource
+
컴파일 할 .wasm 모듈의 이진 코드가 들어있는 typed array 또는 ArrayBuffer입니다.
+
+ +

Return value

+ +

Promise는 컴파일 된 모듈로 표현된 {{jsxref ( "WebAssembly.Module")}} 객체로 반환됩니다.

+ +

Exceptions

+ + + +

Examples

+ +

다음은 compile() 함수를 사용하여 simple.wasm 바이트 코드를 컴파일 하고 postMessage()를 사용하여 worker에 보내는 예제입니다.

+ +
var worker = new Worker("wasm_worker.js");
+
+fetch('simple.wasm').then(response =>
+  response.arrayBuffer()
+).then(bytes =>
+  WebAssembly.compile(bytes)
+).then(mod =>
+  worker.postMessage(mod)
+);
+ +
+

Note: 대부분의 경우에 {{jsxref("WebAssembly.compileStreaming()")}}를 사용하는 것이 좋습니다. 이는 compile()보다 효율적이기 때문입니다.

+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#webassemblycompile', 'compile()')}}{{Spec2('WebAssembly JS')}}Initial draft definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.compile")}}

+
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/compileerror/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/compileerror/index.html new file mode 100644 index 0000000000..40ba328985 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/compileerror/index.html @@ -0,0 +1,114 @@ +--- +title: WebAssembly.CompileError() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError +--- +
{{JSRef}}
+ +

WebAssembly.CompileError()생성자는 WebAssembly 디코딩 또는 유효성 검사 중에 발생한 오류를 나타내는 WebAssembly CompileError 객체를 새로 만듭니다.

+ +

Syntax

+ +
new WebAssembly.CompileError(message, fileName, lineNumber)
+ +

Parameters

+ +
+
message {{optional_inline}}
+
사람이 읽을수 있는 형태의 에러에 대한 설명.
+
fileName {{optional_inline}}{{non-standard_inline}}
+
예외의 원인이 된 코드가 들어있는 파일의 이름입니다.
+
lineNumber {{optional_inline}}{{non-standard_inline}}
+
예외의 원인이 된 코드의 행 번호입니다.
+
+ +

Properties

+ +

CompileError 생성자에는 고유 한 고유 속성이 없지만 프로토 타입 체인을 통해 일부 속성을 상속합니다.

+ +
+
WebAssembly.CompileError.prototype.constructor
+
인스턴스의 프로토 타입을 작성한 함수를 지정합니다.
+
{{jsxref("Error.prototype.message", "WebAssembly.CompileError.prototype.message")}}
+
에러 메시지. ECMA-262는 {{jsxref ( "URIError")}}가 SpiderMonkey에서 자체 message 속성을 제공하도록 지정했지만 {{jsxref ( "Error.prototype.message")}}를 상속받습니다.
+
{{jsxref("Error.prototype.name", "WebAssembly.CompileError.prototype.name")}}
+
에러 명칭. {{jsxref("Error")}}에서 상속합니다.
+
{{jsxref("Error.prototype.fileName", "WebAssembly.CompileError.prototype.fileName")}}
+
에러가 발생한 파일의 경로. {{jsxref("Error")}}에서 상속합니다.
+
{{jsxref("Error.prototype.lineNumber", "WebAssembly.CompileError.prototype.lineNumber")}}
+
에러가 발생한 파일의 코드 줄번호. {{jsxref("Error")}}에서 상속합니다.
+
{{jsxref("Error.prototype.columnNumber", "WebAssembly.CompileError.prototype.columnNumber")}}
+
에러가 발생한 줄의 열 번호. {{jsxref("Error")}}에서 상속합니다.
+
{{jsxref("Error.prototype.stack", "WebAssembly.CompileError.prototype.stack")}}
+
스텍 추적. {{jsxref("Error")}}에서 상속합니다.
+
+ +

Methods

+ +

CompileError 생성자에는 자체 메서드가 없지만 프로토 타입 체인을 통해 일부 메서드를 상속합니다.

+ +
+
{{jsxref("Error.prototype.toSource", "WebAssembly.CompileError.prototype.toSource()")}}
+
동일한 오류로 판단할 수 있는 코드를 반환합니다. {{jsxref("Error")}}에서 상속합니다.
+
{{jsxref("Error.prototype.toString", "WebAssembly.CompileError.prototype.toString()")}}
+
지정된 Error 객체를 나타내는 문자열을 반환합니다. {{jsxref("Error")}}에서 상속합니다.
+
+ +

Examples

+ +

다음 스 니펫은 새 CompileError 인스턴스를 만들고 콘솔에 세부 정보를 기록합니다.

+ +
try {
+  throw new WebAssembly.CompileError('Hello', 'someFile', 10);
+} catch (e) {
+  console.log(e instanceof CompileError); // true
+  console.log(e.message);                 // "Hello"
+  console.log(e.name);                    // "CompileError"
+  console.log(e.fileName);                // "someFile"
+  console.log(e.lineNumber);              // 10
+  console.log(e.columnNumber);            // 0
+  console.log(e.stack);                   // returns the location where the code was run
+}
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#constructor-properties-of-the-webassembly-object', 'WebAssembly constructors')}}{{Spec2('WebAssembly JS')}}Initial WebAssembly draft definition.
{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard', 'NativeError')}}{{Spec2('ESDraft')}}Definition of standard NativeError types.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.CompileError")}}

+
+ +

See also

+ + + +
+
diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html new file mode 100644 index 0000000000..a713ca1c0d --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html @@ -0,0 +1,79 @@ +--- +title: WebAssembly.compileStreaming() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming +--- +
{{JSRef}}
+ +

WebAssembly.compileStreaming()함수는 스트림 된 원본 소스에서 직접 {{jsxref ( "WebAssembly.Module")}}을 컴파일합니다. 이 함수는 모듈을 인스턴스화하기 전에 컴파일해야하는 경우 유용합니다 (그렇지 않으면 {{jsxref ( "WebAssembly.instantiateStreaming ()")}} 함수를 사용해야합니다).

+ +

 

+ +

Syntax

+ +
Promise<WebAssembly.Module> WebAssembly.compileStreaming(source);
+ +

Parameters

+ +
+
source
+
스트리밍 및 컴파일하려는 .wasm 모듈의 기본 소스를 나타내는 {{domxref ( "Response")}} 객체 또는 약속을 수행합니다.
+
+ +

Return value

+ +

Promise는 컴파일 된 모듈로 표현된 WebAssembly.Module 객체로 반환됩니다.

+ +

Exceptions

+ + + +

Examples

+ +

다음 예제 (GitHub의 compile-streaming.html 데모 및 라이브보기)에서 기본 소스의 .wasm 모듈을 직접 스트리밍 한 다음 {{jsxref ( "WebAssembly.Module")}} 객체로 컴파일합니다. compileStreaming() 함수는 {{domxref ( "Response")}} 객체에 대한 promise를 받으므로 직접 {{domxref ( "WindowOrWorkerGlobalScope.fetch ()")}} 호출을 전달할 수 있습니다.

+ +
var importObject = { imports: { imported_func: arg => console.log(arg) } };
+
+WebAssembly.compileStreaming(fetch('simple.wasm'))
+.then(module => WebAssembly.instantiate(module, importObject))
+.then(instance => instance.exports.exported_func());
+ +

결과 모듈 인스턴스는 {{jsxref ( "WebAssembly.instantiate ()")}}를 사용하여 인스턴스화되고 내 보낸 함수가 호출됩니다.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly Embedding', '#webassemblycompilestreaming', 'compileStreaming()')}}{{Spec2('WebAssembly Embedding')}}Initial draft definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.compileStreaming")}}

+
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/global/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/global/index.html new file mode 100644 index 0000000000..c85d74b53c --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/global/index.html @@ -0,0 +1,116 @@ +--- +title: WebAssembly.Global +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Global +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Global +--- +
{{JSRef}}
+ +
 
+ +
WebAssembly.Global 객체는 전역 변수 인스턴스를 나타내며 JavaScript 및 하나 이상의 {{jsxref("WebAssembly.Module")}} 인스턴스에서 가져 오거나 내보낼 수 있습니다. 이렇게하면 여러 모듈을 동적으로 연결할 수 있습니다.
+ +

Constructor Syntax

+ +
var myGlobal = new WebAssembly.Global(descriptor, value);
+ +

Parameters

+ +
+
descriptor
+
A GlobalDescriptor dictionary object, 두 개의 속성이 포함되어 있습니다. +
    +
  • value: {{domxref("USVString")}}는 전역의 데이터 유형을 나타냅니다. i32, i64, f32 및 f64 중 하나입니다.
  • +
  • mutable: 전역 변수를 변경할 수 있는지 여부를 결정하는 부울 값입니다. 기본적으로 false입니다.
  • +
+
+
value
+
변수에 포함 된 값입니다. 변수의 데이터 타입과 일치하는 한 모든 값을 사용할 수 있습니다.
+ 변수에 포함 된 값입니다. 변수의 데이터 타입과 일치하는 모든 값을 사용할 수 있습니다. 값을 지정하지 않으면 DefaultValue 알고리즘에 지정된대로 입력 된 0 값이 사용됩니다.
+
+ +

Function properties of the Module constructor

+ +

None.

+ +

Global instances

+ +

모든 Global 인스턴스는 Global() 생성자의 prototype object에서 상속받습니다.이 인스턴스는 모든 Global 인스턴스에 영향을 미치도록 수정할 수 있습니다.

+ +

Instance properties

+ +

{{page('/ko/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/prototype', 'Properties')}}

+ +

Instance methods

+ +

{{page('/ko/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/prototype', 'Methods')}}

+ +

Examples

+ +

다음 예제에서는 WebAssembly.Global() 생성자를 사용하여 만드는 새 전역 인스턴스를 보여줍니다. 값이 0 인 변경 가능한 i32 유형으로 정의됩니다.

+ +

The value of the global is then changed, first to 42 using the Global.value property, and then to 43 using the incGlobal() function exported out of the global.wasm module (this adds 1 to whatever value is given to it and then returns the new value). 

+ +

그런 다음 global.value 속성을 사용하여 42까지 전역 값을 변경 한 다음 global.wasm 모듈에서 내 보낸 incGlobal() 함수를 사용하여 43으로 변경합니다.(이것은 값이 주어진 값에 1을 더한 다음 새 값을 반환합니다.)

+ +
const output = document.getElementById('output');
+
+function assertEq(msg, got, expected) {
+    output.innerHTML += `Testing ${msg}: `;
+    if (got !== expected)
+        output.innerHTML += `FAIL!<br>Got: ${got}<br>Expected: ${expected}<br>`;
+    else
+        output.innerHTML += `SUCCESS! Got: ${got}<br>`;
+}
+
+assertEq("WebAssembly.Global exists", typeof WebAssembly.Global, "function");
+
+const global = new WebAssembly.Global({value:'i32', mutable:true}, 0);
+
+WebAssembly.instantiateStreaming(fetch('global.wasm'), { js: { global } })
+.then(({instance}) => {
+    assertEq("getting initial value from wasm", instance.exports.getGlobal(), 0);
+    global.value = 42;
+    assertEq("getting JS-updated value from wasm", instance.exports.getGlobal(), 42);
+    instance.exports.incGlobal();
+    assertEq("getting wasm-updated value from JS", global.value, 43);
+});
+ +
+

Note: GitHub에서 실행중인 예제(running live on GitHub)를 볼 수 있습니다. source code도 참조하십시오.

+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#globals', 'WebAssembly.Global()')}}{{Spec2('WebAssembly JS')}}Initial draft definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.Global")}}

+
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/global/prototype/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/global/prototype/index.html new file mode 100644 index 0000000000..3b7e8a9e2b --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/global/prototype/index.html @@ -0,0 +1,69 @@ +--- +title: WebAssembly.Global.prototype +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/prototype +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Global +--- +
{{JSRef}}
+ +

WebAssembly.Global.prototype 속성은 {{jsxref("WebAssembly.Global()")}} 생성자의 프로토 타입을 나타냅니다.

+ +
{{js_property_attributes(0, 0, 0)}}
+ +

Description

+ +

모든 {{jsxref("WebAssembly.Global")}} 인스턴스는 Global.prototype에서 상속받습니다. {{jsxref("WebAssembly.Global()")}} 생성자의 프로토 타입 객체는 모든 {{jsxref( "WebAssembly.Global")}} 인스턴스에 영향을 미치도록 수정할 수 있습니다.

+ +

Properties

+ +
+
Global.prototype.constructor
+
이 객체의 인스턴스를 생성 한 함수를 돌려줍니다. 기본적으로 이것은 {{jsxref("WebAssembly.Global()")}} 생성자입니다.
+
Global.prototype[@@toStringTag]
+
@@toStringTag 속성의 초기 값은 String 값인 "WebAssembly.Global"입니다.
+
Global.prototype.value
+
전역 변수에 포함 된 값 - 전역 값을 직접 설정하고 가져 오는 데 사용할 수 있습니다.
+
+ +

Methods

+ +
+
Global.prototype.valueOf()
+
전역 변수에 포함 된 값을 반환하는 Old-style 메서드입니다.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#globals', 'WebAssembly.Global()')}}{{Spec2('WebAssembly JS')}}Initial draft definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.Global.prototype")}}

+
+ +
+ +
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/index.html new file mode 100644 index 0000000000..8412c9f0e4 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/index.html @@ -0,0 +1,100 @@ +--- +title: WebAssembly +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly +--- +
{{JSRef}}
+ +

WebAssembly 자바스크립트 객체는 모든 WebAssembly에 관계된 기능의 네임스페이스로서 역할합니다.

+ +

대부분의 전역객체와 다르게, WebAssembly는 생성자가 아닙니다 (함수 객체가 아닙니다). 비슷한 예로 수학적인 상수나 함수들을 담고있는 {{jsxref("Math")}} 객체나, 국제화 관련 생성자나 언어에 민감한 다른 함수들을 담고있는 {{jsxref("Intl")}} 등이 있습니다.

+ +

설명

+ +

WebAssembly 객체의 기본적인 사용례는 다음과 같습니다:

+ + + +

메서드

+ +
+
{{jsxref("WebAssembly.instantiate()")}}
+
WebAssembly 코드를 컴파일하고 인스턴스화하여 Module과 첫 번째 Instance를 반환하는 기본 API입니다.
+
{{jsxref("WebAssembly.instantiateStreaming()")}}
+
스트리밍 된 원본 소스에서 직접 WebAssembly 모듈을 컴파일하고 인스턴스화하여 Module과 첫 번째 Instance를 반환합니다.
+
{{jsxref("WebAssembly.compile()")}}
+
WebAssembly 바이너리 코드에서 {{jsxref("WebAssembly.Module")}}을 컴파일하여 인스턴스화를 별도의 단계로 남겨 둡니다.
+
{{jsxref("WebAssembly.compileStreaming()")}}
+
{{jsxref("WebAssembly.Module")}}을 스트림 된 원본 소스에서 직접 컴파일하여 인스턴스화를 별도의 단계로 남겨 둡니다.
+
{{jsxref("WebAssembly.validate()")}}
+
바이트가 유효한 WebAssembly 코드 (true)인지 아닌지 (false)를 반환하여 WebAssembly 바이너리 코드의 지정된 입력 된 배열을 확인합니다.
+
+ +

생성자

+ +
+
{{jsxref("WebAssembly.Global()")}}
+
Creates a new WebAssembly Global object.
+
{{jsxref("WebAssembly.Module()")}}
+
Creates a new WebAssembly Module object.
+
{{jsxref("WebAssembly.Instance()")}}
+
Creates a new WebAssembly Instance object.
+
{{jsxref("WebAssembly.Memory()")}}
+
Creates a new WebAssembly Memory object.
+
{{jsxref("WebAssembly.Table()")}}
+
Creates a new WebAssembly Table object.
+
{{jsxref("WebAssembly.CompileError()")}}
+
Creates a new WebAssembly CompileError object.
+
{{jsxref("WebAssembly.LinkError()")}}
+
Creates a new WebAssembly LinkError object.
+
{{jsxref("WebAssembly.RuntimeError()")}}
+
Creates a new WebAssembly RuntimeError object.
+
+ +

예제

+ +

다음 예제 (GitHub의 instantiate-streaming.html 데모보기 및 라이브보기)에서는 기본 소스에서 .wasm 모듈을 직접 스트리밍 한 다음 컴파일하고 인스턴스화합니다. 프로미스는 ResultObject로 충족됩니다. instantiateStreaming() 함수는 {{domxref ( "Response")}} 객체에 대한 promise를 받아들이므로 직접 {{domxref ( "WindowOrWorkerGlobalScope.fetch()")}} 호출에 전달할 수 있습니다.

+ +
var importObject = { imports: { imported_func: arg => console.log(arg) } };
+
+WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject)
+.then(obj => obj.instance.exports.exported_func());
+ +

그런 다음 ResultObject의 인스턴스 구성에 액세스하고 그 안에 있는 exported_func을 호출합니다.

+ +

스펙

+ + + + + + + + + + + + + + + + +
스펙상태설명
{{SpecName('WebAssembly JS', '#the-webassembly-object', 'WebAssembly')}}{{Spec2('WebAssembly JS')}}초안 정의
+ +

브라우저 호환성

+ +
{{Compat("javascript.builtins.WebAssembly")}}
+ + + +

바깥 고리

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/instance/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/instance/index.html new file mode 100644 index 0000000000..3141c6809a --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/instance/index.html @@ -0,0 +1,74 @@ +--- +title: WebAssembly.Instance +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance +--- +
{{JSRef}}
+ +

WebAssembly.Instance 개체는 WebAssembly.Module의 상태 저장되고 실행 가능한 인스턴스입니다. Instance 객체에는 JavaScript에서 WebAssembly 코드로 호출 할 수있는 모든 Exported WebAssembly functions가 포함되어 있습니다.

+ +

주어진 {{jsxref ( "WebAssembly.Module")}} 객체를 동기적으로 인스턴스화하기 위해 WebAssembly.Instance() 생성자 함수를 호출 할 수 있습니다. 하지만 Instance를 가져 오는 주요 방법은 비동기 {{jsxref ( "WebAssembly.instantiateStreaming ()")}} 함수를 사용하는 것입니다.

+ +

생성자 구문

+ +
+

중요: 대형 모듈의 인스턴스화는 비용이 많이들 수 있으므로 개발자는 동기 인스턴스 생성이 절대적으로 필요한 경우에만 Instance () 생성자를 사용해야합니다. 비동기 {{jsxref ( "WebAssembly.instantiateStreaming ()")}} 메서드를 사용하세요.

+
+ +
var myInstance = new WebAssembly.Instance(module, importObject);
+ +

매개변수

+ +
+
module
+
인스턴스화 할 WebAssembly.Module 객체입니다.
+
importObject {{optional_inline}}
+
함수 또는 WebAssembly.Memory객체와 같이 새로 생성 된 인스턴스로 가져올 값을 포함하는 객체입니다. 선언 된 각 module 가져오기에 대해 일치하는 속성이 하나 있어야합니다. 그렇지 않으면 WebAssembly.LinkError가 발생합니다.
+
+ +

Instance 인스턴스

+ +

모든 Instance 인스턴스는 Instance() 생성자의 prototype object에서 상속받습니다.이 인스턴스를 수정하면 모든 Instance 인스턴스에 영향을 줍니다.

+ +

인스턴스 속성

+ +

{{page('/ko/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/prototype', 'Properties')}}

+ +

인스턴스 메서드

+ +

{{page('/ko/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/prototype', 'Methods')}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#webassemblyinstance-objects', 'Instance')}}{{Spec2('WebAssembly JS')}}Initial draft definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.Instance")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/instantiate/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/instantiate/index.html new file mode 100644 index 0000000000..c7b250c090 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/instantiate/index.html @@ -0,0 +1,168 @@ +--- +title: WebAssembly.instantiate() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate +--- +
{{JSRef}}
+ +

WebAssembly.instantiate() 함수를 사용하면 WebAssembly 코드를 컴파일하고 인스턴스화 할 수 있습니다. 이 함수에는 두개의 overloads가 있습니다.

+ + + +
+

중요 : 이 방법은 wasm 모듈을 가져와 인스턴스화하는 가장 효율적인 방법은 아닙니다. 가능하다면 원시 바이트 코드에서 모듈을 모두 한 단계로 가져오고, 컴파일하고 인스턴스화하는 대신 최신 {{jsxref ( "WebAssembly.instantiateStreaming ()")}} 메서드를 사용해야합니다. {{jsxref ( "ArrayBuffer")}} 로의 변환이 필요합니다.

+
+ +

Syntax

+ +

Primary overload — taking wasm binary code

+ +
Promise<ResultObject> WebAssembly.instantiate(bufferSource, importObject);
+
+ +

Parameters

+ +
+
bufferSource
+
컴파일 할 .wasm 모듈의 이진 코드가 들어있는 typed array 또는 {{jsxref("ArrayBuffer")}}입니다.
+
importObject {{optional_inline}}
+
함수 또는 {{jsxref ( "WebAssembly.Memory")}} 객체와 같이 새로 생성 된 인스턴스로 가져올 값을 포함하는 객체입니다. 컴파일 된 모듈의 각 선언 된 가져 오기에 대해 하나의 일치하는 속성이 있어야합니다. 그렇지 않으면 {{jsxref("WebAssembly.LinkError")}}가 발생합니다.
+
+ +

Return value

+ +

두개의 필드를 포함하는 ResultObject를 가진 Promise를 반환:

+ + + +

Exceptions

+ + + +

Secondary overload — taking a module object instance

+ +
Promise<WebAssembly.Instance> WebAssembly.instantiate(module, importObject);
+
+ +

Parameters

+ +
+
module
+
{{jsxref ( "WebAssembly.Module")}} 객체가 인스턴스화됩니다.
+
importObject {{optional_inline}}
+
함수 또는 {{jsxref ( "WebAssembly.Memory")}} 객체와 같이 새로 생성 된 인스턴스로 가져올 값을 포함하는 객체입니다. 선언 된 각 module 가져 오기에 대해 일치하는 속성이 하나 있어야합니다. 그렇지 않으면 {{jsxref("WebAssembly.LinkError")}} 가 발생합니다.
+
+ +

Return value

+ +

A Promise that resolves to an {{jsxref("WebAssembly.Instance")}} object.

+ +

Exceptions

+ + + +

Examples

+ +

Note: 대부분의 경우 instantiate()보다 더 효율적이므로 {{jsxref ( "WebAssembly.instantiateStreaming ()")}}을 사용하는 것이 좋습니다.

+ +

First overload example

+ +

fetch를 사용하여 일부 WebAssembly 바이트 코드를 가져온 후 우리는 {{jsxref ( "WebAssembly.instantiate ()")}} 함수를 사용하여 모듈을 컴파일하고 인스턴스화하여 해당 프로세스에서 JavaScript 함수를 WebAssembly 모듈로 가져옵니다. 그런 다음 Instance에서 Exported WebAssembly function를 호출합니다.

+ +
var importObject = {
+  imports: {
+    imported_func: function(arg) {
+      console.log(arg);
+    }
+  }
+};
+
+fetch('simple.wasm').then(response =>
+  response.arrayBuffer()
+).then(bytes =>
+  WebAssembly.instantiate(bytes, importObject)
+).then(result =>
+  result.instance.exports.exported_func()
+);
+ +
+

Note: 이 예제는 GitHub의 index.html에서도 찾을 수 있습니다 (라이브보기도 있음).

+
+ +

Second overload example

+ +

다음 예제는 (GitHub의 index-compile.html 데모 혹은 라이브로 보기). {{jsxref ( "WebAssembly.compileStreaming ()")}} 메서드를 사용하여 로드된 simple.wasm 바이트 코드를 컴파일 한 다음 {{domxref("Worker.postMessage", "postMessage()")}}를 사용하여 worker에게 전달합니다.

+ +
var worker = new Worker("wasm_worker.js");
+
+WebAssembly.compileStreaming(fetch('simple.wasm'))
+.then(mod =>
+  worker.postMessage(mod)
+);
+ +

작업자 (wasm_worker.js 참조)에서 모듈이 사용할 가져 오기 객체를 정의한 다음 주 스레드에서 모듈을 수신 할 이벤트 핸들러를 설정합니다. 모듈을 받으면 {{jsxref ( "WebAssembly.instantiate ()")}} 메소드를 사용하여 인스턴스를 만들고 내부에서 내 보낸 함수를 호출합니다.

+ +
var importObject = {
+  imports: {
+    imported_func: function(arg) {
+      console.log(arg);
+    }
+  }
+};
+
+onmessage = function(e) {
+  console.log('module received from main thread');
+  var mod = e.data;
+
+  WebAssembly.instantiate(mod, importObject).then(function(instance) {
+    instance.exports.exported_func();
+  });
+};
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#webassemblyinstantiate', 'instantiate()')}}{{Spec2('WebAssembly JS')}}Initial draft definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.instantiate")}}

+
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html new file mode 100644 index 0000000000..e1b2fde3b7 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html @@ -0,0 +1,83 @@ +--- +title: WebAssembly.instantiateStreaming() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming +--- +
{{JSRef}}
+ +

WebAssembly.instantiateStreaming() 함수는 스트림 된 원본 소스에서 직접 WebAssembly 모듈을 컴파일하고 인스턴스화합니다. Wasm 코드를로드하는 가장 효율적이고 최적화 된 방법입니다.

+ +

Syntax

+ +
Promise<ResultObject> WebAssembly.instantiateStreaming(source, importObject);
+ +

Parameters

+ +
+
source
+
스트리밍, 컴파일 및 인스턴스화하려는 .wasm 모듈의 기본 소스를 나타내는 {{domxref ( "Response")}} 객체 또는 promise.
+
importObject {{optional_inline}}
+
함수 또는 {{jsxref("WebAssembly.Memory")}} 객체와 같이 새로 생성 된 Instance로 가져올 값을 포함하는 객체입니다. 컴파일 된 모듈의 각 선언 된 가져 오기에 대해 하나의 일치하는 속성이 있어야합니다. 그렇지 않으면 WebAssembly.LinkError가 발생합니다.
+
+ +

Return value

+ +

두 개의 필드를 포함하는 ResultObject로 해석되는 Promise :

+ + + +

Exceptions

+ + + +

Examples

+ +

다음 예제 (GitHub의 instantiate-streaming.html 데모보기 및 view it live)에서는 원본 소스에서 .wasm 모듈을 직접 스트리밍 한 다음 컴파일하고 인스턴스화합니다. 약속은 ResultObject로 충족됩니다.instantiateStreaming() 함수는 {{domxref("Response")}} 객체에 대한 promise를 받아들이므로 직접 {{domxref("WindowOrWorkerGlobalScope.fetch()")}} 호출을 전달할 수 있으며 응답을 수행하면 함수에 응답을 전달합니다.

+ +
var importObject = { imports: { imported_func: arg => console.log(arg) } };
+
+WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject)
+.then(obj => obj.instance.exports.exported_func());
+ +

그런 다음 ResultObject의 인스턴스 구성원에 액세스하고 포함 된 내 보낸 함수를 호출합니다.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly Embedding', '#webassemblyinstantiatestreaming', 'instantiateStreaming()')}}{{Spec2('WebAssembly Embedding')}}Initial draft definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.instantiateStreaming")}}

+
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/linkerror/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/linkerror/index.html new file mode 100644 index 0000000000..b9b5c3264c --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/linkerror/index.html @@ -0,0 +1,113 @@ +--- +title: WebAssembly.LinkError() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError +--- +
{{JSRef}}
+ +

The WebAssembly.LinkError() constructor creates a new WebAssembly LinkError object, which indicates an error during module instantiation (besides traps from the start function). 

+ +

WebAssembly.LinkError() 생성자는 새 WebAssembly LinkError 객체를 만듭니다. 이 객체는 모듈 인스턴스화 중의 오류를 나타냅니다 (시작 함수의 traps와 함께).

+ +

Syntax

+ +
new WebAssembly.LinkError(message, fileName, lineNumber)
+ +

Parameters

+ +
+
message {{optional_inline}}
+
사람이 읽을 수 있는 오류 설명.
+
fileName {{optional_inline}}{{non-standard_inline}}
+
예외의 원인이 된 코드가 들어있는 파일의 이름입니다.
+
lineNumber {{optional_inline}}{{non-standard_inline}}
+
예외의 원인이 된 코드의 행 번호입니다.
+
+ +

Properties

+ +

LinkError 생성자에는 고유 한 고유 속성이 없지만 프로토 타입 체인을 통해 일부 속성을 상속합니다.

+ +
+
WebAssembly.LinkError.prototype.constructor
+
인스턴스의 프로토 타입을 작성한 함수를 지정합니다.
+
{{jsxref("Error.prototype.message", "WebAssembly.LinkError.prototype.message")}}
+
에러 메시지. ECMA-262는 {{jsxref ( "URIError")}}가 SpiderMonkey에서 자체 message 속성을 제공하도록 지정했지만 {{jsxref ( "Error.prototype.message")}}를 상속받습니다.
+
{{jsxref("Error.prototype.name", "WebAssembly.LinkError.prototype.name")}}
+
에러 이름. {{jsxref("Error")}}를 상속받습니다.
+
{{jsxref("Error.prototype.fileName", "WebAssembly.LinkError.prototype.fileName")}}
+
해당 에러가 발생한 파일의 경로. {{jsxref("Error")}}를 상속받습니다.
+
{{jsxref("Error.prototype.lineNumber", "WebAssembly.LinkError.prototype.lineNumber")}}
+
에러가 발생한 파일의 행 번호. {{jsxref("Error")}}를 상속받습니다.
+
{{jsxref("Error.prototype.columnNumber", "WebAssembly.LinkError.prototype.columnNumber")}}
+
이 오류가 발생한 행의 열 번호입니다.. {{jsxref("Error")}}를 상속받습니다.
+
{{jsxref("Error.prototype.stack", "WebAssembly.LinkError.prototype.stack")}}
+
스텍 추적. {{jsxref("Error")}}를 상속받습니다.
+
+ +

Methods

+ +

LinkError 생성자에는 자체 메서드가 없지만 프로토 타입 체인을 통해 일부 메서드를 상속합니다.

+ +
+
{{jsxref("Error.prototype.toSource", "WebAssembly.LinkError.prototype.toSource()")}}
+
동일한 오류로 평가 될 수있는 코드를 반환합니다. {{jsxref("Error")}}를 상속받습니다.
+
{{jsxref("Error.prototype.toString", "WebAssembly.LinkError.prototype.toString()")}}
+
지정된 Error 객체를 나타내는 문자열을 반환합니다. {{jsxref("Error")}}를 상속받습니다.
+
+ +

Examples

+ +

다음 snippet은 새 LinkError 인스턴스를 만들고 콘솔에 세부 정보를 기록합니다.

+ +
try {
+  throw new WebAssembly.LinkError('Hello', 'someFile', 10);
+} catch (e) {
+  console.log(e instanceof LinkError); // true
+  console.log(e.message);                 // "Hello"
+  console.log(e.name);                    // "LinkError"
+  console.log(e.fileName);                // "someFile"
+  console.log(e.lineNumber);              // 10
+  console.log(e.columnNumber);            // 0
+  console.log(e.stack);                   // returns the location where the code was run
+}
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#constructor-properties-of-the-webassembly-object', 'WebAssembly constructors')}}{{Spec2('WebAssembly JS')}}Initial WebAssembly draft definition.
{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard', 'NativeError')}}{{Spec2('ESDraft')}}Definition of standard NativeError types.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.LinkError")}}

+
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/memory/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/memory/index.html new file mode 100644 index 0000000000..96b1614fff --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/memory/index.html @@ -0,0 +1,112 @@ +--- +title: WebAssembly.Memory() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory +--- +
{{JSRef}}
+ +

WebAssembly.Memory() 생성자는 WebAssembly Instance가 액세스하는 메모리의 원시 바이트를 가진 ArrayBuffer(크기조정이 가능)인 새 Memory 객체를 만듭니다.

+ +

메모리는 자바스크립트 혹은 WebAssembly 코드 안에서 만들어지며 자바스크립트 그리고 WebAssembly에서 접근하거나 변경이 가능합니다.

+ +

Syntax

+ +
var myMemory = new WebAssembly.Memory(memoryDescriptor);
+ +

Parameters

+ +
+
memoryDescriptor
+
다음의 멤버를 가질수 있는 객체입니다. +
+
initial
+
WebAssembly Page의 단위별 WebAssembly 메모리의 초기 크기입니다.
+
maximum {{optional_inline}}
+
WebAssembly 메모리의 최대 크기는 WebAssembly 페이지 단위로 증가 할 수 있습니다. 이 매개 변수가 있으면 maximum 매개 변수는 엔진에 대해 메모리를 전면에 예약하도록 합니다. 그러나 엔진은 이 예약 요청을 무시하거나 클램핑 할 수 있습니다. 일반적으로 대부분의 WebAssembly 모듈은 maximum 값을 설정할 필요가 없습니다.
+
+
+
+ +
+

Note: WebAssembly 페이지의 크기는 65,536 바이트로 64KiB로 고정되어 있습니다.

+
+ +

Exceptions

+ + + +

Memory instances

+ +

모든 Memory 인스턴스는 Memory()생성자의 prototype object를 상속합니다.이 인스턴스는 모든 Memory 인스턴스에 적용되도록 수정할 수 있습니다.

+ +

Instance properties

+ +
+
Memory.prototype.constructor
+
이 객체의 인스턴스를 생성 한 함수를 돌려줍니다. 기본적으로 이것은 {{jsxref("WebAssembly.Memory()")}} 생성자입니다.
+
{{jsxref("WebAssembly/Memory/buffer","Memory.prototype.buffer")}}
+
메모리에 포함 된 버퍼를 반환하는 접근 자 속성입니다.
+
+ +

Instance methods

+ +
+
{{jsxref("WebAssembly/Memory/grow","Memory.prototype.grow()")}}
+
지정된 수의 WebAssembly 페이지 (각각 64KB 크기)만큼 메모리 인스턴스의 크기를 늘립니다.
+
+ +

Examples

+ +

WebAssembly.Memory 객체를 가져 오는 두 가지 방법이 있습니다. 첫 번째 방법은 JavaScript에서 생성하는 것입니다. 다음 예제에서는 초기 크기가 10 페이지 (640KiB)이고 최대 크기가 100 페이지 (6.4MiB) 인 새 WebAssembly 메모리 인스턴스를 만듭니다.

+ +
var memory = new WebAssembly.Memory({initial:10, maximum:100});
+ +

WebAssembly.Memory 객체를 가져 오는 두 번째 방법은 WebAssembly 모듈에서 내보냅니다. 다음 예제는 (GitHub의 memory.html을 보세요. 라이브로 보기) 생성된 메모리를 가져 오는 동안 {{jsxref("WebAssembly.instantiateStreaming()")}} 메소드를 사용하여로드 된 memory.wasm 바이트 코드를 가져 와서 인스턴스화합니다. 위의 줄에. 그런 다음 메모리에 일부 값을 저장 한 다음 함수를 내 보낸 다음 일부 값의 합계에 사용합니다.

+ +
WebAssembly.instantiateStreaming(fetch('memory.wasm'), { js: { mem: memory } })
+.then(obj => {
+  var i32 = new Uint32Array(memory.buffer);
+  for (var i = 0; i < 10; i++) {
+    i32[i] = i;
+  }
+  var sum = obj.instance.exports.accumulate(0, 10);
+  console.log(sum);
+});
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#webassemblymemory-objects', 'Memory')}}{{Spec2('WebAssembly JS')}}Initial draft definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.Memory")}}

+
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/module/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/module/index.html new file mode 100644 index 0000000000..814835fd00 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/module/index.html @@ -0,0 +1,83 @@ +--- +title: WebAssembly.Module +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Module +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Module +--- +
{{JSRef}}
+ +

WebAssembly.Module 객체는 브라우저에서 이미 컴파일 된 stateless WebAssembly 코드를 포함하며 효율적으로 Workers와 공유하고 여러 번 인스턴스화 할 수 있습니다. 모듈을 인스턴스화하려면 WebAssembly.instantiate() 2차 오버로드를 호출하세요.

+ +

WebAssembly.Module() 생성자 함수를 호출하여 지정된 WebAssembly 바이너리 코드를 동기식으로 컴파일 할 수 있습니다. 그러나 Module을 쓰는 주된 방법은 {{jsxref ( "WebAssembly.compile ()")}}과 같은 비동기 컴파일 함수를 사용하는 것입니다.

+ +

생성자 구문

+ +
+

Important: 대형 모듈의 컴파일은 비용이 많이들 수 있으므로 개발자는 동기 컴파일이 절대적으로 필요한 경우에만 Module () 생성자를 사용해야합니다. 비동기 {{jsxref ( "WebAssembly.compileStreaming ()")}} 메서드를 사용하세요.

+
+ +
var myModule = new WebAssembly.Module(bufferSource);
+ +

매개변수

+ +
+
bufferSource
+
컴파일 할 .wasm 모듈의 이진 코드가 들어있는 typed array또는 ArrayBuffer입니다.
+
+ +

Function Properties of the Module Constructor

+ +
+
{{jsxref("Global_Objects/WebAssembly/Module/customSections", "WebAssembly.Module.customSections()")}}
+
모듈(Module)과 문자열이 주어지면 모듈의 모든 사용자 정의 섹션 내용의 사본을 주어진 문자열 이름으로 반환합니다.
+
{{jsxref("Global_Objects/WebAssembly/Module/exports", "WebAssembly.Module.exports()")}}
+
모듈(Module)이 주어지면 선언 된 모든 내보내기에 대한 설명이 들어있는 배열을 반환합니다.
+
{{jsxref("Global_Objects/WebAssembly/Module/imports", "WebAssembly.Module.imports()")}}
+
모듈(Module)이 주어지면 선언 된 모든 가져오기에 대한 설명이 들어있는 배열을 반환합니다.
+
+ +

Module instances

+ +

모든 Module 인스턴스는 Module() 생성자의 prototype object에서 상속받습니다.이 인스턴스는 모든 Module 인스턴스에 적용되도록 수정할 수 있습니다.

+ +

Instance properties

+ +

{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/prototype', 'Properties')}}

+ +

Instance methods

+ +

모듈 인스턴스에는 기본 메서드가 없습니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#webassemblymodule-objects', 'WebAssembly.Module()')}}{{Spec2('WebAssembly JS')}}Initial draft definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.Module")}}

+
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html new file mode 100644 index 0000000000..ebd8da6f46 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html @@ -0,0 +1,111 @@ +--- +title: WebAssembly.RuntimeError() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError +--- +
{{JSRef}}
+ +

WebAssembly.RuntimeError() 생성자는 WebAssembly에서 trap을 지정할 때마다 throw되는 새 WebAssembly RuntimeError 객체를 만듭니다.

+ +

Syntax

+ +
new WebAssembly.RuntimeError(message, fileName, lineNumber)
+ +

Parameters

+ +
+
message {{optional_inline}}
+
인간이 읽을 수있는 오류 설명.
+
fileName {{optional_inline}}{{non-standard_inline}}
+
예외의 원인이 된 코드가 들어있는 파일의 이름입니다.
+
lineNumber {{optional_inline}}{{non-standard_inline}}
+
예외의 원인이 된 코드의 행 번호입니다.
+
+ +

Properties

+ +

RuntimeError 생성자에는 고유 한 고유 속성이 없지만 프로토 타입 체인을 통해 일부 속성을 상속합니다.

+ +
+
WebAssembly.RuntimeError.prototype.constructor
+
인스턴스의 프로토 타입을 작성한 함수를 지정합니다.
+
{{jsxref("Error.prototype.message", "WebAssembly.RuntimeError.prototype.message")}}
+
에러 메시지. ECMA-262는 {{jsxref ( "URIError")}}가 SpiderMonkey에서 자체 message 속성을 제공하도록 지정했지만 {{jsxref ( "Error.prototype.message")}}를 상속받습니다.
+
{{jsxref("Error.prototype.name", "WebAssembly.RuntimeError.prototype.name")}}
+
오류 이름. {{jsxref ( "Error")}}에서 상속됩니다.
+
{{jsxref("Error.prototype.fileName", "WebAssembly.RuntimeError.prototype.fileName")}}
+
이 오류를 발생시킨 파일의 경로입니다. {{jsxref ( "Error")}}에서 상속됩니다.
+
{{jsxref("Error.prototype.lineNumber", "WebAssembly.RuntimeError.prototype.lineNumber")}}
+
이 오류가 발생한 파일의 행 번호입니다. {{jsxref ( "Error")}}에서 상속됩니다.
+
{{jsxref("Error.prototype.columnNumber", "WebAssembly.RuntimeError.prototype.columnNumber")}}
+
이 오류가 발생한 행의 열 번호입니다. {{jsxref ( "Error")}}에서 상속됩니다.
+
{{jsxref("Error.prototype.stack", "WebAssembly.RuntimeError.prototype.stack")}}
+
스택 추적. {{jsxref ( "Error")}}에서 상속됩니다.
+
+ +

Methods

+ +

RuntimeError 생성자에는 자체 메서드가 없지만 프로토 타입 체인을 통해 일부 메서드를 상속합니다.

+ +
+
{{jsxref("Error.prototype.toSource", "WebAssembly.RuntimeError.prototype.toSource()")}}
+
동일한 오류로 평가 될 수있는 코드를 반환합니다. {{jsxref ( "Error")}}에서 상속됩니다.
+
{{jsxref("Error.prototype.toString", "WebAssembly.RuntimeError.prototype.toString()")}}
+
지정된 Error 객체를 나타내는 문자열을 반환합니다. {{jsxref ( "Error")}}에서 상속됩니다.
+
+ +

Examples

+ +

다음의 스니펫은, 새로운 RuntimeError 인스턴스를 작성해, 그 상세를 콘솔에 기록합니다.

+ +
try {
+  throw new WebAssembly.RuntimeError('Hello', 'someFile', 10);
+} catch (e) {
+  console.log(e instanceof RuntimeError); // true
+  console.log(e.message);                 // "Hello"
+  console.log(e.name);                    // "RuntimeError"
+  console.log(e.fileName);                // "someFile"
+  console.log(e.lineNumber);              // 10
+  console.log(e.columnNumber);            // 0
+  console.log(e.stack);                   // returns the location where the code was run
+}
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#constructor-properties-of-the-webassembly-object', 'WebAssembly constructors')}}{{Spec2('WebAssembly JS')}}Initial WebAssembly draft definition.
{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard', 'NativeError')}}{{Spec2('ESDraft')}}Definition of standard NativeError types.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.RuntimeError")}}

+
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/table/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/table/index.html new file mode 100644 index 0000000000..9d86fe40c7 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/table/index.html @@ -0,0 +1,130 @@ +--- +title: WebAssembly.Table() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Table +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Table +--- +
{{JSRef}}
+ +

WebAssembly.Table() 생성자는 지정된 크기 및 요소 유형의 새 Table 객체를 만듭니다.

+ +

이것은 자바 스크립트 래퍼 객체로, 함수 참조를 저장하는 WebAssembly 테이블을 나타내는 배열과 같은 구조입니다. JavaScript 또는 WebAssembly 코드로 작성된 테이블은 JavaScript 및 WebAssembly에서 액세스 및 변경할 수 있습니다.

+ +
+

Note: 테이블은 현재 function references만 저장할 수 있지만 나중에 확장 될 수 있습니다.

+
+ +

Syntax

+ +
var myTable = new WebAssembly.Table(tableDescriptor);
+ +

Parameters

+ +
+
tableDescriptor
+
다음 멤버를 포함 할 수있는 객체입니다: +
+
element
+
테이블에 저장 될 값 유형을 나타내는 문자열. 현재로서는 "anyfunc"(함수) 값만있을 수 있습니다.
+
initial
+
WebAssembly 테이블의 초기 요소 수입니다.
+
maximum {{optional_inline}}
+
WebAssembly 테이블의 최대 증가 요소 수입니다.
+
+
+
+ +

Exceptions

+ + + +

Table instances

+ +

모든 Table 인스턴스는 Table()생성자의 prototype object에서 상속받습니다.이 인스턴스는 모든 Table 인스턴스에 적용되도록 수정할 수 있습니다.

+ +

Instance properties

+ +
+
Table.prototype.constructor
+
이 객체의 인스턴스를 생성 한 함수를 돌려줍니다. 기본적으로 이것은 {{jsxref("WebAssembly.Table()")}} 생성자입니다.
+
{{jsxref("WebAssembly/Table/length","Table.prototype.length")}}
+
테이블의 길이, 즉 요소의 수를 돌려줍니다.
+
+ +

Instance methods

+ +
+
{{jsxref("WebAssembly/Table/get","Table.prototype.get()")}}
+
접근 자 함수 - 주어진 색인에 저장된 요소를 가져옵니다.
+
{{jsxref("WebAssembly/Table/grow","Table.prototype.grow()")}}
+
지정된 요소 수만큼 Table 인스턴스의 크기를 늘립니다.
+
{{jsxref("WebAssembly/Table/set","Table.prototype.set()")}}
+
지정된 인덱스에 격납되어있는 요소를, 지정된 값으로 설정합니다.
+
+ +

Examples

+ +

다음 예제 (table2.html source codelive version 참조)는 초기 크기가 2인 새 WebAssembly Table 인스턴스를 만듭니다. 그런 다음 두 개의 인덱스 (표 {{jsxref ( "WebAssembly / Table / get", "Table.prototype.get ()")}}를 통해 검색하여 테이블의 길이와 내용을 인쇄합니다. 길이가 2이고 {{jsxref ( "null")}}이 두개라고 출력됩니다.

+ +
var tbl = new WebAssembly.Table({initial:2, element:"anyfunc"});
+console.log(tbl.length);  // "2"
+console.log(tbl.get(0));  // "null"
+console.log(tbl.get(1));  // "null"
+ +

그런 다음 테이블을 포함한 importObj를 만듭니다.

+ +
var importObj = {
+  js: {
+    tbl:tbl
+  }
+};
+ +

마지막으로 {{jsxref ( "WebAssembly.instantiateStreaming ()")}} 메소드를 사용하여 wasm 모듈 (table2.wasm)을 로드하고 인스턴스화합니다. table2.wasm 모듈에는 두 개의 함수 (하나는 42를 반환하고 다른 하나는 83을 반환하는 함수)가 들어 있고 가져온 테이블의 요소 0과 1에 둘 다 저장합니다 (text representation 참조). 인스턴스화 후에도 테이블의 길이는 여전히 2이지만 JS에 호출 할 수있는 호출 가능한 Exported WebAssembly Functions가 요소에 포함됩니다.

+ +
WebAssembly.instantiateStreaming(fetch('table2.wasm'), importObject)
+.then(function(obj) {
+  console.log(tbl.length);
+  console.log(tbl.get(0)());
+  console.log(tbl.get(1)());
+});
+ +

액세서의 끝 부분에 두 번째 함수 호출 연산자를 포함시켜 실제로 참조 된 함수를 호출하고 그 안에 저장된 값을 기록해야합니다 (예 : get(0) 대신 get(0)()).

+ +

이 예제는 자바 스크립트에서 테이블을 만들고 액세스하고 있지만 wasm 인스턴스 내부에서도 같은 테이블을 볼 수 있고 호출 할 수 있음을 보여줍니다.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#webassemblytable-objects', 'Table')}}{{Spec2('WebAssembly JS')}}Initial draft definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.Table")}}

+
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/webassembly/validate/index.html b/files/ko/web/javascript/reference/global_objects/webassembly/validate/index.html new file mode 100644 index 0000000000..a5ea4850e5 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/webassembly/validate/index.html @@ -0,0 +1,75 @@ +--- +title: WebAssembly.validate() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/validate +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/validate +--- +
{{JSRef}}
+ +

WebAssembly.validate() 함수는 바이트가 유효한 wasm 모듈을 형성하는지 (true) 또는 생성하지 않는지 (false)를 반환하여 WebAssembly 바이너리 코드의 지정된 typed array의 유효성을 검사합니다.

+ +

Syntax

+ +
WebAssembly.validate(bufferSource);
+ +

Parameters

+ +
+
bufferSource
+
유효성을 검사 할 WebAssembly 바이너리 코드가 들어있는 typed array 또는 ArrayBuffer입니다.
+
+ +

Return value

+ +

bufferSource가 유효한 wasm 코드 (true)인지 아닌지 (false)를 지정하는 부울입니다.

+ +

Exceptions

+ +

bufferSourcetyped array이나 ArrayBuffer가 아닌 경우 {{jsxref ( "TypeError")}}가 발생합니다.

+ +

Examples

+ +

다음 예제 (validate.html source code 참조 및 see it live)는 .wasm 모듈을 가져 와서 형식화 된 배열로 변환합니다. 그런 다음 validate() 메서드를 사용하여 모듈이 유효한지 확인합니다.

+ +
fetch('simple.wasm').then(response =>
+  response.arrayBuffer()
+).then(function(bytes) {
+  var valid = WebAssembly.validate(bytes);
+  console.log("The given bytes are "
+    + (valid ? "" : "not ") + "a valid wasm module");
+});
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS', '#webassemblyvalidate', 'validate()')}}{{Spec2('WebAssembly JS')}}Initial draft definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.validate")}}

+
+ +

See also

+ + -- cgit v1.2.3-54-g00ecf