1 /* 2 * Copyright 2016 WebAssembly Community Group participants 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef WABT_BINARY_WRITER_H_ 18 #define WABT_BINARY_WRITER_H_ 19 20 #include "src/common.h" 21 #include "src/feature.h" 22 #include "src/opcode.h" 23 #include "src/stream.h" 24 25 namespace wabt { 26 27 struct Module; 28 struct Script; 29 30 struct WriteBinaryOptions { 31 WriteBinaryOptions() = default; WriteBinaryOptionsWriteBinaryOptions32 WriteBinaryOptions(const Features& features, 33 bool canonicalize_lebs, 34 bool relocatable, 35 bool write_debug_names) 36 : features(features), 37 canonicalize_lebs(canonicalize_lebs), 38 relocatable(relocatable), 39 write_debug_names(write_debug_names) {} 40 41 Features features; 42 bool canonicalize_lebs = true; 43 bool relocatable = false; 44 bool write_debug_names = false; 45 }; 46 47 Result WriteBinaryModule(Stream*, const Module*, const WriteBinaryOptions&); 48 49 void WriteType(Stream* stream, Type type, const char* desc = nullptr); 50 51 void WriteStr(Stream* stream, 52 string_view s, 53 const char* desc, 54 PrintChars print_chars = PrintChars::No); 55 56 void WriteOpcode(Stream* stream, Opcode opcode); 57 58 void WriteLimits(Stream* stream, const Limits* limits); 59 60 } // namespace wabt 61 62 #endif /* WABT_BINARY_WRITER_H_ */ 63