1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 2 * vim: set ts=8 sts=4 et sw=4 tw=99: 3 * 4 * Copyright 2015 Mozilla Foundation 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef wasm_binary_to_experimental_text_h 20 #define wasm_binary_to_experimental_text_h 21 22 #include "NamespaceImports.h" 23 24 #include "gc/Rooting.h" 25 #include "js/Class.h" 26 #include "wasm/WasmGeneratedSourceMap.h" 27 28 namespace js { 29 30 class StringBuffer; 31 32 namespace wasm { 33 34 struct ExperimentalTextFormatting 35 { 36 bool allowAsciiOperators:1; 37 bool reduceParens:1; 38 bool groupBlocks:1; 39 ExperimentalTextFormattingExperimentalTextFormatting40 ExperimentalTextFormatting() 41 : allowAsciiOperators(true), 42 reduceParens(true), 43 groupBlocks(true) 44 {} 45 }; 46 47 // Translate the given binary representation of a wasm module into the module's textual 48 // representation. 49 50 MOZ_MUST_USE bool 51 BinaryToExperimentalText(JSContext* cx, const uint8_t* bytes, size_t length, StringBuffer& buffer, 52 const ExperimentalTextFormatting& formatting = ExperimentalTextFormatting(), 53 GeneratedSourceMap* sourceMap = nullptr); 54 55 } // namespace wasm 56 57 } // namespace js 58 59 #endif // namespace wasm_binary_to_experimental_text_h 60